edges.alanmode.alanmode

Functions that run the calibration in a style similar to the C-code.

class edges.alanmode.alanmode.ACQPlot7aMoonParams(*, fstart: float = 50.0, fstop: float = 100.0, smooth: int = 8, tload: float = 300.0, tcal: float = 1000.0, tstart: int = 0, tstop: int = 23, delaystart: int = 0)[source]

Parameters for the ACQPlot7aMoon spectrum reading and averaging script.

Parameters:
  • fstart (float) – The starting frequency for the spectrum.

  • fstop (float) – The stopping frequency for the spectrum.

  • smooth (int) – The number of frequency bins to smooth and downsamples by.

  • tload (float) – A guess at the internal load temperature, acting as a starting point for iterative calibration fitting, but also is applied to “kind of” calibrate the data before finding RFI.

  • tcal (float) – Similar to tload, but for the internal load + noise source.

  • tstart (int) – The starting hour (in gha) for reading spectrum integrations.

  • tstop (int) – The ending hour (in gha) for reading spectrum integrations.

  • delaystart (int) – The number of seconds to delay before including spectra from the files. Can be useful to ignore beginning of files as the system may still be warming up.

classmethod bowman_2018_defaults(delaystart=7200, smooth=8, fstart=40.0, fstop=110.0, tload=300.0, tcal=1000.0, tstart=0, tstop=23)[source]

Construct a set of parameters with defaults matching Bowman+2018.

class edges.alanmode.alanmode.Edges2CalobsParams(*, s11_path: Path, ambient_acqs: list[Path], hotload_acqs: list[Path], open_acqs: list[Path], short_acqs: list[Path])[source]

Parameters defining the calibration observation data for EDGES 2.

Parameters:
  • s11_path (pathlib.Path) – The path to the S11 measurement file. Currently, this file must be a single, precalibrated file in Raul’s legacy output format (CSV).

  • ambient_acqs (list[pathlib.Path]) – A list of paths to the ambient acq spectra files.

  • hotload_acqs (list[pathlib.Path]) – A list of paths to the hot load acq spectra files.

  • open_acqs (list[pathlib.Path]) – A list of paths to the open acq spectra files.

  • short_acqs (list[pathlib.Path]) – A list of paths to the short acq spectra files.

get_raw_s11s()[source]

Read all the raw S11 information.

get_spectrum_files()[source]

Return a dictionary of all associated spectrum files.

class edges.alanmode.alanmode.Edges3CalobsParams(*, specyear: int, specday: int, s11date: str, datadir: Path = PosixPath('/data5/edges/data/EDGES3_data/MRO'), match_resistance: Annotated[float, Parameter(name='res')] = 49.8, calkit_delays: Annotated[float, Parameter(name='ps')] = 33, load_delay: float = NOTHING, open_delay: float = NOTHING, short_delay: float = NOTHING, lna_cable_length: Annotated[float, Parameter(name='cablen')] = 4.26, lna_cable_loss: Annotated[float, Parameter(name='cabloss')] = -91.5, lna_cable_dielectric: Annotated[float, Parameter(name='cabdiel')] = -1.24)[source]

Parameters defining the calibration observation data for EDGES 3.

Parameters:
  • specyear (int) – The year of the spectrum data.

  • specday (int) – The day of the spectrum data.

  • s11date (str) – The date of the S11 measurement in the format YYYY_DDD_HH.

  • datadir (pathlib.Path) – The root directory of the observation data.

  • match_resistance (float) – The measured impedance of the “match” calkit standard. Used to calibrate the Receiver s11.

  • calkit_delays (float) – The delays of the three calkit standards. To set each individually, use the load_delay, open_delay, and short_delay parameters.

  • lna_cable_length (float)

  • load_delay (float) – The delay of the “load” calkit stsandard. By default the same as calkit_delays.

  • open_delay (float) – The delay of the “open” calkit standard. By default the same as calkit_delays.

  • short_delay (float) – The delay of the “short” calkit standard. By default the same as calkit_delays.

  • lna_cable_length (float) – The length of the cable joining the receiver to the VNA in inches.

  • lna_cable_loss (float) – The loss of the cable joining the receiver to the VNA in percent.

  • lna_cable_dielectric (float) – The dielectric constant of the cable joining the receiver to the VNA in percent.

get_caldef() CalObsDefEDGES3[source]

Get a calibration file definition.

get_raw_s11s()[source]

Read all the raw S11 information.

get_spectrum_files() dict[str, list[Path]][source]

Return a dictionary of all associated spectrum files.

class edges.alanmode.alanmode.EdgesScriptParams(*, Lh: Annotated[int, Parameter(name='Lh')] = -1, wfstart: float = 50, wfstop: float = 190, tcold: float = 306.5, thot: float = 393.22, tcab: float = NOTHING, cfit: int = 7, wfit: int = 7, nfit3: int = 10, nfit2: int = 27, nter: int = 8, lna_poly: int = -1)[source]

Parameters for the edges script.

These are parameters for the script traditionally called either edges2k.c or edges3.c.

Parameters:
  • Lh (int) – The mode in which to calculate the loss function.

  • wfstart (float) – The lowest frequency included for fitting the calibration functions.

  • wfstop (float) – The highest frequency included for fitting the calibration functions.

  • tcold (float) – The “true” temperature of the ambient load.

  • thot (float) – The “true” temperature of the hot load.

  • tcab (float) – The “true” temperature of the long-cable calibration loads. By default, the same as tcold.

  • cfit (int) – The number of polynomial terms to use for fitting the scale and offset calibration temperatures (i.e. Tload and Tlns)

  • wfit (int) – The number of polynomial terms to use for fitting the noise-wave calibration temperatures.

  • nfit3 (int) – The number of terms used to model the receiver S11.

  • nfit2 (int) – The number of terms used to model the load S11s.

  • nter (int) – The number of iterations to perform when fitting the noise-wave calibration temperatures.

  • lna_poly (int) – Whether the receiver S11 should be modeled as a polynomial. 0 for False, anything else will determine the model based on nfit3. If nfit3 is greater than 16, a Fourier model will be used, otherwise a Polynomial model.

classmethod bowman_2018_defaults(cfit=6, wfit=5, Lh=-2, wfstart=50.0, wfstop=100.0, tcold=296, thot=399, nfit2=27, nfit3=11, lna_poly=0, **kwargs) Self[source]

Construct a set of parameters with defaults matching Bowman+2018.

edges.alanmode.alanmode.acqplot7amoon(acqfile: str | Path, params: ACQPlot7aMoonParams = ACQPlot7aMoonParams(fstart=50.0, fstop=100.0, smooth=8, tload=300.0, tcal=1000.0, tstart=0, tstop=23, delaystart=0), **kwargs) GSData[source]

A function that does what the acqplot7amoon C-code does.

Parameters:
  • acqfile – The path to the ACQ file to process.

  • params – The parameters for the ACQPlot7aMoon function.

edges.alanmode.alanmode.alancal(defparams: Edges3CalobsParams | Edges2CalobsParams, out: Path = PosixPath('.'), redo_spectra: bool = False, redo_cal: bool = True, acqparams: ACQPlot7aMoonParams = ACQPlot7aMoonParams(fstart=50.0, fstop=100.0, smooth=8, tload=300.0, tcal=1000.0, tstart=0, tstop=23, delaystart=0), calparams: EdgesScriptParams = EdgesScriptParams(Lh=-1, wfstart=50, wfstop=190, tcold=306.5, thot=393.22, tcab=306.5, cfit=7, wfit=7, nfit3=10, nfit2=27, nter=8, lna_poly=-1)) tuple[CalibrationObservation, Calibrator, S11ModelParams, S11ModelParams, Callable | None][source]

Run a calibration in as close a manner to Alan’s code as possible.

This exists mostly for being able to compare to Alan’s memos etc in an easy way. It is much less flexible than using the library directly, and is not recommended for general use.

This is supposed to emulate one of Alan’s C-shell scripts, usually called “docal”, and thus it runs a complete calibration, not just a single part. However, you can turn off parts of the calibration by setting the appropriate flags to False.

Parameters:
  • defparams – Parameters that define where to find files and how to read/calibrate the raw S11s. This is different between EDGES3 and EDGES2.

  • out – A directory where outputs can be written.

  • redo_spectra – Whether to re-average the spectra if they already exist in the output directory.

  • redo_cal – Whether to re-compute the calibration coefficients if they already exist.

  • acqparams – Parameters governing how to average the spectrum files.

  • calparams – Parameters governing how to model S11s and perform the calibration.

Returns:

  • calobs – The CalibrationObservation that holds all the data relevant for performing the receiver calibration.

  • calibrator – The final calibration solutions.

  • s11_model_params – The parameters used to create models of the load S11s.

  • receiver_model_params – The parameters used to create models of the receiver S11.

  • hot_loss_model – The model used to account for losses in the hot load.

edges.alanmode.alanmode.corrcsv(s11: ReflectionCoefficient, cablen: float, cabdiel: float, cabloss: float)[source]

Corrects the S11 data (LNA) for cable effects.

This function is a direct translation of the C-code function corrcsv.

Parameters:
  • freq (np.ndarray) – The frequency array.

  • s11 (np.ndarray) – The S11 data.

  • cablen (float) – The cable length, in inches.

  • cabdiel (float) – The cable dielectric constant, as a percent.

  • cabloss (float) – The cable loss, as a percent.

edges.alanmode.alanmode.edges(spcold: GSData, sphot: GSData, spopen: GSData, spshort: GSData, s11freq: ndarray, s11hot: ndarray, s11cold: ndarray, s11lna: ndarray, s11open: ndarray, s11short: ndarray, tload: float, tcal: float, params: EdgesScriptParams = EdgesScriptParams(Lh=-1, wfstart=50, wfstop=190, tcold=306.5, thot=393.22, tcab=306.5, cfit=7, wfit=7, nfit3=10, nfit2=27, nter=8, lna_poly=-1), s11rig: ndarray | None = None, s12rig: ndarray | None = None, s22rig: ndarray | None = None, **kwargs) tuple[CalibrationObservation, Calibrator, S11ModelParams, S11ModelParams, Callable | None][source]

A function that does what the edges3.c and edges2k.c C-code do.

The primary purpose of this function is to model the input S11’s, and then determine the noise-wave parameters.

Parameters:
  • spcold, sphot, spopen, spshort – The time-averaged spectra for the ambient (cold), hot_load, open, and short loads respectively.

  • s11freq – The frequencies at which the S11 data is sampled.

  • s11hot, s11cold, s11lna, s11open, s11short – The S11 measurements for the hot, ambient, LNA, open, and short loads respectively.

  • tload – A guess of the internal load temperature, used as the initial guess for the optimization. MUST MATCH tload used to generate the time-averaged spectra.

  • tcal – Like tload, but for the internal load + noise source.

  • params – An object defining the parameters used in determining the calibration.

  • s11rig, s12rig, s22rig – The S11, S12, and S22 measurements for the semi-rigid cable respectively. Optional – generally required for EDGES-2.

Returns:

  • calobs – The CalibrationObservation that holds all the data relevant for performing the receiver calibration.

  • calibrator – The final calibration solutions.

  • s11_model_params – The parameters used to create models of the load S11s.

  • receiver_model_params – The parameters used to create models of the receiver S11.

  • hot_loss_model – The model used to account for losses in the hot load.

edges.alanmode.alanmode.reads1p1(res: float, s11_file_open: str, s11_file_short: str, s11_file_load: str, s11_file_ant: str, loadps: float = 33.0, openps: float = 33.0, shortps: float = 33.0) ReflectionCoefficient[source]

Reads the s1p1 file and returns the data.