flint.selfcal.casa¶
Utilities related to using casa tasks to perform self-calibration.
This tooling is mostly centred on using gaincal from casatasks.
Classes¶
Options provided to the casatasks gaincal function. Most options correspond to those in gaincal. |
Functions¶
|
Helper to process and update GaincalOptions on initialise of self-calibration routine |
|
In some circumstances components of self-calibration may be |
Basic checks to ensure that the calibration table |
|
|
|
|
Create a copy of a measurement set in preparation for selfcalibration |
|
Use the casa task mstransform to create nspw spectral windows |
|
Perform self-calibration using casa's gaincal and applycal tasks against |
|
|
|
Attempt to merge together all SPWs in the input measurement |
Module Contents¶
- class flint.selfcal.casa.GainCalOptions(/, **data: Any)[source]¶
Bases:
flint.options.BaseOptionsOptions provided to the casatasks gaincal function. Most options correspond to those in gaincal.
- minsnr: float = 0.0[source]¶
Minimum signal-to-noise of the solutions. Below this the solutions and data are flagged.
- nspw: int = 1[source]¶
The number of spectral windows to use during the self-calibration routine. This will be used to craft an appropriate
select_spw=interval range. If larger than one,gaincalwill be carried out against each interval and results will be appended to a common solutions file.
- flint.selfcal.casa._process_gaincal_options(gain_cal_options: GainCalOptions | None = None, update_gain_cal_options: dict[str, Any] | None = None) GainCalOptions[source]¶
Helper to process and update GaincalOptions on initialise of self-calibration routine
- Parameters:
gain_cal_options (GainCalOptions | None, optional) – Any existing gaincal options. Defaults to None.
update_gain_cal_options (dict[str, Any] | None, optional) – Overrides to provide the to input gaincal options or defaults. Defaults to None.
- Returns:
options to use throughout gaincalibtaion
- Return type:
- flint.selfcal.casa._skippable_ms_copy_and_clean(ms: flint.options.MS, out_ms_path: pathlib.Path, rename_ms: bool = False) bool[source]¶
In some circumstances components of self-calibration may be partway through before being restarted. This is to try to allow continuing from that point if changes are known and operation modes support. Critically:
the input ms must not exist
the output ms must exist
renaming of the ms is active (as opposed to copying)
DATA column exists
- Parameters:
ms (MS) – The target MS that was going to be self-calibrated
out_ms_path (Path) – The expected MS output name
rename_ms (bool, optional) – Whether the MS will simply be renamed. Defaults to False.
- Raises:
ValueError – Raised when neither the input or output MS vsn not be found.
- Returns:
Indicates where previous self-calibration round has partly been attempted, and if it can be continued.
- Return type:
bool
- flint.selfcal.casa.check_for_valid_calibration_table(caltable_path: pathlib.Path) bool[source]¶
Basic checks to ensure that the calibration table from CASAs gaincal is valid
- Parameters:
caltable_path (Path) – Table path to examine
- Returns:
Whether the input table appears to be a CASA solutions table from gaincal
- Return type:
bool
- flint.selfcal.casa.copy_and_clean_ms_casagain(ms: flint.options.MS, round: int = 1, verify: bool = True, rename_ms: bool = False) flint.options.MS[source]¶
Create a copy of a measurement set in preparation for selfcalibration using casa’s gaincal and applycal. Applycal only works when calibrating DATA and creating a CORRECTED_DATA column. Columns are removed in the copied MS to allow this.
If the MS is large the move_ms option will simply renamed the input MS, adjusting the columns appropriately. Note that this potentially involves deleting the DATA column if present and renaming CORRECTED_DATA.
- Parameters:
ms (MS) – Measurement set that would go through self-calibration.
round (int, optional) – The self-calibration round. Defaults to 1.
verify (bool, optional) – Verify that copying the measurementt set (done in preparation for gaincal) was successful. Uses a call to rsync. Defaults to True.
move_ms (bool, optional) – Rather than copying the MS, simple renamed the MS and modify columns appropriately. Defaults to False.
- Returns:
Copy of input measurement set with columns removed as required.
- Return type:
- flint.selfcal.casa.create_spws_in_ms(casa_container: pathlib.Path, ms_path: pathlib.Path, nspw: int) pathlib.Path[source]¶
Use the casa task mstransform to create nspw spectral windows in the input measurement set. This is necessary when attempting to use gaincal to solve for some frequency-dependent solution.
- Parameters:
casa_container (Path) – Path to the singularity container with CASA tooling
ms_path (Path) – The measurement set that should be reformed to have nspw spectral windows
nspw (int) – The number of spectral windows to create
- Returns:
The path to the measurement set that was updated
- Return type:
Path
- flint.selfcal.casa.gaincal_applycal_ms(ms: flint.options.MS, casa_container: pathlib.Path, round: int = 1, gain_cal_options: GainCalOptions | None = None, update_gain_cal_options: dict[str, Any] | None = None, archive_input_ms: bool = False, skip_selfcal: bool = False, rename_ms: bool = False, archive_cal_table: bool = False) flint.options.MS[source]¶
Perform self-calibration using casa’s gaincal and applycal tasks against an input measurement set.
- Parameters:
ms (MS) – Measurement set that will be self-calibrated.
round (int, optional) – Round of self-calibration, which is used for unique names. Defaults to 1.
casa_container (Path) – A path to a singularity container with CASA tooling.
gain_cal_options (Optional[GainCalOptions], optional) – Options provided to gaincal. Defaults to None.
update_gain_cal_options (Optional[Dict[str, Any]], optional) – Update the gain_cal_options with these. Defaults to None.
archive_input_ms (bool, optional) – If True, the input measurement set will be compressed into a single file. Defaults to False.
skip_selfcal (bool, optional) – Should this self-cal be skipped. If True, the a new MS is created but not calibrated the appropriate new name and returned.
rename_ms (bool, optional) – It True simply rename a MS and adjust columns appropriately (potentially deleting them) instead of copying the complete MS. If True archive_input_ms is ignored. Defaults to False.
archive_cal_table (bool, optional) – Archive the output calibration table in a tarball. Defaults to False.
- Raises:
GainCallError – Raised when no self-calibration solutions were found
- Returns:
The self-calibrated measurement set.
- Return type:
- flint.selfcal.casa.merge_spws_in_ms(casa_container: pathlib.Path, ms_path: pathlib.Path) pathlib.Path[source]¶
Attempt to merge together all SPWs in the input measurement set using the cvel casa task. This can be a little fragile.
The cvel task creates a new measurement set, so there would temporially be a secondary measurement set.
- Parameters:
ms_path (Path) – The measurement set that should have its SPWs merged together.
- Returns:
The measurement set with merged SPWs. It will have the same path as ms_path, but is a new measurement set.
- Return type:
Path