Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
AossTower
Commits
f29c1570
Commit
f29c1570
authored
5 years ago
by
William Roberts
Browse files
Options
Downloads
Patches
Plain Diff
Replace "inplace=" with chained function calls
parent
46f06731
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aosstower/level_00/influxdb.py
+5
-6
5 additions, 6 deletions
aosstower/level_00/influxdb.py
aosstower/level_b1/nc.py
+3
-6
3 additions, 6 deletions
aosstower/level_b1/nc.py
with
8 additions
and
12 deletions
aosstower/level_00/influxdb.py
+
5
−
6
View file @
f29c1570
...
...
@@ -92,9 +92,8 @@ class Updater(object):
return
self
.
_calculate_averages
()
def
_calculate_averages
(
self
):
index
=
self
.
data
.
pop
(
'
timestamp
'
)
frame
=
pd
.
DataFrame
(
self
.
data
,
index
=
index
)
frame
.
mask
(
frame
==
-
99999.
,
inplace
=
True
)
frame
=
pd
.
DataFrame
(
self
.
data
)
frame
=
frame
.
set_index
(
'
timestamp
'
).
mask
(
frame
==
-
99999.
)
# Add wind direction components so we can average wind direction properly.
frame
[
'
wind_east
'
],
frame
[
'
wind_north
'
],
_
=
calc
.
wind_vector_components
(
frame
[
'
wind_speed
'
],
frame
[
'
wind_dir
'
])
...
...
@@ -112,8 +111,8 @@ class Updater(object):
frame
[
'
wind_dir_2m
'
]
=
calc
.
wind_vector_degrees
(
winds_frame_2m
[
'
wind_east
'
],
winds_frame_2m
[
'
wind_north
'
])
# Makes 2 minute averages nans if given less than 2 minutes of data.
if
len
(
frame
[
frame
.
index
>
frame
.
index
[
-
1
]
-
timedelta
(
minutes
=
2
)])
<
120
/
self
.
data_interval
:
frame
[
'
wind_speed_2m
'
].
mask
(
frame
[
'
wind_speed_2m
'
]
>
-
1.
,
inplace
=
True
)
frame
[
'
wind_dir_2m
'
].
mask
(
frame
[
'
wind_dir_2m
'
]
>
-
1.
,
inplace
=
True
)
frame
[
'
wind_speed_2m
'
]
=
frame
[
'
wind_speed_2m
'
].
mask
(
frame
[
'
wind_speed_2m
'
]
>
-
1.
)
frame
[
'
wind_dir_2m
'
]
=
frame
[
'
wind_dir_2m
'
].
mask
(
frame
[
'
wind_dir_2m
'
]
>
-
1.
)
# 1 minute rolling peaks
wind_peak_1m
=
frame
[
'
wind_speed
'
].
rolling
(
window
=
'
1T
'
,
closed
=
'
right
'
).
max
()
# criteria for a fast wind to be considered a wind gust
...
...
@@ -123,7 +122,7 @@ class Updater(object):
frame
[
'
gust_10m
'
]
=
calculate_wind_gust
(
frame
[
'
wind_speed
'
],
winds_frame_2m
[
'
wind_speed
'
])
# Makes 10 minute gusts before 12 minutes nans because data is insufficient.
if
len
(
frame
)
<
720
/
self
.
data_interval
:
frame
[
'
gust_10m
'
].
mask
(
frame
[
'
gust_10m
'
]
>
-
1.
,
inplace
=
True
)
frame
[
'
gust_10m
'
]
=
frame
[
'
gust_10m
'
].
mask
(
frame
[
'
gust_10m
'
]
>
-
1.
)
return
frame
.
fillna
(
value
=
np
.
nan
)
...
...
This diff is collapsed.
Click to expand it.
aosstower/level_b1/nc.py
+
3
−
6
View file @
f29c1570
...
...
@@ -37,9 +37,7 @@ def _get_data(input_files):
def
get_data
(
input_files
):
frame
=
pd
.
DataFrame
(
_get_data
(
input_files
))
frame
.
set_index
(
'
stamp
'
,
inplace
=
True
)
frame
.
mask
(
frame
==
-
99999.
,
inplace
=
True
)
frame
.
fillna
(
value
=
np
.
nan
,
inplace
=
True
)
frame
=
frame
.
set_index
(
'
stamp
'
).
mask
(
frame
==
-
99999.
).
fillna
(
value
=
np
.
nan
)
return
frame
...
...
@@ -103,12 +101,11 @@ def create_giant_netcdf(input_files, output_fn, zlib, chunk_size,
# average the values
if
summary
:
frame
=
summary_over_interval
(
new_frame
,
interval_width
)
frame
=
summary_over_interval
(
new_frame
,
interval_width
)
.
fillna
(
np
.
nan
)
else
:
frame
=
new_frame
.
resample
(
interval_width
,
closed
=
'
right
'
,
loffset
=
interval_width
).
mean
()
frame
=
new_frame
.
resample
(
interval_width
,
closed
=
'
right
'
,
loffset
=
interval_width
).
mean
()
.
fillna
(
np
.
nan
)
frame
[
'
wind_dir
'
]
=
calc
.
wind_vector_degrees
(
frame
[
'
wind_east
'
],
frame
[
'
wind_north
'
])
frame
[
'
gust
'
]
=
new_frame
[
'
gust
'
].
resample
(
interval_width
,
closed
=
'
right
'
,
loffset
=
interval_width
).
max
()
frame
.
fillna
(
np
.
nan
,
inplace
=
True
)
if
start
and
end
:
frame
=
frame
[
start
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
):
end
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)]
...
...
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
register
or
sign in
to comment