arrakis.imager ============== .. py:module:: arrakis.imager .. autoapi-nested-parse:: Arrkis imager .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: arrakis.imager.TQDM_OUT Classes ------- .. autoapisummary:: arrakis.imager.ImageSet arrakis.imager.MFSImage Functions --------- .. autoapisummary:: arrakis.imager.cleanup arrakis.imager.cleanup_imageset arrakis.imager.cli arrakis.imager.fix_ms arrakis.imager.fix_ms_askap_corrs arrakis.imager.get_beam arrakis.imager.get_mfs_image arrakis.imager.get_pol_axis_task arrakis.imager.get_prefix arrakis.imager.get_wsclean arrakis.imager.image_beam arrakis.imager.imager_parser arrakis.imager.main arrakis.imager.make_cube arrakis.imager.make_validation_plots arrakis.imager.merge_imagesets arrakis.imager.run_wsclean_singuarlity arrakis.imager.smooth_imageset Module Contents --------------- .. py:class:: ImageSet Bases: :py:obj:`NamedTuple` Container to organise files related to t he imaging of a measurement set. .. !! processed by numpydoc !! .. py:attribute:: aux_lists :type: dict[tuple[str, str], list[str]] | None :value: None Dictionary of lists of auxiliary 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. .. !! processed by numpydoc !! .. py:attribute:: image_lists :type: dict[str, list[str]] Dictionary of lists of images. The keys are the polarisations and the values are the list of images for that polarisation. .. !! processed by numpydoc !! .. py:attribute:: ms :type: pathlib.Path Path to the measurement set that was imaged. .. !! processed by numpydoc !! .. py:attribute:: prefix :type: str Prefix used for the wsclean output files. .. !! processed by numpydoc !! .. py:class:: MFSImage Bases: :py:obj:`NamedTuple` Representation of a multi-frequency synthesis image. .. !! processed by numpydoc !! .. py:attribute:: image :type: numpy.ndarray The image data. .. !! processed by numpydoc !! .. py:attribute:: model :type: numpy.ndarray The model data. .. !! processed by numpydoc !! .. py:attribute:: residual :type: numpy.ndarray The residual data. .. !! processed by numpydoc !! .. py:function:: cleanup(purge: bool, image_sets: list[ImageSet], ignore_files: list[Any] | None = None) -> None 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.** .. !! processed by numpydoc !! .. py:function:: cleanup_imageset(purge: bool, image_set: ImageSet) -> None 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. .. !! processed by numpydoc !! .. py:function:: cli() Command-line interface .. !! processed by numpydoc !! .. py:function:: fix_ms(ms: pathlib.Path) -> pathlib.Path 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. :rtype: Path .. !! processed by numpydoc !! .. py:function:: fix_ms_askap_corrs(ms: pathlib.Path, *args, **kwargs) -> pathlib.Path Applies a correction to raw telescope polarisation products to rotate them to the wsclean expected 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. :rtype: Path .. !! processed by numpydoc !! .. py:function:: get_beam(image_set: ImageSet, cutoff: float | None) -> pathlib.Path 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 :rtype: Path .. !! processed by numpydoc !! .. py:function:: get_mfs_image(prefix_str: str, pol: str, small_size: tuple[int, int] = (512, 512)) -> MFSImage Get the MFS image from the image set. :returns: The MFS image. :rtype: MFSImage .. !! processed by numpydoc !! .. py:function:: get_pol_axis_task(ms: pathlib.Path, feed_idx: int | None = None, col: str = 'RECEPTOR_ANGLE') -> float .. py:function:: get_prefix(ms: pathlib.Path, out_dir: pathlib.Path) -> pathlib.Path 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. :rtype: Path .. !! processed by numpydoc !! .. py:function:: get_wsclean(wsclean: pathlib.Path | str) -> pathlib.Path Pull wsclean image from dockerhub (or wherver). :Parameters: **version** (*str, optional*) -- wsclean image tag. Defaults to "3.1". :returns: Path to wsclean image. :rtype: Path .. !! processed by numpydoc !! .. py:function:: 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 Image a single beam .. !! processed by numpydoc !! .. py:function:: imager_parser(parent_parser: bool = False) -> argparse.ArgumentParser 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 :rtype: argparse.ArgumentParser .. !! processed by numpydoc !! .. py:function:: 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) 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 auxiliary 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. .. !! processed by numpydoc !! .. py:function:: 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] Make a cube from the images .. !! processed by numpydoc !! .. py:function:: make_validation_plots(prefix: pathlib.Path, pols: str) -> None Make validation plots for the images. :Parameters: * **prefix** (*Path*) -- Prefix of the images. * **pols** (*str*) -- Polarisation to make the plots for. .. !! processed by numpydoc !! .. py:function:: merge_imagesets(image_sets: list[ImageSet | None]) -> ImageSet 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. :rtype: ImageSet .. !! processed by numpydoc !! .. py:function:: run_wsclean_singuarlity(command: str, simage: pathlib.Path, out_dir: pathlib.Path, root_dir: pathlib.Path) -> None .. py:function:: smooth_imageset(image_set: ImageSet, common_beam_pkl: pathlib.Path, cutoff: float | None = None, aux_mode: str | None = None) -> ImageSet 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. :rtype: ImageSet .. !! processed by numpydoc !! .. py:data:: TQDM_OUT