spaemis.scaling.timeseries

Proxy scaler

A proxy scaler uses a proxy (a 2d pattern) to disaggregate an emissions timeseries over a target area.

The proxy must cover the area of interest of the emissions timeseries

TimeseriesScaler

class TimeseriesScaler(proxy, proxy_region, source_timeseries, source_filters)[source]

Bases: BaseScaler

Scale a spatial pattern using a timeseries

classmethod create_from_config(method)[source]

Create Scaler from configuration

Return type:

spaemis.scaling.timeseries.TimeseriesScaler

get_timeseries_point

get_timeseries_point(timeseries, source, filters, target_year)[source]

Extract a single value according to some filters

Parameters:
  • timeseries (dict[str, scmdata.run.ScmRun]) – Collection of loaded timeseries

  • source (str) – Timeseries name

  • filters (list[dict[str, str]]) –

    Filter to apply to the selected timeseries

    These filters if applied must result in a single remaining timeseries otherwise a ValueError will be raised.

  • target_year (int) –

    Year to extract

    Must be contained in the targeted timeseries

Raises:

ValueError – If the selected data cannot be retrieved

Returns:

scmdata.run.ScmRun – ScmRun with a containing a single timeseries and year.

This object will retain the metadata of the filtered timeseries

apply_amount

apply_amount(amount, unit, proxy)[source]

Scale a known amount of emissions across a proxy

Parameters:
  • amount (float) –

    Amount of stuff to allocate across the proxy

    The stuff is usually annual emissions of a given species and currently

  • unit (str) –

    Unit of the stuff

    Must be able to be converted to a Pint unit with dimensions [X] * [mass] / [time] where X can be any dimension (typically CO2 or other species in the case of emissions)

  • proxy (xarray.core.dataarray.DataArray) –

    Proxy array

    Can include nans and missing data

Returns:

xarray.core.dataarray.DataArray – DataArray with the same dimensions of proxy where the sum matches amount