Beispiel #1
0
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!')
Beispiel #2
0
def wind_apply_feedinlib(coastDat_years, reference_data):
    coastDat2 = {
        'dhi': 0,
        'dirhi': 0,
        'pressure': 0,
        'temp_air': 2,
        'v_wind': 10,
        'Z0': 0
    }
    basic_path = os.path.join(os.path.expanduser("~"), '.oemof')

    # iterate over passed reference data dict
    wind_feedin_annual = {}
    for unit in list(reference_data.keys()):
        wind_feedin_annual[unit] = {}

        years = [int(y) for y in reference_data[unit]['generation']]

        wind_model = plants.WindPowerPlant(
            model=models.SimpleWindTurbine,
            **{
                'h_hub': reference_data[unit]['h_hub'],
                'd_rotor': reference_data[unit]['d_rotor'],
                'wind_conv_type': reference_data[unit]['wind_conv_type'],
                'data_height': coastDat2
            })

        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('number') is not None:
                wind_feedin_annual[unit][year] = wind_model.feedin(
                    weather=my_weather,
                    number=reference_data[unit]['number']).sum() / 1e6
            elif reference_data[unit].get('capacity') is not None:
                wind_feedin_annual[unit][year] = wind_model.feedin(
                    weather=my_weather,
                    installed_capacity=reference_data[unit]
                    ['capacity']).sum() / 1e6
            else:
                print('at least provide `number` or `capacity`')
    return wind_feedin_annual
Beispiel #3
0
    'azimuth': 180,
    '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):
Beispiel #4
0
 def wind_result_test(self):
     wind_model = model.SimpleWindTurbine(
         required=list(self.required_parameter['wind_model'].keys()))
     wind_power_plant = plant.WindPowerPlant(model=wind_model, **self.site)
     wka_feedin = wind_power_plant.feedin(weather=self.weather)
     nt.eq_(round(wka_feedin.sum() / 1000), 1523340.0)
Beispiel #5
0
 def test_wind_model(self):
     plant.WindPowerPlant(model=model.SimplewindTurbine(["missing"]))
Beispiel #6
0
}

year = 2010

conn = db.connection()
my_weather_single = coastdat.get_weather(
    conn, geopy.Point(loc_berlin['longitude'], loc_berlin['latitude']), year)

geo = geopy.Polygon([(12.2, 52.2), (12.2, 51.6), (13.2, 51.6), (13.2, 52.2)])
multi_weather = coastdat.get_weather(conn, geo, year)

my_weather = multi_weather[0]
# my_weather = my_weather_single

# Initialise different power plants
E126_power_plant = plants.WindPowerPlant(**enerconE126)
V90_power_plant = plants.WindPowerPlant(**vestasV90)

# Create a feedin series for a specific powerplant under specific weather
# conditions. One can define the number of turbines or the over all capacity.
# If no multiplier is set, the time series will be for one turbine.
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)
    def feedin(self, **kwargs):
        mydata = kwargs["weather"].data.v_wind * kwargs["steps"]
        return pd.Series(data=mydata,
                         index=kwargs['weather'].data.index,
                         name='my_feedin_wind_series')


# Writing your own model and passing it to the feedinlib is usefull for testing
# purpose. If you have a good alternative model we request you to publish it
# within the feedinlib or anywhere else, so that we can link to it.

# Loading weather data from csv-file.
my_weather = weather.FeedinWeather()
my_weather.read_feedinlib_csv(filename='weather_wittenberg.csv')


# Initialise your own model and apply it.
mymodel = MyModel(required=['steps'])
myplant = plants.WindPowerPlant(model=mymodel, steps=3)
myfeedin = myplant.feedin(weather=my_weather, number=2)

# Plot
if plot_fkt:
    myfeedin.plot()
    plt.show()
else:
    print(myfeedin)

logging.info('Done!')
Beispiel #8
0
                                     longitude=13,
                                     data_height=coastDat2)

# 2. Variant: Loading a csv-file that has the feedinlib-csv-header (see docs)
my_weather_b = weather.FeedinWeather()
my_weather_b.read_feedinlib_csv(filename=filename2)

# Loading the weather data
my_weather = my_weather_b

# Initialise different power plants
# So far there is only one model available. So you do not have to pass a model
# (s. E126). If model is passed the default model is used.
# We hope that there will be different models in future versions. You can also
# write your own model an pass it to the powerplant.
E126_power_plant = plants.WindPowerPlant(**enerconE126)
V90_power_plant = plants.WindPowerPlant(model=models.SimpleWindTurbine,
                                        **vestasV90)

# Create a feedin series for a specific powerplant under specific weather
# conditions. One can define the number of turbines or the over all capacity.
# If no multiplier is set, the time series will be for one turbine.
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)
Beispiel #9
0
    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
Beispiel #10
0
#geom = [geopy.Polygon(
#[(12.2, 52.2), (12.2, 51.6), (13.2, 51.6), (13.2, 52.2)])]

# -------------------------- Get weather objects ---------------------------- #
print(' ')
print('Collecting weather objects...')
multi_weather = get_data(conn=conn,
                         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