DataStructureDefinition

class nomenclature.DataStructureDefinition(path, dimensions=None)[source]

Definition of datastructure codelists for dimensions used in the IAMC format

Methods

check_aggregate(df, **kwargs)

Check for consistency of scenario data along the variable hierarchy

to_excel(excel_writer[, sheet_name, ...])

Write the variable codelist to an Excel sheet

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:
dfpyam.IamDataFrame

Scenario data to be checked for consistency along the variable hierarchy.

kwargsTolerance arguments for comparison of values

Passed to numpy.isclose via pyam.IamDataFrame.check_aggregate.

Returns:
pandas.DataFrame or None

Data where a variable and its computed aggregate does not match.

Raises:
ValueError

If the DataStructureDefinition does not have a variable dimension.

to_excel(excel_writer, sheet_name=None, sort_by_code=False, **kwargs)[source]

Write the variable codelist to an Excel sheet

Parameters:
excel_writerpath-like, file-like, or ExcelWriter object

File path as string or pathlib.Path, or existing pandas.ExcelWriter.

sheet_namestr, optional

Name of sheet that will have the codelist. If None, use the codelist name.

sort_by_codebool, optional

Sort the codelist before exporting to file.

**kwargs

Passed to pandas.ExcelWriter (if excel_writer is path-like).

validate(df, dimensions=None)[source]

Validate that the coordinates of df are defined in the codelists

Parameters:
dfpyam.IamDataFrame

Scenario data to be validated against the codelists of this instance.

dimensionslist of str, optional

Dimensions to perform validation (defaults to all dimensions of self)

Returns:
None
Raises:
ValueError

If df fails validation against any codelist.