Exemplo n.º 1
0
def get_data(conn=None,
             power_plant=None,
             multi_weather=None,
             year=None,
             geom=None,
             pickle_load=True,
             filename='pickle_dump.p',
             data_type='multi_weather'):
    if not pickle_load:
        if data_type == 'multi_weather':
            data = coastdat.get_weather(conn, geom, year)
        if data_type == 'wind_feedin':
            data = {}
            for i in range(len(multi_weather)):
                data[multi_weather[i].name] = power_plant.feedin(
                    weather=multi_weather[i], installed_capacity=1)
        if data_type == 'pv_feedin':
            data = {}
            for i in range(len(multi_weather)):
                data[multi_weather[i].name] = power_plant.feedin(
                    weather=multi_weather[i], peak_power=1)
        pickle.dump(data, open(filename, 'wb'))
    if pickle_load:
        data = pickle.load(open(filename, 'rb'))
    return data
Exemplo n.º 2
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!')
Exemplo n.º 3
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!')
Exemplo n.º 4
0
def fetch_coastdat2_year_from_db(years=None, overwrite=False):
    """Fetch coastDat2 weather data sets from db and store it to hdf5 files.
    This files relies on the RLI-database structure and a valid access to the
    internal database of the Reiner Lemoine Institut. Contact the author for
    more information or use the hdf5 files of the reegis weather repository:
    https://github.com/...

    [email protected]

    Parameters
    ----------
    overwrite : boolean
        Skip existing files if set to False.
    years : list of integer
        Years to fetch.
    """
    weather = os.path.join(cfg.get('paths', 'weather'),
                           cfg.get('weather', 'file_pattern'))
    geometry = os.path.join(cfg.get('paths', 'geometry'),
                            cfg.get('geometry', 'germany_polygon'))

    polygon = wkt.loads(
        pd.read_csv(geometry, index_col='gid', squeeze=True)[0])

    if years is None:
        years = range(1980, 2020)

    try:
        conn = db.connection()
    except exc.OperationalError:
        conn = None
    for year in years:
        if not os.path.isfile(weather.format(year=str(year))) or overwrite:
            logging.info("Fetching weather data for {0}.".format(year))

            try:
                weather_sets = coastdat.get_weather(conn, polygon, year)
            except AttributeError:
                logging.warning("No database connection found.")
                weather_sets = list()
            if len(weather_sets) > 0:
                logging.info("Success. Store weather data to {0}.".format(
                    weather.format(year=str(year))))
                store = pd.HDFStore(weather.format(year=str(year)), mode='w')
                for weather_set in weather_sets:
                    logging.debug(weather_set.name)
                    store['A' + str(weather_set.name)] = weather_set.data
                store.close()
            else:
                logging.warning("No weather data found for {0}.".format(year))
        else:
            logging.info("Weather data for {0} exists. Skipping.".format(year))
Exemplo n.º 5
0
enerconE126 = {
    'h_hub': 135,
    'd_rotor': 127,
    'wind_conv_type': 'ENERCON E 126 7500',
    'data_height': coastDat2}

vestasV90 = {
    'h_hub': 105,
    'd_rotor': 90,
    'wind_conv_type': 'VESTAS V 90 3000',
    'data_height': coastDat2}

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)
Exemplo n.º 6
0
# import oemof base classes to create energy system objects
import logging
import os
import pandas as pd
import matplotlib.pyplot as plt
import oemof.solph as solph
from oemof import db
from oemof.db import coastdat
from shapely import geometry as geopy
from feedinlib import powerplants as plants

year = 2014

conn = db.connection()
my_weather = coastdat.get_weather(conn, geopy.Point(8.043, 52.279),
                                  year)  # Location Osnabrück

#weather data

coastDat2 = {
    'dhi': 0,
    'dirhi': 0,
    'pressure': 0,
    'temp_air': 2,
    'v_wind': 100,
    'Z0': 0
}

#pv module

yingli210 = {
germany = fetch_geometries(**germany)
germany['geom'] = geoplot.postgis2shapely(germany.geom)
#print(germany)
#print(germany['geom'])
#geom = geopy.Polygon([(12.2, 52.2), (12.2, 51.6), (13.2, 51.6), (13.2, 52.2)])

c = fiona.open('C:/temp/germany_and_offshore.shp')
pol = c.next()
#print(pol['geometry'])
geom = shape(pol['geometry'])
#print(geom)


#use pickle to save or load the weather objects
#multi_weather = pickle.load(open('multi_weather_save.p', 'rb'))
multi_weather = coastdat.get_weather(conn, geom, year)
my_weather = multi_weather[0]

#pickle.dump(multi_weather, open('multi_weather_save.p', 'wb'))

##########-------feedinlib Components--------------------------################

# Specific tion of the weather data set CoastDat2
coastDat2 = {
    'dhi': 0,
    'dirhi': 0,
    'pressure': 0,
    'temp_air': 2,
    'v_wind': 10,
    'Z0': 0}
Exemplo n.º 8
0
    'd_rotor': 127,
    'wind_conv_type': 'ENERCON E 126 7500',
    'data_height': coastDat2
}

vestasV90 = {
    'h_hub': 105,
    'd_rotor': 90,
    'wind_conv_type': 'VESTAS V 90 3000',
    'data_height': coastDat2
}

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)
# import oemof base classes to create energy system objects
import logging
import os
import pandas as pd
import matplotlib.pyplot as plt
import oemof.solph as solph
from oemof import db
from oemof.db import coastdat
from shapely import geometry as geopy
from feedinlib import powerplants as plants

year = 2014

conn = db.connection()
my_weather = coastdat.get_weather(
conn, geopy.Point(8.043, 52.279), year)

coastDat2 = {
       'dhi': 0,
       'dirhi': 0,
       'pressure': 0,
       'temp_air': 2,
       'v_wind': 100,
       'Z0': 0}

yingli210 = {
       'module_name': 'Yingli_YL210__2008__E__',
       'azimuth': 180,
       'tilt': 30,
       'albedo': 0.2}
enerconE126 = {
    'h_hub': 135,
    'd_rotor': 127,
    'wind_conv_type': 'ENERCON E 126 7500',
    'data_height': coastDat2}

# Specification of the pv module
advent210 = {
    'module_name': 'Advent_Solar_Ventura_210___2008_',
    'azimuth': 180,
    'tilt': 30,
    'albedo': 0.2}

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

# Location control
print(location['latitude'])
print(location['longitude'])

# Definition of the power plants
E126_power_plant = plants.WindPowerPlant(**enerconE126)
advent_module = plants.Photovoltaic(**advent210)
wind_feedin = E126_power_plant.feedin(weather=my_weather,
installed_capacity=1)
pv_feedin = advent_module.feedin(weather=my_weather, peak_power=1)