コード例 #1
0
def get_nutslist_for_regions(regions):
    """
    Parameters
    ----------
    regions = Geodataframe
        Geodataframe containing the geometry where NUTS-regions should be mapped to

    Returns: DataFrame
        List of nuts3 regions for all zones in the overall geometry
    -------
    """
    # Fetch NUTS3-geometries from disaggregator database
    nuts3_disaggregator = data.database_shapes()

    # Transform CRS System to match reegis geometries
    nuts_centroid = nuts3_disaggregator.centroid.to_crs(4326)
    nuts_geo = nuts3_disaggregator.to_crs(crs=4326)

    # Match NUTS3-regions with federal states
    nuts_geo = geo.spatial_join_with_buffer(nuts_centroid , regions, 'fs', limit=0)

    # Create dictionary with lists of all NUTS3-regions for each state
    mapped_nuts = pd.DataFrame(index=regions.index, columns=["nuts"])

    for zone in regions.index:
        mapped_nuts.loc[zone, "nuts"] = list(nuts_geo.loc[nuts_geo['fs'] == zone].index)

    return mapped_nuts
コード例 #2
0
def save_nuts3_to_geojson(path):
    # Apparently this doesn't work with geopandas 0.8.0 but with geopandas 0.4.1
    nuts3_gdf = data.database_shapes()

    if not os.path.isdir(path):
        os.mkdir(path)

    for i, r in nuts3_gdf.iterrows():
        gs = gpd.GeoSeries()
        gs[i] = r["geometry"]
        gs.crs = "epsg:25832"
        #gs.to_file(os.path.join(path, str(i) + '.geojson'), driver='GeoJSON')
        gs.to_file(path + '/' + str(i) + '.geojson', driver='GeoJSON')
コード例 #3
0
def get_demandregio_electricity_consumption_by_nuts3(year, region_pick=None):
    """
    Parameters
    ----------
    year : int
        Year of interest, so far only 2015 and 2016 are valid inputs
    region_pick : list
        Selected regions in NUTS-3 format, if None function will return demand for all regions

    Returns: pd.DataFrame
        Dataframe containing aggregated yearly load (households, CTS and industry) for selection
    -------
    """
    if region_pick is None:
        region_pick = data.database_shapes().index # Select all NUTS3 Regions

    fn_pattern = "elc_consumption_by_nuts3_{year}.csv".format(year=year)
    fn = os.path.join(cfg.get("paths", "disaggregator"), fn_pattern)

    if not os.path.isfile(fn):
        # Works unfortunately just for 2015, 2016 due to limited availability of householdpower
        data.cfg["base_year"] = year
        ec_hh = spatial.disagg_households_power(by='households', weight_by_income=True).sum(axis=1) * 1000
        ec_CTS_detail = spatial.disagg_CTS_industry(sector='CTS', source='power', use_nuts3code=True)
        ec_CTS = ec_CTS_detail.sum()
        ec_industry_detail = spatial.disagg_CTS_industry(sector='industry', source='power', use_nuts3code=True)
        ec_industry = ec_industry_detail.sum()

        ec_sum = pd.concat([ec_hh, ec_CTS, ec_industry], axis=1)
        ec_sum.columns = ['households', 'CTS', 'industry']
        ec_sum.to_csv(fn)
        ec_sel = ec_sum.loc[region_pick]

    else:
        ec_sum = pd.read_csv(fn)
        ec_sum.set_index('Unnamed: 0', drop=True, inplace=True)
        ec_sel = ec_sum.loc[region_pick]

    return ec_sel
コード例 #4
0
def calc_wind_pv_areas(path):
    nuts3_gdf = data.database_shapes()
    list_filenames = list()
    suitable_area = pd.DataFrame(index=nuts3_gdf.index,
                                 columns=["wind_area", "pv_area"])

    for nuts3_name in nuts3_gdf.index:
        list_filenames.append(path + '/' + nuts3_name + '.geojson')

    #list_filenames = list_filenames[0:20]

    for n in list_filenames:
        idx = n[len(path) + 1:len(path) + 6]
        area_wind = calculate_wind_area(n)
        suitable_area["wind_area"][idx] = area_wind

    for n in list_filenames:
        idx = n[len(path) + 1:len(path) + 6]
        area_pv = calculate_pv_area(n)
        suitable_area["pv_area"][idx] = area_pv

    return suitable_area
コード例 #5
0
def get_combined_heatload_for_region(year, region_pick=None):
    """
    Parameters
    ----------
    year : int
        Year of interest, so far only 2015 and 2016 are valid inputs
    region_pick : list
        Selected regions in NUTS-3 format, if None function will return demand for all regions

    Returns: pd.DataFrame
        Dataframe containing aggregated yearly low temperature heat demand (households, CTS, industry) as well
        as high temperature heat demand (ProcessHeat) for selection
    -------
    """
    if region_pick is None:
        nuts3_index = data.database_shapes().index # Select all NUTS3 Regions

    fn_pattern = "heat_consumption_by_nuts3_{year}.csv".format(year=year)
    fn = os.path.join(cfg.get("paths", "disaggregator"), fn_pattern)


    if not os.path.isfile(fn):
        tmp0 = get_household_heatload_by_NUTS3(year, nuts3_index)  # Nur bis 2016
        tmp1 = get_CTS_heatload(year, nuts3_index)  # 2015 - 2035 (projection)
        tmp2 = get_industry_heating_hotwater(year, nuts3_index)
        tmp3 = get_industry_CTS_process_heat(year, nuts3_index)

        df_heating = pd.concat([tmp0, tmp1, tmp2, tmp3], axis=1)
        df_heating.columns = ['Households', 'CTS', 'Industry', 'ProcessHeat']
        df_heating.to_csv(fn)

    else:
        df_heating = pd.read_csv(fn)
        df_heating.set_index('nuts3', drop=True, inplace=True)

    return df_heating
from disaggregator import data, config, spatial
from deflex import geometries as geo_deflex
from reegis import geometries as geo_reegis
import integrate_demandregio, Land_Availability_GLAES
import pandas as pd
import os



#data.cfg['base_year'] = 2015
nuts3_regions = data.database_shapes().index

# Fetch electricity consumption for all NUTS3-Regions
elc_consumption = integrate_demandregio.get_demandregio_electricity_consumption_by_nuts3(2015)

# Fetch heat consumption for all NUTS3-Regions
heat_consumption = integrate_demandregio.get_combined_heatload_for_region(2015)

# Load suitable PV/Wind-areas from csv
filename = os.getcwd() + '/GLAES_Eignungsflaechen_Wind_PV_own_assumptions.csv'
suitable_area = pd.read_csv(filename)
suitable_area.set_index('nuts3', drop=True, inplace=True)



# Alternatively if no precalculation is available:
# path = os.getcwd() + '/nuts3_geojson/'
# suitable_area = Land_Availability_GLAES.get_pv_wind_areas_by_nuts3(path, create_geojson=True)

# Define installable capacity per square meter in MW
p_per_qm_wind = 8 / 1e6 # 8 W/m² Fläche
コード例 #7
0
### Within this script releant energy system data for a mid-term scenario is fetched and processed

from disaggregator import data
from scenario_builder import cop_precalc, snippets, heatload_scenario_calculator
from deflex import geometries as geo_deflex
from reegis import land_availability_glaes, demand_disaggregator, entsoe, demand_heat
from scenario_builder import emobpy_processing
import pandas as pd
import os

# Set parameters and get data needed for all scenarios
nuts3_index = data.database_shapes().index
de21 = geo_deflex.deflex_regions(rmap='de21')
year = 2015
# Excel findet sich auch hier: SeaDrive/Für meine Gruppen/QUARREE 100/02_Modellierung/09_Szenarien Q100
path_to_data = '/home/dbeier/reegis/data/scenario_data/commodity_sources_costs.xls'
# Get ENTSO-E load profile from reegis
profile = entsoe.get_entsoe_load(2014).reset_index(drop=True)["DE_load_"]
norm_profile = profile.div(profile.sum())

heat_profiles_reegis = demand_heat.get_heat_profiles_by_region(de21,
                                                               2014,
                                                               name='test')

profile_lt = snippets.return_normalized_domestic_profiles(
    de21, heat_profiles_reegis)
profile_ht = snippets.return_normalized_industrial_profiles(
    de21, heat_profiles_reegis)

# Fetch costs and emission applicable for scenario (sheet1)
costs = snippets.get_cost_emission_scenario_data(path_to_data)