DataStructureDefinition¶
- class nomenclature.DataStructureDefinition(path, dimensions=None)[source]¶
Loads and manages codelists for IAMC data dimensions (e.g., variable, region, scenario).
This class reads project definitions from a folder, initializes codelists for each dimension, and provides methods to validate scenario data, check aggregation consistency, and export codelists to Excel.
Methods
check_aggregate(df, **kwargs)Check for consistency of scenario data along the variable hierarchy
to_excel(excel_writer, **kwargs)Write the codelists to an xlsx spreadsheet
validate(df[, dimensions])Validate that the coordinates of df are defined in the codelists
- check_aggregate(df, **kwargs)[source]¶
Check for consistency of scenario data along the variable hierarchy
- Parameters:
- df
pyam.IamDataFrame Scenario data to be checked for consistency along the variable hierarchy.
- kwargsTolerance arguments for comparison of values
Passed to
numpy.iscloseviapyam.IamDataFrame.check_aggregate.
- df
- Returns:
pandas.DataFrameData where a variable and its computed aggregate does not match.
- Raises:
- ValueError
If the
DataStructureDefinitiondoes not have a variable dimension.
- to_excel(excel_writer, **kwargs)[source]¶
Write the codelists to an xlsx spreadsheet
- Parameters:
- excel_writerstr or
pathlib.Path File path as string or
pathlib.Path.- **kwargs
Passed to
pandas.ExcelWriter
- excel_writerstr or
- validate(df, dimensions=None)[source]¶
Validate that the coordinates of df are defined in the codelists
- Parameters:
- df
pyam.IamDataFrame Scenario data to be validated against the codelists of this instance.
- dimensionslist of str, str, optional
Dimensions to perform validation (defaults to all dimensions of self)
- df
- Returns:
- None
- Raises:
- ValueError
If df fails validation against any codelist.