flint.flagging¶
Utility functions to carry out flagging against ASKAP measurement sets
Classes¶
The command to use when running aoflagger |
Functions¶
Used to evaluate the flags that should be applied to the MS based on |
|
|
|
|
Create a command to run aoflagger against a measurement set |
|
Create and run an aoflagger command in a container |
|
Set the FLAG to True for a collection of rows where ANTENNA1 or ANTENNA2 is in a set of |
|
Flag out the UVWs in a measurement set that have values of zero. |
|
Create the argument parser for the flagging |
|
Will flag a MS based on NaNs or zeros in the nominated data column of a measurement set. |
|
Run the aoflagger command constructed in its singularity container |
Module Contents¶
- class flint.flagging.AOFlaggerCommand[source]¶
Bases:
NamedTupleThe command to use when running aoflagger
- ms: flint.options.MS[source]¶
The MS object that was flagged
- flint.flagging._nan_zero_extreme_flag(data: numpy.typing.NDArray[numpy.complex128], flags: numpy.typing.NDArray[numpy.bool], uvws: numpy.typing.NDArray[numpy.float64], flag_extreme_dxy: bool = True, dxy_thresh: float = 4.0) tuple[numpy.typing.NDArray[numpy.complex128], numpy.typing.NDArray[numpy.bool], numpy.typing.NDArray[numpy.float64]][source]¶
Used to evaluate the flags that should be applied to the MS based on data values (if there are 0’s or nans), uvw values (which can be 0’s) and extreme stokes-v values.
This is the internal checker for the larger nan_zero_extreme_flags_in_ms function.
- Parameters:
data (NDArray[np.complex128]) – Data that is being consider drawn from a DATA like column
flags (NDArray[np.bool]) – The flags that correspond to the DATA column drawn from the FLAG column
uvws (NDArray[np.float64]) – The (U,V,W) coordinates of the data
flag_extreme_dxy (bool, optional) – Whether flagging on extreme stokes-v should be consider. Defaults to True.
dxy_thresh (float, optional) – The threshold of the stokes-v flagging. Defaults to 4.0.
- Returns:
Copies of the input data, flags and uvws. The flags are updated based on the results of the flagging.
- Return type:
tuple[NDArray[np.complex128], NDArray[np.bool], NDArray[np.float64]]
- flint.flagging.create_aoflagger_cmd(ms: flint.options.MS) AOFlaggerCommand[source]¶
Create a command to run aoflagger against a measurement set
- flint.flagging.flag_ms_aoflagger(ms: flint.options.MS, container: pathlib.Path) flint.options.MS[source]¶
Create and run an aoflagger command in a container
- flint.flagging.flag_ms_by_antenna_ids(ms: pathlib.Path | flint.options.MS, ant_ids: int | Collection[int]) flint.options.MS[source]¶
Set the FLAG to True for a collection of rows where ANTENNA1 or ANTENNA2 is in a set of antenna IDs to flag. The flagging is performed via the antenna ID as it is in the measurement set - it is not by the antenna name.
- flint.flagging.flag_ms_zero_uvws(ms: flint.options.MS, chunk_size: int = 10000) flint.options.MS[source]¶
Flag out the UVWs in a measurement set that have values of zero. This happens when some data are flagged before it reaches the TOS.
A critical MS interaction scope is created to ensure if things fail they are known.
- flint.flagging.get_parser() argparse.ArgumentParser[source]¶
Create the argument parser for the flagging
- Returns:
aoflagger argument parser
- Return type:
ArgumentParser
- flint.flagging.nan_zero_extreme_flag_ms(ms: pathlib.Path | flint.options.MS, data_column: str | None = None, flag_extreme_dxy: bool = True, dxy_thresh: float = 4.0, nan_data_on_flag: bool = False, chunk_size: int = 100000) flint.options.MS[source]¶
Will flag a MS based on NaNs or zeros in the nominated data column of a measurement set. These NaNs might be introduced into a column via the application of a applysolutions task. Zeros might be introduced by the correlator dropping cycles and not appropriately setting the corresponding FLAG column (although this might have been fixed).
There is also an optional component to flag based on extreme Stokes-V values.
Visibilities that are marked as bad will have the FLAG column updatede appropriately.
- Parameters:
ms (Union[Path,MS]) – The measurement set that will be processed and have visibilities flagged.
data_column (Optional[str], optional) – The column to inspect. This will override the value in the nominated column of the MS. Defaults to None.
flag_extreme_dxy (bool, optional) – Whether Stokes-V will be inspected and flagged. Defaults to True.
dxy_thresh (float, optional) – Threshold used in the Stokes-V case. Defaults to 4.0.
nan_data_on_flag (bool, optional) – If True, data whose FLAG is set to True will become NaNs. Defaults to False.
chunk_size (int, optional) – Number of rows to process at a time. Defaults to 100000.
- Returns:
The container of the processed MS
- Return type:
- flint.flagging.run_aoflagger_cmd(aoflagger_cmd: AOFlaggerCommand, container: pathlib.Path) None[source]¶
Run the aoflagger command constructed in its singularity container
- Parameters:
aoflagger_cmd (AOFlaggerCommand) – The command that will be executed
container (Path) – Path to the container that contains aoflagger