Skip to content

TechnologyCollection

Bases: BaseModel

Represent a collection of technologies.

Attributes:

Methods:

  • __iter__

    Return an iterator over the list of Technology objects.

  • __len__

    Return the number of technologies in this collection.

  • fit

    Fit a growth model to a specified parameter across all technologies in the collection.

  • from_json

    Load a TechnologyCollection instance from a JSON file.

  • get

    Filter technologies based on regex patterns for non-optional attributes.

  • project

    Project specified parameters for all technologies in the collection to future years.

  • to_csv

    Export the TechnologyCollection to a CSV file.

  • to_currency

    Adjust the currency of all parameters of all contained Technology objects to the target currency.

  • to_dataframe

    Convert the TechnologyCollection to a pandas DataFrame.

  • to_json

    Export the TechnologyCollection to a JSON file, together with a data schema.

technologies instance-attribute

technologies: Annotated[list[Technology], Field(description='List of Technology objects.')]

__iter__

__iter__() -> Iterator[Technology]

Return an iterator over the list of Technology objects.

Returns:

  • Iterator[Technology]

    An iterator over the Technology objects contained in the collection.

__len__

__len__() -> int

Return the number of technologies in this collection.

Returns:

  • int

    The number of Technology objects in the technologies list.

fit

fit(parameter: str, model: GrowthModel, p0: dict[str, float] | None = None) -> GrowthModel

Fit a growth model to a specified parameter across all technologies in the collection.

This method aggregates data points for the specified parameter from all technologies in the collection, adds them to the provided growth model, and fits the model using the initial parameter guesses provided in p0.

Parameters:

  • parameter (str) –

    The name of the parameter to fit the model to (e.g., "installed capacity").

  • model (GrowthModel) –

    An instance of a growth model (e.g., LinearGrowth, ExponentialGrowth) to be fitted. May already be partially initialized with some parameters and/or data points.

  • p0 (dict[str, float], default: None ) –

    Initial guess for the model parameters.

Returns:

  • GrowthModel

    The fitted growth model with optimized parameters.

Raises:

  • ValueError

    If the collection contains incompatible parameters with different units, heating values, or carriers.

from_json classmethod

from_json(file_path: Path | str) -> Self

Load a TechnologyCollection instance from a JSON file.

Parameters:

  • file_path (Path or str) –

    Path to the JSON file containing the data. Can be a pathlib.Path object or a string path.

Returns:

  • TechnologyCollection

    An instance of TechnologyCollection initialized with the data from the JSON file.

Raises:

  • TypeError

    If file_path is not a pathlib.Path or str.

get

get(name: str, region: str, year: int, case: str, detailed_technology: str) -> Self

Filter technologies based on regex patterns for non-optional attributes.

Parameters:

  • name (str) –

    Regex pattern to filter technology names.

  • region (str) –

    Regex pattern to filter region identifiers.

  • year (int) –

    Regex pattern to filter the year of the data.

  • case (str) –

    Regex pattern to filter case or scenario identifiers.

  • detailed_technology (str) –

    Regex pattern to filter detailed technology names.

Returns:

project

project(to_years: list[int], parameters: dict[str, GrowthModel | str]) -> Self

Project specified parameters for all technologies in the collection to future years.

This method uses the provided growth models to project the specified parameters for each technology in the collection to the given future years.

To keep other parameters that should not be projected, add them to the dictionary as well without a growth model. Instead, there are other options available: 'mean', 'closest' and 'NaN'. 'mean' will set the parameter to the mean of all existing values in the collection, while 'NaN' will add the parameter with NaN values as a placeholder. 'closest' will set the parameter to the value of the closest year in the original data, with a preference for past years if equidistant. (Not yet implemented.)

The method creates new Technology objects for each combination of original technology and future year, applying the appropriate growth model projections.

Parameters:

  • to_years (list[int]) –

    List of future years to which the parameters should be projected.

  • parameters (dict[str, GrowthModel | str]) –

    A dictionary mapping parameter names to their respective growth models for projection. If provided, parameter and model cannot be used. To keep other parameters without projecting, available options are 'mean', 'closest' and 'NaN'.

Returns:

  • TechnologyCollection

    A new TechnologyCollection with technologies projected to the specified future years.

Raises:

  • ValueError

    If neither parameter and model, or parameters are not or all provided.

Examples:

>>> tc.project(
...     to_years=[2030, 2040],
...     parameters={
...         "installed capacity": LinearGrowth(m=0.5, A=10),
...         "lifetime": "mean",
...         "efficiency": "NaN"
...     }
... )

to_csv

to_csv(**kwargs: Path | str | bool) -> None

Export the TechnologyCollection to a CSV file.

Parameters:

  • **kwargs (dict, default: {} ) –

    Additional keyword arguments passed to pandas.DataFrame.to_csv(). Common options include: - path_or_buf : str or pathlib.Path or file-like object, optional File path or object, if None, the result is returned as a string. Default is None. - sep : str String of length 1. Field delimiter for the output file. Default is ','. - index : bool Write row names (index). Default is True. - encoding : str String representing the encoding to use in the output file. Default is 'utf-8'.

Notes

The method converts the collection to a pandas DataFrame using self.to_dataframe() and then writes it to a CSV file using the provided kwargs.

to_currency

to_currency(target_currency: str, overwrite_country: None | str = None, source: str = 'worldbank') -> Self

Adjust the currency of all parameters of all contained Technology objects to the target currency.

The conversion includes inflation and exchange rates based on each Technology objects's region. If a different country should be used for inflation adjustment, use overwrite_country.

Parameters:

  • target_currency (str) –

    The target currency (e.g., 'EUR_2020').

  • overwrite_country (str, default: None ) –

    ISO 3166 alpha-3 country code to use for inflation adjustment instead of the object's region.

  • source (str, default: 'worldbank' ) –

    The source of the inflation data, either "worldbank"/"wb" or "international_monetary_fund"/"imf". Defaults to "worldbank". Depending on the source, different years to adjust for inflation may be available.

Returns:

  • TechnologyCollection

    A new TechnologyCollection object with all its parameters adjusted to the target currency.

to_dataframe

to_dataframe() -> DataFrame

Convert the TechnologyCollection to a pandas DataFrame.

Returns:

  • DataFrame

    A DataFrame containing the technology data.

to_json

to_json(file_path: Path, schema_path: Path | None = None, output_schema: bool = False) -> None

Export the TechnologyCollection to a JSON file, together with a data schema.

Parameters:

  • file_path (Path) –

    The path to the JSON file to be created.

  • schema_path (Path, default: None ) –

    The path to the JSON schema file to be created. By default, created with a schema suffix next to file_path.

  • output_schema (bool, default: False ) –

    If True, generates a JSON schema file describing the data structure. The schema will include field descriptions and type information.