cutout_fits.cutout

Attributes

_

Classes

SpatialIndex

Start and end indices for spatial axes.

SpectralIndex

Start and end indices for spectral axes.

StokesIndex

Start and end indices for Stokes axes.

Functions

cutout_beamtable(→ astropy.io.fits.BinTableHDU)

Cut out a beam table

format_shape(→ str)

Produce a string representation of the shape of an cube

get_cutout_parser(→ argparse.ArgumentParser)

get_cutout_shape(→ tuple[int, Ellipsis])

Get the shape of a cutout

get_file_parser(→ argparse.ArgumentParser)

get_spatial_indices(→ SpatialIndex)

Get the start and end indices for spatial axes

get_spectral_indices(→ SpectralIndex)

Get the start and end indices for spectral axes

get_stokes_indices(→ StokesIndex)

Get the start and end indices for Stokes axes

main(→ None)

make_cutout(→ astropy.io.fits.HDUList)

Make a cutout of a FITS file

make_slicer(→ tuple[slice, Ellipsis])

Create a slicer for a given WCS, centre, radius, and frequency range

update_header(→ astropy.io.fits.Header)

Update the header to reflect the cutout

Module Contents

class cutout_fits.cutout.SpatialIndex

Bases: NamedTuple

Start and end indices for spatial axes.

start_ra_index

int | None

end_ra_index

int | None

start_dec_index

int | None

end_dec_index

int | None

end_dec_index: int | None

End index for Dec axis

end_ra_index: int | None

End index for RA axis

start_dec_index: int | None

Start index for Dec axis

start_ra_index: int | None

Start index for RA axis

class cutout_fits.cutout.SpectralIndex

Bases: NamedTuple

Start and end indices for spectral axes.

start_freq_index

int | None

end_freq_index

int | None

end_freq_index: int | None

End index for frequency axis

start_freq_index: int | None

Start index for frequency axis

class cutout_fits.cutout.StokesIndex

Bases: NamedTuple

Start and end indices for Stokes axes.

start_stokes_index

int | None

end_stokes_index

int | None

end_stokes_index: int | None

End index for Stokes axis

start_stokes_index: int | None

Start index for Stokes axis

cutout_fits.cutout.cutout_beamtable(hdu: astropy.io.fits.BinTableHDU, image_wcs: astropy.wcs.WCS, freq_start_hz: float | None = None, freq_end_hz: float | None = None) astropy.io.fits.BinTableHDU

Cut out a beam table

Parameters:
  • hdu (fits.BinTableHDU) – HDU with the beam table

  • image_wcs (WCS) – WCS of the image that needs beams

  • freq_start_hz (float | None, optional) – Starting frequency cut in Hz. Defaults to None.

  • freq_end_hz (float | None, optional) – End frequnecy cut in Hz. Defaults to None.

Returns:

Cutout beam table

Return type:

fits.BinTableHDU

cutout_fits.cutout.format_shape(wcs: astropy.wcs.WCS, shape: tuple[int, Ellipsis]) str

Produce a string representation of the shape of an cube

Parameters:
  • wcs (WCS) – Cube WCS

  • shape (tuple[int,...]) – Shape of the cube

Returns:

String representation of the shape

Return type:

str

cutout_fits.cutout.get_cutout_parser(parent_parser: bool = False) argparse.ArgumentParser
cutout_fits.cutout.get_cutout_shape(wcs: astropy.wcs.WCS, slicer: tuple[slice, Ellipsis]) tuple[int, Ellipsis]

Get the shape of a cutout

Parameters:
  • wcs (WCS) – WCS of the cutout

  • slicer (tuple[slice, ...]) – Slicer for the cutout

Returns:

Shape of the cutout

Return type:

tuple[int, …]

cutout_fits.cutout.get_file_parser(parent_parser: bool = False) argparse.ArgumentParser
cutout_fits.cutout.get_spatial_indices(wcs: astropy.wcs.WCS, centre: astropy.coordinates.SkyCoord, radius: astropy.units.Quantity) SpatialIndex

Get the start and end indices for spatial axes

Parameters:
  • wcs (WCS) – WCS for HDU

  • centre (SkyCoord) – Centre of cutout

  • radius (u.Quantity) – Radius of cutout

Returns:

start_ra_index, end_ra_index, start_dec_index, end_dec_index

Return type:

SpatialIndex

cutout_fits.cutout.get_spectral_indices(wcs: astropy.wcs.WCS, start_freq: astropy.units.Quantity | None = None, end_freq: astropy.units.Quantity | None = None) SpectralIndex

Get the start and end indices for spectral axes

Parameters:
  • wcs (WCS) – WCS for HDU

  • start_freq (u.Quantify | None, optional) – Starting frequency. Defaults to None.

  • end_freq (u.Quantify | None, optional) – End frequency. Defaults to None.

Returns:

start_freq_index, end_freq_index

Return type:

SpectralIndex

cutout_fits.cutout.get_stokes_indices(wcs: astropy.wcs.WCS) StokesIndex

Get the start and end indices for Stokes axes

Parameters:

wcs (WCS) – WCS for HDU

Returns:

start_stokes_index, end_stokes_index

Return type:

StokesIndex

cutout_fits.cutout.main() None
cutout_fits.cutout.make_cutout(infile: str, outfile: str, ra_deg: float, dec_deg: float, radius_arcmin: float, freq_start_hz: float | None = None, freq_end_hz: float | None = None, overwrite: bool = False) astropy.io.fits.HDUList

Make a cutout of a FITS file

Parameters:
  • infile (str) – Path to FITS file - can be a remote URL

  • outfile (str) – Path to output file - must be local

  • ra_deg (float) – Centre RA in degrees

  • dec_deg (float) – Centre Dec in degrees

  • radius_arcmin (float) – Cutout radius in arcminutes

  • freq_start_hz (float | None, optional) – Start frequency in Hz. Defaults to None.

  • freq_end_hz (float | None, optional) – End frequency in Hz. Defaults to None.

  • overwrite (bool) – Whether to overwrite the output file.

Returns:

Cutout HDUList

Return type:

fits.HDUList

cutout_fits.cutout.make_slicer(wcs: astropy.wcs.WCS, centre: astropy.coordinates.SkyCoord, radius: astropy.units.Quantity, start_freq: astropy.units.Quantity | None = None, end_freq: astropy.units.Quantity | None = None) tuple[slice, Ellipsis]

Create a slicer for a given WCS, centre, radius, and frequency range

Parameters:
  • wcs (WCS) – WCS for HDU

  • centre (SkyCoord) – Centre of cutout

  • radius (u.Quantity) – Radius of cutout

  • start_freq (u.Quantity | None, optional) – Starting frequency. Defaults to None.

  • end_freq (u.Quantity | None, optional) – End frequnecy. Defaults to None.

Returns:

Tuple of slices for each axis - in numpy order

Return type:

Tuple[slice,…]

cutout_fits.cutout.update_header(old_header: astropy.io.fits.Header, slicer: tuple[slice, Ellipsis]) astropy.io.fits.Header

Update the header to reflect the cutout

Parameters:
  • old_header (fits.Header) – Original header

  • slicer (tuple[slice, ...]) – Slicer for the cutout

Returns:

Cutout header

Return type:

fits.Header

cutout_fits.cutout._ = False