edges.io.calobsdef3¶
Methods for dealing with EDGES-3 files and structures.
- class edges.io.calobsdef3.CalObsDefEDGES3(*, open: LoadDefEDGES3, short: LoadDefEDGES3, ambient: LoadDefEDGES3, hot_load: LoadDefEDGES3, receiver_s11: ReceiverS11)[source]¶
A class for holding calibration observation definitions for EDGES3.
This class holds specifications for where all the data required for the EDGES-3 receiver calibration is located on disk. That is, it holds only paths to files, rather than actual data.
It is convenient in that it also has methods for finding this files in standard situations (
from_standard_layout()) or creating it from explicit lists of files (from_files()).- Parameters:
open (edges.io.calobsdef3.LoadDefEDGES3) – The loading definition for the open load.
short (edges.io.calobsdef3.LoadDefEDGES3) – The loading definition for the short load.
ambient (edges.io.calobsdef3.LoadDefEDGES3) – The loading definition for the ambient load.
hot_load (edges.io.calobsdef3.LoadDefEDGES3) – The loading definition for the hot load.
receiver – The definition for the Receiver S11.
- classmethod from_files(s11_files: Sequence[str | Path], spectra: Mapping[str, str | Path | Sequence[str | Path]], templog: str | Path | Sequence[str | Path] | None = None, receiver_metadata: dict | None = None) Self[source]¶
Create a CalObsDefEDGES3 instance from explicit lists of files.
No directory layout is assumed, so this is the constructor to use when the files to use have been selected elsewhere (e.g. by a file catalog).
- Parameters:
s11_files – The
.s1pfiles. Each is identified by its label, i.e. the part of its name after theYYYY_DDD_HH_timestamp. The labelsO,S,L(the calkit for the loads),lna_O,lna_S,lna_L(the calkit for the receiver),lna,amb,hot,openandshortmust each be given exactly once. Files with other labels (e.g.ant) are ignored. The files need not share a timestamp.spectra – The spectrum files for each load, keyed by load name (either short names
amb,hot,open,shortor long namesambient,hot_load,open,short). Each value is a file or a list of files, which are sorted by name (i.e. time) and concatenated.templog – The temperature log file(s), merged if more than one.
receiver_metadata – Metadata of the receiver S11 measurement (see
edges.io.calobsdef.ReceiverS11).
- Returns:
CalObsDefEDGES3 – A CalObsDefEDGES3 instance with all loads and receiver S11 populated.
- Raises:
FileNotFoundError – If any required S11 file or load spectra are not given.
ValueError – If an S11 file is not named as expected, or more than one S11 file has the same label.
- classmethod from_standard_layout(rootdir: str | Path, year: int, day: int, s11_year: int | None = None, s11_day: int | None = None, s11_hour: int | str = 'first', allow_closest_s11_within: int = 5, specfmt: Literal['acq', 'gsh5'] = 'acq', receiver_metadata: dict | None = None, s11_dir: str | Path = '.', spectrum_dir: str | Path = 'mro/{load}/{year}', templog: str | Path | Sequence[str | Path] | None = None, allow_multiple_spectra: bool = False) Self[source]¶
Create a CalObsDefEDGES3 instance from the standard directory layout.
This method locates and loads all required calibration and observation files for the specified date and configuration. The directories searched can be changed with
s11_dir,spectrum_dirandtemplog; to specify the files directly, usefrom_files().- Parameters:
rootdir – The root directory containing the data.
year – The year of the observation.
day (int) – The day of the year for the observation.
s11_year (int or None, optional) – The year to use for S11 calibration files. Defaults to year if not provided.
s11_day (int or None, optional) – The day to use for S11 calibration files. Defaults to day if not provided.
s11_hour (int or str, optional) – The hour to use for S11 calibration files, or “first”/”last” for automatic selection.
allow_closest_s11_within (int, optional) – Maximum number of days (either side) to search for the closest S11 file. The search wraps across year boundaries. Days are tried in the order day+1, day-1, day+2, …, so the later day wins a tie.
specfmt ({‘acq’, ‘gsh5’}, optional) – The file format for spectrum files.
receiver_metadata – Metadata of the receiver S11 measurement (see
edges.io.calobsdef.ReceiverS11).s11_dir – Directory holding the
.s1pfiles, relative torootdir(or absolute). It can contain a{year}placeholder.spectrum_dir – Directory holding the spectrum files, relative to
rootdir(or absolute). It can contain{load}and{year}placeholders.templog – The temperature log file(s), relative to
rootdir(or absolute). Several files are merged, de-duplicating overlapping entries. By default,temperature_logger/temperature.logis used if it exists. Pass an empty list to use no temperature log.allow_multiple_spectra – Whether to allow (and concatenate) more than one spectrum file per load on the day.
- Returns:
CalObsDefEDGES3 – A CalObsDefEDGES3 instance with all loads and receiver S11 populated.
- Raises:
AssertionError – If the root directory does not exist.
FileNotFoundError – If required files are not found.
OSError – If multiple files are found where only one is expected.
- property loads: dict[str, LoadDefEDGES3]¶
A dictionary of all loads.
- edges.io.calobsdef3.DEFAULT_RECEIVER_METADATA = {'calkit': 'AGILENT_ALAN', 'calkit_match_resistance': 49.8}¶
Default metadata of the receiver S11 measurement.
- edges.io.calobsdef3.DEFAULT_S11_DIR = '.'¶
Default directory (relative to the root) holding the
.s1pfiles.
- edges.io.calobsdef3.DEFAULT_SPECTRUM_DIR = 'mro/{load}/{year}'¶
Default directory template (relative to the root) holding the spectrum files. It is formatted with
loadandyear.
- edges.io.calobsdef3.DEFAULT_TEMPLOG = 'temperature_logger/temperature.log'¶
Default temperature log (relative to the root).
- class edges.io.calobsdef3.LoadDefEDGES3(*, name: str, s11: LoadS11, spectra: Sequence[str | Path], templog: str | Path | Sequence[str | Path] | None)[source]¶
File-specification for an EDGES-3 Calibration Load.
- Parameters:
name (str) – The name of the load.
s11 (edges.io.calobsdef.LoadS11) – The S11 measurement files.
spectra (list[pathlib.Path]) – The spectrum measurement files. They are concatenated in time.
templog (pathlib.Path | list[pathlib.Path] | None) – The temperature logger file, or a list of files. Several files are merged (overlapping entries are de-duplicated), see
edges.io.templogs.read_temperature_log().
- Variables:
telescope (ClassVar[str | None]) – The telescope used when reading the spectra. None means it is inferred from the header of the spectrum files.
- classmethod from_standard_layout(root: Path, loadname: Literal['amb', 'hot', 'open', 'short'], year: int, day: int, s11_year: int | None = None, s11_day: int | None = None, s11_hour: int | str = 'first', allow_closest_s11_within: int = 5, specfmt: Literal['acq', 'gsh5'] = 'acq', s11_dir: str | Path = '.', spectrum_dir: str | Path = 'mro/{load}/{year}', templog: str | Path | Sequence[str | Path] | None = None, allow_multiple_spectra: bool = False) Self[source]¶
Create a LoadDefEDGES3 instance from a standard directory layout.
This method locates and loads all required calibration and observation files for the specified date and configuration.
- Parameters:
root (PathLike) – The root directory containing the data.
loadname – The name of the load to gather files for.
year (int) – The year of the observation.
day (int) – The day of the year for the observation.
s11_year (int or None, optional) – The year to use for S11 calibration files. Defaults to year if not provided.
s11_day (int or None, optional) – The day to use for S11 calibration files. Defaults to day if not provided.
s11_hour (int or str, optional) – The hour to use for S11 calibration files, or “first”/”last” for automatic selection.
allow_closest_s11_within (int, optional) – Maximum number of days (either side) to search for the closest S11 file. The search wraps across year boundaries. Days are tried in the order day+1, day-1, day+2, …, so the later day wins a tie.
specfmt ({‘acq’, ‘gsh5’}, optional) – The file format for spectrum files.
s11_dir – Directory holding the
.s1pfiles, relative toroot(or absolute). It can contain a{year}placeholder.spectrum_dir – Directory holding the spectrum files, relative to
root(or absolute). It can contain{load}and{year}placeholders.templog – The temperature log file(s), relative to
root(or absolute). Several files are merged. By default,temperature_logger/temperature.logis used if it exists. Pass an empty list to use no temperature log.allow_multiple_spectra – Whether to allow (and concatenate) more than one spectrum file for the load on the day.
- Returns:
LoadDefEDGES3 – A LoadDefEDGES3 instance with all loads and receiver S11 populated.
- Raises:
FileNotFoundError – If required files are not found.
OSError – If multiple files are found where only one is expected.
- edges.io.calobsdef3.from_edges3_layout(cls, root_dir: Path | str, load: Literal['amb', 'ant', 'hot', 'open', 'short', 'lna'], year: int, day: int, hour: int | str = 'first', allow_closest_s11_within: int = 5, s11_dir: str | Path = '.') Self[source]¶
Create a CalkitEdges3 object from a standard directory layout.
- Parameters:
root_dir – The root directory to search in
load – The name of the load for which the calkit observations were taken.
year – The year of observation.
day – The day of observation
hour – The hour of observation, or “first” for automaic search.
allow_closest_s11_within – The number of surrounding days (either side) to search for S11. Days are tried in the order day+1, day-1, day+2, …, so the later day wins a tie.
s11_dir – Directory holding the
.s1pfiles, relative toroot_dir(or absolute). It can contain a{year}placeholder.
- edges.io.calobsdef3.get_s1p_files(load: Literal['amb', 'ant', 'hot', 'open', 'short', 'lna'], year: int, day: int, root_dir: Path | str, hour: int | str = 'first', allow_closest_s11_within: int = 5, s11_dir: str | Path = '.') dict[str, Path][source]¶
Take the load and return a dict of .s1p files for that load.
- Parameters:
load – The name of the load.
year – The year of the S11 measurement.
day – The day of year of the S11 measurement.
root_dir – The root directory of the data.
hour – The hour of the S11 measurement, or “first”/”last” to take the first/last measurement of the day.
allow_closest_s11_within – If no file exists for the given day, search up to this many days either side of it (across year boundaries) for the closest day that has one. Days are tried in the order day+1, day-1, day+2, …, so the later day wins a tie.
s11_dir – Directory holding the
.s1pfiles, relative toroot_dir(or absolute). It can contain a{year}placeholder.
- Returns:
dict – Paths keyed by “input”, “open”, “short” and “match”.
- edges.io.calobsdef3.get_spectrum_files(load: Literal['amb', 'hot', 'short', 'open'], root: Path, year: int, day: int, fmt: Literal['acq', 'gsh5'] = 'acq', spectrum_dir: str | Path = 'mro/{load}/{year}', allow_multiple: bool = False) list[Path][source]¶
Get the spectrum files for a particular load on a particular day.
- Parameters:
load – The name of the load.
root – The root directory of the data.
year – The year of the observation.
day – The day of year of the observation.
fmt – The file format of the spectra.
spectrum_dir – Directory holding the spectrum files, relative to
root(or absolute). It can contain{load}and{year}placeholders.allow_multiple – Whether to allow more than one file for the load on the day. If False, an error is raised when more than one file is found.
- Returns:
list of Path – The files, sorted by name (i.e. by time).
- Raises:
FileNotFoundError – If no files are found.
OSError – If more than one file is found and
allow_multipleis False.
- Warns:
UserWarning – If there are files for the load that start at midnight (
00_00) on the next day. These are probably the continuation of the last file of the day (files are split at UTC midnight), but are not included. To include them, useCalObsDefEDGES3.from_files().