pv_rooftop_buildings
Distribute MaStR PV rooftop capacities to OSM and synthetic buildings. Generate new PV rooftop generators for scenarios eGon2035 and eGon100RE.
See documentation section PV ground mounted for more information.
- class EgonPowerPlantPvRoofBuilding(**kwargs)[source]
Bases:
BaseClass definition of table supply.egon_power_plants_pv_roof_building.
- building_id
- bus_id
- capacity
- gens_id
- index
- orientation_primary
- orientation_primary_angle
- orientation_uniform
- scenario
- voltage_level
- weather_cell_id
- class OsmBuildingsFiltered(**kwargs)[source]
Bases:
BaseClass definition of table openstreetmap.osm_buildings_filtered.
- amenity
- area
- building
- geom
- geom_point
- id
- name
- osm_id
- tags
- class Vg250Lan(**kwargs)[source]
Bases:
BaseClass definition of table boundaries.vg250_lan.
- ade
- ags
- ags_0
- ars
- ars_0
- bem
- bez
- bsg
- debkg_id
- fk_s3
- gen
- geometry
- gf
- ibz
- id
- nbd
- nuts
- rs
- rs_0
- sdv_ars
- sdv_rs
- sn_g
- sn_k
- sn_l
- sn_r
- sn_v1
- sn_v2
- wsk
- add_ags_to_buildings(buildings_gdf: GeoDataFrame, municipalities_gdf: GeoDataFrame) GeoDataFrame[source]
Add information about AGS ID to buildings.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
municipalities_gdf (geopandas.GeoDataFrame) – GeoDataFrame with municipality data.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with AGS ID added.
- add_ags_to_gens(mastr_gdf: GeoDataFrame, municipalities_gdf: GeoDataFrame) GeoDataFrame[source]
Add information about AGS ID to generators.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame with valid and cleaned MaStR data.
municipalities_gdf (geopandas.GeoDataFrame) – GeoDataFrame with municipality data.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame with valid and cleaned MaStR data with AGS ID added.
- add_buildings_meta_data(buildings_gdf: GeoDataFrame, prob_dict: dict, seed: int) GeoDataFrame[source]
Randomly add additional metadata to desaggregated PV plants.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data with desaggregated PV plants.
prob_dict (dict) – Dictionary with values and probabilities per capacity range.
seed (int) – Seed to use for random operations with NumPy and pandas.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM building data with desaggregated PV plants.
- add_bus_ids_sq(buildings_gdf: GeoDataFrame) GeoDataFrame[source]
Add bus ids for status_quo units
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data with desaggregated PV plants.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM building data with bus_id per generator.
- add_commissioning_date(buildings_gdf: GeoDataFrame, start: Timestamp, end: Timestamp, seed: int)[source]
Randomly and linear add start-up date to new pv generators.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data with desaggregated PV plants.
start (pandas.Timestamp) – Minimum Timestamp to use.
end (pandas.Timestamp) – Maximum Timestamp to use.
seed (int) – Seed to use for random operations with NumPy and pandas.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with start-up date added.
- add_overlay_id_to_buildings(buildings_gdf: GeoDataFrame, grid_federal_state_gdf: GeoDataFrame) GeoDataFrame[source]
Add information about overlay ID to buildings.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
grid_federal_state_gdf (geopandas.GeoDataFrame) – GeoDataFrame with intersection shapes between counties and grid districts.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with overlay ID added.
- allocate_pv(q_mastr_gdf: GeoDataFrame, q_buildings_gdf: GeoDataFrame, seed: int) tuple[GeoDataFrame, GeoDataFrame][source]
Allocate the MaStR pv generators to the OSM buildings. This will determine a building for each pv generator if there are more buildings than generators within a given AGS. Primarily generators are distributed with the same qunatile as the buildings. Multiple assignment is excluded.
- Parameters:
q_mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded and qcut MaStR data.
q_buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing qcut OSM buildings data.
seed (int) – Seed to use for random operations with NumPy and pandas.
- Returns:
tuple with two geopandas.GeoDataFrame s – GeoDataFrame containing MaStR data allocated to building IDs. GeoDataFrame containing building data allocated to MaStR IDs.
- allocate_scenarios(mastr_gdf: GeoDataFrame, valid_buildings_gdf: GeoDataFrame, last_scenario_gdf: GeoDataFrame, scenario: str)[source]
Desaggregate and allocate scenario pv rooftop ramp-ups onto buildings.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
valid_buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
last_scenario_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings matched with pv generators from temporally preceding scenario.
scenario (str) – Scenario to desaggrgate and allocate.
- Returns:
tuple –
- geopandas.GeoDataFrame
GeoDataFrame containing OSM buildings matched with pv generators.
- pandas.DataFrame
DataFrame containing pv rooftop capacity per grid id.
- allocate_to_buildings(mastr_gdf: GeoDataFrame, buildings_gdf: GeoDataFrame) tuple[GeoDataFrame, GeoDataFrame][source]
Allocate status quo pv rooftop generators to buildings.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing MaStR data with geocoded locations.
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data with buildings without an AGS ID dropped.
- Returns:
tuple with two geopandas.GeoDataFrame s – GeoDataFrame containing MaStR data allocated to building IDs. GeoDataFrame containing building data allocated to MaStR IDs.
- building_area_range_per_cap_range(mastr_gdf: GeoDataFrame, cap_ranges: list[tuple[int | float, int | float]] | None = None, min_building_size: int | float = 10.0, upper_quantile: float = 0.95, lower_quantile: float = 0.05) dict[tuple[int | float, int | float], tuple[int | float, int | float]][source]
Estimate normal building area range per capacity range. Calculate the mean roof load factor per capacity range from existing PV plants.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
cap_ranges (list(tuple(int, int))) – List of capacity ranges to distinguish between. The first tuple should start with a zero and the last one should end with infinite.
min_building_size (int, float) – Minimal building size to consider for PV plants.
upper_quantile (float) – Upper quantile to estimate maximum building size per capacity range.
lower_quantile (float) – Lower quantile to estimate minimum building size per capacity range.
- Returns:
dict – Dictionary with estimated normal building area range per capacity range.
- calculate_building_load_factor(mastr_gdf: GeoDataFrame, buildings_gdf: GeoDataFrame, rounding: int = 4) GeoDataFrame[source]
Calculate the roof load factor from existing PV systems.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
rounding (int) – Rounding to use for load factor.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing geocoded MaStR data with calculated load factor.
- calculate_max_pv_cap_per_building(buildings_gdf: GeoDataFrame, mastr_gdf: GeoDataFrame, pv_cap_per_sq_m: float | int, roof_factor: float | int) GeoDataFrame[source]
Calculate the estimated maximum possible PV capacity per building.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
pv_cap_per_sq_m (float, int) – Average expected, installable PV capacity per square meter.
roof_factor (float, int) – Average for PV usable roof area share.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with estimated maximum PV capacity.
- cap_per_bus_id(scenario: str) DataFrame[source]
Get table with total pv rooftop capacity per grid district.
- Parameters:
scenario (str) – Scenario name.
- Returns:
pandas.DataFrame – DataFrame with total rooftop capacity per mv grid.
Calculate the share of PV capacity from the total PV capacity within capacity ranges.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
cap_ranges (list(tuple(int, int))) – List of capacity ranges to distinguish between. The first tuple should start with a zero and the last one should end with infinite.
- Returns:
dict – Dictionary with share of PV capacity from the total PV capacity within capacity ranges.
- clean_mastr_data(mastr_gdf: GeoDataFrame, max_realistic_pv_cap: int | float, min_realistic_pv_cap: int | float, seed: int) GeoDataFrame[source]
Clean the MaStR data from implausible data.
Drop MaStR ID duplicates.
Drop generators with implausible capacities.
- Parameters:
mastr_gdf (pandas.DataFrame) – DataFrame containing MaStR data.
max_realistic_pv_cap (int or float) – Maximum capacity, which is considered to be realistic.
min_realistic_pv_cap (int or float) – Minimum capacity, which is considered to be realistic.
seed (int) – Seed to use for random operations with NumPy and pandas.
- Returns:
pandas.DataFrame – DataFrame containing cleaned MaStR data.
- create_scenario_table(buildings_gdf)[source]
Create mapping table pv_unit <-> building for scenario
- desaggregate_pv(buildings_gdf: GeoDataFrame, cap_df: DataFrame, **kwargs) GeoDataFrame[source]
Desaggregate PV capacity on buildings within a given grid district.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
cap_df (pandas.DataFrame) – DataFrame with total rooftop capacity per mv grid.
- Other Parameters:
prob_dict (dict) – Dictionary with values and probabilities per capacity range.
cap_share_dict (dict) – Dictionary with share of PV capacity from the total PV capacity within capacity ranges.
building_area_range_dict (dict) – Dictionary with estimated normal building area range per capacity range.
load_factor_dict (dict) – Dictionary with mean roof load factor per capacity range.
seed (int) – Seed to use for random operations with NumPy and pandas.
pv_cap_per_sq_m (float, int) – Average expected, installable PV capacity per square meter.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM building data with desaggregated PV plants.
- desaggregate_pv_in_mv_grid(buildings_gdf: GeoDataFrame, pv_cap: float | int, **kwargs) GeoDataFrame[source]
Desaggregate PV capacity on buildings within a given grid district.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing buildings within the grid district.
pv_cap (float, int) – PV capacity to desaggregate.
- Other Parameters:
prob_dict (dict) – Dictionary with values and probabilities per capacity range.
cap_share_dict (dict) – Dictionary with share of PV capacity from the total PV capacity within capacity ranges.
building_area_range_dict (dict) – Dictionary with estimated normal building area range per capacity range.
load_factor_dict (dict) – Dictionary with mean roof load factor per capacity range.
seed (int) – Seed to use for random operations with NumPy and pandas.
pv_cap_per_sq_m (float, int) – Average expected, installable PV capacity per square meter.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM building data with desaggregated PV plants.
- determine_end_of_life_gens(mastr_gdf: GeoDataFrame, scenario_timestamp: Timestamp, pv_rooftop_lifetime: Timedelta) GeoDataFrame[source]
Determine if an old PV system has reached its end of life.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
scenario_timestamp (pandas.Timestamp) – Timestamp at which the scenario takes place.
pv_rooftop_lifetime (pandas.Timedelta) – Average expected lifetime of PV rooftop systems.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing geocoded MaStR data and info if the system has reached its end of life.
- drop_buildings_outside_grids(buildings_gdf: GeoDataFrame) GeoDataFrame[source]
Drop all buildings outside of grid areas.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with buildings without an bus ID dropped.
- drop_buildings_outside_muns(buildings_gdf: GeoDataFrame) GeoDataFrame[source]
Drop all buildings outside of municipalities.
- Parameters:
buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing OSM buildings data.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with buildings without an AGS ID dropped.
- drop_gens_outside_muns(mastr_gdf: GeoDataFrame) GeoDataFrame[source]
Drop all generators outside of municipalities.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame with valid and cleaned MaStR data.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame with valid and cleaned MaStR data with generatos without an AGS ID dropped.
- drop_unallocated_gens(gdf: GeoDataFrame) GeoDataFrame[source]
Drop generators which did not get allocated.
- Parameters:
gdf (geopandas.GeoDataFrame) – GeoDataFrame containing MaStR data allocated to building IDs.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing MaStR data with generators dropped which did not get allocated.
- federal_state_data(to_crs: CRS) GeoDataFrame[source]
Get feder state data from eGo^n Database.
- Parameters:
to_crs (pyproj.crs.crs.CRS) – CRS to transform geometries to.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame with federal state data.
- frame_to_numeric(df: DataFrame | GeoDataFrame) DataFrame | GeoDataFrame[source]
Try to convert all columns of a DataFrame to numeric ignoring errors.
- Parameters:
df (pandas.DataFrame or geopandas.GeoDataFrame)
- Returns:
pandas.DataFrame or geopandas.GeoDataFrame
- get_probability_for_property(mastr_gdf: GeoDataFrame, cap_range: tuple[int | float, int | float], prop: str) tuple[array, array][source]
Calculate the probability of the different options of a property of the existing PV plants.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
cap_range (tuple(int, int)) – Capacity range of PV plants to look at.
prop (str) – Property to calculate probabilities for. String needs to be in columns of mastr_gdf.
- Returns:
tuple –
- numpy.array
Unique values of property.
- numpy.array
Probabilties per unique value.
- grid_districts(epsg: int) GeoDataFrame[source]
Load mv grid district geo data from eGo^n Database as geopandas.GeoDataFrame.
- Parameters:
epsg (int) – EPSG ID to use as CRS.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing mv grid district ID and geo shapes data.
- infer_voltage_level(units_gdf: GeoDataFrame) GeoDataFrame[source]
Infer nan values in voltage level derived from generator capacity to the power plants.
- Parameters:
units_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing units with voltage levels from MaStR
Returnsunits_gdf (gpd.GeoDataFrame)
——-
geopandas.GeoDataFrame – GeoDataFrame containing units all having assigned a voltage level.
- load_building_data()[source]
Read buildings from DB Tables:
openstreetmap.osm_buildings_filtered (from OSM)
openstreetmap.osm_buildings_synthetic (synthetic, created by us)
Use column id for both as it is unique hence you concat both datasets. If INCLUDE_SYNTHETIC_BUILDINGS is False synthetic buildings will not be loaded.
- Returns:
gepandas.GeoDataFrame – GeoDataFrame containing OSM buildings data with buildings without an AGS ID dropped.
- load_mastr_data()[source]
Read PV rooftop data from MaStR CSV Note: the source will be replaced as soon as the MaStR data is available in DB.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing MaStR data with geocoded locations.
- mastr_data(index_col: str | int | list[str] | list[int]) GeoDataFrame[source]
Read MaStR data from database.
- Parameters:
index_col (str, int or list of str or int) – Column(s) to use as the row labels of the DataFrame.
- Returns:
pandas.DataFrame – DataFrame containing MaStR data.
- mean_load_factor_per_cap_range(mastr_gdf: GeoDataFrame, cap_ranges: list[tuple[int | float, int | float]] | None = None) dict[tuple[int | float, int | float], float][source]
Calculate the mean roof load factor per capacity range from existing PV plants.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
cap_ranges (list(tuple(int, int))) – List of capacity ranges to distinguish between. The first tuple should start with a zero and the last one should end with infinite.
- Returns:
dict – Dictionary with mean roof load factor per capacity range.
- municipality_data() GeoDataFrame[source]
Get municipality data from eGo^n Database. :returns: gepandas.GeoDataFrame – GeoDataFrame with municipality data.
- osm_buildings(to_crs: CRS) GeoDataFrame[source]
Read OSM buildings data from eGo^n Database.
- Parameters:
to_crs (pyproj.crs.crs.CRS) – CRS to transform geometries to.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data.
- overlay_grid_districts_with_counties(mv_grid_district_gdf: GeoDataFrame, federal_state_gdf: GeoDataFrame) GeoDataFrame[source]
Calculate the intersections of mv grid districts and counties.
- Parameters:
mv_grid_district_gdf (gpd.GeoDataFrame) – GeoDataFrame containing mv grid district ID and geo shapes data.
federal_state_gdf (gpd.GeoDataFrame) – GeoDataFrame with federal state data.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data.
- probabilities(mastr_gdf: GeoDataFrame, cap_ranges: list[tuple[int | float, int | float]] | None = None, properties: list[str] | None = None) dict[source]
Calculate the probability of the different options of properties of the existing PV plants.
- Parameters:
mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing geocoded MaStR data.
cap_ranges (list(tuple(int, int))) – List of capacity ranges to distinguish between. The first tuple should start with a zero and the last one should end with infinite.
properties (list(str)) – List of properties to calculate probabilities for. Strings need to be in columns of mastr_gdf.
- Returns:
dict – Dictionary with values and probabilities per capacity range.
- scenario_data(carrier: str = 'solar_rooftop', scenario: str = 'eGon2035') DataFrame[source]
Get scenario capacity data from eGo^n Database.
- Parameters:
carrier (str) – Carrier type to filter table by.
scenario (str) – Scenario to filter table by.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame with scenario capacity data in GW.
- sort_and_qcut_df(df: DataFrame | GeoDataFrame, col: str, q: int) DataFrame | GeoDataFrame[source]
Determine the quantile of a given attribute in a (Geo)DataFrame. Sort the (Geo)DataFrame in ascending order for the given attribute.
- Parameters:
df (pandas.DataFrame or geopandas.GeoDataFrame) – (Geo)DataFrame to sort and qcut.
col (str) – Name of the attribute to sort and qcut the (Geo)DataFrame on.
q (int) – Number of quantiles.
- Returns:
pandas.DataFrame or gepandas.GeoDataFrame – Sorted and qcut (Geo)DataFrame.
- synthetic_buildings(to_crs: CRS) GeoDataFrame[source]
Read synthetic buildings data from eGo^n Database.
- Parameters:
to_crs (pyproj.crs.crs.CRS) – CRS to transform geometries to.
- Returns:
geopandas.GeoDataFrame – GeoDataFrame containing OSM buildings data.
- validate_output(desagg_mastr_gdf: DataFrame | GeoDataFrame, desagg_buildings_gdf: DataFrame | GeoDataFrame) None[source]
Validate output.
Validate that there are exactly as many buildings with a pv system as there are pv systems with a building
Validate that the building IDs with a pv system are the same building IDs as assigned to the pv systems
Validate that the pv system IDs with a building are the same pv system IDs as assigned to the buildings
- Parameters:
desagg_mastr_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing MaStR data allocated to building IDs.
desagg_buildings_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing building data allocated to MaStR IDs.