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
74caa890
Commit
74caa890
authored
8 years ago
by
kgao
Browse files
Options
Downloads
Patches
Plain Diff
wind_direction wasn't being calculated correctly
parent
24452d52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aosstower/level_b1/daily/nc.py
+39
-10
39 additions, 10 deletions
aosstower/level_b1/daily/nc.py
with
39 additions
and
10 deletions
aosstower/level_b1/daily/nc.py
+
39
−
10
View file @
74caa890
...
...
@@ -9,6 +9,7 @@ import numpy as np
import
platform
from
aosstower
import
station
from
datetime
import
timedelta
as
delta
import
calc
LOG
=
logging
.
getLogger
(
__name__
)
...
...
@@ -111,6 +112,9 @@ def createVariables(ncFile, firstStamp, chunksizes, zlib):
if
key
==
'
base_time
'
:
variable
.
string
=
bts
if
'
time
'
in
key
:
variable
.
calendar
=
'
gregorian
'
for
entry
in
parser
.
database
:
if
(
entry
==
'
stamp
'
):
continue
...
...
@@ -196,11 +200,30 @@ def getRolling(series, minutes):
return
returnSeries
def
getNewWindDirection
(
wind_dir
,
wind_speed
,
stamps
):
newWindDir
=
{}
for
stamp
in
stamps
:
before
=
stamp
-
delta
(
minutes
=
1
)
if
before
not
in
wind_speed
.
index
:
newWindDir
[
stamp
]
=
None
else
:
speed
=
wind_speed
[
before
:
stamp
].
tolist
()
dire
=
wind_dir
[
before
:
stamp
].
tolist
()
wind_dire
=
calc
.
mean_wind_vector
(
speed
,
dire
)[
0
]
newWindDir
[
stamp
]
=
wind_dire
return
pd
.
Series
(
newWindDir
)
def
minuteAverages
(
frame
):
frame
[
'
minute
'
]
=
[(
ts
+
delta
(
minutes
=
1
)).
replace
(
second
=
0
)
for
ts
in
frame
.
index
]
newFrame
=
frame
.
groupby
(
'
minute
'
).
mean
()
newFrame
.
index
.
names
=
[
''
]
columns
=
list
(
newFrame
.
columns
.
values
)
if
'
wind_speed
'
in
columns
:
del
newFrame
[
'
wind_speed
'
]
...
...
@@ -223,14 +246,20 @@ def minuteAverages(frame):
newFrame
[
'
gust
'
]
=
gust
if
'
wind_direction
'
in
columns
:
del
newFrame
[
'
wind_direction
'
]
if
'
wind_dir
'
in
columns
:
del
newFrame
[
'
wind_dir
'
]
dupFrame
=
frame
.
set_index
(
'
minute
'
)
stamps
=
newFrame
.
index
windDirSeries
=
f
rame
[
'
wind_dir
ection
'
]
windDirSeries
=
dupF
rame
[
'
wind_dir
'
]
wind
Dir
Series
=
getRolling
(
windDirSeries
,
list
(
newFrame
.
index
))
windSeries
=
dupFrame
[
'
wind_speed
'
]
newFrame
[
'
wind_direction
'
]
=
windDirSeries
windDirSeries
=
getNewWindDirection
(
windDirSeries
,
windSeries
,
stamps
)
newFrame
[
'
wind_dir
'
]
=
windDirSeries
del
frame
[
'
minute
'
]
...
...
@@ -348,15 +377,15 @@ def createGiantNetCDF(start, end, inputFiles, outputName, zlib, chunkSize):
frame
=
getData
(
inputFiles
)
frame
=
minuteAverages
(
frame
)
if
(
frame
.
empty
):
return
False
else
:
frame
=
minuteAverages
(
frame
)
if
(
start
and
end
):
frame
=
frame
[
start
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
):
end
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)]
print
(
frame
)
if
(
default
):
chunksizes
=
[
len
(
list
(
frame
.
index
))]
...
...
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