### Install oemof.demandlib Source: https://github.com/oemof/demandlib/blob/dev/docs/readme.md Standard installation command for the package. ```default pip install oemof.demand ``` -------------------------------- ### Install development version Source: https://github.com/oemof/demandlib/blob/dev/docs/readme.md Command to install the latest in-development version from the repository. ```default pip install https://github.com/oemof/oemof-demand/archive/dev.zip ``` -------------------------------- ### Find TRY Region by Coordinates Source: https://context7.com/oemof/demandlib/llms.txt Finds the TRY region for a given longitude and latitude. Requires geopandas and shapely to be installed. Falls back to a known region number if installation fails. ```python try: # Berlin coordinates longitude = 13.405 latitude = 52.52 try_region = vdi.find_try_region(longitude, latitude) print(f"TRY region for Berlin: {try_region}") # Output: TRY region for Berlin: 4 # Munich coordinates longitude = 11.576 latitude = 48.137 try_region = vdi.find_try_region(longitude, latitude) print(f"TRY region for Munich: {try_region}") except ImportError: print("Install geopandas and shapely: pip install geopandas shapely") # Fallback: use known region number directly try_region = 4 ``` -------------------------------- ### Get Scaled Power Profiles Source: https://github.com/oemof/demandlib/blob/dev/docs/bdew.md Retrieves scaled power profiles for electrical loads. A conversion factor can be applied to adjust units (e.g., Wh to W). ```python e_slp.get_scaled_power_profiles({"h0": 3000, "g0": 5000}, conversion_factor=4) ``` -------------------------------- ### Find TRY Weather Region from Coordinates Source: https://context7.com/oemof/demandlib/llms.txt Determines the appropriate DWD test reference year (TRY) region based on geographical coordinates. This function requires the optional geopandas and shapely packages to be installed. ```python from oemof.demand import vdi # Find TRY region from coordinates (requires geopandas and shapely) ``` -------------------------------- ### Access and scale BDEW profiles Source: https://github.com/oemof/demandlib/blob/dev/docs/bdew.md Demonstrates initializing the ElecSlp class, listing available profiles, and scaling them based on energy values. ```python from oemof.demand import bdew e_slp = bdew.ElecSlp(year=2020) # get all available types print(e_slp.get_profiles().columns) # get the "h0" and "g0" profile profiles = e_slp.get_profiles("h0", "g0") # get scaled profiles scaled_profiles = e_slp.get_scaled_profiles({"h0": 3000, "g0": 5000}) # get scaled profiles with power values instead of energy values ``` -------------------------------- ### Run All Checks and Docs Builder with Tox Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Execute all project checks and the documentation builder using tox. ```bash tox ``` -------------------------------- ### Clone oemof-demand Repository Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Clone your forked repository locally to begin development. ```bash git clone git@github.com:YOURGITHUBNAME/oemof-demand.git ``` -------------------------------- ### simple_profile Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Creates an industrial step load profile based on annual demand and various time-based factors. ```APIDOC ## simple_profile ### Description Create industrial step load profile. ### Method N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **annual_demand** (float) - Total demand over the period given upon initialisation of IndustrialLoadProfile through parameter dt_index. This is actually only the annual demand, if an entire year was given. - **am** (datetime.time) - Defines the beginning of the workday. Times between am and pm, including the start and end time defined by am and pm, are assigned “day” factors from profile_factors. Other times are assigned “night” factors. Default: 7 a.m. - **pm** (datetime.time) - Defines the end of the workday. Times between am and pm, including the start and end time defined by am and pm, are assigned “day” factors from profile_factors. Other times are assigned “night” factors. Default: 11:30 p.m. - **week** (list(int)) - List of weekdays, where 1 corresponds to Monday, 2 to Tuesday, etc. Weekdays are assigned “week” factors from profile_factors. Default: [1, 2, 3, 4, 5]. - **weekend** (list(int)) - List of weekend days, where 1 corresponds to Monday, 2 to Tuesday, etc. Weekend days are assigned “weekend” factors from profile_factors. Default: [6, 7]. - **holiday** (list(int)) - List of holiday days. Holidays given upon initialisation of the IndustrialLoadProfile object are tagged with weekday 0 if holiday_is_sunday is set to False, wherefore the default for this parameter is [0]. Holidays are assigned “holiday” factors from profile_factors. Default: [0]. - **profile_factors** (dict) - Dictionary with load profile scaling factors for night and day of weekdays, weekend days and holidays. The dictionary must have the same form as the dictionary given as the default value. Default: { "week": {"day": 0.8, "night": 0.6}, "weekend": {"day": 0.9, "night": 0.7}, "holiday": {"day": 0.9, "night": 0.7}, } ### Returns - pd.Series - Series with demand per time step (unit depends on the unit the annual_demand was provided with). Index is a DatetimeIndex containing all time steps the IndustrialLoadProfile was initialised with. ``` -------------------------------- ### Import BDEW module Source: https://github.com/oemof/demandlib/blob/dev/docs/bdew.md Initial import required to access BDEW load profile functionality. ```python from oemof.demand import bdew ... ``` -------------------------------- ### Run All Test Environments in Parallel Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Utilize tox to run all configured test environments concurrently for faster feedback. ```bash tox -p auto ``` -------------------------------- ### Combine BDEW and Industrial Load Profiles Source: https://context7.com/oemof/demandlib/llms.txt Demonstrates combining BDEW electrical profiles (residential, commercial, agriculture) with industrial load profiles for comprehensive demand modeling. This allows for a mixed-use scenario simulation. ```python import datetime from datetime import time as settime import pandas as pd from oemof.demand import bdew from oemof.demand import particular_profiles as profiles # Configuration year = 2024 holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 5, 1): "Labour Day", datetime.date(2024, 10, 3): "Day of German Unity", datetime.date(2024, 12, 25): "Christmas Day", datetime.date(2024, 12, 26): "Second Christmas Day", } # Annual demands by sector (kWh) annual_demands = { "residential": 50000, # H0 profile "commercial": 120000, # G0 profile "agriculture": 30000, # L0 profile "industry": 500000, # Industrial step profile } # Generate BDEW profiles e_slp = bdew.ElecSlp(year=year, holidays=holidays) bdew_profiles = e_slp.get_scaled_power_profiles({ "h0_dyn": annual_demands["residential"], # Dynamic household profile "g0": annual_demands["commercial"], "l0": annual_demands["agriculture"], }) ``` -------------------------------- ### Generate Industrial Load Profile (Default Settings) Source: https://context7.com/oemof/demandlib/llms.txt Generates a step-function industrial load profile with default settings for day/night and weekday/weekend. The annual demand is scaled accordingly. ```python import datetime from datetime import time as settime import pandas as pd from oemof.demand import particular_profiles as profiles # Create datetime index year = 2024 dt_index = pd.date_range( datetime.datetime(year, 1, 1), datetime.datetime(year + 1, 1, 1), freq="15min", inclusive="left" ) # Define holidays holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 5, 1): "Labour Day", datetime.date(2024, 12, 25): "Christmas Day", } # Initialize industrial load profile ilp = profiles.IndustrialLoadProfile( dt_index=dt_index, holidays=holidays, holiday_is_sunday=False, # Apply separate holiday factors ) # Generate profile with default settings # Default: 7am-11:30pm day, Mon-Fri week, Sat-Sun weekend profile_default = ilp.simple_profile(annual_demand=100000) # 100 MWh print("Annual demand check:", (profile_default.sum() * 0.25).round(0), "kWh") # Output: Annual demand check: 100000.0 kWh ``` -------------------------------- ### Generate BDEW Heat Demand Profiles (HeatBuilding) Source: https://context7.com/oemof/demandlib/llms.txt Generates heat demand profiles for buildings using the BDEW sigmoid method. Requires a datetime index, temperature data, and building characteristics such as type, age class, and wind exposure. Annual heat demand and warm water inclusion can be specified. ```python import datetime import pandas as pd from oemof.demand import bdew # Create datetime index for one year (hourly resolution) year = 2024 df_index = pd.date_range( datetime.datetime(year, 1, 1, 0), periods=8784 if (year % 4 == 0) else 8760, # Account for leap year freq="h" ) # Generate synthetic temperature data (or load from file) # Temperature should be in degrees Celsius import numpy as np days = np.arange(len(df_index)) / 24 temperature = pd.Series( 10 + 10 * np.sin(2 * np.pi * (days - 80) / 365) + np.random.normal(0, 3, len(df_index)), index=df_index ) # Define holidays holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 12, 25): "Christmas Day", } # Create heat profile for single-family house # building_class: 1-11 for EFH/MFH, 0 for commercial buildings # wind_class: 0 (not windy) or 1 (windy location) efh_heat = bdew.HeatBuilding( df_index, holidays=holidays, temperature=temperature, shlp_type="EFH", # Single-family house building_class=1, # Building age class (1-11) wind_class=1, # Windy location annual_heat_demand=25000, # Annual demand in kWh ww_incl=True, # Include warm water demand name="SingleFamilyHouse", ) efh_profile = efh_heat.get_bdew_profile() print("EFH annual heat demand:", efh_profile.sum().round(0), "kWh") # Output: EFH annual heat demand: 25000.0 kWh ``` -------------------------------- ### Generate VDI 4655 load profiles Source: https://github.com/oemof/demandlib/blob/dev/docs/vdi4655.md Defines building parameters and regional climate data to calculate hourly load curves. ```python from oemof.demand import vdi # Define houses houses = [ { "name": "EFH_1", "house_type": "EFH", "N_Pers": 3, "N_WE": 1, "Q_Heiz_a": 6000, "Q_TWW_a": 1500, "W_a": 5250, "summer_temperature_limit": 15, "winter_temperature_limit": 5, } ] # Create region region = vdi.Region( 2017, climate=vdi.Climate().from_try_data(try_region=4), houses=houses, resample_rule="1h" ) # Generate load curves load_curves = region.get_load_curve_houses() ``` -------------------------------- ### get_profiles Method Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Retrieves all or selected normalized load profiles. Profiles are normalized to 1. Use `e_slp.get_profiles().columns` to see available profile types. ```APIDOC ## GET /profiles ### Description Get all or the selected profiles. The profiles are normalised to 1. ### Method GET ### Endpoint `/profiles` ### Parameters #### Query Parameters - **profile_types** (strings) - Optional - To select profiles you can pass the name of the types as strings. ### Request Example ```python from oemof.demand import bdew e_slp = bdew.ElecSlp(year=2020) print(e_slp.get_profiles().columns) # Example: Get 'h0' and 'g0' profiles selected_profiles = e_slp.get_profiles("h0", "g0") print(selected_profiles.head()) ``` ### Response #### Success Response (200) - **pandas.DataFrame** - Table with all or the selected profiles. #### Response Example ```json { "example": " h0 g0\n2020-01-01 00:00:00 0.000017 0.000016\n2020-01-01 00:15:00 0.000015 0.000015\n2020-01-01 00:30:00 0.000014 0.000015\n2020-01-01 00:45:00 0.000012 0.000014\n2020-01-01 01:00:00 0.000012 0.000013" } ``` ### Summation Example ```python print(e_slp.get_profiles("h0", "g0").sum()) # Output: # h0 1.0 # g0 1.0 # dtype: float64 ``` ``` -------------------------------- ### Commit and Push Changes Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Stage all changes, commit them with a descriptive message, and push the branch to GitHub. ```bash git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Generate Industrial Load Profile (Custom Settings) Source: https://context7.com/oemof/demandlib/llms.txt Generates an industrial load profile with custom workday hours, weekday/weekend/holiday definitions, and specific profile factors for day and night loads. This allows for detailed modeling of industrial energy consumption patterns. ```python import datetime from datetime import time as settime import pandas as pd from oemof.demand import particular_profiles as profiles # Create datetime index year = 2024 dt_index = pd.date_range( datetime.datetime(year, 1, 1), datetime.datetime(year + 1, 1, 1), freq="15min", inclusive="left" ) # Define holidays holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 5, 1): "Labour Day", datetime.date(2024, 12, 25): "Christmas Day", } # Initialize industrial load profile ilp = profiles.IndustrialLoadProfile( dt_index=dt_index, holidays=holidays, holiday_is_sunday=False, # Apply separate holiday factors ) # Generate profile with custom settings profile_custom = ilp.simple_profile( annual_demand=500000, # 500 MWh annual demand am=settime(6, 0, 0), # Workday starts at 6:00 pm=settime(22, 0, 0), # Workday ends at 22:00 week=[1, 2, 3, 4, 5], # Monday to Friday weekend=[6, 7], # Saturday and Sunday holiday=[0], # Holidays tagged as day 0 profile_factors={ "week": {"day": 1.0, "night": 0.7}, # Full load day, 70% night "weekend": {"day": 0.5, "night": 0.3}, # 50% day, 30% night "holiday": {"day": 0.2, "night": 0.1}, # Minimal holiday operation }, ) # Convert to DataFrame with proper power units industrial_demand = pd.DataFrame({ "Standard": profile_default, # Assuming profile_default is defined from previous snippet "Custom": profile_custom, }) print("Peak power (kW):", industrial_demand.max()) print("Min power (kW):", industrial_demand.min()) ``` -------------------------------- ### Run tests with coverage on Windows Source: https://github.com/oemof/demandlib/blob/dev/docs/readme.md Sets environment variables to append coverage data before running tests on Windows. ```default set PYTEST_ADDOPTS=--cov-append tox ``` -------------------------------- ### Create a New Branch for Development Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Create a new branch for your bugfix or feature development. ```bash git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Scale profiles to energy units Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Scale normalized profiles based on annual energy demand values. ```pycon >>> from oemof.demand import bdew >>> e_slp = bdew.ElecSlp(year=2020) >>> e_slp.get_scaled_profiles({"h0": 3000, "g0": 5000}).head() g0 h0 2020-01-01 00:00:00 0.080084 0.050657 2020-01-01 00:15:00 0.076466 0.045591 2020-01-01 00:30:00 0.072897 0.041125 2020-01-01 00:45:00 0.069671 0.037408 2020-01-01 01:00:00 0.067030 0.034650 ``` ```pycon >>> e_slp.get_scaled_profiles({"h0": 3000, "g0": 5000}).sum() g0 5000.0 h0 3000.0 dtype: float64 ``` -------------------------------- ### ElecSlp Class Initialization Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Initializes the ElecSlp class to generate electrical standardized load profiles based on the BDEW method. It accepts the year and optional parameters for seasons and holidays. ```APIDOC ## ElecSlp Class ### Description Generate electrical standardized load profiles based on the BDEW method. ### Parameters #### Path Parameters - **year** (integer) - Required - Year of the demand series. #### Query Parameters - **seasons** (dictionary) - Optional - Describing the time ranges for summer, winter and transition periods. The seasons dictionary will update the existing one, so only changed keys have to be defined. Make sure not to create time gaps. The “h0_dyn” will not work with changed seasons, so you have to use your own smoothing curve to create a “h0_dyn” profile. - **holidays** (dictionary or list) - Optional - The keys of the dictionary or the items of the list should be datetime objects of the days that are holidays. ### Request Example ```python from oemof.demand import bdew e_slp = bdew.ElecSlp(year=2020) ``` ``` -------------------------------- ### Scale profiles to power units Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Calculate power profiles from annual energy demand using a conversion factor. ```pycon >>> from oemof.demand import bdew >>> e_slp = bdew.ElecSlp(year=2020) >>> e_slp.get_scaled_power_profiles({"h0": 3000, "g0": 5000}).head() g0 h0 2020-01-01 00:00:00 0.320338 0.202627 2020-01-01 00:15:00 0.305866 0.182365 2020-01-01 00:30:00 0.291590 0.164500 2020-01-01 00:45:00 0.278682 0.149633 2020-01-01 01:00:00 0.268122 0.138602 >>> cf = 4 >>> spp = e_slp.get_scaled_power_profiles({"h0": 3000, "g0": 5000}, ... conversion_factor=cf) >>> spp.sum() g0 20000.0 h0 12000.0 dtype: float64 >>> spp.div(cf).sum() g0 5000.0 h0 3000.0 dtype: float64 ``` -------------------------------- ### Generate Industrial Electrical Profile Source: https://github.com/oemof/demandlib/blob/dev/docs/further_profiles.md Initializes an IndustrialLoadProfile and generates a step load profile using custom scaling factors for different time periods. ```python import datetime import oemof.demand.particular_profiles as profiles import pandas as pd holidays = { datetime.date(2018, 1, 1): "New year", } # Set up IndustrialLoadProfile ilp = profiles.IndustrialLoadProfile( dt_index=pd.date_range("01-01-2018", "01-01-2019", freq="15min"), holidays=holidays ) # Get step load profile with own scaling factors and definition of # beginning of workday ind_elec_demand = ilp.simple_profile( annual_demand=1e4, am=datetime.time(9, 0, 0), profile_factors={ "week": {"day": 1.0, "night": 0.8}, "weekend": {"day": 0.8, "night": 0.6}, "holiday": {"day": 0.2, "night": 0.2}, }, ) ``` -------------------------------- ### Create BDEW Heat Profiles for Buildings Source: https://context7.com/oemof/demandlib/llms.txt Generates hourly heat demand profiles for multi-family and commercial buildings using the BDEW standard. Requires defining building parameters, holidays, and temperature data. ```python import pandas as pd from demandlib import bdew # Assuming df_index, holidays, and temperature are defined elsewhere # Example placeholders: df_index = pd.date_range('2024-01-01', '2024-12-31', freq='h') holidays = {} temperature = pd.Series(20, index=df_index) # Create heat profile for multi-family house mfh_heat = bdew.HeatBuilding( df_index, holidays=holidays, temperature=temperature, shlp_type="MFH", # Multi-family house building_class=5, # Building age class wind_class=0, # Not windy annual_heat_demand=80000, # Annual demand in kWh name="MultiFamilyHouse", ) mfh_profile = mfh_heat.get_bdew_profile() # Create heat profile for commercial building (GHD sector) # Commercial buildings use building_class=0 ghd_heat = bdew.HeatBuilding( df_index, holidays=holidays, temperature=temperature, shlp_type="GHA", # Retail/wholesale building_class=0, # Must be 0 for non-residential wind_class=0, annual_heat_demand=140000, ww_incl=True, name="RetailBuilding", ) ghd_profile = ghd_heat.get_bdew_profile() # Combine profiles into DataFrame demand = pd.DataFrame({ "EFH": efh_profile, # Assuming efh_profile is defined elsewhere "MFH": mfh_profile, "GHD": ghd_profile, }) print("Peak heat demand (kW):", demand.max()) ``` -------------------------------- ### Generate and Aggregate Industrial Load Profiles Source: https://context7.com/oemof/demandlib/llms.txt Creates an industrial profile based on annual demand and specific time factors, then combines it with other sector profiles into a single DataFrame. ```python ilp = profiles.IndustrialLoadProfile( dt_index=e_slp.date_time_index, holidays=holidays, ) industrial_profile = ilp.simple_profile( annual_demand=annual_demands["industry"], am=settime(6, 0, 0), pm=settime(22, 0, 0), profile_factors={ "week": {"day": 1.0, "night": 0.6}, "weekend": {"day": 0.4, "night": 0.2}, "holiday": {"day": 0.1, "night": 0.1}, }, ) # Combine all profiles total_demand = pd.DataFrame({ "Residential": bdew_profiles["h0_dyn"], "Commercial": bdew_profiles["g0"], "Agriculture": bdew_profiles["l0"], "Industry": industrial_profile, }) total_demand["Total"] = total_demand.sum(axis=1) # Resample to hourly values hourly_demand = total_demand.resample("h").mean() print("Total annual demand (kWh):", (hourly_demand.sum()).round(0)) print("Peak total demand (kW):", hourly_demand["Total"].max().round(1)) print("Average demand (kW):", hourly_demand["Total"].mean().round(1)) ``` -------------------------------- ### Class: oemof.demand.vdi.regions.Region Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Initializes a region object to define boundary conditions for load profile generation. ```APIDOC ## Class: oemof.demand.vdi.regions.Region ### Description Defines region-dependent boundary conditions for load profiles based on VDI 4655. ### Parameters - **year** (int) - Required - Year of the profile. - **climate** (object) - Required - Climate data source. - **seasons** (dict) - Optional - Times of the seasons if fixed seasons are used. - **holidays** (dict or list) - Optional - Holiday definitions. - **houses** (list) - Optional - List of house definition dictionaries. - **resample_rule** (str) - Optional - Time interval to resample the profile (e.g., '1h'). - **zero_summer_heat_demand** (bool) - Optional - Set heat demand on summer days to zero. ``` -------------------------------- ### Add Holidays to Electrical Load Profiles Source: https://github.com/oemof/demandlib/blob/dev/docs/bdew.md Initializes an electrical load profile object with custom holidays. Holidays are treated as Sundays in calculations. ```python holidays = { datetime.date(2010, 1, 1): "New year", datetime.date(2010, 10, 3): "Day of German Unity", } e_slp = bdew.ElecSlp(year=2010, holidays=holidays) ``` -------------------------------- ### Generate VDI 4655 Residential Load Profiles Source: https://context7.com/oemof/demandlib/llms.txt Generates hourly heat, hot water, and electricity load curves for residential buildings based on VDI 4655 standards. Requires defining house configurations, climate data, and holidays. ```python import datetime from oemof.demand import vdi # Define holidays for the year holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 3, 29): "Good Friday", datetime.date(2024, 4, 1): "Easter Monday", datetime.date(2024, 5, 1): "Labour Day", datetime.date(2024, 5, 9): "Ascension Thursday", datetime.date(2024, 5, 20): "Whit Monday", datetime.date(2024, 10, 3): "Day of German Unity", datetime.date(2024, 12, 25): "Christmas Day", datetime.date(2024, 12, 26): "Second Christmas Day", } # Define house configurations houses = [ { "name": "House_A", "house_type": "EFH", # Single-family house "N_Pers": 4, # Number of persons (max 12 for EFH) "N_WE": 1, # Number of apartments "Q_Heiz_a": 12000, # Annual heating demand (kWh) "Q_TWW_a": 2500, # Annual hot water demand (kWh) "W_a": 4500, # Annual electricity demand (kWh) "summer_temperature_limit": 15, # Summer threshold (°C) "winter_temperature_limit": 5, # Winter threshold (°C) }, { "name": "House_B", "house_type": "MFH", # Multi-family house "N_Pers": 24, # Total persons "N_WE": 8, # Number of apartments (max 40 for MFH) "Q_Heiz_a": 48000, # Annual heating demand (kWh) "Q_TWW_a": 12000, # Annual hot water demand (kWh) "W_a": 32000, # Annual electricity demand (kWh) }, ] # Create climate object from DWD test reference year data # TRY regions: 1-15 covering different German climate zones try_region = 4 # Example: Brandenburg region climate = vdi.Climate().from_try_data(try_region=try_region) # Create region with houses region = vdi.Region( year=2024, climate=climate, holidays=holidays, houses=houses, resample_rule="1h", # Resample to hourly (default is 1-minute) zero_summer_heat_demand=True, # Optional: no heating in summer ) # Generate load curves for all houses load_curves = region.get_load_curve_houses() print("Load curve columns:", load_curves.columns.tolist()) # Output: MultiIndex with (house_name, house_type, energy_type) # Access specific house data house_a_heating = load_curves["House_A", "EFH", "Q_Heiz_TT"] house_a_hotwater = load_curves["House_A", "EFH", "Q_TWW_TT"] house_a_electricity = load_curves["House_A", "EFH", "W_TT"] print("House A annual heating:", house_a_heating.sum().round(0), "kWh") print("House A annual hot water:", house_a_hotwater.sum().round(0), "kWh") print("House A annual electricity:", house_a_electricity.sum().round(0), "kWh") # Output matches configured annual demands # Aggregate by energy type across all houses total_by_energy = load_curves.T.groupby(level=2).sum().T print("Total heating demand:", total_by_energy["Q_Heiz_TT"].sum().round(0), "kWh") ``` -------------------------------- ### Run a Subset of Tests with Tox and Pytest Source: https://github.com/oemof/demandlib/blob/dev/docs/contributing.md Execute a specific subset of tests by specifying the environment name and pytest markers. ```bash tox -e envname -- pytest -k test_myfeature ``` -------------------------------- ### Run tests with coverage on non-Windows systems Source: https://github.com/oemof/demandlib/blob/dev/docs/readme.md Runs tests with coverage data appended for non-Windows environments. ```default PYTEST_ADDOPTS=--cov-append tox ``` -------------------------------- ### Method: get_load_curve_houses Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Generates time series of energy demand values for all houses in the region. ```APIDOC ## Method: get_load_curve_houses ### Description Calculates energy demands (heating, hot water, electricity) for each house based on VDI 4655 typical day profiles. ### Response - **pandas.DataFrame** - MultiIndex DataFrame containing time series data for energy demand in kWh per time step. ``` -------------------------------- ### Generate BDEW Electrical Standard Load Profiles (ElecSlp) Source: https://context7.com/oemof/demandlib/llms.txt Generates standardized electrical load profiles for households, businesses, and agricultural operations. Profiles can be normalized, scaled by annual demand, or converted to power profiles. Requires defining holidays and the year for profile generation. ```python import datetime from oemof.demand import bdew # Define holidays (treated as Sundays for load calculation) holidays = { datetime.date(2024, 1, 1): "New year", datetime.date(2024, 12, 25): "Christmas Day", datetime.date(2024, 12, 26): "Second Christmas Day", } # Initialize electrical load profile generator for year 2024 e_slp = bdew.ElecSlp(year=2024, holidays=holidays) # Get all available profile types print("Available profiles:", list(e_slp.get_profiles().columns)) # Output: ['g0', 'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'h0', 'h0_dyn', 'l0', 'l1', 'l2'] # Get normalized profiles (sum to 1.0) profiles = e_slp.get_profiles("h0", "g0") print("Profile sum:", profiles.sum()) # Output: h0 1.0 # g0 1.0 # Scale profiles by annual demand (kWh) annual_demands = {"h0": 3500, "g0": 5000, "h0_dyn": 3500} scaled_energy = e_slp.get_scaled_profiles(annual_demands) print("Scaled energy sums (kWh):", scaled_energy.sum()) # Output: g0 5000.0 # h0 3500.0 # h0_dyn 3500.0 # Get power profiles (conversion_factor=4 converts 15-min energy to power) # 3500 kWh annual demand yields instantaneous power values in kW power_profiles = e_slp.get_scaled_power_profiles(annual_demands, conversion_factor=4) print("Power profile shape:", power_profiles.shape) # Output: (35136, 3) # 366 days * 24 hours * 4 quarters for leap year # Access datetime index print("Time range:", power_profiles.index[0], "to", power_profiles.index[-1]) # Output: 2024-01-01 00:00:00 to 2024-12-31 23:45:00 ``` -------------------------------- ### get_scaled_profiles Method Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Retrieves profiles scaled by their annual energy demand. The sum of each profile column equals the annual demand provided. ```APIDOC ## GET /scaled_profiles ### Description Get profiles scaled by their annual value. The sum of each profile column equals the annual demand provided. ### Method GET ### Endpoint `/scaled_profiles` ### Parameters #### Query Parameters - **ann_el_demand_per_sector** (dict) - Required - The annual demand in an energy unit for each type. ### Request Example ```python from oemof.demand import bdew e_slp = bdew.ElecSlp(year=2020) scaled_profiles = e_slp.get_scaled_profiles({"h0": 3000, "g0": 5000}) print(scaled_profiles.head()) ``` ### Response #### Success Response (200) - **pandas.DataFrame** - Table with scaled profiles. #### Response Example ```json { "example": " g0 h0\n2020-01-01 00:00:00 0.080084 0.050657\n2020-01-01 00:15:00 0.076466 0.045591\n2020-01-01 00:30:00 0.072897 0.041125\n2020-01-01 00:45:00 0.069671 0.037408\n2020-01-01 01:00:00 0.067030 0.034650" } ``` ### Summation Example ```python print(e_slp.get_scaled_profiles({"h0": 3000, "g0": 5000}).sum()) # Output: # g0 5000.0 # h0 3000.0 # dtype: float64 ``` ``` -------------------------------- ### Read Custom DWD Weather File Source: https://context7.com/oemof/demandlib/llms.txt Parses DWD test reference year weather data files for use with the VDI 4655 module. Ensure the file path is correct and the file is in the expected format. ```python from oemof.demand.vdi import dwd_try # Read custom DWD weather file (2016 format from https://kunden.dwd.de/obt/) weather_file_path = "/path/to/TRY2015_01_Jahr.dat" weather_data = dwd_try.read_dwd_weather_file(weather_file_path) print("Weather data columns:", weather_data.columns.tolist()) # Output: ['TAMB', 'CCOVER'] (Temperature and cloud coverage) print("Temperature range:", weather_data["TAMB"].min(), "to", weather_data["TAMB"].max(), "°C") print("Data points:", len(weather_data)) # Output: Data points: 8760 (hourly values for one year) ``` -------------------------------- ### Retrieve and inspect load profiles Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Access available load profile types and retrieve normalized data for specific profiles. ```pycon >>> from oemof.demand import bdew >>> e_slp = bdew.ElecSlp(year=2020) >>> ", ".join(sorted(e_slp.get_profiles().columns)) 'g0, g1, g2, g3, g4, g5, g6, h0, h0_dyn, l0, l1, l2' >>> e_slp.get_profiles("h0", "g0").head() h0 g0 2020-01-01 00:00:00 0.000017 0.000016 2020-01-01 00:15:00 0.000015 0.000015 2020-01-01 00:30:00 0.000014 0.000015 2020-01-01 00:45:00 0.000012 0.000014 2020-01-01 01:00:00 0.000012 0.000013 ``` ```pycon >>> e_slp.get_profiles("h0", "g0").sum() h0 1.0 g0 1.0 dtype: float64 ``` -------------------------------- ### get_scaled_power_profiles Method Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Retrieves profiles scaled by their annual energy demand. Each value represents the average power of an interval. A conversion factor is used to convert energy units to power units. ```APIDOC ## GET /scaled_power_profiles ### Description Get profiles scaled by their annual value. Each value represents the average power of an interval. A conversion factor is used to calculate power units from energy units. ### Method GET ### Endpoint `/scaled_power_profiles` ### Parameters #### Query Parameters - **ann_el_demand_per_sector** (dict) - Required - The annual demand in an energy unit for each type. - **conversion_factor** (float) - Optional - Factor to convert the energy unit of the annual value to the power unit of each interval. Defaults to 4. ### Request Example ```python from oemof.demand import bdew e_slp = bdew.ElecSlp(year=2020) scaled_profiles = e_slp.get_scaled_power_profiles({"h0": 3000, "g0": 5000}) print(scaled_profiles.head()) ``` ### Response #### Success Response (200) - **pandas.DataFrame** - Table with scaled profiles. #### Response Example ```json { "example": " g0 h0\n2020-01-01 00:00:00 0.320338 0.202627\n2020-01-01 00:15:00 0.305866 0.182365\n2020-01-01 00:30:00 0.291590 0.164500\n2020-01-01 00:45:00 0.278682 0.149633\n2020-01-01 01:00:00 0.268122 0.138602" } ``` ### Summation Example ```python cf = 4 spp = e_slp.get_scaled_power_profiles({"h0": 3000, "g0": 5000}, conversion_factor=cf) print(spp.sum()) # Output: # g0 20000.0 # h0 12000.0 # dtype: float64 # To get back to annual energy values: print(spp.div(cf).sum()) # Output: # g0 5000.0 # h0 3000.0 # dtype: float64 ``` ``` -------------------------------- ### VDI 4655 Regions Module Source: https://github.com/oemof/demandlib/blob/dev/docs/reference/index.md Implements the calculation of load profiles for heat and power demand of houses within a region, based on the German VDI 4655 standard. ```APIDOC ## VDI 4655 Regions Module ### Description The region module combines profiles from VDI 4655 for heat and power demand of houses within one region. This is an implementation of the calculation of load profiles defined in the German VDI 4655. ### Method N/A (This is a module description, not a specific endpoint) ### Endpoint N/A ### Notes This script creates full year energy demand time series of domestic buildings for use in simulations. This is achieved by an implementation of the VDI 4655, which gives sample energy demands for a number of typical days (‘Typtage’). The energy demand contains heating, hot water and electricity. For a given year, the typical days can be matched to the actual calendar days, based on the following conditions: Season, Day, Cloud coverage, and House type. ### Class: Climate #### Description Climate object for VDI time series. #### Parameters - **temperature** (iterable of numbers) - The ambient temperature in the area as daily mean values. The number of values must equal 365 or 366 for a leap year. Use the TRY data if no temperature data is available. - **cloud_coverage** (iterable of numbers) - The cloud coverage in the area as daily mean values. The number of values must equal 365 or 366 for a leap year. - **energy_factors** (any) - Not described in detail. #### Methods - **check_attributes()**: No description provided. - **from_try_data(try_region, hoy=8760)**: Creates a Climate object from TRY data. `hoy` defaults to 8760. ```