Skip to main content

A package to produce produce FITS cubes.

Project description

FITSCUBE

Actions Status Codecov Status

PyPI version

PyPI platforms

From the wsclean docs:

WSClean does not output these images in a normal “imaging cube” like CASA does, i.e., a single fits file with several images in it. For now I’ve decided not to implement this (one of the reasons for this is that information about the synthesized beam is not properly stored in a multi-frequency fits file). One has of course the option to combine the output manually, e.g. with a simple Python script.

This is a simple Python script to combine (single-frequency) FITS images manually.

Current assumptions:

  • All files have the same WCS
  • All files have the same shape / pixel grid
  • Frequency is either a WCS axis or in the REFFREQ header keyword
  • All the relevant information is in the first header of the first image

Installation

Install from PyPI (stable):

pip install fitscube

Or, install from this git repo (latest):

pip install git+https://github.com/AlecThomson/fitscube.git

To install and use the uvloop Async runner do:

pip install fitscube[uvloop]

Usage

Command line:

❯ fitscube -h
usage: fitscube [-h] {combine,extract} ...

Tooling to create fitscubes

positional arguments:
  {combine,extract}
    combine          Combine FITS images together into a cube
    extract          Extract a plane from an existing cube

options:
  -h, --help         show this help message and exit
❯ fitscube combine -h
usage: fitscube combine [-h] [-o] [--create-blanks] [--time-domain] [--spec-file SPEC_FILE | --specs SPECS [SPECS ...] | --ignore-spec] [-v] [--max-workers MAX_WORKERS]
                        file_list [file_list ...] out_cube

positional arguments:
  file_list             List of FITS files to combine (in frequency or time order)
  out_cube              Output FITS file

options:
  -h, --help            show this help message and exit
  -o, --overwrite       Overwrite output file if it exists
  --create-blanks       Try to create a blank cube with evenly spaced frequencies
  --time-domain         Flag for constructing a time-domain cube
  --spec-file SPEC_FILE
                        File containing frequencies in Hz or times in MJD s (if --time-domain == True)
  --specs SPECS [SPECS ...]
                        List of frequencies or times in Hz or MJD s respectively
  --ignore-spec         Ignore frequency or time information and just stack (probably not what you want)
  -v, --verbosity       Increase output verbosity
  --max-workers MAX_WORKERS
                        Maximum number of workers to use for concurrent processing
❯ fitscube extract -h
usage: fitscube extract [-h] [--channel-index CHANNEL_INDEX] [--hdu-index HDU_INDEX] [-v] [--overwrite] [--output-path OUTPUT_PATH] fits_cube

positional arguments:
  fits_cube             The cube to extract a plane from

options:
  -h, --help            show this help message and exit
  --channel-index CHANNEL_INDEX
                        The channel to extract
  --hdu-index HDU_INDEX
                        The HDU index of the data card containing the cube data
  -v, --verbosity       Increase output verbosity
  --overwrite           overwrite the output file, if it exists.
  --output-path OUTPUT_PATH
                        The name of the new output file. If not specified it is generated from the fits cube name

Python:

from pathlib import Path

from fitscube import combine_fits

file_list = list(Path().glob("*.fits"))

frequencies = combine_fits(
    file_list
)

Convolving to a common resolution

See RACS-Tools.

License

MIT

Contributing

Contributions are welcome. Please open an issue or pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fitscube-2.3.2.tar.gz (689.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fitscube-2.3.2-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file fitscube-2.3.2.tar.gz.

File metadata

  • Download URL: fitscube-2.3.2.tar.gz
  • Upload date:
  • Size: 689.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fitscube-2.3.2.tar.gz
Algorithm Hash digest
SHA256 decc2a068868f0c878f582173a4a616eba8db099cb22702434bc25cf23eb4d1a
MD5 39fb8f6e947318b16f048e7e0a7ca56c
BLAKE2b-256 b55ccfdcc35dc566f9a09c55db7fe2343793cd7578bfdf6b5dd5103e65b175ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitscube-2.3.2.tar.gz:

Publisher: cd.yml on AlecThomson/fitscube

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitscube-2.3.2-py3-none-any.whl.

File metadata

  • Download URL: fitscube-2.3.2-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fitscube-2.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ae6af55a5e4d868cc256d12476af0b741f7c1978fa5f388378319c3457b6890
MD5 5551272d11e690a571a8dcc3c8ac97ae
BLAKE2b-256 df62a198b98458f91c7c2c8ae016559bdc373e665a37f8d48274bcd4e2b0be8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitscube-2.3.2-py3-none-any.whl:

Publisher: cd.yml on AlecThomson/fitscube

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page