Skip to main content

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.

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.4.0.tar.gz (693.9 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.4.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fitscube-2.4.0.tar.gz
  • Upload date:
  • Size: 693.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fitscube-2.4.0.tar.gz
Algorithm Hash digest
SHA256 aec5d4ae296a04543e9cfc5c0598db7b5e57924c4e46f3ee0c7d81e70483b36b
MD5 6ddd10d85a6dc58fb6e3bc6f2a1ca833
BLAKE2b-256 5af760a1cb8d94db79268cc7a2a26ba584a4a151e9af0ef3ee21dd3871c93e00

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitscube-2.4.0.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.4.0-py3-none-any.whl.

File metadata

  • Download URL: fitscube-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fitscube-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e88bd147c0f7f459d9f800faa1c540f76b646e94c26b37091f27566ab957702
MD5 da4e8a4dfa31b102f5a921f4a37506a5
BLAKE2b-256 b6f083ee6b03f339a9350a213f808e096b4db9dd4042825062803beb64e6333c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitscube-2.4.0-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.

Release history Release notifications | RSS feed

2.5.1

2 files

2.5.0

2 files

2.4.1

2 files

This release

2.4.0 This release

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.0.0

2 files

0.6.0

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page