RegionProcessor¶
- class nomenclature.RegionProcessor(*, region_codelist, variable_codelist, mappings)[source]¶
Region aggregation mappings for scenario processing
Methods
apply
(df)Apply region processing
check_region_aggregation
(df[, rtol_difference])Return region aggregation results and differences between aggregated and model native data
from_directory
(path, dsd)Initialize a RegionProcessor from a directory of model-aggregation mappings.
- apply(df)[source]¶
Apply region processing
- Parameters:
- dfIamDataFrame
Input data that the region processing is applied to
- Returns:
- IamDataFrame:
Processed data
- Raises:
- ValueError
If df contains regions that are not listed in the model mapping, or
If the region-processing results in an empty IamDataFrame.
- check_region_aggregation(df, rtol_difference=0.01)[source]¶
Return region aggregation results and differences between aggregated and model native data
- Parameters:
- dfIamDataFrame
Input data
- rtol_differencefloat, optional
limit on the relative tolerance for differences, by default 0.01
- Returns:
- tuple[IamDataFrame, pd.DataFrame]
IamDataFrame containing aggregation results and pandas dataframe containing the differences
- classmethod from_directory(path, dsd)[source]¶
Initialize a RegionProcessor from a directory of model-aggregation mappings.
- Parameters:
- pathDirectoryPath
Directory which holds all the mappings.
- dsdDataStructureDefinition
Instance of DataStructureDefinition used for validation of mappings and region aggregation.
- Returns:
- RegionProcessor
The resulting region processor object.
- Raises:
- ValueError
Raised in case there are multiple mappings defined for the same model or there is an issue with region the RegionAggregationMapping
- AttributeError
Raised if the provided DataStructureDefinition does not contain the dimensions
region
andvariable
.