-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_wind.py
More file actions
160 lines (134 loc) · 5.03 KB
/
test_wind.py
File metadata and controls
160 lines (134 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-
"""
Info
----
In this testfile the basic functionalities of the WindPower class are tested.
Run each time you make changes on an existing function.
Adjust if a new function is added or parameters in an existing function are
changed.
"""
import matplotlib.pyplot as plt
import datetime
from vpplib.environment import Environment
from vpplib.wind_power import WindPower
from windpowerlib import data as wt
data = wt.get_turbine_types(print_out=False)
# For Debugging uncomment:
# import logging
# logging.getLogger().setLevel(logging.DEBUG)
latitude = 51.200001
longitude = 6.433333
timestamp_int = 12
"""CSV - Use this method to avoid DWD API issues
timestamp_str = "2015-11-09 12:00:00"
environment = Environment(start="2015-01-01 00:00:00", end="2015-12-31 23:45:00")
environment.get_wind_data(
file="./input/wind/dwd_wind_data_2015.csv", utc=False
)
"""
"""OBSERVATION - Commented out due to wetterdienst breaking changes
Using dwd observation (weather recording) database for weather data
use_timezone_aware_time_index has to be set to True because there is a timezone shift within the queried time period. Otherwise the dataframe's time index would be non monotonic.
"""
timestamp_now = datetime.datetime.now(datetime.timezone.utc)
# Round down to the last 15 minute value
minute = (timestamp_now.minute // 15) * 15
timestamp_now = timestamp_now.replace(minute=minute, second=0, microsecond=0)
timestamp_str = (timestamp_now + datetime.timedelta(days=-2)).strftime("%Y-%m-%d %H:%M:%S")
environment = Environment(
start = (timestamp_now + datetime.timedelta(days=-5)).strftime("%Y-%m-%d %H:%M:%S"),
end = (timestamp_now + datetime.timedelta(days=-1)).strftime("%Y-%m-%d %H:%M:%S"),
use_timezone_aware_time_index = True,
surpress_output_globally = False)
environment.get_dwd_wind_data(lat=latitude, lon=longitude)
"""MOSMIX
Using dwd mosmix (weather forecast) database for weather data.
The forecast is queried for the next 10 days automatically.
force_end_time is set to True to get a resulting dataframe from the start time
to the end time even if there is no forecast data for the last hours of the time
period --> Missing data is filled with NaN values.
"""
time_now = Environment().get_time_from_dwd()
mosmix_timestamp_str = str((time_now + datetime.timedelta(days = 5)).replace(minute = 0, second = 0))
mosmix_environment = Environment(
start = time_now,
end = time_now + datetime.timedelta(hours = 240),
force_end_time = True,
use_timezone_aware_time_index = True,
surpress_output_globally = False)
mosmix_environment.get_dwd_wind_data(lat=latitude, lon=longitude)
# WindTurbine data
turbine_type = "E-126/4200"
hub_height = 135
rotor_diameter = 127
fetch_curve = "power_curve"
data_source = "oedb"
# ModelChain data
# possible wind_speed_model: 'logarithmic', 'hellman',
#'interpolation_extrapolation', 'log_interpolation_extrapolation'
wind_speed_model = "logarithmic"
density_model = "ideal_gas"
temperature_model = "linear_gradient"
power_output_model = "power_coefficient_curve" #'power_curve'
density_correction = True
obstacle_height = 0
hellman_exp = None
wind = WindPower(
unit="kW",
identifier=None,
environment=environment,
turbine_type=turbine_type,
hub_height=hub_height,
rotor_diameter=rotor_diameter,
fetch_curve=fetch_curve,
data_source=data_source,
wind_speed_model=wind_speed_model,
density_model=density_model,
temperature_model=temperature_model,
power_output_model=power_output_model,
density_correction=density_correction,
obstacle_height=obstacle_height,
hellman_exp=hellman_exp,
)
def test_prepare_time_series(wind):
wind.prepare_time_series()
print("prepare_time_series:")
print(wind.timeseries.head())
wind.timeseries.plot(figsize=(16, 9))
plt.show()
def test_value_for_timestamp(wind, timestamp):
timestepvalue = wind.value_for_timestamp(timestamp)
print("\nvalue_for_timestamp:\n", timestepvalue)
def observations_for_timestamp(wind, timestamp):
print("observations_for_timestamp:")
observation = wind.observations_for_timestamp(timestamp)
print(observation, "\n")
test_prepare_time_series(wind)
test_value_for_timestamp(wind, timestamp_int)
test_value_for_timestamp(wind, timestamp_str)
observations_for_timestamp(wind, timestamp_int)
observations_for_timestamp(wind, timestamp_str)
# MOSMIX Wind test
print("\n" + "="*60)
print("MOSMIX Wind Test")
print("="*60)
mosmix_wind = WindPower(
unit="kW",
identifier="wind_mosmix",
environment=mosmix_environment,
turbine_type=turbine_type,
hub_height=hub_height,
rotor_diameter=rotor_diameter,
fetch_curve=fetch_curve,
data_source=data_source,
wind_speed_model=wind_speed_model,
density_model=density_model,
temperature_model=temperature_model,
power_output_model=power_output_model,
density_correction=density_correction,
obstacle_height=obstacle_height,
hellman_exp=hellman_exp,
)
test_prepare_time_series(mosmix_wind)
test_value_for_timestamp(mosmix_wind, 12)
observations_for_timestamp(mosmix_wind, 12)