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
15b29953
Commit
15b29953
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
remove duplicated code
parent
6039aacd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/amv/aeolus.py
+1
-75
1 addition, 75 deletions
modules/amv/aeolus.py
with
1 addition
and
75 deletions
modules/amv/aeolus.py
+
1
−
75
View file @
15b29953
...
...
@@ -9,6 +9,7 @@ from metpy import *
import
h5py
from
netCDF4
import
Dataset
from
aeolus.aeolus_amv
import
get_aeolus_time_dict
from
util.lon_lat_grid
import
earth_to_indexs
from
util.geos_nav
import
GEOSNavigation
from
util.util
import
bin_data_by
,
get_bin_ranges
...
...
@@ -133,81 +134,6 @@ def get_file_containing_time(timestamp, files_path, dto_func, file_time_span):
return
flist
[
k
],
ftimes
[
k
],
k
# imports the S4 NOAA output
# filename: full path as a string, '/home/user/filename'
# returns a dict: time -> list of profiles (a profile is a list of levels)
def
get_aeolus_time_dict
(
filename
,
lon360
=
False
,
do_sort
=
True
):
time_dict
=
{}
with
open
(
filename
)
as
file
:
while
True
:
prof_hdr
=
file
.
readline
()
if
not
prof_hdr
:
break
toks
=
prof_hdr
.
split
()
yr
=
int
(
float
(
toks
[
0
]))
mon
=
int
(
float
(
toks
[
1
]))
dy
=
int
(
float
(
toks
[
2
]))
hr
=
int
(
float
(
toks
[
3
]))
mn
=
int
(
float
(
toks
[
4
]))
ss
=
int
(
float
(
toks
[
5
]))
lon
=
float
(
toks
[
6
])
lat
=
float
(
toks
[
7
])
nlevs
=
int
(
toks
[
8
])
if
lon360
:
if
lon
<
0
:
lon
+=
360.0
else
:
if
lon
>
180.0
:
lon
-=
360.0
dto
=
datetime
.
datetime
(
year
=
yr
,
month
=
mon
,
day
=
dy
,
hour
=
hr
,
minute
=
mn
,
second
=
ss
)
dto
=
dto
.
replace
(
tzinfo
=
timezone
.
utc
)
timestamp
=
dto
.
timestamp
()
prof
=
[]
if
time_dict
.
get
(
timestamp
,
-
1
)
==
-
1
:
prof_s
=
[]
prof_s
.
append
(
prof
)
time_dict
[
timestamp
]
=
prof_s
else
:
prof_s
=
time_dict
.
get
(
timestamp
)
prof_s
.
append
(
prof
)
for
k
in
range
(
nlevs
):
line
=
file
.
readline
()
toks
=
line
.
split
()
lvlidx
=
int
(
toks
[
0
])
hhh
=
float
(
toks
[
1
])
*
1000.0
hht
=
float
(
toks
[
2
])
*
1000.0
hhb
=
float
(
toks
[
3
])
*
1000.0
err
=
float
(
toks
[
4
])
azm
=
float
(
toks
[
5
])
ws
=
float
(
toks
[
6
])
len
=
float
(
toks
[
7
])
tup
=
(
lat
,
lon
,
hhh
,
hht
,
hhb
,
azm
,
ws
)
prof
.
append
(
tup
)
file
.
close
()
if
do_sort
:
keys
=
np
.
array
(
list
(
time_dict
.
keys
()))
keys
.
sort
()
keys
=
keys
.
tolist
()
sorted_time_dict
=
{}
for
key
in
keys
:
sorted_time_dict
[
key
]
=
time_dict
.
get
(
key
)
time_dict
=
sorted_time_dict
return
time_dict
def
time_dict_to_cld_layers
(
time_dict
):
time_dict_layers
=
{}
...
...
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