openairclim.write_output

Writes output: results netCDF file and diagnositics files

openairclim.write_output.query_checksum_table(spec, resp, inv)[source]

Look up in checksum table, if for the particular spec/resp/inv combination pre-calculated data exists

Parameters:
  • spec (str) – Name of the species

  • resp (xarray) – Response xarray Dataset

  • inv (xarray) – Emission inventory xarray Dataset

Returns:

xarray Dataset with weight parameters,

Number of rows in checksum table

Return type:

xarray/None, int

openairclim.write_output.update_checksum_table(spec, resp, inv, cache_file)[source]
Add a row to the existing checksum table with hashes of resp and inv,

and path to cache_file

Parameters:
  • spec (str) – Name of the species

  • resp (xarray) – Response xarray

  • inv (xarray) – Emission inventory

  • cache_file (str) – Path to cache file

Returns:

Representation of the current checksum table

Return type:

pd.DataFrame

openairclim.write_output.update_output_dict(output_dict, ac, result_type, val_arr_dict)[source]

Update output_dict for a given aircraft with a new result type.

Parameters:
  • output_dict (dict) – The main output dictionary to update. Format: {ac: {var: np.ndarray}}

  • ac (str) – Aircraft identifier from config file

  • result_type (str) – Prefix for variable names, e.g. “RF”

  • val_arr_dict (dict) – Dictionary of {species: np.ndarray} results. Each array shold be 1D and represent a time series.

Returns:

Modifies output_dict in-place.

Return type:

None

openairclim.write_output.write_climate_metrics(config: dict, metrics_dict: dict, mode: str = 'w') Dataset[source]

Writes climate metrics to netCDF file.

Parameters:
  • config (dict) – Configuration from config file

  • metrics_dict (dict) – Dictionary of climate metrics, keys are metric types

  • mode (str, optional) – Can be “w” for write or “a” for append. Defaults to “w”.

Returns:

xarray Dataset of climate metrics

Return type:

xr.Dataset

openairclim.write_output.write_concentrations(config, resp_dict, conc_dict)[source]

Output of concentration changes, Convert dictionary of time series numpy arrays into dictionary of xarray Datasets, write to netCDF files, one per species

Parameters:
  • config (dict) – Configuration from config file

  • resp_dict (dict) – Dictionary of response xarray Datasets, keys are species

  • conc_dict (dict) – Dictionary of time series numpy arrays (time, lat, plev), keys are species

Returns:

Dictionary of concentration changes (time, lat, plev), keys are species

Return type:

dict

openairclim.write_output.write_output_dict_to_netcdf(config, output_dict, mode='w')[source]

Convert nested output dictionary into xarray Dataset and write to netCDF file.

Parameters:
  • config (dict) – Configuration from config file

  • output_dict (dict) – Nested output dictionary. Levels are {ac: {var: np.ndarray}}, where ac is the aircraft identifier, var is a variable, e.g. “RF_CO2” and np.ndarray is of length time (as defined in config)

  • mode (str, optional) – Options: “a” (append) and “w” (write).

Returns:

OpenAirClim results

Return type:

xr.Dataset