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
4c72d54d
Commit
4c72d54d
authored
4 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
Use SpatialEarth2D
parent
81dc0128
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
modules/aeolus/aeolus_amv.py
+13
-7
13 additions, 7 deletions
modules/aeolus/aeolus_amv.py
modules/amv/intercompare.py
+2
-1
2 additions, 1 deletion
modules/amv/intercompare.py
with
15 additions
and
8 deletions
modules/aeolus/aeolus_amv.py
+
13
−
7
View file @
4c72d54d
...
@@ -5,7 +5,7 @@ import numpy as np
...
@@ -5,7 +5,7 @@ import numpy as np
import
xarray
as
xr
import
xarray
as
xr
from
netCDF4
import
Dataset
,
Dimension
,
Variable
from
netCDF4
import
Dataset
,
Dimension
,
Variable
from
aeolus.geos_nav
import
GEOSNavigation
from
aeolus.geos_nav
import
GEOSNavigation
from
util.util
import
haversine_np
from
util.util
import
haversine_np
,
SpatialEarth2D
from
amv.intercompare
import
best_fit
,
bin_data_by
,
get_press_bin_ranges
,
spd_dir_from_uv
,
uv_from_spd_dir
,
\
from
amv.intercompare
import
best_fit
,
bin_data_by
,
get_press_bin_ranges
,
spd_dir_from_uv
,
uv_from_spd_dir
,
\
direction_difference
direction_difference
import
math
import
math
...
@@ -314,8 +314,8 @@ def match_amvs_to_raobs(raob_dict, raob_time, amv_files, filepath=None):
...
@@ -314,8 +314,8 @@ def match_amvs_to_raobs(raob_dict, raob_time, amv_files, filepath=None):
if
raob
is
None
:
if
raob
is
None
:
continue
continue
lat
=
key
[
0
]
lat
=
key
.
lat
lon
=
key
[
1
]
lon
=
key
.
lon
c_rng
,
l_rng
=
get_search_box
(
nav
,
lon
,
lat
)
c_rng
,
l_rng
=
get_search_box
(
nav
,
lon
,
lat
)
if
c_rng
is
None
:
if
c_rng
is
None
:
...
@@ -409,8 +409,8 @@ def create_file2(filename, raob_to_amv_dct, raob_dct, amv_files):
...
@@ -409,8 +409,8 @@ def create_file2(filename, raob_to_amv_dct, raob_dct, amv_files):
prf_tmp
[
i_c
:
i_d
]
=
prof
[:,
1
]
prf_tmp
[
i_c
:
i_d
]
=
prof
[:,
1
]
i_c
+=
nlevs
i_c
+=
nlevs
plat
=
key
[
0
]
plat
=
key
.
lat
plon
=
key
[
1
]
plon
=
key
.
lon
prf_lat
[
idx
::]
=
plat
prf_lat
[
idx
::]
=
plat
prf_lon
[
idx
::]
=
plon
prf_lon
[
idx
::]
=
plon
...
@@ -639,7 +639,10 @@ def run_best_fit(raob_to_amv_dct, raob_dct, gfs_filename=None, amvs_list=[], bf_
...
@@ -639,7 +639,10 @@ def run_best_fit(raob_to_amv_dct, raob_dct, gfs_filename=None, amvs_list=[], bf_
gfs_press
=
gfs_press
.
values
gfs_press
=
gfs_press
.
values
gfs_press
=
gfs_press
[::
-
1
]
gfs_press
=
gfs_press
[::
-
1
]
uv_wind
=
get_vert_profile_s
(
xr_dataset
,
[
'
u-wind
'
,
'
v-wind
'
],
locs
[:,
1
],
locs
[:,
0
],
method
=
'
nearest
'
)
lon_idx
=
SpatialEarth2D
.
_fields
.
index
(
'
lon
'
)
lat_idx
=
SpatialEarth2D
.
_fields
.
index
(
'
lat
'
)
uv_wind
=
get_vert_profile_s
(
xr_dataset
,
[
'
u-wind
'
,
'
v-wind
'
],
locs
[:,
lon_idx
],
locs
[:,
lat_idx
],
method
=
'
nearest
'
)
uv_wind
=
uv_wind
.
values
uv_wind
=
uv_wind
.
values
wspd
,
wdir
=
spd_dir_from_uv
(
uv_wind
[
0
,
:,
:],
uv_wind
[
1
,
:,
:])
wspd
,
wdir
=
spd_dir_from_uv
(
uv_wind
[
0
,
:,
:],
uv_wind
[
1
,
:,
:])
wspd
=
wspd
.
magnitude
wspd
=
wspd
.
magnitude
...
@@ -1138,7 +1141,8 @@ def compare_amvs_bestfit(amvs_list, bfs_list, bin_size=200):
...
@@ -1138,7 +1141,8 @@ def compare_amvs_bestfit(amvs_list, bfs_list, bin_size=200):
def
make_plot
():
def
make_plot
():
f
=
open
(
'
/Users/tomrink/amv_raob.pkl
'
,
'
rb
'
)
# f = open('/Users/tomrink/amv_raob.pkl', 'rb')
f
=
open
(
'
/Users/tomrink/bf_bf_gfs.pkl
'
,
'
rb
'
)
tup_r
=
pickle
.
load
(
f
)
tup_r
=
pickle
.
load
(
f
)
f
.
close
()
f
.
close
()
...
@@ -1187,6 +1191,8 @@ def make_plot():
...
@@ -1187,6 +1191,8 @@ def make_plot():
spd_mad_g
.
append
(
np
.
average
(
np
.
abs
(
bin_spd_g
[
i
])))
spd_mad_g
.
append
(
np
.
average
(
np
.
abs
(
bin_spd_g
[
i
])))
spd_bias_g
.
append
(
np
.
average
(
bin_spd_g
[
i
]))
spd_bias_g
.
append
(
np
.
average
(
bin_spd_g
[
i
]))
#do_plot(x_values, [pres_mad_r], ['LBF'], ['blue'], title='RAOB-BFS', x_axis_label='MAD', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [pres_mad_r, pres_mad_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='MAD', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [pres_mad_r, pres_mad_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='MAD', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [spd_mad_r, spd_mad_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='MAE (m/s)', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [spd_mad_r, spd_mad_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='MAE (m/s)', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [pres_bias_r, pres_bias_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='BIAS', y_axis_label='hPa', invert=True, flip=True)
#do_plot(x_values, [pres_bias_r, pres_bias_g], ['RAOB', 'GFS'], ['blue', 'red'], title='ACHA - BestFit', x_axis_label='BIAS', y_axis_label='hPa', invert=True, flip=True)
...
...
This diff is collapsed.
Click to expand it.
modules/amv/intercompare.py
+
2
−
1
View file @
4c72d54d
...
@@ -17,6 +17,7 @@ from util.util import minimize_quadratic
...
@@ -17,6 +17,7 @@ from util.util import minimize_quadratic
from
netCDF4
import
Dataset
from
netCDF4
import
Dataset
import
datetime
import
datetime
from
datetime
import
timezone
from
datetime
import
timezone
from
util.util
import
SpatialEarth2D
#-- AMV intercompare stuff ------------------------------------------
#-- AMV intercompare stuff ------------------------------------------
...
@@ -223,7 +224,7 @@ def get_raob_dict_cdf(pathname):
...
@@ -223,7 +224,7 @@ def get_raob_dict_cdf(pathname):
raob
=
np
.
stack
([
all_levs
.
_data
,
all_temp
.
_data
,
all_spd
.
_data
,
all_dir
.
_data
],
axis
=
1
)
raob
=
np
.
stack
([
all_levs
.
_data
,
all_temp
.
_data
,
all_spd
.
_data
,
all_dir
.
_data
],
axis
=
1
)
raob_dct
[
(
lat
,
lon
)]
=
raob
raob_dct
[
SpatialEarth2D
(
lat
=
lat
,
lon
=
lon
)]
=
raob
rtgrp
.
close
()
rtgrp
.
close
()
...
...
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