arrakis.imager

Arrkis imager

Attributes

TQDM_OUT

Classes

ImageSet

Container to organise files related to t he imaging of a measurement set.

MFSImage

Representation of a multi-frequency synthesis image.

Functions

cleanup(→ None)

Utility to remove all images described by an collection of ImageSets. Internally

cleanup_imageset(→ None)

Delete images associated with an input ImageSet

cli()

Command-line interface

fix_ms(→ pathlib.Path)

Apply the corrections to the FEED table of a measurement set that

fix_ms_askap_corrs(→ pathlib.Path)

Applies a correction to raw telescope polarisation products to rotate them

get_beam(→ pathlib.Path)

Derive a common resolution across all images within a set of ImageSet

get_mfs_image() → MFSImage)

Get the MFS image from the image set.

get_pol_axis_task(→ float)

get_prefix(→ pathlib.Path)

Derive a consistent prefix style from a input MS name.

get_wsclean(→ pathlib.Path)

Pull wsclean image from dockerhub (or wherver).

image_beam(→ ImageSet)

Image a single beam

imager_parser(→ argparse.ArgumentParser)

Return the argument parser for the imager routine.

main(msdir, out_dir[, num_beams, temp_dir_images, ...])

Arrakis imager flow

make_cube(→ Tuple[pathlib.Path, pathlib.Path])

Make a cube from the images

make_validation_plots(→ None)

Make validation plots for the images.

merge_imagesets(→ ImageSet)

Merge a collection of ImageSets into a single ImageSet.

run_wsclean_singuarlity(→ None)

smooth_imageset(→ ImageSet)

Smooth all images described within an ImageSet to a desired resolution

Module Contents

class arrakis.imager.ImageSet[source]

Bases: NamedTuple

Container to organise files related to t he imaging of a measurement set.

aux_lists: Dict[Tuple[str, str], List[str]] | None = None[source]

Dictionary of lists of auxillary images. The keys are a tuple of the polarisation and the image type, and the values are the list of images for that polarisation and image type.

image_lists: Dict[str, List[str]][source]

Dictionary of lists of images. The keys are the polarisations and the values are the list of images for that polarisation.

ms: pathlib.Path[source]

Path to the measurement set that was imaged.

prefix: str[source]

Prefix used for the wsclean output files.

class arrakis.imager.MFSImage[source]

Bases: NamedTuple

Representation of a multi-frequency synthesis image.

image: numpy.ndarray[source]

The image data.

model: numpy.ndarray[source]

The model data.

residual: numpy.ndarray[source]

The residual data.

arrakis.imager.cleanup(purge: bool, image_sets: List[ImageSet], ignore_files: List[Any] | None = None) None[source]

Utility to remove all images described by an collection of ImageSets. Internally called cleanup_imageset.

Parameters:
  • purge (bool) – Whether files are actually removed or skipped.

  • image_sets (List[ImageSet]) – Collection of ImageSets that would be deleted

  • ignore_files (Optional, List[Any]) – Collection of items to ignore. Nothing is done with this

  • and is purely used to exploit the dask dependency tracking.

arrakis.imager.cleanup_imageset(purge: bool, image_set: ImageSet) None[source]

Delete images associated with an input ImageSet

Parameters:
  • purge (bool) – Whether files will be deleted or skipped.

  • image_set (ImageSet) – Collection of files that will be removed.

arrakis.imager.cli()[source]

Command-line interface

arrakis.imager.fix_ms(ms: pathlib.Path) pathlib.Path[source]

Apply the corrections to the FEED table of a measurement set that is required for the ASKAP measurement sets.

Parameters:

ms (Path) – Path to the measurement set to fix.

Returns:

Path to the corrected measurement set.

Return type:

Path

arrakis.imager.fix_ms_askap_corrs(ms: pathlib.Path, *args, **kwargs) pathlib.Path[source]

Applies a correction to raw telescope polarisation products to rotate them to the wsclean espected form. This is essentially related to the third-axis of ASKAP and reorientating its ‘X’ and ‘Y’s.

Parameters:

ms (Path) – Path to the measurement set to be corrected.

Returns:

Path of the measurementt set containing the corrections.

Return type:

Path

arrakis.imager.get_beam(image_set: ImageSet, cutoff: float | None) pathlib.Path[source]

Derive a common resolution across all images within a set of ImageSet

Parameters:
  • image_set (ImageSet) – ImageSet that a common resolution will be derived for

  • cuttoff (float, optional) – The maximum major axis of the restoring beam that is allowed when

  • searching for the lowest common beam. Images whose restoring beam’s major acis is larger than

  • this are ignored. Defaults to None.

Returns:

Path to the pickled beam object

Return type:

Path

arrakis.imager.get_mfs_image(prefix_str: str, pol: str, small_size: Tuple[int, int] = (512, 512)) MFSImage[source]

Get the MFS image from the image set.

Returns:

The MFS image.

Return type:

MFSImage

arrakis.imager.get_pol_axis_task(ms: pathlib.Path, feed_idx: int | None = None, col: str = 'RECEPTOR_ANGLE') float[source]
arrakis.imager.get_prefix(ms: pathlib.Path, out_dir: pathlib.Path) pathlib.Path[source]

Derive a consistent prefix style from a input MS name.

Parameters:
  • ms (Path) – Path to a Measurement Set that a prefix will be derived from

  • out_dir (Path) – The final location that wsclean output data will be written to

Returns:

The prefix, including the output directory name.

Return type:

Path

arrakis.imager.get_wsclean(wsclean: pathlib.Path | str) pathlib.Path[source]

Pull wsclean image from dockerhub (or wherver).

Parameters:

version (str, optional) – wsclean image tag. Defaults to “3.1”.

Returns:

Path to wsclean image.

Return type:

Path

arrakis.imager.image_beam(ms: pathlib.Path, field_idx: int, out_dir: pathlib.Path, prefix: pathlib.Path, simage: pathlib.Path, temp_dir_wsclean: pathlib.Path, temp_dir_images: pathlib.Path, pols: str = 'IQU', nchan: int = 36, scale: float = 2.5, npix: int = 4096, join_polarizations: bool = True, join_channels: bool = True, squared_channel_joining: bool = True, mgain: float = 0.7, niter: int = 100000, auto_mask: float = 3, force_mask_rounds: int | None = None, auto_threshold: float = 1, gridder: str | None = None, robust: float = -0.5, mem: float = 90, absmem: float | None = None, taper: float | None = None, minuv_l: float = 0.0, parallel_deconvolution: int | None = None, nmiter: int | None = None, local_rms: bool = False, local_rms_window: float | None = None, multiscale: bool = False, multiscale_scale_bias: float | None = None, multiscale_scales: str | None = '0,2,4,8,16,32,64,128', data_column: str = 'CORRECTED_DATA', no_mf_weighting: bool = False, no_update_model_required: bool = True, beam_fitting_size: float | None = 1.25, disable_pol_local_rms: bool = False, disable_pol_force_mask_rounds: bool = False) ImageSet[source]

Image a single beam

arrakis.imager.imager_parser(parent_parser: bool = False) argparse.ArgumentParser[source]

Return the argument parser for the imager routine.

Parameters:

parent_parser (bool, optional) – Ensure the parser is configured so it can be added as a parent to a new parser. This will disables the -h/–help action from being generated. Defaults to False.

Returns:

Arguments required for the imager routine

Return type:

argparse.ArgumentParser

arrakis.imager.main(msdir: pathlib.Path, out_dir: pathlib.Path, num_beams: int = 36, temp_dir_images: pathlib.Path | None = None, temp_dir_wsclean: pathlib.Path | None = None, cutoff: float | None = None, robust: float = -0.5, pols: str = 'IQU', nchan: int = 36, size: int = 6074, scale: float = 2.5, mgain: float = 0.8, niter: int = 100000, auto_mask: float = 3, force_mask_rounds: int | None = None, auto_threshold: float = 1, taper: float | None = None, purge: bool = False, minuv: float = 0.0, parallel_deconvolution: int | None = None, gridder: str | None = None, nmiter: int | None = None, local_rms: bool = False, local_rms_window: float | None = None, wsclean_path: pathlib.Path | str = 'docker://alecthomson/wsclean:latest', multiscale: bool | None = None, multiscale_scale_bias: float | None = None, multiscale_scales: str | None = '0,2,4,8,16,32,64,128', absmem: float | None = None, make_residual_cubes: bool | None = False, ms_glob_pattern: str = 'scienceData*_averaged_cal.leakage.ms', data_column: str = 'CORRECTED_DATA', skip_fix_ms: bool = False, no_mf_weighting: bool = False, disable_pol_local_rms: bool = False, disable_pol_force_mask_rounds: bool = False)[source]

Arrakis imager flow

Parameters:
  • msdir (Path) – Path to the directory containing the MS files.

  • out_dir (Path) – Path to the directory where the images will be written.

  • num_beams (int, optional) – Number of beams to image. Defaults to 36.

  • temp_dir_images (Optional[Path], optional) – Path for temporary files to be written. Defaults to None.

  • temp_dir_wsclean (Optional[Path], optional) – Path for temporary files to be written by WSClean. Defaults to None.

  • cutoff (Optional[float], optional) – WSClean cutoff. Defaults to None.

  • robust (float, optional) – WSClean Briggs robust parameter. Defaults to -0.5.

  • pols (str, optional) – WSClean polarisations. Defaults to “IQU”.

  • nchan (int, optional) – WSClean number of output channels. Defaults to 36.

  • size (int, optional) – WSClean image size. Defaults to 6074.

  • scale (float, optional) – WSClean pixel size (arcseconds). Defaults to 2.5.

  • mgain (float, optional) – WSClean mgain. Defaults to 0.8.

  • niter (int, optional) – WSClean niter. Defaults to 100_000.

  • auto_mask (float, optional) – WSClean automatic masking (in SNR). Defaults to 3.

  • force_mask_rounds (Union[int, None], optional) – WSClean force mask rounds (requires modified WSClean). Defaults to None.

  • auto_threshold (float, optional) – WSClean auto threshold (in SNR). Defaults to 1.

  • taper (Union[float, None], optional) – WSClean taper (in arcsec). Defaults to None.

  • purge (bool, optional) – Purge auxillary files after imaging. Defaults to False.

  • minuv (float, optional) – WSClean minuv-l. Defaults to 0.0.

  • parallel_deconvolution (Optional[int], optional) – WSClean parallel deconvolution. Defaults to None.

  • gridder (Optional[str], optional) – WSClean gridder. Defaults to None.

  • nmiter (Optional[int], optional) – WSClean nmiter. Defaults to None.

  • local_rms (bool, optional) – WSClean local_rms. Defaults to False.

  • local_rms_window (Optional[float], optional) – WSClean local_rms_window. Defaults to None.

  • wsclean_path (Path | str, optional) – Path or URL for WSClean container. Defaults to “docker://alecthomson/wsclean:latest”.

  • multiscale (Optional[bool], optional) – WSClean multiscale. Defaults to None.

  • multiscale_scale_bias (Optional[float], optional) – WSClean multiscale bias. Defaults to None.

  • multiscale_scales (Optional[str], optional) – WSClean scales. Defaults to “0,2,4,8,16,32,64,128”.

  • absmem (Optional[float], optional) – WSClean absmem usage. Defaults to None.

  • make_residual_cubes (Optional[bool], optional) – Make resiudal image cubes. Defaults to False.

  • ms_glob_pattern (str, optional) – Globe pattern for MS files. Defaults to “scienceData*_averaged_cal.leakage.ms”.

  • data_column (str, optional) – Data column to image. Defaults to “CORRECTED_DATA”.

  • skip_fix_ms (bool, optional) – Apply FixMS. Defaults to False.

  • no_mf_weighting (bool, optional) – WSClean no_mf_weighting. Defaults to False.

  • disable_pol_local_rms (bool, optional) – Disable local RMS for polarisation images. Defaults to False.

  • disable_pol_force_mask_rounds (bool, optional) – Disable force mask rounds for polarisation images. Defaults to False.

arrakis.imager.make_cube(pol: str, image_set: ImageSet, common_beam_pkl: pathlib.Path, pol_angle_deg: float, aux_mode: str | None = None) Tuple[pathlib.Path, pathlib.Path][source]

Make a cube from the images

arrakis.imager.make_validation_plots(prefix: pathlib.Path, pols: str) None[source]

Make validation plots for the images.

Parameters:
  • prefix (Path) – Prefix of the images.

  • pols (str) – Polarisation to make the plots for.

arrakis.imager.merge_imagesets(image_sets: List[ImageSet | None]) ImageSet[source]

Merge a collection of ImageSets into a single ImageSet.

Parameters:

image_sets (List[ImageSet]) – Collection of ImageSets to merge.

Returns:

A single ImageSet containing all the images from the input ImageSets.

Return type:

ImageSet

arrakis.imager.run_wsclean_singuarlity(command: str, simage: pathlib.Path, out_dir: pathlib.Path, root_dir: pathlib.Path) None[source]
arrakis.imager.smooth_imageset(image_set: ImageSet, common_beam_pkl: pathlib.Path, cutoff: float | None = None, aux_mode: str | None = None) ImageSet[source]

Smooth all images described within an ImageSet to a desired resolution

Parameters:
  • image_set (ImageSet) – Container whose image_list will be convolved to common resolution

  • common_beam_pkl (Path) – Location of pickle file with beam description

  • cutoff (Optional[float], optional) – PSF cutoff passed to the beamcon_2D worker. Defaults to None.

  • aux_model (Optional[str], optional) – The image type in the aux_lists property of image_set that contains the images to smooth. If

  • not set then the `image_lists` property of `image_set` is used. Defaults to None.

Returns:

A copy of image_set pointing to the smoothed images. Note the aux_images property is not carried forward.

Return type:

ImageSet

arrakis.imager.TQDM_OUT[source]