ebm.heating_system_forecast module

class HeatingSystemsForecast(shares_start_year: DataFrame, efficiencies: DataFrame, forecast: DataFrame, building_code_list: list[str], period: YearRange)[source]

Bases: object

__init__(shares_start_year: DataFrame, efficiencies: DataFrame, forecast: DataFrame, building_code_list: list[str], period: YearRange)[source]

Init HeatingSystemsForecast.

calculate_forecast() DataFrame[source]

Project heating system shares across model years.

Returns

pd.Dataframe

TEK shares for heating systems per year, along with different load shares and efficiencies.

Raises

ValueError

If sum of shares for a building_code is not equal to 1.

static new_instance(period: YearRange, database_manager: DatabaseManager = None) HeatingSystemsForecast[source]

Create a new instance of the HeatingSystemsProjection class, using the specified YearRange Period and an optional database manager.

If a database manager is not provided, a new DatabaseManager instance will be created.

Parameters

period: YearRange

period of forecast

database_manager: DatabaseManager

a database manager for heating system forecast

Returns

HeatingSystemsForecast

A new instance of HeatingSystemsProjection initialized with data from the specified database manager.

static pad_projection(hf: DataFrame, years_to_pad: YearRange) DataFrame[source]

Left pad dataframe hf with years in years_to_pad. The padding will be equal to existing first year of hf.

Parameters

hfpd.DataFrame

heating systems to pad

years_to_padYearRange

range of years to pad unto hf

Returns

pd.DataFrame

hf with left padding

add_missing_heating_systems(heating_systems_shares: DataFrame, heating_systems: HeatingSystems = None, start_year: int | None = None) DataFrame[source]

Add missing HeatingSystems per BuildingCategory and building_codewith a default TEK_share of 0.

add_load_shares_and_efficiencies(df: DataFrame, heating_systems_efficiencies: DataFrame) DataFrame[source]

Add load share and efficiency data to heating system share records by merging with efficiency reference data.

Parameters

dfpandas.DataFrame

DataFrame containing heating system shares, including columns for year and heating system type.

heating_systems_efficienciespandas.DataFrame

DataFrame containing efficiency and load share data for each heating system type.

Returns

pandas.DataFrame

Merged DataFrame with heating system shares enriched with efficiency and load share information.

Notes

  • The merge is performed on the HEATING_SYSTEMS column using a left join.

  • The YEAR column is cast to integer to ensure consistent data types.

aggregere_lik_oppvarming_fjern_0(df: DataFrame) DataFrame[source]

Aggregate heating system shares by summing TEK_share values, excluding entries with zero share.

Parameters

dfpandas.DataFrame

Input DataFrame containing heating system share data, including TEK_share values.

Returns

pandas.DataFrame

Aggregated DataFrame grouped by building category, building code, heating system, and year, with summed TEK_share values excluding zero-share entries.

Notes

  • Rows where TEK_share is zero are removed before aggregation.

  • The resulting DataFrame is grouped by [BUILDING_CATEGORY, BUILDING_CODE, HEATING_SYSTEMS, YEAR].

expand_building_category_building_code(projection: DataFrame, building_code_list: list[str]) DataFrame[source]

Add necessary building categories and building_code to the heating_systems_forecast dataframe.

project_heating_systems(shares_start_year_all_systems: DataFrame, projected_shares: DataFrame, period: YearRange) DataFrame[source]

Forecast heating system shares over a given period based on initial shares and projected replacement rates.

Parameters

shares_start_year_all_systemspandas.DataFrame

DataFrame containing TEK_share values for all heating systems at the start year.

projected_sharespandas.DataFrame

DataFrame containing projected replacement shares for heating systems across years.

periodYearRange

The projection period, defined by a start and end year.

Returns

pandas.DataFrame

A DataFrame with projected TEK_share values for both existing and new heating systems across the specified period.

Notes

  • The function melts the projected shares into long format and filters them to match the projection period.

  • It calculates new shares based on replacement rates and adjusts existing shares accordingly.

  • New and existing heating system shares are merged and aggregated, removing duplicates and zero-share entries.

  • The final output contains TEK_share values per year, building category, building code, and heating system.

  • Internal helper functions like aggregere_lik_oppvarming_fjern_0 are used to clean and aggregate data.

  • The YEAR column is explicitly cast to integer at the end to ensure consistency.

check_sum_of_shares(projected_shares: DataFrame, precision: int = 10) None[source]

Make sure that the sum of heating_system_share equals 1 per TEK, building category and year.

Parameters

projected_shares: pd.Dataframe

Dataframe must contain columns: ‘building_category’, ‘building_code’, ‘year’ and ‘heating_system_share’

precision: int

Precision used for value check (with round)

Raises

ValueError

If sum of shares for a building_codeis not equal to 1.

add_existing_heating_system_shares_to_projection(new_shares: DataFrame, existing_shares: DataFrame, period: YearRange) DataFrame[source]

Extend heating system shares in the projection period by preserving TEK_share values for systems with unprojected existing building code shares.

Parameters

new_sharespandas.DataFrame

DataFrame containing projected heating system shares for buildings.

existing_sharespandas.DataFrame

DataFrame containing existing heating system shares for buildings.

periodYearRange

The projection period, defined by a start and end year.

Returns

pandas.DataFrame

Combined DataFrame with projected shares and extended existing shares for heating systems not present in the new projections.

Notes

  • Heating systems with existing shares but missing from the new projections will retain their TEK_share values across the projection period.

  • The function filters out combinations already present in the new projections and extends the remaining ones across the projection years.

  • The Sortering column is used internally for identifying unique combinations of building category, code, and heating system.