How to calculate air density using the brightwind library


[1]:
import datetime
print('Last updated: {}'.format(datetime.date.today().strftime('%d %B, %Y')))
Last updated: 26 June, 2019

Outline:

This guide will demonstrate how to get some useful statistics from a sample dataset using the following steps:

  • Import the brightwind library and some sample data

  • Calculate the air density for each timestamp in the data

  • Calculate the air density with the average temperature and pressure recorded at the site

  • Scale the air density up to hub height using a typical lapse rate


[2]:
import brightwind as bw
[3]:
# specify location of existing sample dataset
filepath = r'C:\...\brightwind\datasets\demo\demo_data.csv'
# load data as dataframe
data = bw.load_csv(filepath)
# show first few rows of dataframe
data.head(5)
[3]:
Spd80mN Spd80mS Spd60mN Spd60mS Spd40mN Spd40mS Spd80mNStd Spd80mSStd Spd60mNStd Spd60mSStd ... Dir78mSStd Dir58mS Dir58mSStd Dir38mS Dir38mSStd T2m RH2m P2m PrcpTot BattMin
Timestamp
2016-01-09 15:30:00 8.370 7.911 8.160 7.849 7.857 7.626 1.240 1.075 1.060 0.947 ... 6.100 110.1 6.009 112.2 5.724 0.711 100.0 935.0 0.0 12.94
2016-01-09 15:40:00 8.250 7.961 8.100 7.884 7.952 7.840 0.897 0.875 0.900 0.855 ... 5.114 110.9 4.702 109.8 5.628 0.630 100.0 935.0 0.0 12.95
2016-01-09 17:00:00 7.652 7.545 7.671 7.551 7.531 7.457 0.756 0.703 0.797 0.749 ... 4.172 113.1 3.447 111.8 4.016 1.126 100.0 934.0 0.0 12.75
2016-01-09 17:10:00 7.382 7.325 6.818 6.689 6.252 6.174 0.844 0.810 0.897 0.875 ... 4.680 118.8 5.107 115.6 5.189 0.954 100.0 934.0 0.0 12.71
2016-01-09 17:20:00 7.977 7.791 8.110 7.915 8.140 7.974 0.556 0.528 0.562 0.524 ... 3.123 115.9 2.960 113.6 3.540 0.863 100.0 934.0 0.0 12.69

5 rows × 29 columns

Calculate Air Density

The air density can be calculated for each timestamp in the timeseries by passing the temperature (in degrees Celsius) and pressure (in hPa) by passing the column relating to temperature and pressure from the site data using the calc_air_density() function.

[4]:
bw.calc_air_density(data.T2m,data.P2m)
[4]:
Timestamp
2016-01-09 15:30:00    1.190011
2016-01-09 15:40:00    1.190363
2016-01-09 17:00:00    1.186939
2016-01-09 17:10:00    1.187684
2016-01-09 17:20:00    1.188079
2016-01-09 17:30:00    1.188651
2016-01-09 17:40:00    1.186854
2016-01-09 17:50:00    1.187205
2016-01-09 18:00:00    1.186590
2016-01-09 18:10:00    1.186941
2016-01-09 18:20:00    1.188168
2016-01-09 18:30:00    1.188255
2016-01-09 18:40:00    1.187994
2016-01-09 18:50:00    1.187333
2016-01-09 19:00:00    1.186236
2016-01-09 19:10:00    1.186279
2016-01-09 19:20:00    1.186193
2016-01-09 19:30:00    1.185708
2016-01-09 19:40:00    1.184046
2016-01-09 19:50:00    1.182997
2016-01-09 20:00:00    1.182304
2016-01-09 20:10:00    1.181993
2016-01-09 20:20:00    1.182428
2016-01-09 20:30:00    1.181735
2016-01-09 20:40:00    1.182304
2016-01-09 20:50:00    1.184046
2016-01-09 21:00:00    1.182213
2016-01-09 21:10:00    1.181641
2016-01-09 21:20:00    1.181382
2016-01-09 21:30:00    1.180685
                         ...
2017-11-23 06:00:00    1.196908
2017-11-23 06:10:00    1.196418
2017-11-23 06:20:00    1.196156
2017-11-23 06:30:00    1.196021
2017-11-23 06:40:00    1.198492
2017-11-23 06:50:00    1.197337
2017-11-23 07:00:00    1.197429
2017-11-23 07:10:00    1.197603
2017-11-23 07:20:00    1.197472
2017-11-23 07:30:00    1.197826
2017-11-23 07:40:00    1.198264
2017-11-23 07:50:00    1.197472
2017-11-23 08:00:00    1.197385
2017-11-23 08:10:00    1.196983
2017-11-23 08:20:00    1.197075
2017-11-23 08:30:00    1.198964
2017-11-23 08:40:00    1.198745
2017-11-23 08:50:00    1.199056
2017-11-23 09:00:00    1.198478
2017-11-23 09:10:00    1.198657
2017-11-23 09:20:00    1.200903
2017-11-23 09:30:00    1.200193
2017-11-23 09:40:00    1.200456
2017-11-23 09:50:00    1.199483
2017-11-23 10:00:00    1.200105
2017-11-23 10:10:00    1.199177
2017-11-23 10:20:00    1.199838
2017-11-23 10:30:00    1.199794
2017-11-23 10:40:00    1.199439
2017-11-23 10:50:00    1.201066
Length: 95629, dtype: float64

Getting the time series of air density may not be as interesting as getting the average air density for the site for the time period covered by the dataset. Alternatively we can pass the mean of the temperature and pressure columns to return an average value of air density.

[5]:
bw.calc_air_density(data.T2m.mean(),data.P2m.mean())
[5]:
1.185160775505084

Finally, we can scale the air density up from the measurement point to 80m higher to represent the hub height of a potential turbine. This can be done by setting the elevation_ref and elevation_site variables in the function. The function automatically assumes a lapse rate of -0.113 kg/m3/km and a specific gas constant of 286.9 J/(kg.K). These can be modified directly by setting the lapse_rate variable and the specific_gas_constant variable.

[6]:
bw.calc_air_density(data.T2m.mean(),data.P2m.mean(),elevation_ref=234,elevation_site=314)
[6]:
1.176