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
383e547d
Commit
383e547d
authored
4 years ago
by
rink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot..
parent
e7c7cd65
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/aeolus/aeolus_amv.py
+53
-17
53 additions, 17 deletions
modules/aeolus/aeolus_amv.py
with
53 additions
and
17 deletions
modules/aeolus/aeolus_amv.py
+
53
−
17
View file @
383e547d
...
@@ -106,6 +106,19 @@ class CarrStereo(AMVFiles):
...
@@ -106,6 +106,19 @@ class CarrStereo(AMVFiles):
self
.
lon_name
=
'
Lon
'
self
.
lon_name
=
'
Lon
'
self
.
lat_name
=
'
Lat
'
self
.
lat_name
=
'
Lat
'
self
.
out_params
=
[
'
Lon
'
,
'
Lat
'
,
'
Element
'
,
'
Line
'
,
'
V_3D_u
'
,
'
V_3D_v
'
,
'
pres
'
,
'
Fcst_Spd
'
,
'
Fcst_Dir
'
,
'
SatZen
'
,
'
InversionFlag
'
,
'
CloudPhase
'
,
'
CloudType
'
]
self
.
params
=
[
'
V_3D
'
,
'
H_3D
'
,
'
pres
'
,
'
Fcst_Spd
'
,
'
Fcst_Dir
'
,
'
SatZen
'
,
'
InversionFlag
'
,
'
CloudPhase
'
,
'
CloudType
'
]
self
.
meta_dict
=
{
'
H_3D
'
:
(
'
m
'
,
'
f4
'
),
'
pres
'
:
(
'
hPa
'
,
'
f4
'
),
'
Fcst_Spd
'
:
(
'
m s-1
'
,
'
f4
'
),
'
Fcst_Dir
'
:
(
'
degree
'
,
'
f4
'
),
'
SatZen
'
:
(
'
degree
'
,
'
f4
'
),
'
InversionFlag
'
:
(
None
,
'
u1
'
),
'
CloudPhase
'
:
(
None
,
'
u1
'
),
'
CloudType
'
:
(
None
,
'
u1
'
),
'
V_3D_u
'
:
(
'
m s-1
'
,
'
f4
'
),
'
V_3D_v
'
:
(
'
m s-1
'
,
'
f4
'
),
'
Lon
'
:
(
'
degrees east
'
,
'
f4
'
),
'
Lat
'
:
(
'
degrees north
'
,
'
f4
'
)}
def
get_navigation
(
self
):
def
get_navigation
(
self
):
return
GEOSNavigation
(
sub_lon
=-
137.0
)
return
GEOSNavigation
(
sub_lon
=-
137.0
)
...
@@ -118,10 +131,13 @@ class CarrStereo(AMVFiles):
...
@@ -118,10 +131,13 @@ class CarrStereo(AMVFiles):
return
dto
return
dto
def
get_parameters
(
self
):
def
get_parameters
(
self
):
params
=
[
'
V_3D
'
,
'
H_3D
'
,
'
pres
'
,
'
Fcst_Spd
'
,
'
Fcst_Dir
'
,
'
SatZen
'
,
return
self
.
params
'
InversionFlag
'
,
'
CloudPhase
'
,
'
CloudType
'
]
return
params
def
get_out_parameters
(
self
):
return
self
.
out_params
def
get_meta_dict
(
self
):
return
self
.
meta_dict
def
get_datetime
(
pathname
):
def
get_datetime
(
pathname
):
...
@@ -449,8 +465,9 @@ def match_amvs_to_aeolus(aeolus_dict, amv_files_path, amv_source='OPS', band='14
...
@@ -449,8 +465,9 @@ def match_amvs_to_aeolus(aeolus_dict, amv_files_path, amv_source='OPS', band='14
if
num_amvs
==
0
:
if
num_amvs
==
0
:
continue
continue
# dist = haversine_np(lon, lat, amv_lons[in_box], amv_lats[in_box])
# dist = haversine_np(lon, lat, amv_lons[in_box], amv_lats[in_box])
params_nd
=
np
.
vstack
(
param_s
)
param_nd
=
np
.
vstack
(
param_s
)
params_nd
=
params_nd
[:,
in_box
]
param_nd
=
param_nd
[:,
in_box
]
match_dict
[
key
]
=
param_nd
#match_dict[key] = (amv_lons[in_box], amv_lats[in_box], amv_pres[in_box], amv_spd[in_box], amv_dir[in_box], dist)
#match_dict[key] = (amv_lons[in_box], amv_lats[in_box], amv_pres[in_box], amv_spd[in_box], amv_dir[in_box], dist)
return
match_dict
return
match_dict
...
@@ -459,7 +476,8 @@ def match_amvs_to_aeolus(aeolus_dict, amv_files_path, amv_source='OPS', band='14
...
@@ -459,7 +476,8 @@ def match_amvs_to_aeolus(aeolus_dict, amv_files_path, amv_source='OPS', band='14
# full path as string filename to create, '/home/user/newfilename'
# full path as string filename to create, '/home/user/newfilename'
# aeolus_to_amv_dct: output from match_amvs_to_aeolus
# aeolus_to_amv_dct: output from match_amvs_to_aeolus
# aeolus_dct: output from get_aeolus_time_dict
# aeolus_dct: output from get_aeolus_time_dict
def
create_file
(
filename
,
aeolus_to_amv_dct
,
aeolus_dct
):
# amv_files: container representing specific AMV product info
def
create_file
(
filename
,
aeolus_to_amv_dct
,
aeolus_dct
,
amv_files
):
keys
=
list
(
aeolus_to_amv_dct
.
keys
())
keys
=
list
(
aeolus_to_amv_dct
.
keys
())
num_amvs
=
[]
num_amvs
=
[]
...
@@ -469,9 +487,10 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
...
@@ -469,9 +487,10 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
namvs
=
0
namvs
=
0
nlevs
=
0
nlevs
=
0
for
key
in
keys
:
for
key
in
keys
:
lons
,
lats
,
pres
,
spd
,
dir
,
dist
=
aeolus_to_amv_dct
.
get
(
key
)
# lons, lats, pres, spd, dir, dist = aeolus_to_amv_dct.get(key)
num_amvs
.
append
(
len
(
lons
))
param_nd
=
aeolus_to_amv_dct
.
get
(
key
)
namvs
+=
len
(
lons
)
num_amvs
.
append
(
param_nd
.
shape
[
1
])
namvs
+=
len
(
param_nd
.
shape
[
1
])
prof_s
=
aeolus_dct
.
get
(
key
)
prof_s
=
aeolus_dct
.
get
(
key
)
prof
=
prof_s
[
0
]
prof
=
prof_s
[
0
]
...
@@ -499,9 +518,20 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
...
@@ -499,9 +518,20 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
amv_dist
=
rootgrp
.
createVariable
(
'
amv_dist
'
,
'
f4
'
,
[
'
amvs
'
])
amv_dist
=
rootgrp
.
createVariable
(
'
amv_dist
'
,
'
f4
'
,
[
'
amvs
'
])
amv_dist
.
units
=
'
km
'
amv_dist
.
units
=
'
km
'
nc4_vars
=
[]
out_params
=
amv_files
.
get_out_parameters
()
meta_dict
=
amv_files
.
get_meta_dict
()
for
pidx
,
param
in
enumerate
(
out_params
):
u
,
t
=
meta_dict
.
get
(
param
)
var
=
rootgrp
.
createVariable
(
param
,
t
,
[
'
amvs
'
])
var
.
units
=
u
nc4_vars
.
append
(
var
)
num_amvs_per_prof
=
rootgrp
.
createVariable
(
'
num_amvs_per_prof
'
,
'
i4
'
,
[
'
num_aeolus_profs
'
])
num_amvs_per_prof
=
rootgrp
.
createVariable
(
'
num_amvs_per_prof
'
,
'
i4
'
,
[
'
num_aeolus_profs
'
])
num_levs_per_prof
=
rootgrp
.
createVariable
(
'
num_levs_per_prof
'
,
'
i4
'
,
[
'
num_aeolus_profs
'
])
num_levs_per_prof
=
rootgrp
.
createVariable
(
'
num_levs_per_prof
'
,
'
i4
'
,
[
'
num_aeolus_profs
'
])
prof_time
=
rootgrp
.
createVariable
(
'
time
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
prof_time
=
rootgrp
.
createVariable
(
'
time
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
# ---- Profile variables ---------------
prf_lon
=
rootgrp
.
createVariable
(
'
prof_longitude
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
prf_lon
=
rootgrp
.
createVariable
(
'
prof_longitude
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
prf_lon
.
units
=
'
degrees east
'
prf_lon
.
units
=
'
degrees east
'
prf_lat
=
rootgrp
.
createVariable
(
'
prof_latitude
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
prf_lat
=
rootgrp
.
createVariable
(
'
prof_latitude
'
,
'
f4
'
,
[
'
num_aeolus_profs
'
])
...
@@ -516,6 +546,7 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
...
@@ -516,6 +546,7 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
prf_hht
.
units
=
'
meter
'
prf_hht
.
units
=
'
meter
'
prf_hhb
=
rootgrp
.
createVariable
(
'
prof_hhb
'
,
'
f4
'
,
[
'
profs
'
])
prf_hhb
=
rootgrp
.
createVariable
(
'
prof_hhb
'
,
'
f4
'
,
[
'
profs
'
])
prf_hhb
.
units
=
'
meter
'
prf_hhb
.
units
=
'
meter
'
# --------------------------------------
i_a
=
0
i_a
=
0
i_c
=
0
i_c
=
0
...
@@ -525,13 +556,18 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
...
@@ -525,13 +556,18 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct):
i_b
=
i_a
+
namvs
i_b
=
i_a
+
namvs
i_d
=
i_c
+
nlevs
i_d
=
i_c
+
nlevs
lons
,
lats
,
pres
,
spd
,
dir
,
dist
=
aeolus_to_amv_dct
.
get
(
key
)
# lons, lats, pres, spd, dir, dist = aeolus_to_amv_dct.get(key)
amv_lon
[
i_a
:
i_b
]
=
lons
[:]
# amv_lon[i_a:i_b] = lons[:]
amv_lat
[
i_a
:
i_b
]
=
lats
[:]
# amv_lat[i_a:i_b] = lats[:]
amv_spd
[
i_a
:
i_b
]
=
spd
[:]
# amv_spd[i_a:i_b] = spd[:]
amv_dir
[
i_a
:
i_b
]
=
dir
[:]
# amv_dir[i_a:i_b] = dir[:]
amv_pres
[
i_a
:
i_b
]
=
pres
[:]
# amv_pres[i_a:i_b] = pres[:]
amv_dist
[
i_a
:
i_b
]
=
dist
[:]
# amv_dist[i_a:i_b] = dist[:]
# i_a += namvs
param_nd
=
aeolus_to_amv_dct
.
get
(
key
)
for
pidx
,
param
in
enumerate
(
out_params
):
nc4_vars
[
pidx
][
i_a
:
i_b
]
=
param_nd
[
pidx
,
:]
i_a
+=
namvs
i_a
+=
namvs
prof_s
=
aeolus_dct
.
get
(
key
)
prof_s
=
aeolus_dct
.
get
(
key
)
...
@@ -566,7 +602,7 @@ def create_amv_to_aeolus_match_file(aeolus_files_dir, amv_files_dir, outfile=Non
...
@@ -566,7 +602,7 @@ def create_amv_to_aeolus_match_file(aeolus_files_dir, amv_files_dir, outfile=Non
m_d
=
match_amvs_to_aeolus
(
a_d
,
amv_files_dir
,
amv_source
,
band
,
amv_files
)
m_d
=
match_amvs_to_aeolus
(
a_d
,
amv_files_dir
,
amv_source
,
band
,
amv_files
)
if
outfile
is
not
None
:
if
outfile
is
not
None
:
create_file
(
outfile
,
m_d
,
a_d
)
create_file
(
outfile
,
m_d
,
a_d
,
amv_files
)
# match_file: pathname for the product file
# match_file: pathname for the product file
...
...
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