Package API
pypsa_validation_processing
__all__ = ['Network_Processor']
module-attribute
Network_Processor
Processes a PyPSA NetworkCollection against IAMC variable definitions.
Reads variable definitions from a definitions folder, executes the corresponding statistics functions to extract values from a given PyPSA NetworkCollection, and returns the results as a pyam.IamDataFrame.
Outputs are converted to the units of common definitions, set in the
definitions variable in definitions_path via
:meth:pyam.IamDataFrame.convert_unit if convert_units is True in config.
calculate_variables_values() -> None
Calculate values for all defined variables.
Iterates over all variables in self.dsd, calls
:meth:_execute_function_for_variable for each one, and assembles
the results.
When self.aggregate_per_year is True (default), assembles a
single :class:pyam.IamDataFrame with one column per investment year
and stores it in self.dsd_with_values.
When self.aggregate_per_year is False, stores a
list[tuple[int, pyam.IamDataFrame]] in self.dsd_with_values,
one entry per investment year. Each :class:pyam.IamDataFrame
contains the full time-series for that year.
Applies aggregation based on self.aggregation_level config.
read_definitions() -> nomenclature.DataStructureDefinition
Read IAMC variable definitions from the definitions folder.
Populates dsd with a
:class:nomenclature.DataStructureDefinition built from
self.definitions_path and returns it.
Returns:
| Type | Description |
|---|---|
DataStructureDefinition
|
The loaded data structure definition. |
structure_pyam_from_pandas(df: pd.DataFrame) -> pyam.IamDataFrame
Creates a pyam.IamDataFrame from a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame with IAMC variables as columns and years as index. |
required |
Returns:
| Type | Description |
|---|---|
IamDataFrame
|
A pyam.IamDataFrame with IAMC variables as columns and years as index. |
Notes
When aggregation_level="country", region labels are country codes by
default. If map_country_codes_to_names is True in config, country
codes are mapped to full names via :data:REGION_MAPPING. For
country="all", the country column in df (populated by
:meth:_aggregate_to_country) is used as the region dimension, one row
per country. When aggregation_level="region", the location column
in df is used directly.
write_output_to_xlsx() -> Path
Write the computed IAMC data to an Excel file (or files).
- When
aggregate_per_year=True: writes a single file<self.path_dsd_with_values>/PYPSA_{model}_{scenario}_{country}.xlsx. - When
aggregate_per_year=False: creates a sub-folder<self.path_dsd_with_values>/PYPSA_timeseries_{model}_{scenario}_{country}/and writes one file per investment year namedPYPSA_{model}_{scenario}_{country}_{year}.xlsx.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written file ( |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If :meth: |