Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def setUpClass(self):
        self.required_parameter = {}
        self.required_parameter['wind_model'] = {
            'h_hub': 'height of the hub in meters',
            'd_rotor': 'diameter of the rotor in meters',
            'wind_conv_type':
            'wind converter according to the list in the csv file.'}

        self.required_parameter['pv_model'] = {
            'azimuth': 'Azimuth angle of the pv module',
            'tilt': 'Tilt angle of the pv module',
            'module_name': 'According to the sandia module library.',
            'albedo': 'Albedo value'}

        self.height_of_measurement = {
            'dhi': 0,
            'dirhi': 0,
            'pressure': 0,
            'temp_air': 2,
            'v_wind': 10,
            'Z0': 0}

        self.site = {
            'module_name': 'Yingli_YL210__2008__E__',
            'azimuth': 180,
            'tilt': 30,
            'albedo': 0.2,
            'h_hub': 135,
            'd_rotor': 127,
            'wind_conv_type': 'ENERCON E 126 7500'}

        timezone = 'Europe/Berlin'
        n = 876
        self.weather_df = pandas.DataFrame(index=pandas.date_range(
            pandas.datetime(2010, 1, 1, 0), periods=n, freq='H',
            tz=timezone))
        self.weather_df['temp_air'] = 280.5 * numpy.ones(n)
        self.weather_df['pressure'] = 100168 * numpy.ones(n)
        self.weather_df['dirhi'] = 111 * numpy.ones(n)
        self.weather_df['dhi'] = 111 * numpy.ones(n)
        self.weather_df['v_wind'] = 4.8 * numpy.ones(n)
        self.weather_df['z0'] = 0.15 * numpy.ones(n)
        self.weather = weather.FeedinWeather(
            data=self.weather_df,
            timezone=timezone,
            latitude=52,
            longitude=12,
            data_height=self.height_of_measurement)
Ejemplo n.º 3
0
def create_single_weather(df, rename_dc):
    """Create an oemof weather object for the given geometry"""
    my_weather = weather.FeedinWeather()
    data_height = {}
    name = None
    # Create a pandas.DataFrame with the time series of the weather data set
    weather_df = pd.DataFrame(index=df.time_series.iloc[0].index)
    for row in df.iterrows():
        key = rename_dc[row[1].type]
        weather_df[key] = row[1].time_series
        data_height[key] = row[1].height if not np.isnan(row[1].height) else 0
        name = row[1].gid
    my_weather.data = weather_df
    my_weather.timezone = weather_df.index.tz
    my_weather.longitude = df.geom_point.iloc[0].x
    my_weather.latitude = df.geom_point.iloc[0].y
    my_weather.geometry = df.geom_point.iloc[0]
    my_weather.data_height = data_height
    my_weather.name = name
    return my_weather
Ejemplo n.º 4
0
def create_single_weather(df, geo, rename_dc):
    ''
    my_weather = weather.FeedinWeather()
    data_height = {}

    # Create a pandas.DataFrame with the time series of the weather data set
    weather_df = pd.DataFrame(index=df.time_series.iloc[0].index)
    for row in df.iterrows():
        key = rename_dc[row[1].type]
        weather_df[key] = row[1].time_series
        data_height[key] = row[1].height if not np.isnan(row[1].height) else 0
    my_weather.data = weather_df
    my_weather.timezone = weather_df.index.tz
    if geo.geom_type == 'Point':
        my_weather.longitude = geo.x
        my_weather.latitude = geo.y
    else:
        my_weather.longitude = geo.centroid.x
        my_weather.latitude = geo.centroid.y
    my_weather.geometry = geo
    my_weather.data_height = data_height
    my_weather.name = row[1].gid
    return my_weather
Ejemplo n.º 5
0
 def test_load_feedinlib(self):
     my_weather = weather.FeedinWeather()
     basic_path = os.path.dirname(os.path.abspath(__file__))
     filename = os.path.join(basic_path, 'test_weather.csv')
     my_weather.read_feedinlib_csv(filename=filename)
Ejemplo n.º 6
0
 def test_csv_weather_file(self):
     my_weather = weather.FeedinWeather()
     my_weather.read_feedinlib_csv(filename='')
Ejemplo n.º 7
0
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
    def __init__(self, required=['steps']):
        self.required = required

    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)
Ejemplo n.º 9
0
def ready_example_data(filename, datetime_column='Unnamed: 0'):
    df = pd.read_csv(filename)
    return df.set_index(pd.to_datetime(df[datetime_column])).tz_localize(
        'UTC').tz_convert('Europe/Berlin').drop(datetime_column, 1)


filename1 = 'weather.csv'
filename2 = 'weather_wittenberg.csv'

# Two Variants to create your weather object
# 1. Variant: Passing all data to the weather class
weather_df = ready_example_data(filename1)
my_weather_a = weather.FeedinWeather(data=weather_df,
                                     timezone='Europe/Berlin',
                                     latitude=52,
                                     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.