flint.peel.potato¶
Utilities the connect to Stefan Duchesne potatopeel module, which is responsible for peeling sources in racs. The repository is available at:
https://gitlab.com/Sunmish/potato/-/tree/main
Potato stands for “Peel Out That Annoying Terrible Object”.
Although this is a python module, for the moment it is expected to be in a singularity container. There are several reasons for this, but the principal one is that the numba module used by potatopeel may be difficult to get working correctly alongside dask and flint. Keeping it simple at this point is the main aim. There is also the problem of casatasks + python-casacore not jiving in newer python versions.
Classes¶
Temporary container to hold the normalised source properties that |
|
Container for potato configuration command results |
|
Container class to hold options that go into the potatopy |
|
The mandatory arguments for potato peel. |
|
Container to hold the items of the hot potato command |
|
Container class to hold options that go to the potato peel |
Functions¶
|
Create the peel_configuration.py command that will be called |
|
Construct the CLI options that would be provided to |
|
Construct the CLI command for hot_potato, and appropriately |
Create the appropriate set of potato option class instances. This function |
|
|
A dummy function to print colnames in a MS table |
|
|
|
Construct and run a CLI command into the peel_configuration.py |
|
Construct and run a hot_potato command to peel out sources from |
|
Obtain a set of sources to peel from a reference candidate set. This will |
|
|
|
Given the astropy table of known sources to peel, normalise their |
|
Locate and load the packaged set of known sources to peel. These sources |
|
Peel out sources from a measurement set using PotatoPeel. Candidate sources |
|
The potatopeel software requires the data column being operated against to be |
|
Evaluate whether a source will be within the field of view |
Module Contents¶
- class flint.peel.potato.NormalisedSources[source]¶
Bases:
NamedTupleTemporary container to hold the normalised source properties that would be provided to potato
- class flint.peel.potato.PotatoConfigCommand[source]¶
Bases:
NamedTupleContainer for potato configuration command results
- class flint.peel.potato.PotatoConfigOptions[source]¶
Bases:
NamedTupleContainer class to hold options that go into the potatopy configuration creation software by Stefan Duchesne. See:
- class flint.peel.potato.PotatoPeelArguments[source]¶
Bases:
NamedTupleThe mandatory arguments for potato peel.
- image_fov: float[source]¶
The field-of-view in degrees of the main in-field image. If a sources is within this radius it is not peeled (because it would be imaged)
- class flint.peel.potato.PotatoPeelCommand[source]¶
Bases:
NamedTupleContainer to hold the items of the hot potato command
- ms: flint.options.MS[source]¶
The measurement set that potato has operated against
- class flint.peel.potato.PotatoPeelOptions[source]¶
Bases:
NamedTupleContainer class to hold options that go to the potato peel software by Stefan Duchesne. FLINT uses the hot_potato version. ee:
https://gitlab.com/Sunmish/potato
- with_options(**kwargs) PotatoPeelOptions[source]¶
- direct_subtract: bool = True[source]¶
Whether a direct model subtraction (without self-cal) should be used ift he source is faint
- intermediate_peels: bool = True[source]¶
Creates an image after each calibration and subtraction loop to show iterative improvements of the subject peel source
- minpeelflux: float = 0.5[source]¶
Minimum flux, in Jy, for the peeling procedure (image->selfcal->image)
- flint.peel.potato._potato_config_command(config_path: pathlib.Path, potato_config_options: PotatoConfigOptions) PotatoConfigCommand[source]¶
Create the peel_configuration.py command that will be called in the potato singularity image. This is the CLI version of the code (not calling the python function).
- Parameters:
config_path (Path) – Output location of the configuration file
potato_config_options (PotatoConfigOptions) – Instance of all the options to use
- Returns:
The CLI command that will be executed to create a potato configuration file
- Return type:
PotatoconfigCommand
- flint.peel.potato._potato_options_to_command(potato_options: PotatoPeelArguments | PotatoConfigOptions | PotatoPeelOptions, skip_keys: Collection[str] | None = None, check_double_keys: bool = False) str[source]¶
Construct the CLI options that would be provided to a potato peel CLI program
- Parameters:
potato_options (Union[PotatoPeelArguments,PotatoConfigOptions, PotatoPeelOptions]) – An instance of one of the option classes to draw from
skip_keys (Optional[Collection[str]], optional) – A collections of keys to ignore when build the CLI. If None all keys in the provided options instance are used. Defaults to None.
check_double_leys (bool, optional) – Some long form names in hot_potato are single dash while others are double dash. This is not the case in the config creation tool. This will check to see if the double should be used. Defaults to False.
- Raises:
TypeError – When an unrecognised data type is found in the provided options class
- Returns:
A string of the CLI options and keys
- Return type:
str
- flint.peel.potato._potato_peel_command(ms: flint.options.MS, potato_peel_arguments: PotatoPeelArguments, potato_peel_options: PotatoPeelOptions) PotatoPeelCommand[source]¶
Construct the CLI command for hot_potato, and appropriately handle the mandatory and optional arguments.
- Parameters:
ms (MS) – The measurement set that will be peeled
potato_peel_arguments (PotatoPeelArguments) – The mandatory arguments for hot_potato
potato_peel_options (PotatoPeelOptions) – The hot_potato options to supply
- Returns:
The hot_potato command that was constructed from the input PotatoPeelOptions
- Return type:
- flint.peel.potato._prepare_potato_options(ms: flint.options.MS, potato_container: pathlib.Path, update_potato_config_options: dict[str, Any] | None = None, update_potato_peel_options: dict[str, Any] | None = None) tuple[PotatoConfigOptions | None, PotatoPeelOptions][source]¶
Create the appropriate set of potato option class instances. This function will assess if a configuration file has been specified, and if not it will generate one from the potato configuration generator program. This is a call out to singularity.
- Parameters:
ms (MS) – The measurement set to be peeled
potato_container (Path) – Path to the container that holds potato
update_potato_config_options (dict[str, Any]) – Options to override defaults of the PotatoConfigOptions. Defaults to None.
update_potato_peel_options (dict[str, Any]) – Options to override defaults of the PotatoPeelOptions. Defaults to None.
- Returns:
The populated set of classes. If a user provide configuration was provided there None is returned in place of PotatoConfigOptions
- Return type:
tuple[PotatoConfigOptions | None, PotatoPeelOptions]
- flint.peel.potato._print_ms_colnames(ms: flint.options.MS) flint.options.MS[source]¶
A dummy function to print colnames in a MS table
- flint.peel.potato.create_run_potato_config(potato_container: pathlib.Path, ms_path: pathlib.Path | flint.options.MS, potato_config_options: PotatoConfigOptions) PotatoConfigCommand[source]¶
Construct and run a CLI command into the peel_configuration.py script of the potatopeel package.
- Parameters:
potato_container (Path) – Container with the potatopeel package installed
ms_path (Union[Path, MS]) – Path to the measurement set that will be peeled
potato_config_options (PotatoConfigOptions) – Options to tweak the values in the peel configuration
- Returns:
Container of the path to the peel configuration file and the corresponding command that generated it
- Return type:
- flint.peel.potato.create_run_potato_peel(potato_container: pathlib.Path, ms: flint.options.MS, potato_peel_arguments: PotatoPeelArguments, potato_peel_options: PotatoPeelOptions) PotatoPeelCommand[source]¶
Construct and run a hot_potato command to peel out sources from a measurement set.
- Parameters:
potato_container (Path) – Container with the potato peel software and appropriate tools (including wsclean)
ms (MS) – The measurement set that contains sources to peel
potato_peel_arguments (PotatoPeelArguments) – The mandatory arguments that go into hot_potato.
potato_peel_options (PotatoPeelOptions) – Options that are supplied to hot_potato.
- Returns:
The executed hot_potato command
- Return type:
- flint.peel.potato.find_sources_to_peel(ms: flint.options.MS, image_options: flint.imager.wsclean.WSCleanOptions, field_idx: int = 0, maximum_offset: float = 30, minimum_apparent_brightness: float = 0.5, override_beam_position_with: astropy.coordinates.SkyCoord | None = None) astropy.table.Table | None[source]¶
Obtain a set of sources to peel from a reference candidate set. This will evaluate whether a source should be peels based on two criteria:
if it is below a nominal primary beam cut off level (10 percent, assuming a gaussian primary beam)
if the sources is within some separation of the imaging center
- Parameters:
ms (MS) – The measurement set that is being considered
image_options (WSCleanOptions) – The imaging parameters that will be used to compute a placeholder WCS
field_idx (int, optional) – Which field in the MS to draw the position from. Defaults to 0.
maximum_offset (float, optional) – The largest separation, in degrees, before a source is ignored. Defaults to 30.0.
minimum_apparent_brightness (float, optional) – The minimum apparent brightnessm, in Jy, a source should be before attempting to peel. Defaults to 0.5.
override_beam_position_with (Optional[SkyCoord], optional) – Ignore the beam position of the input MS, instead use this. Do not rely on this option as it may be taken away. Defaults to None.
- Returns:
Collection of sources to peel from the reference table. Column names are Name, RA, Dec, Aperture. This is the package table. If no sources need to be peeled None is returned.
- Return type:
Union[Table,None]
- flint.peel.potato.get_source_props_from_table(table: astropy.table.Table) NormalisedSources[source]¶
Given the astropy table of known sources to peel, normalise their inputs for the potato peel CLI
- Parameters:
table (Table) – Table of sources to peel
- Returns:
Collection of normalised sources properties that will be provided to hot_potato
- Return type:
- flint.peel.potato.load_known_peel_sources() astropy.table.Table[source]¶
Locate and load the packaged set of known sources to peel. These sources are drawn from Duchesne et. al. (2023), Table 3.
- Returns:
The astropy Table of candidate sources to remove.
- Return type:
Table
- flint.peel.potato.potato_peel(ms: flint.options.MS, potato_container: pathlib.Path, update_potato_config_options: dict[str, Any] | None = None, update_potato_peel_options: dict[str, Any] | None = None, image_options: flint.imager.wsclean.WSCleanOptions | None = None) flint.options.MS[source]¶
Peel out sources from a measurement set using PotatoPeel. Candidate sources from a known list of sources (see Table 3 or RACS-Mid paper) are considered.
- Parameters:
ms (MS) – The measurement set to peel out known sources
potato_container (Path) – Location of container with potatopeel software installed
update_potato_config_options (Optional[Dict[str, Any]], optional) – A dictionary with values to use to update the default options within the PotatoConfigOptions. If None use the defaults. Defaults to None.
update_potato_peel_options (Optional[Dict[str, Any]], optional) – A dictionary with values to use to update the default options within the PotatoPeelOptions. If None use the defaults. Defaults to None.
image_options (Optional[WSCleanOptions], optional) – Any imaging options that should be used to determine if sources require peeling (e.g. image size, pixel size)
- Returns:
Updated measurement set
- Return type:
- flint.peel.potato.prepare_ms_for_potato(ms: flint.options.MS) flint.options.MS[source]¶
The potatopeel software requires the data column being operated against to be called DATA. This is a requirement of CASA and its gaincal / applysolution task.
If there is already a DATA column and this is not the nominated data column described by the MS then it is removed, and the nominated data column is renamed.
If the DATA column already exists and it is the nominated column described by MS then this is returned. If there is a CORRECTED_DATA column in this situation it is removed.
- flint.peel.potato.source_within_image_fov(source_coord: astropy.coordinates.SkyCoord, beam_coord: astropy.coordinates.SkyCoord, image_size: int, pixel_scale: astropy.units.Quantity | str) bool[source]¶
Evaluate whether a source will be within the field of view of an image.
- Parameters:
source_coord (SkyCoord) – The source position to consider
beam_coord (SkyCoord) – The center beam position to consider
image_size (int) – The image size. This assumes a square image.
pixel_scale (Union[u.Quantity, str]) – The pixel size, assuming square pixels.
- Returns:
Whether the source is expected to be in the field of view
- Return type:
bool