flint.convol

Tooling related to the convolution of images. Principally this is mostly to smooth to a common resolution

Classes

BeamShape

A simple container to represent a fitted 2D gaussian,

Functions

check_if_cube_fits(→ bool)

Check to see whether the data component of a FITS images is a cube.

cli(→ None)

convolve_cubes(→ Collection[pathlib.Path])

convolve_images(→ list[pathlib.Path])

Convolve a set of input images to a common resolution as specified

get_common_beam(→ BeamShape)

Return the minimum beam size required to encompass the beams described

get_cube_common_beam(→ list[BeamShape])

Given a set of input cube FITS files, compute a common beam

get_parser(→ argparse.ArgumentParser)

Module Contents

class flint.convol.BeamShape[source]

Bases: NamedTuple

A simple container to represent a fitted 2D gaussian, intended for the main lobe of the synthesised beam. This class has been defined to avoid issues with the serialisation of astropy.units, which can cause strange and wonderful errors when being sent over the wire to workers.

classmethod from_radio_beam(radio_beam: radio_beam.Beam) BeamShape[source]

A helper function to convert a radio_beam.Beam into a BeamShape. This is prinicpally intended to be used when there is a need to exchange a Beam between processes that would need to serialise the object.

Parameters:

radio_beam (Beam) – The Beam to convert to normalised and known units

Returns:

The normalised container without astropy units.

Return type:

BeamShape

bmaj_arcsec: float[source]

The size of the major-axis of the beam, in arcseconds.

bmin_arcsec: float[source]

The size of the minor-axis of the beam, in arcseconds.

bpa_deg: float[source]

Rotation of the beam, in degrees.

flint.convol.check_if_cube_fits(fits_file: pathlib.Path) bool[source]

Check to see whether the data component of a FITS images is a cube. Returns True is the data-shape needs 3-dimensions to be represented.

Note: Unclear on usefulness

Parameters:

fits_file (Path) – FITS file that will be examinined

Returns:

Whether the input FITS file is a cube or not.

Return type:

bool

flint.convol.cli() None[source]
flint.convol.convolve_cubes(cube_paths: Collection[pathlib.Path], beam_shapes: list[BeamShape], cutoff: float | None = None, convol_suffix: str = 'conv', executor_type: Literal['thread', 'process', 'mpi'] = 'thread') Collection[pathlib.Path][source]
flint.convol.convolve_images(image_paths: Collection[pathlib.Path], beam_shape: BeamShape, cutoff: float | None = None, convol_suffix: str = 'conv', output_paths: list[pathlib.Path] | None = None) list[pathlib.Path][source]

Convolve a set of input images to a common resolution as specified by the beam_shape. If the major-axis of the native resolution is larger than cutoff (in arcseconds) then the racs_tools beamconv_2D task will nan it.

Additionally, some input subject image will simply copied if:

  • the input beam_shape is not finite, or

  • the beamshape encoded in the FITS header of the subject image is not defined

Parameters:
  • image_paths (Collection[Path]) – Set of image paths to FITS images to convol

  • beam_shape (BeamShape) – The specification of the desired final resolution

  • cutoff (Optional[float], optional) – Images whose major-axis is larger than this will be blank. Expected in arcseconds. Defaults to None.

  • convol_suffix (str, optional) – The suffix added to .fits to indicate smoothed image. Defaults to ‘conv’.

  • output_paths (list[Path] | None, optional) – The final output file namesfor each input image. If provided this renamed files created using the convol_suffix. Defaults to None.

Returns:

Set of paths to the smoothed images

Return type:

Collection[Path]

flint.convol.get_common_beam(image_paths: Collection[pathlib.Path], cutoff: float | None = None) BeamShape[source]

Return the minimum beam size required to encompass the beams described in the FITS header (e.g. BMAJ,BMIN,BPA) of the input images. This is used when preparing to convolve to a common resolution.

Parameters:
  • image_paths (Collection[Path]) – The paths to the FITS images that will be examined.

  • cutoff (Optional[float], optional) – The maximum beam size an input image is allowed to have. BMAJ’s larger than this are ignored from the calculation. Defaults to None.

Returns:

Smalled common beam available to be used

Return type:

BeamShape

flint.convol.get_cube_common_beam(cube_paths: Collection[pathlib.Path], cutoff: float | None = None) list[BeamShape][source]

Given a set of input cube FITS files, compute a common beam for each channel.

Parameters:
  • cube_paths (Collection[Path]) – Set of cube FITS files to inspect to derive a common beam

  • cutoff (Optional[float], optional) – A cutoff value, in arcsec, that specifies the maximum BMAJ allowed. Defaults to None.

Returns:

List of target beam shapes to use, corresponding to each channel

Return type:

List[BeamShape]

flint.convol.get_parser() argparse.ArgumentParser[source]