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
4627ba92
Commit
4627ba92
authored
4 years ago
by
rink
Browse files
Options
Downloads
Patches
Plain Diff
first crack best fit altitude coords
parent
24e8c721
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/intercompare.py
+73
-0
73 additions, 0 deletions
modules/amv/intercompare.py
with
73 additions
and
0 deletions
modules/amv/intercompare.py
+
73
−
0
View file @
4627ba92
...
...
@@ -1039,6 +1039,79 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
return
bf_data
def
best_fit_altitude
(
amv_spd
,
amv_dir
,
amv_alt
,
amv_lat
,
amv_lon
,
fcst_spd
,
fcst_dir
,
fcst_alt
,
test_a
=
True
,
test_b
=
True
):
verbose
=
False
fcst_num_levels
=
fcst_spd
.
shape
[
0
]
alt_diff
=
1000.0
alt_top
=
20000.0
alt_bot
=
0
flag
=
3
bf_tup
=
(
None
,
None
,
None
,
flag
)
if
amv_alt
>
alt_top
:
if
verbose
:
print
(
'
AMV location lat,lon,lat ({0},{1},{2}) is higher than max altitude {3}
'
.
format
(
amv_lat
,
amv_lon
,
amv_alt
,
alt_top
))
return
bf_tup
# Calculate the height +/- alt_diff from the AMV height
alt_max
=
min
((
amv_alt
+
alt_diff
),
alt_top
)
alt_min
=
max
((
amv_lat
-
alt_diff
),
alt_bot
)
# 1d array of indices to consider for best fit height
kk
=
np
.
where
((
fcst_alt
>
alt_min
)
&
(
fcst_alt
<
alt_max
))
if
len
(
kk
[
0
])
==
0
:
if
verbose
:
print
(
'
AMV location lat,lon,alt ({0},{1},{2}) failed to find fcst alt around AMV
'
.
format
(
amv_lat
,
amv_lon
,
amv_alt
))
return
bf_tup
# Diagnostic field: Find the model minimum speed and maximum speed within PressDiff of the AMV.
if
verbose
:
sat_wind_min_spd
=
min
(
fcst_spd
[
kk
])
sat_wind_max_spd
=
max
(
fcst_spd
[
kk
])
# Compute U anv V for both AMVs and forecast
amv_uwind
=
-
amv_spd
*
np
.
sin
((
np
.
pi
/
180.0
)
*
amv_dir
)
amv_vwind
=
-
amv_spd
*
np
.
cos
((
np
.
pi
/
180.0
)
*
amv_dir
)
fcst_uwind
=
-
fcst_spd
*
np
.
sin
((
np
.
pi
/
180.0
)
*
fcst_dir
)
fcst_vwind
=
-
fcst_spd
*
np
.
cos
((
np
.
pi
/
180.0
)
*
fcst_dir
)
# Calculate the vector difference between the AMV and model background at all levels.
vec_diff
=
np
.
sqrt
((
amv_uwind
-
fcst_uwind
)
**
2
+
(
amv_vwind
-
fcst_vwind
)
**
2
)
# Find the model level of best-fit pressure, from the minimum vector difference.
min_vec_diff
=
min
(
vec_diff
[
kk
])
imin
=
np
.
where
(
vec_diff
==
min_vec_diff
)
if
len
(
imin
[
0
])
==
0
:
if
verbose
:
print
(
'
AMV location lat,lon,alt ({0},{1},{2}) failed to find min vector difference in layers around AMV
'
.
format
(
amv_lat
,
amv_lon
,
amv_alt
))
return
bf_tup
imin
=
imin
[
0
][
0
]
imin
=
kk
[
0
][
imin
]
if
imin
==
fcst_num_levels
-
1
:
if
verbose
:
print
(
'
AMV location lat,lon,alt ({0},{1},{2}) failed to find min vector difference in layers around AMV
'
.
format
(
amv_lat
,
amv_lon
,
amv_alt
))
return
bf_tup
a2
=
fcst_alt
[
imin
]
v2
=
vec_diff
[
imin
]
if
imin
==
0
:
return
bf_tup
a2
=
fcst_alt
[
imin
]
v2
=
vec_diff
[
imin
]
a1
=
fcst_alt
[
imin
-
1
]
v2
=
vec_diff
[
imin
-
1
]
a3
=
fcst_alt
[
imin
+
1
]
v3
=
vec_diff
[
imin
+
1
]
return
bf_tup
def
get_press_bin_ranges
(
lop
,
hip
,
bin_size
=
100
):
bin_ranges
=
[]
delp
=
hip
-
lop
...
...
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