Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsCommon
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
MetObsCommon
Commits
6a56a1f4
Verified
Commit
6a56a1f4
authored
4 months ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Update deprecated pandas time intervals
parent
11f1b39a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
metobscommon/util/nc.py
+9
-9
9 additions, 9 deletions
metobscommon/util/nc.py
with
9 additions
and
9 deletions
metobscommon/util/nc.py
+
9
−
9
View file @
6a56a1f4
...
...
@@ -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
=
'
1
T
'
,
center
=
False
).
max
()
wind_peak_1m
=
wind_speed_5s
.
rolling
(
window
=
'
1
min
'
,
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
=
'
10
T
'
,
center
=
False
).
max
()
max_10m_gusts
=
gusts
.
rolling
(
window
=
'
10
min
'
,
center
=
False
).
max
()
# Minimum 5-second average in the past 10 minutes
min_10m_5avg
=
wind_speed_5s
.
rolling
(
window
=
'
10
T
'
,
center
=
False
).
min
()
min_10m_5avg
=
wind_speed_5s
.
rolling
(
window
=
'
10
min
'
,
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
(
'
1
T
'
,
closed
=
'
right
'
).
mean
()
new_frame
.
index
=
new_frame
.
index
+
to_offset
(
"
1
T
"
)
new_frame
=
frame
.
resample
(
'
1
min
'
,
closed
=
'
right
'
).
mean
()
new_frame
.
index
=
new_frame
.
index
+
to_offset
(
"
1
min
"
)
# 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
(
'
5
S
'
,
closed
=
'
right
'
).
mean
()
winds_frame_5s
.
index
=
winds_frame_5s
.
index
+
to_offset
(
'
5
S
'
)
winds_frame_5s
=
winds_frame_5s
.
resample
(
'
5
s
'
,
closed
=
'
right
'
).
mean
()
winds_frame_5s
.
index
=
winds_frame_5s
.
index
+
to_offset
(
'
5
s
'
)
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
(
'
1
T
'
,
closed
=
'
right
'
).
max
()
new_gust
.
index
=
new_gust
.
index
+
to_offset
(
'
1
T
'
)
new_gust
=
gust
.
resample
(
'
1
min
'
,
closed
=
'
right
'
).
max
()
new_gust
.
index
=
new_gust
.
index
+
to_offset
(
'
1
min
'
)
new_frame
[
'
gust
'
]
=
new_gust
return
new_frame
.
fillna
(
np
.
nan
)
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment