O3API Reference

If you are looking for information on a specific function, class or method, this part of the documentation is for you.

api

O3as REST API methods:

load

module containing the LoadData class to initialize datasets and load them in-memory:

Created on Sun Feb 13 16:29:07 2022

@author: valentin

class o3api.load.LoadData(data_basepath, plot_type)[source]

Base Class to initialize the dataset

Parameters

plot_type – The plot type (e.g. tco3_zm, tco3_return, vmro3_zm, …)

load_dataset(model_path)[source]

Load dataset from the datafile path (one model)

Parameters

model_path – Full path to the model data

Returns

xarray Dataset with the model data

Return type

xarray.Dataset

load_dataset_ensemble()[source]

Load data from the list of datafiles (self._datafile_paths) in memory.

Returns

dictionary of datasets as {‘model’: xarray dataset }

prepare

module with the PreparaData class to perform data selection:

class o3api.prepare.PrepareData(data, **kwargs)[source]

Class to perform data selection, based on Dataset.

Parameters
  • begin – Year to start data scanning from

  • end – Year to finish data scanning

  • month – Month(s) to select, if not a whole year

  • lat_min – Minimum latitude to define the range (-90..90)

  • lat_max – Maximum latitude to define the range (-90..90)

get_dataslice(model)[source]

Function to select the slice of data according to the time and latitude requested

Parameters

model – The model to process

Returns

xarray dataset selected according to the time and latitude

Return type

xarray

get_raw_data_pd(model) DataFrame[source]

Process the model to get tco3_zm raw data

Parameters

model – The model to process for tco3_zm

Returns

raw data points in preparation for plotting

Return type

pd.DataFrame

get_raw_ensemble_pd(models) DataFrame[source]

Build the ensemble of tco3_zm models

Parameters

models – Models to process for tco3_zm

Returns

ensemble of models as pd.DataFrame

Return type

pd.DataFrame

to_pd_dataframe(ds, model) DataFrame[source]

Convert xarray variable to pandas dataframe (faster method?)

Parameters
  • ds – xarray dataset

  • model – The model to process for self.plot_type

:return dataset as pandas dataframe :rtype: pandas dataframe

tco3_zm

module with two classes: ProcessForTCO3Zm and ProcessForTCO3ZmReturn to produce tco3_zm and tco3_return plots correspondingly:

class o3api.tco3_zm.ProcessForTCO3Zm(data, **kwargs)[source]

Subclass of PrepareData to calculate tco3_zm

get_ensemble_for_plot(models) DataFrame[source]

Build the ensemble of tco3_zm models for plotting, include reference

Parameters

models – Models to process for tco3_zm

Returns

ensemble of models, including the reference, as pd.DataFrame

Return type

pd.DataFrame

get_ensemble_shifted(data) DataFrame[source]

Shift tco3_zm data to reference year

Parameters

data – data to process as pd.DataFrame

Returns

shifted data points for plotting

Return type

pd.DataFrame

get_ensemble_smoothed(models, smooth_win) DataFrame[source]

Smooth tco3_zm data using boxcar

Parameters

models – Models to process for tco3_return

Returns

smoothed data points

Return type

pd.DataFrame

get_ensemble_stats(data) DataFrame[source]

Calculate Mean, Std, Median for tco3_zm data

Parameters

data – data to process as pd.DataFrame

Returns

updated pd.DateFrame with stats columns

Return type

pd.DataFrame

get_ensemble_yearly(models) DataFrame[source]
Rebin tco3_zm data for yearly entries:

(0). optionally interpolate missing values in the reference measurement 1. group by year 2. average by applying mean()

Parameters

models – Models to process for tco3 plots

Returns

yearly averaged data points

Return type

pd.DataFrame

get_ref_value()[source]

Get reference value for the reference year

Returns

reference value (tco3_zm at reference year)

class o3api.tco3_zm.ProcessForTCO3ZmReturn(data, **kwargs)[source]

Subclass of ProcessForTCO3Zm to calculate tco3_return

get_ensemble_for_plot(models)[source]

Build the ensemble of tco3_return points for plotting

Parameters

models – Models to process for tco3_zm

Returns

ensemble of models, including the mean, as pd.DataFrame

Return type

pd.DataFrame

get_return_years(data)[source]

Calculate return year for every model

Parameters

data – data to process

Returns

return years for models

Return type

pd.DataFrame

plothelpers

O3as help functions to create figures:

o3api.plothelpers.cleanse_models(**kwargs)[source]

Cleansing models from empty entries, spaces, and quotes

Parameters

kwargs – The provided in the API call parameters

Returns

models cleansed from empty entries, spaces, quotes

Return type

list

o3api.plothelpers.get_date_range(ds)[source]

Return the range of dates in the provided dataset

Parameters

ds – xarray dataset to check

Returns

date_min, date_max

o3api.plothelpers.get_periodicity(pd_time)[source]

Calculate periodicity in the provided data

Parameters

pd_time (pandas DatetimeIndex) – The time period

Returns

Calculated periodicity as the number of points per year

Return type

int

o3api.plothelpers.get_plot_info_html(**kwargs)[source]

Generate info text (HTML) for the plot

Parameters

kwargs – The provided in the API call parameters

Returns

information text (HTML) with legal info, parameters etc

Return type

string

o3api.plothelpers.get_plot_info_txt(**kwargs)[source]

Generate info text for the plot

Parameters

kwargs – The provided in the API call parameters

Returns

information text with legal info, parameters etc

Return type

string

o3api.plothelpers.get_plot_params(**kwargs)[source]

Get plot parameters

Parameters

kwargs – The provided in the API call parameters

Returns

plot_params with added input parameters

Return type

string

o3api.plothelpers.set_figure_attr(fig, **kwargs)[source]

Configure the figure attributes

Parameters
  • fig – Figure instance

  • kwargs – The provided in the API call parameters

Returns

none

o3api.plothelpers.set_filename(**kwargs)[source]

Set file name

Parameters

kwargs – The provided in the API call parameters

Returns

file_name with added input parameters (no extension given!)

Return type

string