low_comm_tools.plotting.ao_calibrate
Code to use AO calibrate
Classes
Structure to load an AO-style solutions file |
|
Structure to hold metadata about a measurement set |
Functions
Divide the bandpass complex gains (solved for initially by something like |
|
|
Plot vertical or horizontal lines where data are flagged. |
|
|
|
Load in an AO-style solutions file |
|
|
|
Parse the metadata from a measurement set |
|
Plot solutions for AO-style solutions |
|
Save a AOSolutions file to the ao-standard binary format. |
|
Attempt to select an optimal reference antenna. This works in |
Module Contents
- class low_comm_tools.plotting.ao_calibrate.AOSolutions[source]
Bases:
NamedTupleStructure to load an AO-style solutions file
- classmethod load(path: pathlib.Path) AOSolutions[source]
Load in an AO-stule solution file. See load_solutions_file, which is internally used.
- plot_solutions(ref_ant: int | None = 0) collections.abc.Iterable[pathlib.Path][source]
Plot the solutions of all antenna for the first time-interval in the aosolutions file. The XX and the YY will be plotted.
- Parameters:
ref_ant (Optional[int], optional) – Reference antenna to use. If None is specified there is no division by a reference antenna. Defaults to 0.
- Returns:
Path to the phase and amplited plots created.
- Return type:
Iterable[Path]
- save(output_path: pathlib.Path) pathlib.Path[source]
Save the instance of AOSolution to a standard aosolution binary file
- Parameters:
output_path (Path) – Location to write the file to
- Returns:
Location the file was written to
- Return type:
Path
- bandpass: numpy.typing.NDArray[numpy.complexfloating[Any, Any]][source]
Complex data representing the antenna Jones. Shape is (nsol, nant, nchan, npol)
- path: pathlib.Path[source]
Path of the solutions file loaded
- class low_comm_tools.plotting.ao_calibrate.MSMetaData(/, **data: Any)[source]
Bases:
low_comm_tools.options.BaseOptionsStructure to hold metadata about a measurement set
- low_comm_tools.plotting.ao_calibrate.divide_bandpass_by_ref_ant_preserve_phase(complex_gains: numpy.typing.NDArray[numpy.complexfloating[Any, Any]], ref_ant: int) numpy.typing.NDArray[numpy.complexfloating[Any, Any]][source]
Divide the bandpass complex gains (solved for initially by something like calibrate) by a nominated reference antenna. In the case of
calibratethere is no implicit reference antenna. This is valid for cases where the xy-phase is set to 0 (true via the ASKAP on-dish calibrator).This particular function is most appropriate for the calibrate style solutions, which solve for the Jones in one step. In HMS notation this are normally split into two separate 2x2 matrices, one for the gains with zero off-diagonal elements and a leakage matrix with ones on the diagonal.
This is the preferred function to use whena attempting to set a phase reference antenna to precomputed Jones bandpass solutions.
The input complex gains should be in the form: >> (ant, channel, pol)
Internally reference phasores are constructed for the G_x and G_y terms of the reference antenna. They are then applied: >> G_xp = G_x / G_xref >> G_xyp = G_xy / G_yref >> G_yxp = G_yx / G_xref >> G_y = G_y / G_yref
which is applied to all antennas in
complex_gains.- Parameters:
complex_gains (np.ndarray) – The complex gains that will be normalised
ref_ant (int) – The desired reference antenna to use
- Returns:
The normalised bandpass solutions
- Return type:
np.ndarray
- low_comm_tools.plotting.ao_calibrate.fill_between_flags(ax: matplotlib.axes.Axes, flags: numpy.typing.NDArray[numpy.bool_], values: numpy.typing.NDArray[numpy.complexfloating[Any, Any]] | numpy.typing.NDArray[numpy.floating[Any]] | None = None, direction: str = 'x') None[source]
Plot vertical or horizontal lines where data are flagged.
NOTE: This is pretty inefficient and not intended for regular use.
- Parameters:
ax (plt.Axes) – Axes object to plot lines on
flags (np.ndarray) – Flags to consider. If True, plot.
values (Optional[np.ndarray], optional) – The values to plot at. Useful if the position does not map to location. Defaults to None.
direction (str, optional) – If x use axvline, if y use axhline. Defaults to “x”.
- low_comm_tools.plotting.ao_calibrate.get_parser() argparse.ArgumentParser[source]
- low_comm_tools.plotting.ao_calibrate.load_aosolutions_file(solutions_path: pathlib.Path) AOSolutions[source]
Load in an AO-style solutions file
- Parameters:
solutions_path (Path) – The path of the solutions file to load
- Returns:
Structure container the deserialized solutions file
- Return type:
- low_comm_tools.plotting.ao_calibrate.parse_ms_metadata(ms_path: pathlib.Path | str) MSMetaData[source]
Parse the metadata from a measurement set
- Parameters:
ms_path (Path) – Path to the measurement set to parse
- Returns:
The parsed metadata
- Return type:
- low_comm_tools.plotting.ao_calibrate.plot_solutions(solutions: pathlib.Path | AOSolutions, ref_ant: int | None = 0, ms_path: pathlib.Path | None = None) collections.abc.Collection[pathlib.Path][source]
Plot solutions for AO-style solutions
- Parameters:
solutions (Path) – Path to the solutions file
ref_ant (Optional[int], optional) – Reference antenna to use. If None is specified there is no division by a reference antenna. Defaults to 0.
- Returns:
Collection[Path] – The paths of the two plots createda
- low_comm_tools.plotting.ao_calibrate.save_aosolutions_file(aosolutions: AOSolutions, output_path: pathlib.Path) pathlib.Path[source]
Save a AOSolutions file to the ao-standard binary format.
- Parameters:
aosolutions (ApplySolutions) – Instance of the solutions to save
output_path (Path) – Output path to write the files to
- Returns:
Path the file was written to
- Return type:
Path
- low_comm_tools.plotting.ao_calibrate.select_refant(bandpass: numpy.typing.NDArray[numpy.complexfloating[Any, Any]]) int[source]
Attempt to select an optimal reference antenna. This works in a fairly simple way, and simply selects the antenna which is select based purely on the number of valid/unflagged solutions in the bandpass aosolutions file.
- Parameters:
bandpass (np.ndarray) – The aosolutions file that has been
for (solved)
- Returns:
The index of the reference antenna that should be used.
- Return type: