openairclim.read_netcdf

Methods for reading netCDF input

openairclim.read_netcdf.check_spec_attributes(config, inv_dict)[source]

Check emission attributes in inventories for given species in config TODO Expand list of possible emission units

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

  • inv_dict (dict) – Dictionary of xarray Datasets, keys are years of input inventories

Raises:

KeyError – if incorrect units found

openairclim.read_netcdf.get_evolution_type(config)[source]

Get evolution type

Parameters:

config (dict) – Configuration dictionary from config

Raises:

ValueError – if type attribute in evolution file is invalid

Returns:

evolution_tpye: norm or scaling or False

Return type:

str, bool

openairclim.read_netcdf.get_results(config: dict, ac='TOTAL') tuple[dict, dict, dict, dict][source]

Get the simulation results from the output netCDF file.

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

  • ac (str, optional) – Aircraft identifier, defaults to TOTAL

Returns:

dictionaries of numpy arrays containing the simulation results,

keys are species.

Return type:

dict

openairclim.read_netcdf.open_inventories(config, base=False)[source]

Open inventories from config, check attribute sections and time constraints

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

  • base (bool) – If TRUE, loads base inventory, else input inventory

Raises:
  • IndexError – if no inv_year is within time_range, for evolution_type = “norm” or “scaling” or False

  • IndexError – if time_range is not within evolution_time, for evolution_type = “norm” or “scaling”

  • IndexError – if no inv_year is within evolution_time, for evolution_tpye = “norm” or “scaling”

  • IndexError – if time_range first and last year are not in inv_years, for evolution_type = “scaling”

Returns:

Dictionary of xarray Datasets, keys are years of input inventories

Return type:

dict

openairclim.read_netcdf.open_netcdf(netcdf)[source]

Converts netCDF file or list of netCDF files to dictionary of xarray Datasets

Parameters:

netcdf (str or list) – (List of) netCDF file names

Returns:

Dictionary of xarray Datasets, keys are basenames of input netCDF

Return type:

dict

openairclim.read_netcdf.open_netcdf_from_config(config, section, species, resp_type)[source]

Open netcdf files and convert to xarray Datasets for given section in config and given species

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

  • section (str) – Section in config

  • species (list) – List of considered species

  • resp_type (str) – Response type, e.g. “conc”, “rf”

Returns:

Dictionary of xarray Datasets, one Dataset for each species,

keys are species names

Return type:

dict

openairclim.read_netcdf.split_inventory_by_aircraft(config, inv_dict)[source]

Split dictionary of emission inventories by aircraft identifiers defined in the config file.

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

  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

Returns:

Nested dictionary of emission inventories. Keys are aircraft

identifier, followed by year.

Return type:

dict