Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Tom Rink
python
Commits
60d68f30
Commit
60d68f30
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
add new method to time sort icing dicts, use it in `pirep_icing`
parent
3d8d3557
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/icing/pireps.py
+33
-1
33 additions, 1 deletion
modules/icing/pireps.py
with
33 additions
and
1 deletion
modules/icing/pireps.py
+
33
−
1
View file @
60d68f30
import
datetime
import
datetime
from
datetime
import
timezone
from
datetime
import
timezone
from
dateutil
import
tz
import
numpy
as
np
import
re
import
re
from
pathlib
import
Path
from
pathlib
import
Path
import
h5py
import
h5py
...
@@ -22,6 +22,34 @@ ATYPE = '/TP'
...
@@ -22,6 +22,34 @@ ATYPE = '/TP'
RMK
=
'
/RM
'
RMK
=
'
/RM
'
def
time_sort_pirep_dict
(
the_dict
):
new_dict
=
{}
keys
=
[]
tidx
=
[]
for
ts
in
list
(
the_dict
.
keys
()):
rpts
=
the_dict
[
ts
]
for
idx
,
tup
in
enumerate
(
rpts
):
keys
.
append
(
ts
)
tidx
.
append
(
idx
)
sidxs
=
np
.
argsort
(
keys
)
ice_keys
=
keys
[
sidxs
]
ice_tidx
=
tidx
[
sidxs
]
for
idx
,
key
in
enumerate
(
ice_keys
):
rpts
=
the_dict
[
key
]
tup
=
rpts
[
ice_tidx
[
idx
]]
n_rpts
=
new_dict
.
get
(
key
)
if
n_rpts
is
None
:
n_rpts
=
[]
new_dict
[
key
]
=
n_rpts
n_rpts
.
append
(
tup
)
return
new_dict
# Returns icing, no_icing (no icing observed), neg-icing (icing expected, but not observed)
# Returns icing, no_icing (no icing observed), neg-icing (icing expected, but not observed)
def
pirep_icing
(
filename
,
lon_range
=
[
-
180
,
180
],
lat_range
=
[
-
63
,
63
]):
def
pirep_icing
(
filename
,
lon_range
=
[
-
180
,
180
],
lat_range
=
[
-
63
,
63
]):
...
@@ -158,6 +186,10 @@ def pirep_icing(filename, lon_range=[-180, 180], lat_range=[-63, 63]):
...
@@ -158,6 +186,10 @@ def pirep_icing(filename, lon_range=[-180, 180], lat_range=[-63, 63]):
else
:
else
:
rpts
.
append
(
tup
)
rpts
.
append
(
tup
)
ice_dict
=
time_sort_pirep_dict
(
ice_dict
)
no_ice_dict
=
time_sort_pirep_dict
(
no_ice_dict
)
neg_ice_dict
=
time_sort_pirep_dict
(
neg_ice_dict
)
return
ice_dict
,
no_ice_dict
,
neg_ice_dict
return
ice_dict
,
no_ice_dict
,
neg_ice_dict
...
...
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