diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index d0f85a1a..ff1a3e46 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -24,9 +24,9 @@ from _helpers import ( from add_electricity import sanitize_carriers from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystem import HeatSystem -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_sector import HeatSector +from scripts.definitions.heat_system import HeatSystem +from scripts.definitions.heat_system_type import HeatSystemType logger = logging.getLogger(__name__) cc = coco.CountryConverter() diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 7e405a42..4d57db31 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -12,7 +12,7 @@ from _helpers import set_scenario_config from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_system_type import HeatSystemType sys.path.append("..") diff --git a/scripts/enums/HeatSector.py b/scripts/enums/HeatSector.py deleted file mode 100644 index 03bcaffd..00000000 --- a/scripts/enums/HeatSector.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - - -class HeatSector(Enum): - """ - Enumeration class representing different heat sectors. - - Attributes: - RESIDENTIAL (str): Represents the residential heat sector. - SERVICES (str): Represents the services heat sector. - """ - - RESIDENTIAL = "residential" - SERVICES = "services" - - def __str__(self) -> str: - """ - Returns the string representation of the heat sector. - - Returns: - str: The string representation of the heat sector. - """ - return self.value diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py deleted file mode 100644 index 75cd3344..00000000 --- a/scripts/enums/HeatSystem.py +++ /dev/null @@ -1,263 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystemType import HeatSystemType - - -class HeatSystem(Enum): - """ - Enumeration representing different heat systems. - - Attributes - ---------- - RESIDENTIAL_RURAL : str - Heat system for residential areas in rural locations. - SERVICES_RURAL : str - Heat system for service areas in rural locations. - RESIDENTIAL_URBAN_DECENTRAL : str - Heat system for residential areas in urban decentralized locations. - SERVICES_URBAN_DECENTRAL : str - Heat system for service areas in urban decentralized locations. - URBAN_CENTRAL : str - Heat system for urban central areas. - - Methods - ------- - __str__() - Returns the string representation of the heat system. - central_or_decentral() - Returns whether the heat system is central or decentralized. - system_type() - Returns the type of the heat system. - sector() - Returns the sector of the heat system. - rural() - Returns whether the heat system is for rural areas. - urban_decentral() - Returns whether the heat system is for urban decentralized areas. - urban() - Returns whether the heat system is for urban areas. - heat_demand_weighting(urban_fraction=None, dist_fraction=None) - Calculates the heat demand weighting based on urban fraction and distribution fraction. - heat_pump_costs_name(heat_source) - Generates the name for the heat pump costs based on the heat source. - """ - - RESIDENTIAL_RURAL = "residential rural" - SERVICES_RURAL = "services rural" - RESIDENTIAL_URBAN_DECENTRAL = "residential urban decentral" - SERVICES_URBAN_DECENTRAL = "services urban decentral" - URBAN_CENTRAL = "urban central" - - def __init__(self, *args): - super().__init__(*args) - - def __str__(self) -> str: - """ - Returns the string representation of the heat system. - - Returns - ------- - str - The string representation of the heat system. - """ - return self.value - - @property - def central_or_decentral(self) -> str: - """ - Returns whether the heat system is central or decentralized. - - Returns - ------- - str - "central" if the heat system is central, "decentral" otherwise. - """ - if self == HeatSystem.URBAN_CENTRAL: - return "central" - else: - return "decentral" - - @property - def system_type(self) -> HeatSystemType: - """ - Returns the type of the heat system. - - Returns - ------- - str - The type of the heat system. - - Raises - ------ - RuntimeError - If the heat system is invalid. - """ - if self == HeatSystem.URBAN_CENTRAL: - return HeatSystemType.URBAN_CENTRAL - elif ( - self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return HeatSystemType.URBAN_DECENTRAL - elif self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: - return HeatSystemType.RURAL - else: - raise RuntimeError(f"Invalid heat system: {self}") - - @property - def sector(self) -> HeatSector: - """ - Returns the sector of the heat system. - - Returns - ------- - HeatSector - The sector of the heat system. - """ - if ( - self == HeatSystem.RESIDENTIAL_RURAL - or self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - ): - return HeatSector.RESIDENTIAL - elif ( - self == HeatSystem.SERVICES_RURAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return HeatSector.SERVICES - else: - "tot" - - @property - def is_rural(self) -> bool: - """ - Returns whether the heat system is for rural areas. - - Returns - ------- - bool - True if the heat system is for rural areas, False otherwise. - """ - if self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: - return True - else: - return False - - @property - def is_urban_decentral(self) -> bool: - """ - Returns whether the heat system is for urban decentralized areas. - - Returns - ------- - bool - True if the heat system is for urban decentralized areas, False otherwise. - """ - if ( - self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return True - else: - return False - - @property - def is_urban(self) -> bool: - """ - Returns whether the heat system is for urban areas. - - Returns - ------- - bool True if the heat system is for urban areas, False otherwise. - """ - return not self.is_rural - - def heat_demand_weighting(self, urban_fraction=None, dist_fraction=None) -> float: - """ - Calculates the heat demand weighting based on urban fraction and - distribution fraction. - - Parameters - ---------- - urban_fraction : float, optional - The fraction of urban heat demand. - dist_fraction : float, optional - The fraction of distributed heat demand. - - Returns - ------- - float - The heat demand weighting. - - Raises - ------ - RuntimeError - If the heat system is invalid. - """ - if "rural" in self.value: - return 1 - urban_fraction - elif "urban central" in self.value: - return dist_fraction - elif "urban decentral" in self.value: - return urban_fraction - dist_fraction - else: - raise RuntimeError(f"Invalid heat system: {self}") - - def heat_pump_costs_name(self, heat_source: str) -> str: - """ - Generates the name for the heat pump costs based on the heat source and - system. - - Parameters - ---------- - heat_source : str - The heat source. - - Returns - ------- - str - The name for the heat pump costs. - """ - return f"{self.central_or_decentral} {heat_source}-sourced heat pump" - - @property - def resistive_heater_costs_name(self) -> str: - """ - Generates the name for the resistive heater costs based on the heat - system. - - Returns - ------- - str - The name for the heater costs. - """ - return f"{self.central_or_decentral} resistive heater" - - @property - def gas_boiler_costs_name(self) -> str: - """ - Generates the name for the gas boiler costs based on the heat system. - - Returns - ------- - str - The name for the gas boiler costs. - """ - return f"{self.central_or_decentral} gas boiler" - - @property - def oil_boiler_costs_name(self) -> str: - """ - Generates the name for the oil boiler costs based on the heat system. - - Returns - ------- - str - The name for the oil boiler costs. - """ - return "decentral oil boiler" diff --git a/scripts/enums/HeatSystemType.py b/scripts/enums/HeatSystemType.py deleted file mode 100644 index 5bd1bee3..00000000 --- a/scripts/enums/HeatSystemType.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - - -class HeatSystemType(Enum): - """ - Enumeration representing different types of heat systems. - """ - - URBAN_CENTRAL = "urban central" - URBAN_DECENTRAL = "urban decentral" - RURAL = "rural" - - def __str__(self) -> str: - """ - Returns the string representation of the heat system type. - - Returns: - str: The string representation of the heat system type. - """ - return self.value - - @property - def is_central(self) -> bool: - """ - Returns whether the heat system type is central. - - Returns: - bool: True if the heat system type is central, False otherwise. - """ - return self == HeatSystemType.URBAN_CENTRAL diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 83b76bb9..d9d0f6e3 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -37,9 +37,9 @@ from pypsa.geo import haversine_pts from pypsa.io import import_components_from_dataframe from scipy.stats import beta -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystem import HeatSystem -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_sector import HeatSector +from scripts.definitions.heat_system import HeatSystem +from scripts.definitions.heat_system_type import HeatSystemType spatial = SimpleNamespace() logger = logging.getLogger(__name__)