orca.transform.gainscaling ========================== .. py:module:: orca.transform.gainscaling .. autoapi-nested-parse:: Transforms that relate to amplitude scaling. It uses autocorrelation to figure out the scaling factor between two snapshots on a per-antenna per-channel per-pol basis. NOTE: It uses the autocorrelation flags to figure out which antennas are flagged and does not solve for those antennas. Attributes ---------- .. autoapisummary:: orca.transform.gainscaling.log Functions --------- .. autoapisummary:: orca.transform.gainscaling.auto_corr_data_and_flag orca.transform.gainscaling.calculate_gain_scale orca.transform.gainscaling.apply_gain_scale_in_place orca.transform.gainscaling.correct_scaling Module Contents --------------- .. py:data:: log .. py:function:: auto_corr_data_and_flag(t: casacore.tables.table, data_column: str) -> Tuple[numpy.ndarray, numpy.ndarray] Extract autocorrelation data and flags from a measurement set table. :param t: Open casacore table object. :param data_column: Name of the data column to read. :returns: Tuple of (data, flag) arrays for autocorrelation baselines. .. py:function:: calculate_gain_scale(to_scale_data: numpy.ndarray, to_scale_flag: numpy.ndarray, target_data: numpy.ndarray, target_flag: numpy.ndarray) -> numpy.ndarray Calculate the gain scaling factor to match autocorrelation levels. Computes per-antenna per-channel per-polarization scaling factors required to scale one dataset's autocorrelations to match another's. :param to_scale_data: Autocorrelation data to be scaled. :param to_scale_flag: Flags for to_scale_data. :param target_data: Target autocorrelation data to match. :param target_flag: Flags for target_data. :returns: Scaling factors array; flagged values are set to 1.0. .. py:function:: apply_gain_scale_in_place(data: numpy.ndarray, scale_spectrum: numpy.ndarray) -> None Apply single pol scaling factor per antenna to cross-correlated data. This is similar to applycal in CASA. It multiples a cross-correlation by the scaling factor that corresponds to the two antennas (each of which has 2 polarizations) involved. Warning: this mutates data in place while returning a reference to it. :param data: Cross-correlated data with shape (N_vis, N_chan, 4), ordered by antennas :param scale_spectrum: Single polarization scaling factors; shape (N_ant, N_chan, 2), ordered by antennas Returns: data multiplied by scale_spectrum .. py:function:: correct_scaling(to_scale_ms: str, target_ms: str, data_column: str = 'CORRECTED_DATA') Correct for per-antenna per-pol per-channel scaling between two measurement sets. Scales data in to_scale_ms such that its autocorrelation matches target_ms. Uses autocorrelation ratios to derive per-antenna scaling factors. :param to_scale_ms: Measurement set to scale (modified in-place). :param target_ms: Reference measurement set whose autocorrelation levels to match. :param data_column: The data column to apply this operation to. :returns: None. Modifies to_scale_ms in place.