flint.cube¶
Create, split and adjust FITS cubes
Functions¶
|
Combine wsclean subband channel images into a cube. Each collection attribute |
|
Rotate the FITS cube axes to a shape of (chan, pol, dec, ra) |
|
Write |
|
Extract each channel of a FITS cube into its own image, named following the |
Module Contents¶
- flint.cube.combine_images_to_cube(images: list[pathlib.Path], prefix: str, mode: str, fitscube_options: flint.options.FitsCubeOptions, bounding_box: bool | fitscube.bounding_box.BoundingBox | None = None, beam_shape: flint.convol.BeamShape | None = None) pathlib.Path[source]¶
Combine wsclean subband channel images into a cube. Each collection attribute of the input image_set will be inspected. The MFS images will be ignored.
A output file name will be generated based on the prefix and mode (e.g. image, residual, psf, dirty).
- Parameters:
images (list[Path]) – The images to combine into a cube
prefix (str) – The prefix of the images to combine
mode (str) – The type of images to combine, e.g. image, residual, psf, dirty
fitscube_options (FitsCubeOptions) – Options to control the cube creation
bounding_box (bool | BoundingBox | None, optional) – Overrides
fitscube_options.bounding_boxcube (when given. Used to force a box shared with another)
None. (cube records it in its header and carries no beam table. Defaults to)
beam_shape (BeamShape | None, optional) – The one beam every plane was convolved to. When given the
None.
- Returns:
The path to the created FITS cube
- Return type:
Path
- flint.cube.rotate_cube(output_cube_path: str | pathlib.Path, inplace: bool = True) pathlib.Path[source]¶
Rotate the FITS cube axes to a shape of (chan, pol, dec, ra) # which is what yandasoft linmos tasks expect.
- Parameters:
output_cube_path (str | Path) – Path to the FITS cube to rotate.
inplace (bool, optional) – If True, modify the file in-place. If False, write to a temporary file and then replace the original. Defaults to True.
- Returns:
Path to the rotated FITS cube.
- Return type:
Path
- flint.cube.set_cube_beam(cube: pathlib.Path, beam_shape: flint.convol.BeamShape) pathlib.Path[source]¶
Write
beam_shapeinto the cube’s header and drop any beam table.fitscube writes a table whenever the planes’ beams differ, and the blank planes of a cube convolved to one beam carry a zero beam that counts as a difference. CARTA can not open the table that results.
- Parameters:
cube (Path) – The cube to update in place
beam_shape (BeamShape) – The beam every populated plane is at
- Raises:
ValueError –
beam_shapeis not finite, as when no image had a beam to solve one from- Returns:
The updated cube
- Return type:
Path
- flint.cube.split_cube_into_planes(cube: pathlib.Path, output_path: pathlib.Path | None = None, num_workers: int = 4) list[pathlib.Path][source]¶
Extract each channel of a FITS cube into its own image, named following the flint processed name format so that the planes may be regrouped across beams by
transpose_and_sort_channel_images.- Parameters:
cube (Path) – The FITS cube to split apart
output_path (Path | None, optional) – Directory the planes are written into. Only the flint name fields are retained, so cubes that share them (e.g. an image cube and its weights) need separate directories. Defaults to alongside
cube.num_workers (int, optional) – Planes written at once. Defaults to 4.
- Returns:
The per-channel images extracted from
cube- Return type:
list[Path]
- Raises:
NotSupportedError – If
cubeis compressed (.gz or .fz), as astropy cannot memmap a compressed FITS file and would decompress the whole cube into memory. SetFitsCubeOptions.compress=Falsefor cubes that get split.