Multiple infillers API

Multiple infillers

Multiple infillers provide easy-to-use infiller options for the most common use-cases.

Decompose collection with time-dependent ratio API

Uses the ‘time-dependent ratio’ database cruncher designed for constructing an aggregate variable and breaking this mix into its constituents.

class silicone.multiple_infillers.decompose_collection_with_time_dep_ratio.DecomposeCollectionTimeDepRatio(db)[source]

Bases: object

Constructs an aggregate variable and uses the ‘time-dependent ratio’ technique to calculate what this predicts for our database.

infill_components(aggregate, components, to_infill_df, metric_name='AR5GWP100', only_consistent_cases=True)[source]

Derive the relationship between the composite variables and their sum, then use this to deconstruct the sum.

Parameters
  • aggregate (str) – The variable for which we want to calculate timeseries (e.g. "Emissions|CO2"). Unlike in most crunchers, we do not expect the database to already contain this data.

  • components (list[str]) –

    The variables whose sum should be equal to the timeseries of the aggregate

    (e.g. ["Emissions|CO2|AFOLU", "Emissions|CO2|Energy"]).

  • to_infill_df (pyam.IamDataFrame) – The dataframe that already contains the aggregate variable, but needs the components to be infilled.

  • metric_name (str) – The name of the conversion metric to use. This will usually be AR<4/5/6>GWP100.

  • only_consistent_cases (bool) – Do we want to only use model/scenario combinations where all aggregate and components have data at all times? This will reduce the risk of inconsistencies or unevenness in the results, but may reduce the amount of data.

Returns

The infilled data resulting from the calculation.

Return type

pyam.IamDataFrame

Raises

ValueError – There is no data for variable_leaders or variable_follower in the database.

Infill all required emissions for openscm API

silicone.multiple_infillers.infill_all_required_emissions_for_openscm.infill_all_required_variables(to_fill, database, variable_leaders, required_variables_list=None, cruncher=<class 'silicone.database_crunchers.quantile_rolling_windows.QuantileRollingWindows'>, output_timesteps=None, infilled_data_prefix=None, to_fill_old_prefix=None, check_data_returned=False, **kwargs)[source]

This is function designed to infill all required data given a minimal amount of input.

Parameters
  • to_fill (pyam.IamDataFrame) – The dataframe which is to be infilled

  • database (pyam.IamDataFrame) – The dataframe containing all information to be used in the infilling process.

  • variable_leaders (list[str]) – The name of the variable(s) found in to_fill which should be used to determine the values of the other variables. For most infillers (including the default) this list must contain only one entry. E.g. [“Emissions|CO2”]

  • required_variables_list (list[str]) – The list of variables to infill. Each will be done separately. The default behaviour (None option) will result in this being filled with the complete list of required emissions.

  • cruncher – The class of cruncher to use to compute the infilled values. Defaults to QuantileRollingWindows, which uses the median value of a rolling window. See the cruncher documentation for more details.

  • output_timesteps (list[int or datetime]) – List of times at which to return infilled values. Will interpolate values in between known data, but will not extend beyond the range of data provided.

  • infilled_data_prefix (str) – A string that should be prefixed on all the variable names of the results returned. Used to distinguish returned values from those input.

  • to_fill_old_prefix (str) – Any string already found at the beginning of the variables names of the input to_fill dataframe. This will be removed before comparing the variable names with database.

  • check_data_returned (bool) – If true, we perform checks that all desired data has been returned. Potential reasons for failing this include requesting results at times outside our input time range, as well as code bugs.

  • kwargs (**) – An optional dictionary of keyword : arguments to be used with the cruncher.

Returns

The infilled dataframe (including input data) at requested times. All variables now begin with infilled_data_prefix instead of to_fill_old_prefix.

Return type

pyam.IamDataFrame

Infill composite values API

silicone.multiple_infillers.infill_composite_values.infill_composite_values(df, composite_dic=None)[source]

Constructs a series of aggregate variables, calculated as the sums of variables that have been reported. If given factors terms too, the terms will be multiplied by the factors before summing.

Parameters
  • df (pyam.IamDataFrame) – Input data from which to construct consistent values. This is assumed to be fully infilled. This will not be checked.

  • composite_dic (dict{str: list[str]} or dict{str: dict{str: float}}) – Key: The variable names of the composite. Value: The variable names of the constituents, which may include wildcards (‘*’). Optionally, these values may be dictionaries of the names to factors, which we multiply the numbers by before summing them. Defaults to a list of PFC, HFC, F-Gases, CO2 and Kyoto gases.

Returns

pyam.IamDataFrame containing the composite values.

Return type

pyam.IamDataFrame