openairclim.utils.create_artificial_inventories

Create emission inventories with random values.

class openairclim.utils.create_artificial_inventories.ArtificialInventory(year: int, ac_lst: list[str] | None = None, lon_range: list[float] = [0.0, 360.0], lat_range: list[float] = [-90.0, 90.0], plev_range: list[float] = [200.0, 1000.0], scaling: float = 1.0, size: int = 10000)[source]

Bases: object

Class for generating artificial emission inventories.

convert_df_to_xr() → Self[source]

Convert the pandas dataframe to an xarray dataset.

Returns:

This instance, for chaining. The converted dataset is stored on self.inv.

Return type:

Self

Raises:

RuntimeError – If called before create_uniform_dist().

create(distribution: str = 'uniform') → Dataset[source]

Create an emission inventory with the specified distribution.

Parameters:

distribution (str, optional) – The distribution to use for creating the emission inventory. Can be either “uniform” or “normal”. Defaults to “uniform”.

Returns:

The emission inventory as an xarray dataset.

Return type:

xr.Dataset

create_normal_dist() → None[source]

Create an inventory with a normal distribution.

create_uniform_dist() → Self[source]

Create an emission inventory with a uniform distribution.

Returns:

This instance, for chaining.

Return type:

Self

mean_dict = {'CO2': 1346749.125, 'H2O': 540429.125, 'NOx': 6783.677734375, 'distance': 87872.8671875, 'fuel': 432343.28125, 'lat': 27.598291397094727, 'lon': 163.00254821777344, 'plev': 438.63165283203125}
stat_size = 606169
class openairclim.utils.create_artificial_inventories.ArtificialInventoryDict(year_arr: list[int], delta: float = 0.03, ac_lst: list[str] | None = None)[source]

Bases: object

Class for generating artificial emission inventories.

Parameters:
  • year_arr (list) – List of inventory years.

  • delta (float, optional) – Linear increase rate of emissions. Defaults to DELTA.

  • ac_lst (list, optional) – List of aircraft identifiers (strings). Defaults to None (ac coordinate not generated).

year_arr

List of inventory years.

Type:

list

year_0

First year in the list.

Type:

int

delta

Linear increase rate of emissions.

Type:

float

inv_dict

Dictionary of xarray datasets, where the keys are the inventory years and the values are the datasets for that year.

Type:

dict

create(evolution: str = 'increment') → dict[source]

Create an emission inventory with the specified evolution.

Parameters:

evolution (str, optional) – Evolution method. Can be either “increment” or “uniform”. Defaults to “increment”.

Returns:

Dictionary of xarray datasets, keys are inventory years.

Return type:

dict

create_linear_increase() → Self[source]

Create an inventory with a linear increase in emissions.

Returns:

This instance, for chaining. The inventories are stored on self.inv_dict.

Return type:

Self

inv_dict: dict | None
openairclim.utils.create_artificial_inventories.convert_xr_dict_to_nc(inv_dict: dict, prefix: str = 'rnd_inv', out_path: str = '.') → None[source]

Convert a dictionary of xarray datasets to netCDF files and save.

Create out_path if not existing.

Parameters:
  • inv_dict (dict) – Dictionary of xarray datasets, where the keys are the inventory years and the values are the datasets for that year.

  • prefix (str, optional) – Prefix for the output netCDF files. Defaults to “rnd_inv”.

  • out_path (str, optional) – The path to the output directory. Defaults to OUT_PATH.

Returns:

None

openairclim.utils.create_artificial_inventories.main()[source]

Parse command-line arguments and create artificial emission inventories.

openairclim.utils.create_artificial_inventories.plot_sample_emission_inventory(rnd_inv_dict: dict, out_path: str = '.') → None[source]

Plots a sample emission inventory from rnd_inv_dict.

Parameters:
  • rnd_inv_dict (dict) – Dictionary of xarray datasets, where the keys are the inventory years and the values are the datasets for that year.

  • out_path (str, optional) – The path to the output directory. Defaults to OUT_PATH.

Returns:

None