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.5.1.tar.gz (791.1 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.5.1-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fitscube-2.5.1.tar.gz
Algorithm Hash digest
SHA256 8ad83bd5a02f9dda108785fcb00a5066ea582cfe81937067d47f52be673c56d0
MD5 719573b0d75e56da519d07e565cb2a76
BLAKE2b-256 8c62872a1ed7f41d46e3a27c7b0a5b290e3c18b7a98f32cffecd541aca590ba1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: fitscube-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 29.3 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.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b70992229de4faaf221f7c76713b1fa6a6bdda432bd3d69d5951acdedd93d02d
MD5 9c54a1a44192987ef744baf6a36d3c69
BLAKE2b-256 355dec7c95e81adacce2575c3374caa019bbf4e7cda26445345825b2f16f6f30

See more details on using hashes here.

Provenance

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

This release

2.5.1 This release

2 files

2.5.0

2 files

2.4.1

2 files

2.4.0

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