This notebook shows some of the features of windng:
Loading wind data files into pandas DataFrame.
Monthly means.
Selection of a reference period.
Long term analysis.
Speed and direction distribution.
Turbulence intensity calculations.
Nicely plotting all that stuff.
First of all, let's set up a pylab environment an import windng modules.
%pylab inline
import windng.io as wio
import windng.plot.windplot as wplot
import windng.weibull as weibull
import windng.wind as wind
Populating the interactive namespace from numpy and matplotlib
The file 'sample_data_80m.txt' contains some wind data. Let's see how it looks like.
with open('sample_data_80m.txt') as f:
for i in range(10):
print f.readline(),
date time speed gust dir std_dir std_speed 100730 1710 4.24 4.78 11.2 5.20 0.59 100730 1720 4.02 5.46 20.8 10.35 0.59 100730 1730 4.25 6.34 19.7 9.43 0.72 100730 1740 4.74 5.28 36.7 3.90 0.23 100730 1750 4.09 4.82 32.3 5.11 0.37 100730 1800 3.80 4.69 27.0 5.54 0.31 100730 1810 3.92 4.59 25.4 4.92 0.22 100730 1820 3.83 4.32 28.1 5.44 0.26 100730 1830 4.28 4.82 35.4 2.11 0.25
The function read_wind()
reads the data file into a pandas DataFrame. The frequency '10T' means "every ten minutes".
df = wio.read_wind('sample_data_80m.txt', freq='10T', index_name=None)
read_wind()
returns a DataFrame
instance. You can use the methods head()
and tail()
to get the first and the last few data rows and describe()
to compute some statistics.
df.head()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
2010-07-30 17:10:00 | 4.24 | 4.78 | 11.2 | 5.20 | 0.59 |
2010-07-30 17:20:00 | 4.02 | 5.46 | 20.8 | 10.35 | 0.59 |
2010-07-30 17:30:00 | 4.25 | 6.34 | 19.7 | 9.43 | 0.72 |
2010-07-30 17:40:00 | 4.74 | 5.28 | 36.7 | 3.90 | 0.23 |
2010-07-30 17:50:00 | 4.09 | 4.82 | 32.3 | 5.11 | 0.37 |
df.tail()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
2011-08-31 23:10:00 | 9.53 | 13.18 | 213.2 | 7.88 | 1.56 |
2011-08-31 23:20:00 | 8.50 | 12.54 | 202.1 | 10.88 | 1.41 |
2011-08-31 23:30:00 | 7.85 | 11.90 | 189.9 | 9.05 | 1.30 |
2011-08-31 23:40:00 | 10.33 | 14.69 | 189.3 | 9.10 | 1.35 |
2011-08-31 23:50:00 | 9.79 | 13.78 | 185.2 | 7.34 | 1.19 |
df.describe()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
count | 53941.000000 | 53941.000000 | 53941.000000 | 53941.000000 | 53941.000000 |
mean | 6.551699 | 8.297167 | 177.365952 | 7.938613 | 0.657215 |
std | 3.167691 | 3.974822 | 119.245305 | 7.504295 | 0.453564 |
min | 0.000000 | 0.330000 | 0.000000 | 0.020000 | 0.030000 |
25% | 4.270000 | 5.460000 | 40.700000 | 3.860000 | 0.310000 |
50% | 6.120000 | 7.720000 | 177.500000 | 6.220000 | 0.560000 |
75% | 8.400000 | 10.430000 | 299.500000 | 9.400000 | 0.900000 |
max | 21.360000 | 31.500000 | 360.000000 | 99.400000 | 5.090000 |
Plotting raw data is straightforward thanks to pandas plotting capabilities. We'll plot speed and gust during the first days of aug-2011 as an example.
df['1-aug-2010':'10-aug-2010'][['speed', 'gust']].plot(figsize=(14, 4))
plt.grid(True, which='both')
The function monthly_means()
returns a DataFrame with mean, actual number of observations, number of possible observations and recovery rate for each month.
monthly = wind.monthly_means(df['speed'])
monthly
mean | count | possible | rec_rate | |
---|---|---|---|---|
2010-07 | 5.342842 | 183 | 4464 | 0.040995 |
2010-08 | 6.101917 | 4433 | 4464 | 0.993056 |
2010-09 | 5.199063 | 4290 | 4320 | 0.993056 |
2010-10 | 7.068592 | 4446 | 4464 | 0.995968 |
2010-11 | 7.084802 | 4242 | 4320 | 0.981944 |
2010-12 | 8.061710 | 4438 | 4464 | 0.994176 |
2011-01 | 6.082673 | 4422 | 4464 | 0.990591 |
2011-02 | 7.810676 | 4007 | 4032 | 0.993800 |
2011-03 | 6.970415 | 4457 | 4464 | 0.998432 |
2011-04 | 6.909014 | 4301 | 4320 | 0.995602 |
2011-05 | 5.153267 | 3805 | 4464 | 0.852375 |
2011-06 | 5.999156 | 2037 | 4320 | 0.471528 |
2011-07 | 6.809452 | 4453 | 4464 | 0.997536 |
2011-08 | 5.576329 | 4427 | 4464 | 0.991711 |
monthly.describe()
mean | count | possible | rec_rate | |
---|---|---|---|---|
count | 14.000000 | 14.000000 | 14.00000 | 14.000000 |
mean | 6.440708 | 3852.928571 | 4392.00000 | 0.877912 |
std | 0.942134 | 1232.386582 | 123.09846 | 0.279118 |
min | 5.153267 | 183.000000 | 4032.00000 | 0.040995 |
25% | 5.682036 | 4065.750000 | 4320.00000 | 0.984106 |
50% | 6.455685 | 4361.500000 | 4464.00000 | 0.993056 |
75% | 7.044048 | 4436.750000 | 4464.00000 | 0.995245 |
max | 8.061710 | 4457.000000 | 4464.00000 | 0.998432 |
The same can be achieved with other frequencies using downsample()
, which accept a frequency parameter.
wind.downsample(df['speed'], freq='M')
mean | count | possible | rec_rate | |
---|---|---|---|---|
2010-07 | 5.342842 | 183 | 4464 | 0.040995 |
2010-08 | 6.101917 | 4433 | 4464 | 0.993056 |
2010-09 | 5.199063 | 4290 | 4320 | 0.993056 |
2010-10 | 7.068592 | 4446 | 4464 | 0.995968 |
2010-11 | 7.084802 | 4242 | 4320 | 0.981944 |
2010-12 | 8.061710 | 4438 | 4464 | 0.994176 |
2011-01 | 6.082673 | 4422 | 4464 | 0.990591 |
2011-02 | 7.810676 | 4007 | 4032 | 0.993800 |
2011-03 | 6.970415 | 4457 | 4464 | 0.998432 |
2011-04 | 6.909014 | 4301 | 4320 | 0.995602 |
2011-05 | 5.153267 | 3805 | 4464 | 0.852375 |
2011-06 | 5.999156 | 2037 | 4320 | 0.471528 |
2011-07 | 6.809452 | 4453 | 4464 | 0.997536 |
2011-08 | 5.576329 | 4427 | 4464 | 0.991711 |
wind.downsample(df['speed'], freq='D').head()
mean | count | possible | rec_rate | |
---|---|---|---|---|
2010-07-30 | 5.142564 | 39 | 144 | 0.270833 |
2010-07-31 | 5.397083 | 144 | 144 | 1.000000 |
2010-08-01 | 5.657622 | 143 | 144 | 0.993056 |
2010-08-02 | 7.265874 | 143 | 144 | 0.993056 |
2010-08-03 | 7.816667 | 144 | 144 | 1.000000 |
Use plot_means()
to get a graphical representation of means and recovery rates.
wplot.plot_means(monthly, style='-o')
(<matplotlib.axes._subplots.AxesSubplot at 0x7074650>, <Container object of 14 artists>)
plt.figure(figsize=(14, 4))
wplot.plot_means(wind.downsample(df['speed'], freq='W'), title='Weekly means')
(<matplotlib.axes._subplots.AxesSubplot at 0x6b09d90>, <Container object of 58 artists>)
Use the function reference_periods()
to get a DataFrame whith a summary of the available reference periods. It can take monthly means (as returned by monthly_means()
) and a number of years as arguments and returns first and last month (as pandas Period instances), mean speed, number of observations and recovery rate for each possible reference period lasting the specified number of years.
periods = wind.reference_periods(monthly, years=1)
periods
start | end | mean | count | rec_rate | |
---|---|---|---|---|---|
0 | 2010-07 | 2011-06 | 6.622053 | 45061 | 0.857325 |
1 | 2010-08 | 2011-07 | 6.643714 | 49331 | 0.938565 |
2 | 2010-09 | 2011-08 | 6.596608 | 49325 | 0.938451 |
The resulting DataFrame may help you to select the best reference period. We will choose the second one (indexed with 1) for this example. Now we can slice the original DataFrame in order to get another DataFrame containing data in the selected reference period.
rp_index = 1
start = periods['start'][rp_index].start_time
end = periods['end'][rp_index].end_time
rp_df = df[start:end]
Let's take a glance of it using head()
, tail()
and describe()
like before.
rp_df.head()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
2010-08-01 00:00:00 | 2.49 | 2.85 | 326.2 | 3.35 | 0.13 |
2010-08-01 00:10:00 | 2.83 | 3.17 | 324.5 | 3.95 | 0.19 |
2010-08-01 00:20:00 | 2.53 | 3.12 | 322.3 | 7.55 | 0.29 |
2010-08-01 00:30:00 | 2.40 | 2.71 | 327.8 | 8.30 | 0.14 |
2010-08-01 00:40:00 | 1.92 | 2.53 | 338.9 | 12.26 | 0.31 |
rp_df.tail()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
2011-07-31 23:10:00 | 4.43 | 4.92 | 19.4 | 3.17 | 0.16 |
2011-07-31 23:20:00 | 4.74 | 5.23 | 24.9 | 2.42 | 0.18 |
2011-07-31 23:30:00 | 4.52 | 5.46 | 28.1 | 3.24 | 0.31 |
2011-07-31 23:40:00 | 4.46 | 5.56 | 31.9 | 4.33 | 0.42 |
2011-07-31 23:50:00 | 4.71 | 5.61 | 33.7 | 3.07 | 0.36 |
rp_df.describe()
speed | gust | dir | std_dir | std_speed | |
---|---|---|---|---|---|
count | 49331.000000 | 49331.000000 | 49331.000000 | 49331.000000 | 49331.000000 |
mean | 6.643714 | 8.403035 | 176.255304 | 7.805873 | 0.661742 |
std | 3.215960 | 4.042820 | 119.525750 | 7.279381 | 0.456595 |
min | 0.000000 | 0.330000 | 0.000000 | 0.020000 | 0.030000 |
25% | 4.310000 | 5.460000 | 38.900000 | 3.860000 | 0.310000 |
50% | 6.200000 | 7.810000 | 177.000000 | 6.170000 | 0.560000 |
75% | 8.550000 | 10.560000 | 299.150000 | 9.260000 | 0.910000 |
max | 21.360000 | 31.500000 | 360.000000 | 99.400000 | 5.090000 |
You can also slice the monthly means the same way.
rp_monthly = monthly[start:end]
rp_monthly
mean | count | possible | rec_rate | |
---|---|---|---|---|
2010-08 | 6.101917 | 4433 | 4464 | 0.993056 |
2010-09 | 5.199063 | 4290 | 4320 | 0.993056 |
2010-10 | 7.068592 | 4446 | 4464 | 0.995968 |
2010-11 | 7.084802 | 4242 | 4320 | 0.981944 |
2010-12 | 8.061710 | 4438 | 4464 | 0.994176 |
2011-01 | 6.082673 | 4422 | 4464 | 0.990591 |
2011-02 | 7.810676 | 4007 | 4032 | 0.993800 |
2011-03 | 6.970415 | 4457 | 4464 | 0.998432 |
2011-04 | 6.909014 | 4301 | 4320 | 0.995602 |
2011-05 | 5.153267 | 3805 | 4464 | 0.852375 |
2011-06 | 5.999156 | 2037 | 4320 | 0.471528 |
2011-07 | 6.809452 | 4453 | 4464 | 0.997536 |
wplot.plot_means(monthly, style='-o')
wplot.plot_means(rp_monthly['mean'], style='-o', lw=2)
<matplotlib.axes._subplots.AxesSubplot at 0x6a7bbd0>
The file 'sample_lt_data.txt' contains more than 20 years of hourly wind data which can be correlated with the mast data in order to get an estimation of the long term speed.
with open('sample_lt_data.txt') as f:
for i in range(10):
print f.readline(),
YYYYMMDD HHMM M(m/s) D(deg) T(C) PRE(hPa) 19920101 0100 5.5 26 5.9 922.2 19920101 0200 5.2 30 5.5 922.0 19920101 0300 4.3 26 4.8 922.0 19920101 0400 3.5 34 4.9 921.9 19920101 0500 2.6 50 5.1 921.8 19920101 0600 1.2 110 5.3 921.7 19920101 0700 1.4 153 4.5 921.6 19920101 0800 2.9 128 4.4 921.8 19920101 0900 3.4 129 4.4 921.9
lt_df = wio.read_wind('sample_lt_data.txt', freq='H', index_name=None)
lt_df.head()
M(m/s) | D(deg) | T(C) | PRE(hPa) | |
---|---|---|---|---|
1992-01-01 01:00:00 | 5.5 | 26 | 5.9 | 922.2 |
1992-01-01 02:00:00 | 5.2 | 30 | 5.5 | 922.0 |
1992-01-01 03:00:00 | 4.3 | 26 | 4.8 | 922.0 |
1992-01-01 04:00:00 | 3.5 | 34 | 4.9 | 921.9 |
1992-01-01 05:00:00 | 2.6 | 50 | 5.1 | 921.8 |
lt_df.tail()
M(m/s) | D(deg) | T(C) | PRE(hPa) | |
---|---|---|---|---|
2012-08-16 20:00:00 | 1.6 | 163 | 20.8 | 909.5 |
2012-08-16 21:00:00 | 1.1 | 206 | 21.8 | 909.5 |
2012-08-16 22:00:00 | 1.7 | 221 | 22.7 | 909.4 |
2012-08-16 23:00:00 | 2.3 | 216 | 23.2 | 909.4 |
2012-08-17 00:00:00 | 3.0 | 211 | 23.4 | 909.3 |
lt_df.describe()
M(m/s) | D(deg) | T(C) | PRE(hPa) | |
---|---|---|---|---|
count | 180816.000000 | 180816.000000 | 180816.000000 | 180816.000000 |
mean | 6.255725 | 197.681704 | 11.515355 | 910.242471 |
std | 3.055461 | 121.312632 | 6.866746 | 5.917669 |
min | 0.000000 | 0.000000 | -9.900000 | 879.000000 |
25% | 4.000000 | 128.000000 | 6.100000 | 907.300000 |
50% | 6.000000 | 185.000000 | 10.700000 | 910.800000 |
75% | 8.200000 | 327.000000 | 16.600000 | 913.800000 |
max | 21.000000 | 360.000000 | 32.400000 | 928.700000 |
Monthly mean speed will be used to correlate both series.
lt_monthly = wind.monthly_means(lt_df['M(m/s)'])
lt_monthly.head()
mean | count | possible | rec_rate | |
---|---|---|---|---|
1992-01 | 6.375639 | 743 | 744 | 0.998656 |
1992-02 | 4.769971 | 696 | 696 | 1.000000 |
1992-03 | 7.211425 | 744 | 744 | 1.000000 |
1992-04 | 7.284583 | 720 | 720 | 1.000000 |
1992-05 | 6.177285 | 744 | 744 | 1.000000 |
lt_monthly.tail()
mean | count | possible | rec_rate | |
---|---|---|---|---|
2012-04 | 6.978611 | 720 | 720 | 1.000000 |
2012-05 | 6.053091 | 744 | 744 | 1.000000 |
2012-06 | 5.731806 | 720 | 720 | 1.000000 |
2012-07 | 6.362903 | 744 | 744 | 1.000000 |
2012-08 | 5.534545 | 385 | 744 | 0.517473 |
lt_monthly.describe()
mean | count | possible | rec_rate | |
---|---|---|---|---|
count | 248.000000 | 248.000000 | 248.000000 | 248.000000 |
mean | 6.255722 | 729.096774 | 730.548387 | 0.998049 |
std | 0.855525 | 29.339261 | 19.502042 | 0.030640 |
min | 4.577778 | 385.000000 | 672.000000 | 0.517473 |
25% | 5.636324 | 720.000000 | 720.000000 | 1.000000 |
50% | 6.171939 | 744.000000 | 744.000000 | 1.000000 |
75% | 6.745104 | 744.000000 | 744.000000 | 1.000000 |
max | 8.579301 | 744.000000 | 744.000000 | 1.000000 |
The function lt_analysis()
takes two series of monthly data as arguments and performs an MCP analysis.
model = wind.lt_analysis(monthly, lt_monthly)
print model.summary_as_series()
model.used_data
Slope 0.895115 Intercept 0.992711 R-squared 0.894360 Long term speed 6.592152 Number of points 11.000000 dtype: float64
mast | lt_source | |
---|---|---|
2010-08 | 6.101917 | 5.747581 |
2010-09 | 5.199063 | 4.577778 |
2010-10 | 7.068592 | 6.247312 |
2010-11 | 7.084802 | 7.029583 |
2010-12 | 8.061710 | 7.512769 |
2011-01 | 6.082673 | 5.577823 |
2011-02 | 7.810676 | 7.346577 |
2011-03 | 6.970415 | 6.916532 |
2011-04 | 6.909014 | 6.705556 |
2011-07 | 6.809452 | 7.018683 |
2011-08 | 5.576329 | 5.427957 |
Always look at a graphical representation of the data when doing statistical analysis.
model.used_data.reindex(monthly.index).plot(style='-o')
plt.grid(True, which='both')
wplot.plot_regression_scatter(model.used_data['lt_source'], model.used_data['mast'], model.slope, model.intercept)
([<matplotlib.lines.Line2D at 0xc86f310>], [<matplotlib.lines.Line2D at 0xc86f290>])
Once you have an estimation of the long term speed at your mast you may want to adjust your data so the mean speed in the reference period becomes equal to the estimated long term speed.
df['speed'] *= (model.lt_speed / rp_df['speed'].mean())
assert abs(rp_df['speed'].mean() - model.lt_speed) < 1e-7
Use speed_hist()
to get an histogram of the wind speed. The keyword argument dataframe=True
instructs the function to return the histogram as a pandas DataFrame.
speed_dist = wind.speed_hist(rp_df['speed'], dataframe=True)
speed_dist
start | end | freq | |
---|---|---|---|
0 | 0 | 1 | 0.007602 |
1 | 1 | 2 | 0.036792 |
2 | 2 | 3 | 0.069145 |
3 | 3 | 4 | 0.101640 |
4 | 4 | 5 | 0.135087 |
5 | 5 | 6 | 0.128236 |
6 | 6 | 7 | 0.123229 |
7 | 7 | 8 | 0.104093 |
8 | 8 | 9 | 0.086477 |
9 | 9 | 10 | 0.063854 |
10 | 10 | 11 | 0.045813 |
11 | 11 | 12 | 0.034380 |
12 | 12 | 13 | 0.023069 |
13 | 13 | 14 | 0.015345 |
14 | 14 | 15 | 0.009973 |
15 | 15 | 16 | 0.006892 |
16 | 16 | 17 | 0.004115 |
17 | 17 | 18 | 0.002372 |
18 | 18 | 19 | 0.001216 |
19 | 19 | 20 | 0.000527 |
20 | 20 | 21 | 0.000122 |
21 | 21 | 22 | 0.000020 |
The function weibull_fit()
fits data to a weibull distribution and returns shape and scale parameters as a tuple. By default a maximum likelyhood estimator is calculated.
shape, scale = weibull.weibull_fit(rp_df['speed'])
print 'Weibull fit'
print 'Shape = {}'.format(shape)
print 'Scale = {}'.format(scale)
Weibull fit Shape = 2.18510430953 Scale = 7.45238978873
Use plot_speed_hist()
to plot the histogram and optionally the fitted weibull PDF.
wplot.plot_speed_hist(speed_dist, weibull=(shape, scale))
(<Container object of 22 artists>, [<matplotlib.lines.Line2D at 0x5e5be90>])
In order to compute frequency roses you can use the function freq_rose()
.
freq_rose = wind.freq_rose(rp_df['dir'], dataframe=True)
freq_rose
center | start | end | freq | |
---|---|---|---|---|
0 | 0.0 | -11.25 | 11.25 | 0.171941 |
1 | 22.5 | 11.25 | 33.75 | 0.140034 |
2 | 45.0 | 33.75 | 56.25 | 0.048773 |
3 | 67.5 | 56.25 | 78.75 | 0.010784 |
4 | 90.0 | 78.75 | 101.25 | 0.006872 |
5 | 112.5 | 101.25 | 123.75 | 0.007298 |
6 | 135.0 | 123.75 | 146.25 | 0.023819 |
7 | 157.5 | 146.25 | 168.75 | 0.088687 |
8 | 180.0 | 168.75 | 191.25 | 0.204800 |
9 | 202.5 | 191.25 | 213.75 | 0.054976 |
10 | 225.0 | 213.75 | 236.25 | 0.025562 |
11 | 247.5 | 236.25 | 258.75 | 0.021163 |
12 | 270.0 | 258.75 | 281.25 | 0.016197 |
13 | 292.5 | 281.25 | 303.75 | 0.016095 |
14 | 315.0 | 303.75 | 326.25 | 0.050962 |
15 | 337.5 | 326.25 | 348.75 | 0.112039 |
Then you can plot it using bar_rose()
.
wplot.bar_rose(freq_rose['freq'])
plt.title('Frequency rose')
<matplotlib.text.Text at 0xb1afd90>
A similar function exists for power roses.
power_rose = wind.power_rose(rp_df['speed'], rp_df['dir'], dataframe=True)
power_rose
center | start | end | freq | |
---|---|---|---|---|
0 | 0.0 | -11.25 | 11.25 | 0.176089 |
1 | 22.5 | 11.25 | 33.75 | 0.119497 |
2 | 45.0 | 33.75 | 56.25 | 0.036832 |
3 | 67.5 | 56.25 | 78.75 | 0.002205 |
4 | 90.0 | 78.75 | 101.25 | 0.000682 |
5 | 112.5 | 101.25 | 123.75 | 0.001491 |
6 | 135.0 | 123.75 | 146.25 | 0.019002 |
7 | 157.5 | 146.25 | 168.75 | 0.083895 |
8 | 180.0 | 168.75 | 191.25 | 0.175227 |
9 | 202.5 | 191.25 | 213.75 | 0.071326 |
10 | 225.0 | 213.75 | 236.25 | 0.054737 |
11 | 247.5 | 236.25 | 258.75 | 0.019169 |
12 | 270.0 | 258.75 | 281.25 | 0.010601 |
13 | 292.5 | 281.25 | 303.75 | 0.013196 |
14 | 315.0 | 303.75 | 326.25 | 0.062023 |
15 | 337.5 | 326.25 | 348.75 | 0.154028 |
wplot.bar_rose(power_rose['freq'], color='r')
plt.title('Power rose')
<matplotlib.text.Text at 0xb1b0a90>
The function turbulence()
computes absolute frequency and mean, characteristic and representative turbulence intensity (as in the second and third edition, respectively, of IEC-61400-1.)
ti = wind.turbulence(rp_df['speed'], rp_df['std_speed'])
ti
count | mean_TI | char_TI | repr_TI | |
---|---|---|---|---|
speed | ||||
1 | 1062 | 0.271276 | 0.426593 | 0.470082 |
2 | 2587 | 0.197683 | 0.323649 | 0.358919 |
3 | 4084 | 0.146558 | 0.239552 | 0.265590 |
4 | 6024 | 0.117118 | 0.190954 | 0.211628 |
5 | 6767 | 0.107197 | 0.172010 | 0.190158 |
6 | 6221 | 0.099376 | 0.155574 | 0.171310 |
7 | 5497 | 0.092198 | 0.143585 | 0.157973 |
8 | 4736 | 0.089182 | 0.137318 | 0.150797 |
9 | 3752 | 0.087227 | 0.134973 | 0.148342 |
10 | 2688 | 0.087795 | 0.133696 | 0.146549 |
11 | 1944 | 0.088695 | 0.133003 | 0.145409 |
12 | 1329 | 0.091335 | 0.135090 | 0.147341 |
13 | 1000 | 0.094208 | 0.140988 | 0.154087 |
14 | 607 | 0.098216 | 0.141612 | 0.153763 |
15 | 405 | 0.105537 | 0.145492 | 0.156679 |
16 | 277 | 0.110616 | 0.149268 | 0.160090 |
17 | 147 | 0.117894 | 0.152726 | 0.162479 |
18 | 86 | 0.117219 | 0.153937 | 0.164218 |
19 | 37 | 0.112046 | 0.156395 | 0.168813 |
20 | 14 | 0.114572 | 0.145258 | 0.153850 |
21 | 3 | 0.124861 | 0.158888 | 0.168416 |
22 | 0 | NaN | NaN | NaN |
Use plot_char_ti()
and plot_char_ti()
to plot characteristic and representative turbulence intensity against the turbulence intensity categories defined in the standard.
wplot.plot_char_ti(ti, lw=2)
([<matplotlib.lines.Line2D at 0x65ae090>], <Container object of 20 artists>)
wplot.plot_repr_ti(ti, lw=2)
([<matplotlib.lines.Line2D at 0x68f0f50>], <Container object of 20 artists>)
Now that you have a representative reference period you can save it for use with other software. For example you can export to openWind csv format.
kwargs = dict()
kwargs['mm'] = 1
kwargs['lon'] = 0
kwargs['lat'] = 40
kwargs['hubheight'] = 80
kwargs['shortname'] = 'Sample mast'
kwargs['longname'] = 'Sample mast 80 m'
kwargs['speedcol'] = 'speed'
kwargs['dircol'] = 'dir'
rp_df['TI'] = 100 * rp_df['std_speed'] / rp_df['speed']
rp_df['Temperature'] = 12
rp_df['Density'] = 1.225
wio.write_openwind(rp_df, 'sample_data_80m_LT_ow.csv', **kwargs)
with open('sample_data_80m_LT_ow.csv') as f:
for i in range(10):
print f.readline(),
MM,1 0,40,80 2,Sample mast,Sample mast 80 m Year,Month,Day,Hour,Minute,WS,DIR,Temp,Density,TI[%] 2010,08,01,00,00,2.47067511031,326.2,12,1.225,5.26171974039 2010,08,01,00,10,2.80803637035,324.5,12,1.225,6.7662941266 2010,08,01,00,20,2.51036467031,322.3,12,1.225,11.5521064899 2010,08,01,00,30,2.3813736003,327.8,12,1.225,5.8789599407 2010,08,01,00,40,1.90509888024,338.9,12,1.225,16.2721212644 2010,08,01,00,50,1.79595259023,295.2,12,1.225,14.4769968548
Or you can compute a frequency table and then create a WAsP .tab file. We'll use 12 sectors here instead of the default 16 for better display.
ftable = wind.freq_table(rp_df['speed'], rp_df['dir'], nsectors=12, dataframe=True)
from IPython.core.display import HTML
display(HTML(ftable.to_html()))
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0.000487 | 0.000608 | 0.000628 | 0.000547 | 0.000628 | 0.000912 | 0.000811 | 0.000932 | 0.000689 | 0.000426 | 0.000446 | 0.000487 |
1 | 0.003669 | 0.004034 | 0.003953 | 0.002737 | 0.003000 | 0.004075 | 0.004987 | 0.002412 | 0.001601 | 0.001703 | 0.002189 | 0.002433 |
2 | 0.010399 | 0.011251 | 0.005007 | 0.002554 | 0.002433 | 0.007784 | 0.013420 | 0.005189 | 0.001946 | 0.002595 | 0.002250 | 0.004318 |
3 | 0.021346 | 0.016460 | 0.004318 | 0.001480 | 0.001520 | 0.008210 | 0.025663 | 0.005980 | 0.002737 | 0.002473 | 0.003811 | 0.007642 |
4 | 0.033103 | 0.019440 | 0.002757 | 0.000689 | 0.000912 | 0.009588 | 0.038961 | 0.006852 | 0.003770 | 0.002270 | 0.003892 | 0.012852 |
5 | 0.031846 | 0.018143 | 0.001662 | 0.000385 | 0.001115 | 0.008595 | 0.036204 | 0.005514 | 0.004176 | 0.002757 | 0.003162 | 0.014676 |
6 | 0.029860 | 0.017271 | 0.001176 | 0.000324 | 0.001095 | 0.008291 | 0.035252 | 0.004642 | 0.003629 | 0.002514 | 0.003061 | 0.016116 |
7 | 0.023271 | 0.014494 | 0.001155 | 0.000162 | 0.001297 | 0.009588 | 0.027995 | 0.003547 | 0.002372 | 0.002291 | 0.002210 | 0.015710 |
8 | 0.019055 | 0.014595 | 0.000912 | 0.000061 | 0.000932 | 0.007804 | 0.020393 | 0.002757 | 0.002088 | 0.002007 | 0.002068 | 0.013805 |
9 | 0.014859 | 0.012872 | 0.000547 | 0.000000 | 0.000588 | 0.005412 | 0.013257 | 0.002737 | 0.001196 | 0.001399 | 0.001865 | 0.009122 |
10 | 0.011656 | 0.008271 | 0.000547 | 0.000020 | 0.000365 | 0.003081 | 0.009163 | 0.002169 | 0.000750 | 0.000568 | 0.001500 | 0.007723 |
11 | 0.008027 | 0.005271 | 0.000243 | 0.000020 | 0.000142 | 0.002392 | 0.006892 | 0.001662 | 0.000892 | 0.000405 | 0.001257 | 0.007176 |
12 | 0.004966 | 0.002635 | 0.000182 | 0.000000 | 0.000061 | 0.001622 | 0.003933 | 0.002250 | 0.000892 | 0.000304 | 0.000730 | 0.005494 |
13 | 0.003547 | 0.001642 | 0.000122 | 0.000000 | 0.000020 | 0.000750 | 0.002433 | 0.002189 | 0.000932 | 0.000203 | 0.000507 | 0.003000 |
14 | 0.001966 | 0.000791 | 0.000020 | 0.000000 | 0.000020 | 0.000669 | 0.001743 | 0.001865 | 0.000973 | 0.000000 | 0.000304 | 0.001622 |
15 | 0.001257 | 0.000162 | 0.000020 | 0.000000 | 0.000000 | 0.000304 | 0.001115 | 0.001824 | 0.000730 | 0.000020 | 0.000162 | 0.001297 |
16 | 0.000791 | 0.000101 | 0.000000 | 0.000000 | 0.000000 | 0.000162 | 0.000831 | 0.000872 | 0.000243 | 0.000000 | 0.000243 | 0.000872 |
17 | 0.000466 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000203 | 0.000466 | 0.000588 | 0.000061 | 0.000000 | 0.000020 | 0.000568 |
18 | 0.000243 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000061 | 0.000365 | 0.000345 | 0.000020 | 0.000000 | 0.000041 | 0.000142 |
19 | 0.000122 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000041 | 0.000162 | 0.000122 | 0.000061 | 0.000000 | 0.000000 | 0.000020 |
20 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000061 | 0.000041 | 0.000020 | 0.000000 | 0.000000 | 0.000000 |
21 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000020 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
wio.make_tab('sample_data_80m_LT.tab', ftable, desc='Sample data', height=80)
with open('sample_data_80m_LT.tab') as f:
print f.read()
Sample data | Vmean=6.59 PMean=314.26 0.000000 0.000000 80.00 12 1.00 0.00 22.09 14.80 2.33 0.90 1.41 7.95 24.41 5.45 2.98 2.19 2.97 12.51 1.00 2.20 4.11 27.03 60.95 44.48 11.47 3.32 17.11 23.14 19.41 15.01 3.89 2.00 16.61 27.25 170.01 304.74 212.34 51.22 20.43 44.25 53.78 77.63 73.67 19.45 3.00 47.07 76.00 215.34 284.42 172.17 97.86 54.97 95.20 65.35 118.30 75.72 34.52 4.00 96.61 111.19 185.70 164.79 107.60 103.21 105.13 109.71 91.90 112.75 128.24 61.10 5.00 149.83 131.32 118.57 76.75 64.56 120.54 159.61 125.70 126.62 103.51 130.97 102.76 6.00 144.14 122.55 71.49 42.89 78.91 108.05 148.31 101.15 140.23 125.69 106.41 117.34 7.00 135.15 116.66 50.57 36.12 77.47 104.23 144.41 85.16 121.85 114.60 103.00 128.85 8.00 105.33 97.90 49.69 18.06 91.82 120.54 114.68 65.08 79.65 104.44 74.35 125.61 9.00 86.25 98.59 39.23 6.77 66.00 98.11 83.54 50.58 70.12 91.50 69.58 110.37 10.00 67.25 86.95 23.54 0.00 41.61 68.04 54.31 50.20 40.16 63.77 62.76 72.93 11.00 52.76 55.87 23.54 2.26 25.82 38.74 37.54 39.79 25.19 25.88 50.48 61.75 12.00 36.33 35.60 10.46 2.26 10.04 30.07 28.23 30.49 29.95 18.48 42.29 57.37 13.00 22.48 17.80 7.85 0.00 4.30 20.39 16.11 41.28 29.95 13.86 24.56 43.92 14.00 16.06 11.09 5.23 0.00 1.43 9.43 9.97 40.16 31.31 9.24 17.05 23.99 15.00 8.90 5.34 0.87 0.00 1.43 8.41 7.14 34.21 32.68 0.00 10.23 12.97 16.00 5.69 1.10 0.87 0.00 0.00 3.82 4.57 33.47 24.51 0.92 5.46 10.37 17.00 3.58 0.68 0.00 0.00 0.00 2.04 3.40 15.99 8.17 0.00 8.19 6.97 18.00 2.11 0.00 0.00 0.00 0.00 2.55 1.91 10.78 2.04 0.00 0.68 4.54 19.00 1.10 0.00 0.00 0.00 0.00 0.76 1.49 6.32 0.68 0.00 1.36 1.13 20.00 0.55 0.00 0.00 0.00 0.00 0.51 0.66 2.23 2.04 0.00 0.00 0.16 21.00 0.00 0.00 0.00 0.00 0.00 0.00 0.25 0.74 0.68 0.00 0.00 0.00 22.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.37 0.00 0.00 0.00 0.00