lair.inventories.Inventory#
- class lair.inventories.Inventory(data, pollutant, src_units=None, time_step='annual', crs='EPSG:4326', version=None, standardize_units=False)[source]#
Bases:
BaseGridBase class for inventories.
- Parameters:
- get_standard_name()[source]#
Get the standard name of the inventory.
- Returns:
str – The standard name.
- Return type:
- property absolute_emissions: Dataset#
Calculate the absolute emissions (total per gridcell for time step by variable).
- Returns:
xr.DataArray – The absolute emissions.
- property total_emissions: DataArray#
Calculate the total emissions by summation over all variables.
- Returns:
xr.DataArray – The total emissions.
- property collapsed: DataArray#
Collapse the inventory data to a single variable.
- Returns:
xr.DataArray – The collapsed data.
- property data: Dataset#
The inventory data.
Note
pint units have been dequantified and stored in variable attributes.
- Returns:
xr.DataArray | xr.Dataset – The inventory data.
- quantify()[source]#
Quantify the data using pint units for each variable.
- Returns:
xr.Dataset – The quantified data.
- Return type:
- convert_units(dst_units, inplace=False)[source]#
Convert the units of the data to the desired output units.
- integrate()[source]#
Integrate the data over the spatial dimensions to get the total emissions per time step.
- Returns:
xr.DataArray – The integrated data.
- Return type:
- regrid(out_grid, method='conservative', inplace=False)[source]#
Regrid the data to a new grid. Uses xesmf for regridding.
Note
At present, xesmf only supports regridding lat-lon grids. self.data must be on a lat-lon grid. Possibly could use xesmf.frontend.BaseRegridder to regrid to a generic grid.
Warning
xarray.Dataset.cf.add_bounds is known to have issues, including near the 180th meridian. Care should be taken when using this method, especially with global datasets.
- Parameters:
out_grid (xr.DataArray) – The new grid to resample to. Must be a lat-lon grid.
method (str, optional) –
The regridding method, by default ‘conservative’.
Note
Other xesmf regrid methods can be passed, but it is highly encouraged to use a conservative method for fluxes.
inplace (bool, optional) – Whether to modify the data in place, by default False.
- Returns:
Inventory – The regridded inventory. If inplace=True returns self, otherwise returns a new Inventory copy.
- Return type:
- resample(resolution, regrid_method='conservative', inplace=False)[source]#
Resample the data to a new resolution.
- Parameters:
- Returns:
BaseGrid – The resampled grid
- Return type:
- reproject(resolution, regrid_method='conservative', inplace=False)[source]#
Reproject the data to a lat lon rectilinear grid.
- Parameters:
- Returns:
BaseGrid – The reprojected grid
- Return type:
- plot(ax=None, time='mean', sector=None, **kwargs)[source]#
Plot the inventory data.
- Parameters:
ax (matplotlib.axes.Axes) – The axes to plot on.
time (str | int, optional) – The time step to plot, by default ‘mean’. If ‘mean’, the mean emissions are plotted. Otherwise pass a string selector or integer index.
sector (str, optional) – The sector to plot, by default None. If None, the total emissions are plotted.
kwargs (dict) – Additional keyword arguments to pass to xarray’s plot method.
- Returns:
matplotlib.axes.Axes – The axes with the plot.
- Return type: