lair.inventories.sum_sectors#
- lair.inventories.sum_sectors(data, exclude=None)[source]#
Sum emissions from all sectors in the dataset.
What “all sectors” covers depends on the product: see each inventory’s docstring (e.g. EPA v1 annual includes
Forest_Fires, EPA v2 express includes the supplementalPostMeter).- Parameters:
- Returns:
xr.DataArray – The sum of emissions from the sectors, in their units.
- Raises:
ValueError – If
excludenames a sector that is not indata, or if the sectors that are summed are in different units (the numbers cannot be added as they are; convert them to one unit first).- Return type:
See also
Inventory.total_emissionsThis sum of an inventory’s data.
Inventory.integrateThe total over a region, as a mass.
Examples
A sector with no emission in a cell (NaN) adds nothing there:
>>> import xarray as xr >>> from lair.inventories import sum_sectors >>> units = {"units": "kg m-2 s-1"} >>> data = xr.Dataset( ... { ... "energy": ("x", [1.0, float("nan")], units), ... "waste": ("x", [2.0, 3.0], units), ... } ... ) >>> sum_sectors(data).values array([3., 3.]) >>> sum_sectors(data, exclude=["energy"]).values array([2., 3.])