Skip to content
Snippets Groups Projects
Verified Commit 6a56a1f4 authored by David Hoese's avatar David Hoese
Browse files

Update deprecated pandas time intervals

parent 11f1b39a
No related branches found
No related tags found
No related merge requests found
......@@ -223,7 +223,7 @@ def calculate_wind_gust(wind_speed_5s, wind_speed_2m):
"""
# 1 minute rolling peaks
wind_peak_1m = wind_speed_5s.rolling(window='1T', center=False).max()
wind_peak_1m = wind_speed_5s.rolling(window='1min', center=False).max()
# criteria for a fast wind to be considered a wind gust
gust_mask = (wind_speed_2m >= KNOTS_9) & \
(wind_peak_1m >= wind_speed_2m + KNOTS_5)
......@@ -231,9 +231,9 @@ def calculate_wind_gust(wind_speed_5s, wind_speed_2m):
# determine highest gust in the last 10 minutes
# 5 seconds * 120 = 10 minutes
max_10m_gusts = gusts.rolling(window='10T', center=False).max()
max_10m_gusts = gusts.rolling(window='10min', center=False).max()
# Minimum 5-second average in the past 10 minutes
min_10m_5avg = wind_speed_5s.rolling(window='10T', center=False).min()
min_10m_5avg = wind_speed_5s.rolling(window='10min', center=False).min()
# criteria for a wind gust to be reportable
reportable_mask = (max_10m_gusts >= wind_speed_2m + KNOTS_3) & \
(wind_speed_2m > KNOTS_2) & \
......@@ -253,13 +253,13 @@ def minute_averages(frame):
frame['wind_east'], frame['wind_north'], _ = calc.wind_vector_components(frame['wind_speed'], frame['wind_dir'])
# round up each 1 minute group so data at time T is the average of data
# from T - 1 (exclusive) to T (inclusive).
new_frame = frame.resample('1T', closed='right').mean()
new_frame.index = new_frame.index + to_offset("1T")
new_frame = frame.resample('1min', closed='right').mean()
new_frame.index = new_frame.index + to_offset("1min")
# 2 minute rolling average of 5 second data (5 seconds * 24 = 120 seconds = 2 minutes)
winds_frame_5s = frame[['wind_speed', 'wind_east', 'wind_north']]
winds_frame_5s = winds_frame_5s.resample('5S', closed='right').mean()
winds_frame_5s.index = winds_frame_5s.index + to_offset('5S')
winds_frame_5s = winds_frame_5s.resample('5s', closed='right').mean()
winds_frame_5s.index = winds_frame_5s.index + to_offset('5s')
winds_frame_2m = winds_frame_5s.rolling(24, win_type='boxcar').mean()
# rolling average is used for 1 minute output
......@@ -270,8 +270,8 @@ def minute_averages(frame):
gust = calculate_wind_gust(winds_frame_5s['wind_speed'], winds_frame_2m['wind_speed'])
# "average" the gusts to minute resolution to match the rest of the data
new_gust = gust.resample('1T', closed='right').max()
new_gust.index = new_gust.index + to_offset('1T')
new_gust = gust.resample('1min', closed='right').max()
new_gust.index = new_gust.index + to_offset('1min')
new_frame['gust'] = new_gust
return new_frame.fillna(np.nan)
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment