Instruments#

This module implements UATAQ instruments as classes.

Each instrument class is a subclass of the Instrument abstract base class and implements methods for reading and parsing data files.

The Instrument class provides a common interface for all instrument classes and defines abstract methods that must be implemented by each subclass.

class lair.uataq.instruments.Instrument(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: object

Abstract base class for instrument objects.

Attributes

model

(str) Model of the instrument.

SID

(str) Site ID where the instrument is installed.

name

(str) Name of the instrument.

groups

(list[str]) Research groups that operate the instrument.

loggers

(set[str]) Loggers used by the research groups to record data.

config

(dict) Configuration settings for the instrument.

Methods

get_files(group: str, lvl: str) -> list[str]

Get list of file paths for a given level.

read_data(group: str, lvl: str, time_range: TimeRange, num_processes: int, file_pattern: str) -> pd.DataFrame

Read and parse group data files for the given level and time range using multiple processes.

__init__(SID: str, name: str, loggers: dict, config: dict)[source]#

Initialize the Instrument object.

Parameters:
SIDstr

Site ID where the instrument is installed.

namestr

Name of the instrument.

loggersdict

Dictionary of loggers used by different research groups.

configdict

Configuration settings for the instrument.

get_highest_lvl(group: str) str[source]#

Get the highest data level for the instrument.

Parameters:
groupstr

The research group whose data to retrieve.

Returns:
str

The highest data level.

get_files(group: str, lvl: str) list[str][source]#

Get list of file paths for a given level.

Parameters:
groupstr

The research group whose data to retrieve.

lvlstr

The level of the data to retrieve.

Returns:
list[str]

A list of file paths.

get_datafiles(group: str, lvl: str, time_range: TimeRange, pattern: str | None = None) list[DataFile][source]#

Get data files for the given level and time range from the groupspace.

Parameters:
groupstr

The research group whose data to retrieve.

lvlstr

The level of the data to retrieve.

time_rangeTimeRange

The time range of the data to retrieve.

patternstr

A string pattern to filter the file paths.

Returns:
list[DataFile]

A list of data files.

standardize_data(group: str, data: DataFrame) DataFrame[source]#

Manipulate the data to a standard format between research groups, renaming columns, converting units, mapping values, etc. as needed.

Parameters:
groupstr

The research group whose data to standardize.

datapandas.DataFrame

The data to standardize.

Returns:
pandas.DataFrame

The standardized data.

read_data(group: str, lvl: str | None = None, time_range: TimeRange | str | list[str | datetime | None] | tuple[str | datetime | None, str | datetime | None] | slice | None = None, num_processes: int | Literal['max'] = 1, file_pattern: str | None = None) DataFrame[source]#

Read and parse data files for the given level and time range, using multiple processes if specified.

Parameters:
groupstr

The research group whose data to read.

lvlstr

The level of the data to read.

time_rangestr | list[Union[str, dt.datetime, None]] | tuple[Union[str, dt.datetime, None], Union[str, dt.datetime, None]] | slice | None

The time range to read data. Default is None which reads all available data.

num_processesint | ‘max’

The number of processes to use for parallelization.

file_patternstr

A string pattern to filter the file paths.

Returns:
pandas.DataFrame

A concatenated DataFrame containing the parsed data from files.

lair.uataq.instruments.configure_instrument(SID: str, name: str, config: dict, loggers: dict | None = None) Instrument[source]#

Configure an instrument object based on the given configuration settings.

Parameters:
SIDstr

Site ID where the instrument is installed.

namestr

Name of the instrument.

configdict

Configuration settings for the instrument.

loggersdict, optional

Dictionary of loggers used by different research groups.

Returns:
Instrument

An instrument object configured with the given settings.

Raises:
ValueError

If the instrument model is not found in the catalog.

ValueError

If no loggers are found for the instrument at the site.

class lair.uataq.instruments.InstrumentEnsemble(SID: str, configs: dict, loggers: dict | None = None)[source]#

Bases: object

Container for an ensemble of instruments at a site.

Attributes

SID

(str) Site ID of the ensemble.

configs

(dict[str, dict]) Dictionary of configuration settings for each instrument.

names

(list[str]) List of instrument names in the ensemble.

loggers

(set[str]) Set of loggers used by the research groups.

groups

(set[str]) Set of research groups that operate the instruments.

pollutants

(set[str]) Set of pollutants measured by the instruments.

__init__(SID: str, configs: dict, loggers: dict | None = None)[source]#

Initialize the InstrumentEnsemble object.

Parameters:
SIDstr

Site ID of the ensemble.

configsdict[instrument, config]

Dictionary of configuration settings for each instrument.

loggersdict[group, logger], optional

Dictionary of loggers used by different research groups.

class lair.uataq.instruments.SensorMixin[source]#

Bases: object

Mixin for instrument objects that measure a pollutant.

Attributes:

pollutants (tuple): Tuple of pollutants measured by the instrument.

class lair.uataq.instruments.BB_205(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.BB_405(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.CR1000(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument

class lair.uataq.instruments.GPS(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument

read_data(group: str, lvl: str, time_range: TimeRange | str | list[str | datetime | None] | tuple[str | datetime | None, str | datetime | None] | slice | None = [None, None], num_processes: int | Literal['max'] = 1, file_pattern: str | None = None) DataFrame[source]#

Read and parse data files for the given level and time range, using multiple processes if specified.

Parameters:
groupstr

The research group whose data to read.

lvlstr

The level of the data to read.

time_rangestr | list[Union[str, dt.datetime, None]] | tuple[Union[str, dt.datetime, None], Union[str, dt.datetime, None]] | slice | None

The time range to read data. Default is None which reads all available data.

num_processesint | ‘max’

The number of processes to use for parallelization.

file_patternstr

A string pattern to filter the file paths.

Returns:
pandas.DataFrame

A concatenated DataFrame containing the parsed data from files.

class lair.uataq.instruments.LGR_NO2(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.LGR_UGGA(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Licor_6262(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Licor_7000(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Licor_6262

class lair.uataq.instruments.Magee_AE33(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.MetOne_ES405(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.MetOne_ES642(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Teledyne_T200(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Teledyne_T300(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Teledyne_T400(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Teledyne_T500u(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

class lair.uataq.instruments.Teom_1400ab(SID: str, name: str, loggers: dict, config: dict)[source]#

Bases: Instrument, SensorMixin

lair.uataq.instruments.catalog: dict[str, Type[Instrument]] = {'2b_205': <class 'lair.uataq.instruments.BB_205'>, '2b_405': <class 'lair.uataq.instruments.BB_405'>, 'cr1000': <class 'lair.uataq.instruments.CR1000'>, 'gps': <class 'lair.uataq.instruments.GPS'>, 'lgr_no2': <class 'lair.uataq.instruments.LGR_NO2'>, 'lgr_ugga': <class 'lair.uataq.instruments.LGR_UGGA'>, 'licor_6262': <class 'lair.uataq.instruments.Licor_6262'>, 'licor_7000': <class 'lair.uataq.instruments.Licor_7000'>, 'magee_ae33': <class 'lair.uataq.instruments.Magee_AE33'>, 'metone_es405': <class 'lair.uataq.instruments.MetOne_ES405'>, 'metone_es642': <class 'lair.uataq.instruments.MetOne_ES642'>, 'teledyne_t200': <class 'lair.uataq.instruments.Teledyne_T200'>, 'teledyne_t300': <class 'lair.uataq.instruments.Teledyne_T300'>, 'teledyne_t400': <class 'lair.uataq.instruments.Teledyne_T400'>, 'teledyne_t500u': <class 'lair.uataq.instruments.Teledyne_T500u'>, 'teom_1400ab': <class 'lair.uataq.instruments.Teom_1400ab'>}#

Instrument catalog