Bindings to EBAS

EBAS handles the data using files in a .nas format.

Flags

EBAS has a flag system: https://projects.nilu.no/ccc/flags/flags.html

We tried to translate the flags to the Avoca flags, but it is not guaranteed that all flags have the same meaning.

API

Module to handle data of the format required by ebas.

class avoca.bindings.ebas.DataLevel(*values)

Values for different type of data used by ebas.

avoca.bindings.ebas.data_level_after_qa(data_level: DataLevel) DataLevel

Return the data level after the QA.

avoca.bindings.ebas.extract_concentration_field(text: str) dict[str, float]

Extract the concentrations from the text.

This is a temporary solution that we found to communicate the concentrations of the standards thgrough the nas files.

avoca.bindings.ebas.get_data_level(nas: EbasNasaAmes) DataLevel

Get the data level of the nas file.

avoca.bindings.ebas.get_last_written_nas_file(directory: Path) Path | None

Return path to the last nas file.

avoca.bindings.ebas.nas_to_avoca(nas: EbasNasaAmes) DataFrame

Convert the ebas file to a pandas dataframe for @voc@.

To read the nas file, you can do:

from ebas.io.file.nasa_ames import EbasNasaAmes

file = "path/to/file.nas"
nas = EbasNasaAmes()
nas.read(file)
df = nas_to_avoca(nas)

Doing this will remove some specific flag information. In particular, @voc@ only accepts flags per compound and not per variable as in ebas.

This for each compound, the flag collects all the compounds of the variables.

@voc@ also requires a runtype for each run. We use for that the calibration flag suggested by ebas. We have to assume that this flag is the same for all compounds.

avoca.bindings.ebas.read_ebas_csv(file: PathLike) DataFrame

Read the EBAS csv file and return a DataFrame.

This format comes from other EBAS tools.

avoca.bindings.ebas.set_dataframe(nas, df_export: DataFrame, compounds: dict[str, str] | None = None, data_level: DataLevel = DataLevel.CONCS, start_offset: timedelta | None = None, end_offset: timedelta | None = None, flag_all: list[int] = [], invalidate_conc_calib: bool = True)

Put the data from the export dataframe into the nas object.

Parameters:
  • nas – The nas object to fill

  • df_export – The dataframe with the data to export. Format follows the other avoca format.

  • compounds – The dictionary with the compounds. The keys are the the names in df_export. Values are the names in ebas.

  • data_level – The level of the data to export.

  • start_offset – The offset to add to the start time

  • end_offset – The offset to add to the end time

  • flag_all – List of flags to add to all the data

  • invalidate_conc_calib – If True, the concentration calibration will be invalidated (flag 980) for all calib samples.

Returns:

A dictionary with the metadata of the compounds exported.