edges.analysis.calibrate¶
Module defining calibration routines for field data in EDGES.
- edges.analysis.calibrate.apply_beam_correction(data: GSData, beam: str | Path | BeamFactor, freq_model: Model, integrate_before_ratio: bool = True, oversample_factor: int = 5, resample_beam_lsts: bool = True, lsts: ndarray | None = None, cut_to_data_lsts: bool = True) GSData[source]¶
Apply beam correction to the data.
This always applies the beam correction to each time sample in the data. If you want to average the data before applying the beam correction, you must average the data before applying this function to it. The input beam factor object should cover the full range of LSTs included in the data itself.
The beam factor object is defined at a set of LSTs, and by default, the correction applied to the data is the average beam factor in each LST-bin of the data. To use the beam factor interpolated to the LSTs of the data instead, set
interpolate_to_lststo True.There are two ways to define the average beam factor within an LST-bin: either by taking the mean of ratios (of beam-weighted foreground model to reference beam-weighted foreground model) or the ratio of means. Switch between these by using the
integrate_before_ratioparameter.- Parameters:
data – Data to be calibrated.
beam – Either a path to a file containing beam correction coefficients, or the BeamFactor object itself.
freq_model – The (linear) model to use when evaluating the beam factor at the data freqs.
integrate_before_ratio – Whether to integrate (over time) the beam-weighted sky temperature and the reference sky temperature individually before taking their ratio to get the beam factor.
oversample_factor – The number of LST samples to use when interpolating the beam factor to the LSTs of the data. For every data LST,
oversample_factorLSTs will be interpolated to (regularly spaced between each data LST, regardless of whether the data LSTs are regular). This is only used ifresample_beam_lstsis True.resample_beam_lsts – Whether to resample LSTs before averaging (by
oversample_factor).lsts – If given, resample to these LSTs exactly, instead of trying to use the LST ranges in the data with oversample_factor.
cut_to_data_lsts – If True, cut the LSTs at which the beam is sampled to lie within the LST ranges of the data in each LST bin. Only set this to False if you have a single LST bin in the data and you know precisely the LSTs at which you want to sample the beam.
- edges.analysis.calibrate.apply_beam_factor_directly(data: GSData, beam_file: str | Path) GSData[source]¶
Apply a beam correction factor from a file directly to the data.
This function multiplies the data by the beam correction factor from the provided beamfile. It handles data with a single load and updates the data unit to “temperature”.
- Parameters:
data – The GSData object containing the data to correct.
beamfile – The path to the beamfile containing the correction factors. The correction factors should be in the fourth column of the csv file, and should have a size equal to the number of frequencies in the data.
- Returns:
data – A new GSData object with the corrected data and residuals.
- Raises:
NotImplementedError – If the data contains more than one load.
- edges.analysis.calibrate.apply_loss_correction(data: GSData, ambient_temp: Annotated[Quantity, PhysicalType('temperature')], loss: ndarray | None = None, loss_function: Callable | None = None, **kwargs) GSData[source]¶
Apply a loss-correction to data.
- Parameters:
data – The GSData object on which to apply the loss-correction.
ambient_temp – The ambient temperature at which to apply the loss-correction.
loss – An array of losses, where the size of the array must be equal to the number of frequencies in the data. If None, a loss function is used to compute the losses.
loss_function – A function to compute the loss. The function must accept an array of frequencies as its first argument, and may accept arbitrary other keyword arguments, which will can be passed as kwargs to this function. Either this or loss must be specified.
Notes
Loss functions can be stacked, either by multiplying the losses before passing them to this function, or by calling this function multiple times, once for each loss.
- edges.analysis.calibrate.apply_noise_wave_calibration(data: GSData, calibrator: Calibrator | str | Path, antenna_s11: ReflectionCoefficient, tload: float | None = None, tns: float | None = None) GSData[source]¶
Apply noise-wave calibration to data.
This function requires a
edges.cal.cal_coefficients.Calibratorobject (or a path to a file containing such an object) which must be created beforehand. The antenna S11 used is found automatically by searching for the file that has the closest match to the time of the data. This can be constrained by passing options that match the regex pattern for the S11 files.- Parameters:
data – Data to be calibrated.
calobs – Calibrator object or path to file containing calibrator object.
antenna_s11