def insert_repowering_scenarios(): # get data mun_data = load_mun_data()[['gen_count_wind', 'gen_capacity_wind']] mun_data['gen_count_wind'] = mun_data['gen_count_wind'].astype(int) # insert no-repowering-scenario scn = { 'id': 0, 'name': 'Kein Repowering/aktuell', 'description': 'Es wird kein Repowering vorgenommen.', 'data': json.dumps(mun_data.round(decimals=1).to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn) # insert 1:1 scenario mun_data['gen_capacity_wind'] = (mun_data['gen_count_wind'] * 4.2).round(decimals=1) scn = { 'name': '1:1-Repowering', 'description': 'Standorttreues Repowering aller heute in Betrieb ' 'befindlichen Altanlagen durch eine neue Anlage, ' 'sowohl innerhalb als auch außerhalb von ' 'Vorranggebieten (VR/EG) für Windenergie.', 'data': json.dumps(mun_data.to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn)
def insert_status_quo_scenario(): # def create_wkt_element(geom): # return WKTElement(geom, srid=3035) mun_data = load_mun_data() # test RE area object repot_area_params = {'repot_area_params': 0} repot_mun_data = {'repot_mun_data': 0} mpoly_wkt = 'MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((5 5,7 5,7 7,5 7, 5 5)))' repot_areas_obj = REPotentialAreas.objects.create( area_params=json.dumps(repot_area_params), mun_data=json.dumps(repot_mun_data), geom=mpoly_wkt) # prepare scenario data mun_data.rename(columns={'pop_2017': 'pop'}, inplace=True) mun_data_cols = [ 'dem_el_energy_hh', 'dem_el_energy_ind', 'dem_el_energy_rca', 'dem_th_energy_hh', 'dem_th_energy_hh_efh', 'dem_th_energy_hh_mfh', 'dem_th_energy_rca', 'gen_capacity_bio', 'gen_capacity_combined_cycle', 'gen_capacity_hydro', 'gen_capacity_pv_ground', 'gen_capacity_pv_roof_large', 'gen_capacity_pv_roof_small', 'gen_capacity_sewage_landfill_gas', 'gen_capacity_steam_turbine', 'gen_capacity_storage', 'gen_capacity_wind', 'gen_count_bio', 'gen_count_combined_cycle', 'gen_count_hydro', 'gen_count_pv_ground', 'gen_count_pv_roof_large', 'gen_count_pv_roof_small', 'gen_count_sewage_landfill_gas', 'gen_count_steam_turbine', 'gen_count_wind', 'gen_el_energy_hydro', 'gen_el_energy_pv_ground', 'gen_el_energy_pv_roof', 'gen_el_energy_wind', 'pop' ] mun_data_filtered = mun_data[mun_data_cols].round(decimals=1) global_params = { 'resid_save_el': 0, 'crt_save_el': 0, 'battery': 0, 'dsm_resid': 0, 'emobility': 0, 'resid_save_th': 0, 'crt_save_th': 0, 'resid_pth': 0, 'crt_pth': 0, 'dist_resid': 1000, 'use_forest': False, 'use_ffh_areas': False, 'use_cult_areas': False, 'repowering_scn': 0 } region_data = mun_data_filtered.sum(axis=0).round(decimals=1).to_dict() region_data.update(global_params) scn_data = json.dumps( { 'reg_params': global_params, 'mun_data': mun_data_filtered.to_dict(orient='index') }, sort_keys=True) uuid = UUID(hashlib.md5(scn_data.encode('utf-8')).hexdigest()) scn_data_obj = ScenarioData.objects.create(data=scn_data, data_uuid=uuid) repowering_scenario = RepoweringScenario.objects.get(id=0) print('Scenario data hash UUID:', uuid) scn = Scenario.objects.create( name='Status quo', description='Dieses Szenario enthält den aktuellen Zustand ' 'der Energieversorgung und Flächennutzung in ' 'der Region.', is_user_scenario=False, data=scn_data_obj, re_potential_areas=repot_areas_obj, repowering_scenario=repowering_scenario) scn = Scenario.objects.create( name='Status quo 2', description='Dieses Szenario enthält den aktuellen Zustand ' 'der Energieversorgung und Flächennutzung in ' 'der Region.', is_user_scenario=False, data=scn_data_obj, re_potential_areas=repot_areas_obj, repowering_scenario=repowering_scenario)
def insert_repowering_scenarios(): # get data mun_data = load_mun_data()[['gen_count_wind', 'gen_capacity_wind']] mun_data['gen_count_wind'] = mun_data['gen_count_wind'].astype(int) # insert no-repowering-scenario scn = { 'id': 0, 'name': 'Kein Repowering/aktuell', 'description': 'Es wird kein Repowering vorgenommen.', 'data': json.dumps(mun_data.round(decimals=1).to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn) # insert 1:1 scenario mun_data['gen_capacity_wind'] = (mun_data['gen_count_wind'] * 4.2).round(decimals=1) scn = { 'name': '1:1-Repowering', 'description': 'Standorttreues Repowering aller heute in Betrieb ' 'befindlichen Altanlagen durch eine neue Anlage, ' 'sowohl innerhalb als auch außerhalb von ' 'Vorranggebieten (VR/EG) für Windenergie.', 'data': json.dumps(mun_data.to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn) # insert free scenario # TODO: Insert data scn = { 'id': -1, 'name': 'Freier Zubau', 'description': 'In diesem Szenario können Windenergieanlagen unter ' 'Verwendung zusätzlicher Potenzialflächen frei zugebaut ' 'werden.', #'data': json.dumps(mun_data.to_dict(orient='index'), sort_keys=True 'data': json.dumps({}) } RepoweringScenario.objects.create(**scn) # insert VR/EG scenario mun_data_vreg = load_mun_data()[[ 'gen_count_wind', 'gen_capacity_wind', 'reg_prio_area_wec_area' ]] mun_data_vreg['gen_count_wind'] = ( mun_data_vreg['reg_prio_area_wec_area'] / 20).round() mun_data_vreg['gen_capacity_wind'] = (mun_data_vreg['gen_count_wind'] * 4.2).round(decimals=1) mun_data_vreg.drop(columns=['reg_prio_area_wec_area'], inplace=True) scn = { 'id': 2, 'name': 'Volle Nutzung VR/EG', 'description': 'In allen aktuellen Vorranggebieten (VR/EG) für ' 'Windenergie wird ein Maximum an Neuanlagen ' 'installiert. Alle Anlagen außerhalb dieser ' 'Gebiete werden abgebaut.', 'data': json.dumps(mun_data_vreg.to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn)
import pandas as pd import oemof.solph as solph from stemp_abw.dataio.load_static import load_timeseries, load_mun_data TIMESERIES = load_timeseries() MUN_DATA = load_mun_data() def prepare_feedin_timeseries(mun_data, reg_params): """Calculate capacity(mun)-weighted aggregated feedin timeseries per technology for entire region Returns ------- :obj:`dict` of :obj:`list` Aggregated feedin timeseries """ # needed columns from scenario's mun data for feedin cols = ['gen_capacity_wind', 'gen_capacity_pv_ground', 'gen_capacity_pv_roof_small', 'gen_capacity_pv_roof_large', 'gen_capacity_hydro'] # mapping for RE capacity columns to RE timeseries columns # if repowering scenario present, use wind_fs time series tech_mapping = { 'gen_capacity_wind':
def insert_repowering_scenarios(): # get data mun_data = load_mun_data()[['gen_count_wind', 'gen_capacity_wind']] mun_data['gen_count_wind'] = mun_data['gen_count_wind'].astype(int) # insert no-repowering-scenario scn = { 'id': 0, 'name_de': 'Kein Repowering/aktuell', 'desc_de': 'Es wird kein Repowering vorgenommen.', 'name_en': 'No Repowering', 'desc_en': 'No repowering will be carried out.', 'data': json.dumps(mun_data.round(decimals=1).to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn) # insert 1:1 scenario mun_data['gen_capacity_wind'] = (mun_data['gen_count_wind'] * 4.2).round(decimals=1) scn = { 'name_de': '1:1-Repowering', 'desc_de': 'Standorttreues Repowering aller heute in Betrieb ' 'befindlichen Altanlagen durch eine neue Anlage, ' 'sowohl innerhalb als auch außerhalb von ' 'Vorranggebieten (VR/EG) für Windenergie.', 'name_en': '1:1 Repowering', 'desc_en': 'Local repowering of all currently active old plants ' 'by a new plant, both within and outside priority areas ' '(VR/EG) for wind energy.', 'data': json.dumps(mun_data.to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn) # insert free scenario # TODO: Insert data scn = { 'id': -1, 'name_de': 'Freier Zubau', 'desc_de': 'In diesem Szenario können Windenergieanlagen unter ' 'Verwendung zusätzlicher Potenzialflächen frei zugebaut ' 'werden.', 'name_en': 'Variable Extension', 'desc_en': 'You are free to choose your extension. Other areas can ' 'be selected in addition to the priority areas (VG/EG).', #'data': json.dumps(mun_data.to_dict(orient='index'), sort_keys=True 'data': json.dumps({}) } RepoweringScenario.objects.create(**scn) # insert VR/EG scenario mun_data_vreg = load_mun_data()[[ 'gen_count_wind', 'gen_capacity_wind', 'reg_prio_area_wec_area' ]] mun_data_vreg['gen_count_wind'] = ( mun_data_vreg['reg_prio_area_wec_area'] / 20).round() mun_data_vreg['gen_capacity_wind'] = (mun_data_vreg['gen_count_wind'] * 4.2).round(decimals=1) mun_data_vreg.drop(columns=['reg_prio_area_wec_area'], inplace=True) scn = { 'id': 2, 'name_de': 'Volle Nutzung VR/EG', 'desc_de': 'In allen aktuellen Vorranggebieten (VR/EG) für ' 'Windenergie wird ein Maximum an Neuanlagen ' 'installiert. Alle Anlagen außerhalb dieser ' 'Gebiete werden abgebaut.', 'name_en': 'Full utilization VR/EG', 'desc_en': 'A maximum number of new turbines will be installed ' 'in all current priority areas (VR/EG) for wind energy ' '(you can find them in **Areas -> Static Areas**). All ' 'turbines outside these areas will be disassembled.', 'data': json.dumps(mun_data_vreg.to_dict(orient='index'), sort_keys=True) } RepoweringScenario.objects.create(**scn)