karabo.imaging.imager_wsclean

Overview

This package summarizes tools and functions to be used with the imager based on the WSClean algorithm.

Classes

class WscleanDirtyImager(config: DirtyImagerConfig)

Dirty imager based on the WSClean library.

WSClean is integrated by calling the wsclean command line tool. The parameters in the config (DirtyImagerConfig) attribute are passed to wsclean. Use the create_image_custom_command function if you need to set params not available in DirtyImagerConfig.

config

Config containing parameters for dirty imaging

Type:

DirtyImagerConfig

__init__(config: DirtyImagerConfig) None

Initializes the instance with a config.

Parameters:

config (DirtyImagerConfig) – see config attribute

create_dirty_image(visibility: Visibility, /, *, output_fits_path: Path | str | None = None) Image

Creates a dirty image from a visibility.

Parameters:
  • visibility – Visibility object from which to create the dirty image. Contains the visibilities of an observation.

  • output_fits_path – Path to write the dirty image to. Example: /tmp/dirty.fits. If None, will be set to a temporary directory and a default file name. Defaults to None.

Returns:

Dirty image

Return type:

Image

class WscleanImageCleanerConfig(imaging_npixel: int, imaging_cellsize: float, niter: int | None = 50000, mgain: float | None = 0.8, auto_threshold: int | None = 3)

Config / parameters of a WscleanImageCleaner.

Adds parameters specific to WscleanImageCleaner.

niter

Maximum number of clean iterations to perform. Defaults to 50000.

Type:

Optional[int]

mgain

Cleaning gain for major iterations: Ratio of peak that will be subtracted in each major iteration. To use major iterations, 0.85 is a good value. Defaults to 0.8.

Type:

Optional[float]

auto_threshold

Relative clean threshold. Estimate noise level using a robust estimator and stop at sigma x stddev. Defaults to 3.

Type:

Optional[int]

__init__(imaging_npixel: int, imaging_cellsize: float, niter: int | None = 50000, mgain: float | None = 0.8, auto_threshold: int | None = 3) None
class WscleanImageCleaner(config: WscleanImageCleanerConfig)

Image cleaner based on the WSClean library.

WSClean is integrated by calling the wsclean command line tool. The parameters in the config (WscleanImageCleanerConfig) attribute are passed to wsclean. Use the create_image_custom_command function if you need to set params not available in WscleanImageCleanerConfig. Parameters in the config that are explicitly set to None will not be passed to the command line tool, which will then resort to its own default values.

config

Config containing parameters for WSClean image cleaning.

Type:

WscleanImageCleanerConfig

__init__(config: WscleanImageCleanerConfig) None

Initializes the instance with a config.

Parameters:

config (WscleanImageCleanerConfig) – see config attribute

create_cleaned_image(visibility: Visibility, /, *, dirty_fits_path: Path | str | None = None, output_fits_path: Path | str | None = None) Image

Creates a clean image from a dirty image or from visibilities.

Parameters:
  • visibility – Visibility from which a clean image should be created.

  • dirty_fits_path – Path to dirty image FITS file that should be reused to create a clean image. If None, dirty image will be created first from the visibilities. Defaults to None.

  • output_fits_path – Path to write the clean image to. Example: /tmp/restored.fits. If None, will be set to a temporary directory and a default file name. Defaults to None.

Returns:

Clean image

Return type:

Image

Functions

create_image_custom_command(command: str, output_filenames: str | List[str] = 'wsclean-image.fits') Image | List[Image]

Create a dirty or cleaned image using your own command.

Allows the use of the full WSClean functionality with all parameters. Command has to start with ‘wsclean ‘. The working directory the command runs in will be a temporary directory. Use absolute paths to reference files or directories like the measurement set.

Parameters:
  • command – Command to execute. Example: wsclean -size 2048 2048 -scale 0.00222222deg -niter 50000 -mgain 0.8 -abs-threshold 100µJy /tmp/measurements.MS

  • output_filenames – WSClean output filename(s) (relative to the working directory) that should be returned as Image objects. Can be a string for one file or a list of strings for multiple files. Example 1: “wsclean-image.fits” Example 2: [‘wsclean-image.fits’, ‘wsclean-residual.fits’]

Returns:

  • If output_filenames is a string, returns an Image object of the file output_filenames.

  • If output_filenames is a list of strings, returns a list of Image objects, one object per filename in output_filenames.