o3skim package

O3as package with classes and utilities to handle ozone data skimming.

The main usage of the package resides on the generation of “Source” class instances from the loading of netCDF files though collection descriptions generated by source files.

However, as the generation of collection descriptions in a form of dict type might be difficult, a yaml file can be converted into the required variable by using the util “load” with the path to the ‘sources.yaml’ file as input.

Once the desired collection is formated in the shape of dict variable, a source object can be created from using the class “Source”. During this step the model data is loaded into the source instance involving on the background process the data sorting and standardization. Note that those models with errors on the collection specification are not loaded neither interrupt the loading process. However, notice of those event is logged on strerr together with the stack execution info.

After the data has been loaded the object intstance correctly created, it is possible to use the internal methods to generate a reduced output on the current folder.

To simplify the management of the data and output directories, the package offest a “cd” utility which can be used together with a “with” statement to change temporary the location of the execution folder.

class o3skim.Source(name, metadata={}, **collections)[source]

Conceptual class for a data source. It is produced by the loading and standardization of multiple data models.

The current supported model variables are “tco3_zm” and “vmro3_zm”, which should contain the information on how to retrieve the data from the netCDF collection.

Parameters
  • name (str) – Name to provide to the source.

  • metadata (dict, optional) – Source metadata, defaults to {}.

  • **collections – kwarg where each ‘key’ is the model name and its ‘value’ another dictionary with the variable loading statements for that model. {name:str, paths: str, coordinates: dict, metadata: dict}

skim(groupby=None)[source]

Request to skim all source data into the current folder.

The output is generated into multiple folder where each model output is generated in a forder with the source name defined at the source initialization followed by ‘_’ and the model name: “<source_name>_<model_name>”. If there was metadata added when creating the source, it is delivered into a “metadata.yaml” file on the directory.

Parameters

groupby (str, optional) – How to group output (None, ‘year’, ‘decade’).

o3skim.cd(dir)[source]

Changes the directory inside a ‘with’ context. When the code reaches the end of the ‘with’ block or the code fails, the previous folder is restored.

Parameters

dir (str) – Path folder where to change the working directory.

o3skim.load(yaml_file)[source]

Loads the .yaml file and returns a python dictionary with all the yaml keys and values. Note a yaml file can have key:values sotored inside values, therefore the returned dictionary might have dictionaries stored inside values.

Parameters

yaml_file (str) – Path pointing to the yaml configuration file.

Returns

Dictionary with the yaml structure key:value.

Return type

dict