ebm.model.database_manager module

class DatabaseManager(file_handler: FileHandler = None)[source]

Bases: object

Manages database operations.

COL_TEK = 'building_code'
COL_TEK_BUILDING_YEAR = 'building_year'
COL_TEK_START_YEAR = 'period_start_year'
COL_TEK_END_YEAR = 'period_end_year'
COL_BUILDING_CATEGORY = 'building_category'
COL_BUILDING_CONDITION = 'building_condition'
COL_AREA = 'area'
COL_ENERGY_REQUIREMENT_PURPOSE = 'purpose'
COL_ENERGY_REQUIREMENT_VALUE = 'kwh_m2'
COL_HEATING_REDUCTION = 'reduction_share'
DEFAULT_VALUE = 'default'
__init__(file_handler: FileHandler = None)[source]
get_building_code_list()[source]

Get a list of building_code.

Returns: - building_code_list (list): List of building_code.

make_building_purpose(years: YearRange | None = None) DataFrame[source]

Returns a dataframe of all combinations building_categories, teks, original_condition, purposes and optionally years.

Parameters

years : YearRange, optional

Returns

pd.DataFrame

get_building_codes() DataFrame[source]

Retrieve building_code_parameters

Returns

pd.DataFrame

Pandas Dataframe containing building_code with parameters

get_building_code_params(building_code_list: List[str] = None)[source]

Retrieve building_codeparameters for a list of building_code.

This method fetches building_codeparameters for each building_codeID in the provided list, converts the relevant data to a dictionary, and maps these values to the corresponding attributes of the TEKParameters dataclass. The resulting dataclass instances are stored in a dictionary with building_code as keys.

Parameters: - building_code_list (list of str): List of building_code.

Returns: - building_code_params (dict): Dictionary where each key is a building_codeID and each value

is a TEKParameters dataclass instance containing the parameters for that building_codeID.

get_scurve_params()[source]

Get input dataframe with S-curve parameters/assumptions.

Returns: - scurve_params (pd.DataFrame): DataFrame with S-curve parameters.

get_construction_population() DataFrame[source]

Get construction population DataFrame.

Returns: - construction_population (pd.DataFrame): Dataframe containing population numbers

year population household_size

get_new_buildings_category_share() DataFrame[source]

Get building category share by year as a DataFrame.

The number can be used in conjunction with number of households to calculate total number of buildings of category house and apartment block

Returns: - new_buildings_category_share (pd.DataFrame): Dataframe containing population numbers

“year”, “Andel nye småhus”, “Andel nye leiligheter”, “Areal nye småhus”, “Areal nye leiligheter”

get_building_category_floor_area(building_category: BuildingCategory) Series[source]

Get population and household size DataFrame from a file.

Returns: - construction_population (pd.DataFrame): Dataframe containing population numbers

“area”,”type of building”,”2010”,”2011”

get_area_parameters() DataFrame[source]

Get total area (m^2) per building category and TEK.

Parameters: - building_category (str): Optional parameter that filter the returned dataframe by building_category

Returns: - area_parameters (pd.DataFrame): Dataframe containing total area (m^2) per

building category and TEK.

get_area_start_year() Dict[BuildingCategory, Series][source]

Retrieve total floor area in the model start year for each TEK within a building category.

Returns

dict

A dictionary where: - keys are BuildingCategory objects derived from the building category string. - values are pandas.Series with the ‘tek’ column as the index and the corresponding

‘area’ column as the values.

get_behaviour_factor() DataFrame[source]
get_energy_req_original_condition() DataFrame[source]
Get dataframe with energy requirement (kWh/m^2) for floor area in original condition. The result will be

calibrated using the dataframe from DatabaseManger.get_calibrate_heating_rv

Returns

pd.DataFrame

Dataframe containing energy requirement (kWh/m^2) for floor area in original condition, per building category and purpose.

get_energy_req_reduction_per_condition() DataFrame[source]

Get dataframe with shares for reducing the energy requirement of the different building conditions. This function calls explode_unique_columns to expand building_category and TEK as necessary.

Returns

pd.DataFrame

Dataframe containing energy requirement reduction shares for the different building conditions, per building category, TEK and purpose.

get_energy_need_yearly_improvements() DataFrame[source]

Get dataframe with yearly efficiency rates for energy need improvements. This function calls explode_unique_columns to expand building_category and TEK as necessary.

The column yearly_efficiency_improvement is expected to contain the yearly reduction as a float between 0.1 and 1.0.

Returns

pd.DataFrame

Dataframe containing yearly efficiency rates (%) for energy need improvements, per building category, tek and purpose.

get_energy_need_policy_improvement() DataFrame[source]

Get dataframe with total energy need improvement in a period related to a policy. This function calls explode_unique_columns to expand building_category and TEK as necessary.

Returns

pd.DataFrame

Dataframe containing total energy need improvement (%) in a policy period, per building category, tek and purpose.

get_holiday_home_fuelwood_consumption() Series[source]
get_holiday_home_fossilfuel_consumption() Series[source]
get_holiday_home_electricity_consumption() Series[source]
get_holiday_home_by_year() DataFrame[source]
get_calibrate_heating_rv() Series[source]
get_calibrate_heating_systems() DataFrame[source]
get_area_per_person(building_category: BuildingCategory = None) Series[source]

Return area_per_person as a pd.Series

Parameters

building_category: BuildingCategory, optional

filter for building category

Returns

pd.Series

float values indexed by building_category, (year)

validate_database()[source]
get_heating_systems_shares_start_year()[source]
get_heating_system_efficiencies()[source]
get_heating_system_forecast()[source]
explode_unique_columns(df, unique_columns)[source]
explode_building_category_column(df, unique_columns)[source]
explode_building_code_column(ff, unique_columns)[source]