def main(): windgenerator = collect_energymap_data() capacity = collect_ego_turbines() power_classes = get_power_classes(capacity) selected_plants = get_plant_per_class(windgenerator, power_classes) power_class_to_db(power_classes, selected_plants) cfg = db.readcfg(config) temp = {} powerplants = {} powerplants['solar'] = plants.Photovoltaic( **{k: asnumber(v) for k, v in cfg.items('Photovoltaic')}) powerplants['wind_offshore'] = plants.WindPowerPlant( **{k: asnumber(v) for k, v in cfg.items('WindTurbineOffshore')}) print('Calculating feedins...') for coastdat_id, type_of_generation, geom in points: try: weather = coastdat.get_weather(conn, geom, weather_year) except IndexError: print('Geometry cannot be handled: %s, %s' % (geom.x, geom.y)) continue if type_of_generation == 'wind_offshore': feedin = correction_offshore * powerplants[type_of_generation].\ feedin(weather=weather, installed_capacity=1) power_class = 0 temp[(coastdat_id, type_of_generation, power_class)] = feedin.values elif type_of_generation == 'wind_onshore': power_class = 1 for index, row in selected_plants.iterrows(): plant = wind_dict(row) feedin = correction_onshore * plants.WindPowerPlant(**plant).\ feedin(weather=weather, installed_capacity=1) temp[(coastdat_id, type_of_generation, power_class)] = feedin.values power_class += 1 elif type_of_generation == 'solar': feedin = correction_solar * powerplants[type_of_generation].\ feedin(weather=weather, peak_power=1) power_class = 0 temp[(coastdat_id, type_of_generation, power_class)] = feedin.values else: continue #temp[(coastdat_id, type_of_generation)] = feedin.values df = pd.DataFrame(temp) df_to_renewable_feedin(df, weather_year, weather_scenario_id) print('Done!')
'tilt': 30, 'albedo': 0.2 } #wind turbine enerconE126 = { 'h_hub': 135, 'd_rotor': 127, 'wind_conv_type': 'ENERCON E 126 7500', 'data_height': coastDat2 } # E126_power_plant = plants.WindPowerPlant(**enerconE126) yingli_module = plants.Photovoltaic(**yingli210) wind_feedin = E126_power_plant.feedin(weather=my_weather, installed_capacity=1) pv_feedin = yingli_module.feedin(weather=my_weather, peak_power=1) #conn = db.connection() #pol = c.next() #multi_weather = coastdat.get_weather(conn, germany_u['geom'][0], year) def optimise_storage_size(filename="storage_invest.csv", solvername='cbc', debug=True, number_timesteps=8760, tee_switch=True): logging.info('Initialize the energy system')
def pv_result_test(self): pv_model = model.PvlibBased( required=list(self.required_parameter['pv_model'].keys())) pv_plant = plant.Photovoltaic(model=pv_model, **self.site) pv_feedin = pv_plant.feedin(weather=self.weather) nt.eq_(round(pv_feedin.sum() / 1000), 31.0)
def test_pv_model(self): plant.Photovoltaic(model=model.PvlibBased(required=["missing"]))
def pv_apply_feedinlib(coastDat_years, reference_data=None): # get reference data if reference_data is None: reference_data = pv_generation_reference_data() coastDat2 = { 'dhi': 0, 'dirhi': 0, 'pressure': 0, 'temp_air': 2, 'v_wind': 10, 'Z0': 0 } pv_feedin_annual = {} basic_path = os.path.join(os.path.expanduser("~"), '.oemof') # iterate over passed reference data dict for unit in list(reference_data.keys()): pv_feedin_annual[unit] = {} # update reference data with default values if values are missing if reference_data[unit]['azimuth'] is None: logging.warning('Azimuth unknown... overwrite with 0') reference_data[unit]['azimuth'] = 180 if reference_data[unit]['tilt'] is None: logging.warning('Tilt unknown... overwrite with 30') reference_data[unit]['tilt'] = 30 years = [int(y) for y in reference_data[unit]['generation']] # choose module type and add location module_type = { 'module_name': reference_data[unit]['module_name'], 'azimuth': reference_data[unit]['azimuth'], 'tilt': reference_data[unit]['tilt'], 'albedo': 0.2, 'latitude': reference_data[unit]['location']['lat'], 'longitude': reference_data[unit]['location']['lon'], 'tz': reference_data[unit]['tz'] } pv_module = plants.Photovoltaic(model=models.PvlibBased, **module_type) for year in set(years).intersection(coastDat_years): # get weather data file = 'weather_' + unit + '_' + str(year) + '.csv' filename = os.path.join(basic_path, file) if not os.path.isfile(filename): fetch_test_data_file(file, basic_path) my_weather_df = read_test_data(filename) my_weather = weather.FeedinWeather( data=my_weather_df, timezone=reference_data[unit]['tz'], latitude=reference_data[unit]['location']['lon'], longitude=reference_data[unit]['location']['lat'], data_height=coastDat2) if reference_data[unit].get('module_number') is not None: pv_feedin_annual[unit][year] = pv_module.feedin( weather=my_weather, number=reference_data[unit]['module_number']).sum() / 1e3 elif reference_data[unit].get('capacity') is not None: pv_feedin_annual[unit][year] = pv_module.feedin( weather=my_weather, peak_power=reference_data[unit]['capacity']).sum() / 1e3 else: print('at least supply `module_number` or `capacity`') return pv_feedin_annual
E126_feedin = E126_power_plant.feedin(weather=my_weather, number=2) V90_feedin = V90_power_plant.feedin(weather=my_weather, installed_capacity=(15 * 10**6)) E126_feedin.name = 'E126' V90_feedin.name = 'V90' if plt: E126_feedin.plot(legend=True) V90_feedin.plot(legend=True) plt.show() else: print(V90_feedin) # Apply the model yingli_module = plants.Photovoltaic(**yingli210) advent_module = plants.Photovoltaic(**advent210) # Apply the pv plant pv_feedin1 = yingli_module.feedin(weather=my_weather, number=30000) pv_feedin2 = yingli_module.feedin(weather=my_weather, area=15000) pv_feedin3 = yingli_module.feedin(weather=my_weather, peak_power=15000) pv_feedin4 = yingli_module.feedin(weather=my_weather) pv_feedin5 = advent_module.feedin(weather=my_weather) pv_feedin4.name = 'Yingli' pv_feedin5.name = 'Advent' # Output if plt: pv_feedin4.plot(legend=True)
installed_capacity=15 * 10**6) E126_feedin.name = 'E126' V90_feedin.name = 'V90' if plt: E126_feedin.plot(legend=True) V90_feedin.plot(legend=True) plt.show() else: print(V90_feedin) # Initialise different power plants # If you do not pass a model the default model is used. So far there is only # one model available. This might change in future versions. yingli_module = plants.Photovoltaic(**yingli210) advent_module = plants.Photovoltaic(model=models.PvlibBased, **advent210) pv_feedin1 = yingli_module.feedin(weather=my_weather, number=30000) pv_feedin2 = yingli_module.feedin(weather=my_weather, area=15000) pv_feedin3 = yingli_module.feedin(weather=my_weather, peak_power=15000) pv_feedin4 = yingli_module.feedin(weather=my_weather) pv_feedin5 = advent_module.feedin(weather=my_weather) pv_feedin4.name = 'Yingli' pv_feedin5.name = 'Advent' # Output if plt: pv_feedin4.plot(legend=True) pv_feedin5.plot(legend=True)
def get_timeseries(self, conn, **kwargs): '' weather = coastdat.get_weather(conn, kwargs['geometry'], kwargs['year']) pv_df = 0 pv_cap = {} wind_df = 0 wind_cap = {} if not isinstance(weather, list): weather = [weather] for w_cell in weather: ee_pps = pg_pp.get_energymap_pps(conn, geometry1=w_cell.geometry, geometry2=kwargs['geometry']) # Find type of wind turbine and its parameters according to the # windzone. wz = tools.get_windzone(conn, w_cell.geometry) kwargs['wind_conv_type'] = (kwargs['wka_model_dc'].get( wz, kwargs['wka_model'])) kwargs['d_rotor'] = (kwargs['d_rotor_dc'].get( wz, kwargs['d_rotor'])) kwargs['h_hub'] = (kwargs['h_hub_dc'].get(wz, kwargs['h_hub'])) # Determine the feedin time series for the weather cell # Wind energy wind_peak_power = ee_pps[ee_pps.type == 'wind_power'].cap.sum() wind_power_plant = pp.WindPowerPlant(**kwargs) wind_series = wind_power_plant.feedin( weather=w_cell, installed_capacity=wind_peak_power) wind_series.name = w_cell.name wind_cap[w_cell.name] = wind_peak_power # PV pv_peak_power = ee_pps[ee_pps.type == 'solar_power'].cap.sum() pv_plant = pp.Photovoltaic(**kwargs) pv_series = pv_plant.feedin(weather=w_cell, peak_power=pv_peak_power) pv_series.name = w_cell.name pv_cap[w_cell.name] = pv_peak_power # Combine the results to a DataFrame try: pv_df = pd.concat([pv_df, pv_series], axis=1) wind_df = pd.concat([wind_df, wind_series], axis=1) except: pv_df = pv_series.to_frame() wind_df = wind_series.to_frame() # Write capacity into a dataframe capw = pd.Series(pd.DataFrame.from_dict(wind_cap, orient='index')[0]) capw.name = 'wind_pwr' cappv = pd.Series(pd.DataFrame.from_dict(pv_cap, orient='index')[0]) cappv.name = 'pv_pwr' cap = pd.concat([capw, cappv], axis=1) return pv_df, wind_df, cap
year=year, geom=geom[0], pickle_load=load_multi_weather, filename='multiweather_pickle_{0}.p'.format(year), data_type='multi_weather') # ------------------------------ Feedin data -------------------------------- # if (energy_source == 'Wind' or energy_source == 'Wind_PV'): turbine = plants.WindPowerPlant(**enerconE126) feedin = get_data(power_plant=turbine, multi_weather=multi_weather, pickle_load=load_wind_feedin, filename='windfeedin_pickle_{0}.p'.format(year), data_type='wind_feedin') if (energy_source == 'PV' or energy_source == 'Wind_PV'): module = plants.Photovoltaic(**advent210) feedin = get_data(power_plant=module, multi_weather=multi_weather, pickle_load=load_pv_feedin, filename='pv_feedin_pickle_{0}.p'.format(year), data_type='pv_feedin') # TODO: total sum of feedins for PV + Wind (feedin: Dictionary, keys: gids) # -------------------- Calms: Calculations and Geoplots --------------------- # # Calculate calms print('Calculating calms...') # t0 = time.clock() for i in range(len(power_limit)): print(' ...with power limit: ' + str(int(power_limit[i] * 100)) + '%') # Get all calms calms_dict = create_calms_dict(power_limit[i], feedin) dict_list = []