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
333d189c
Commit
333d189c
authored
4 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
53e8ba23
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/amv/intercompare.py
+25
-22
25 additions, 22 deletions
modules/amv/intercompare.py
with
25 additions
and
22 deletions
modules/amv/intercompare.py
+
25
−
22
View file @
333d189c
...
@@ -419,25 +419,22 @@ def run_best_fit(amvs, raob_dct, dist_threshold=200, min_num_levs=20):
...
@@ -419,25 +419,22 @@ def run_best_fit(amvs, raob_dct, dist_threshold=200, min_num_levs=20):
for
j
in
range
(
num_amvs
):
for
j
in
range
(
num_amvs
):
tup
=
raob_nbor_dct
[
j
]
tup
=
raob_nbor_dct
[
j
]
if
tup
is
not
None
:
if
tup
is
not
None
:
cnt
+=
1
nbor_keys
=
tup
[
0
]
nbor_keys
=
tup
[
0
]
nbor_dsts
=
tup
[
1
]
nbor_dsts
=
tup
[
1
]
s_i
=
np
.
argsort
(
nbor_dsts
).
tolist
()
last_dist
=
dist_threshold
for
k
in
range
(
len
(
nbor_keys
)):
keep_raob
=
None
dist
=
nbor_dsts
[
s_i
[
k
]]
for
k
,
ll_tup
in
enumerate
(
nbor_keys
):
ll_tup
=
nbor_keys
[
s_i
[
k
]]
dist
=
nbor_dsts
[
k
]
raob
=
raob_dct
.
get
(
ll_tup
)
raob
=
raob_dct
.
get
(
ll_tup
)
if
raob
.
shape
[
0
]
<
min_num_levs
:
if
raob
.
shape
[
0
]
<
min_num_levs
:
continue
continue
if
dist
<
last_dist
:
last_dist
=
dist
keep_raob
=
raob
if
keep_raob
is
not
None
:
rspd
=
raob
[:,
raob_spd_idx
]
rspd
=
keep_raob
[:,
raob_spd_idx
]
rdir
=
raob
[:,
raob_dir_idx
]
rdir
=
keep_raob
[:,
raob_dir_idx
]
rprs
=
raob
[:,
raob_pres_idx
]
rprs
=
keep_raob
[:,
raob_pres_idx
]
aspd
=
amvs
[
j
,
amv_spd_idx
]
aspd
=
amvs
[
j
,
amv_spd_idx
]
adir
=
amvs
[
j
,
amv_dir_idx
]
adir
=
amvs
[
j
,
amv_dir_idx
]
...
@@ -445,9 +442,11 @@ def run_best_fit(amvs, raob_dct, dist_threshold=200, min_num_levs=20):
...
@@ -445,9 +442,11 @@ def run_best_fit(amvs, raob_dct, dist_threshold=200, min_num_levs=20):
alat
=
amvs
[
j
,
amv_lat_idx
]
alat
=
amvs
[
j
,
amv_lat_idx
]
alon
=
amvs
[
j
,
amv_lon_idx
]
alon
=
amvs
[
j
,
amv_lon_idx
]
bf
=
best_fit
(
aspd
,
adir
,
aprs
,
alat
,
alon
,
rspd
,
rdir
,
rprs
)
bf
=
best_fit
(
aspd
,
adir
,
aprs
,
alat
,
alon
,
rspd
,
rdir
,
rprs
,
verbose
=
True
)
bf
=
(
j
,
bf
[
0
],
bf
[
1
],
bf
[
2
],
bf
[
3
])
bf
=
(
j
,
bf
[
0
],
bf
[
1
],
bf
[
2
],
bf
[
3
])
bestfits
.
append
(
bf
)
if
bf
[
4
]
==
0
:
bestfits
.
append
(
bf
)
break
return
bestfits
return
bestfits
...
@@ -954,8 +953,10 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
...
@@ -954,8 +953,10 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
SatwindGoodConstraint
=
1
SatwindGoodConstraint
=
1
flag
=
0
flag
=
0
# Check for overall good agreement
# Check for overall good agreement
vdiff
=
np
.
sqrt
((
amv_uwind
-
SatwindBestFitU
)
**
2
+
(
amv_vwind
-
SatwindBestFitV
)
**
2
)
#vdiff = np.sqrt((amv_uwind - SatwindBestFitU) ** 2 + (amv_vwind - SatwindBestFitV) ** 2)
if
vdiff
>
4.0
:
vdiff
=
np
.
sqrt
((
fcst_uwind
-
SatwindBestFitU
)
**
2
+
(
fcst_vwind
-
SatwindBestFitV
)
**
2
)
min_vdiff
=
min
(
vdiff
)
if
min_vdiff
>
4.0
:
SatwindGoodConstraint
=
0
SatwindGoodConstraint
=
0
flag
=
2
flag
=
2
...
@@ -963,7 +964,8 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
...
@@ -963,7 +964,8 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
if
SatwindGoodConstraint
==
1
:
if
SatwindGoodConstraint
==
1
:
mm
=
np
.
where
(
fcst_prs
>
(
SatwindBestFitPress
+
100
))[
0
]
mm
=
np
.
where
(
fcst_prs
>
(
SatwindBestFitPress
+
100
))[
0
]
nn
=
np
.
where
(
fcst_prs
<
(
SatwindBestFitPress
-
100
))[
0
]
nn
=
np
.
where
(
fcst_prs
<
(
SatwindBestFitPress
-
100
))[
0
]
if
(
np
.
sum
(
VecDiff
[
mm
]
<
(
vdiff
+
2.0
))
+
np
.
sum
(
VecDiff
[
nn
]
<
(
vdiff
+
2.0
)))
>
0
:
#if (np.sum(VecDiff[mm] < (vdiff + 2.0)) + np.sum(VecDiff[nn] < (vdiff + 2.0))) > 0:
if
(
np
.
sum
(
vdiff
[
mm
]
<
(
min_vdiff
+
2.0
))
+
np
.
sum
(
vdiff
[
nn
]
<
(
min_vdiff
+
2.0
)))
>
0
:
SatwindGoodConstraint
=
0
SatwindGoodConstraint
=
0
flag
=
1
flag
=
1
...
@@ -977,7 +979,7 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
...
@@ -977,7 +979,7 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
bfit_v
=
undef
bfit_v
=
undef
if
verbose
:
if
verbose
:
print
(
'
*** AMV best-fit ***
'
)
print
(
'
*** AMV best-fit
******************************
***
'
)
print
(
'
AMV -> p/minspd/maxspd: {0} {1} {2}
'
.
format
(
amv_prs
,
SatwindMinSpeed
,
SatwindMaxSpeed
))
print
(
'
AMV -> p/minspd/maxspd: {0} {1} {2}
'
.
format
(
amv_prs
,
SatwindMinSpeed
,
SatwindMaxSpeed
))
# print('Bestfit -> p1,p2,p3,v1,v2,v3: {0} {1} {2} {3} {4} {5}'.format(p1,p2,p3,v1,v2,v3))
# print('Bestfit -> p1,p2,p3,v1,v2,v3: {0} {1} {2} {3} {4} {5}'.format(p1,p2,p3,v1,v2,v3))
print
(
'
Bestfit -> pbest,bfu,bfv,amvu,amvv,bgu,bgv: {0} {1} {2} {3} {4} {5} {6}
'
.
format
(
print
(
'
Bestfit -> pbest,bfu,bfv,amvu,amvv,bgu,bgv: {0} {1} {2} {3} {4} {5} {6}
'
.
format
(
...
@@ -985,7 +987,7 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
...
@@ -985,7 +987,7 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc
print
(
'
Good Constraint: {0}
'
.
format
(
SatwindGoodConstraint
))
print
(
'
Good Constraint: {0}
'
.
format
(
SatwindGoodConstraint
))
print
(
'
Minimum Vector Difference: {0}
'
.
format
(
VecDiff
[
imin
]))
print
(
'
Minimum Vector Difference: {0}
'
.
format
(
VecDiff
[
imin
]))
print
(
'
Vector Difference Profile:
'
)
print
(
'
Vector Difference Profile:
'
)
print
(
VecD
iff
)
print
(
vd
iff
)
print
(
'
Pressure Profile:
'
)
print
(
'
Pressure Profile:
'
)
print
(
fcst_prs
)
print
(
fcst_prs
)
...
@@ -1090,8 +1092,9 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
...
@@ -1090,8 +1092,9 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
good_constraint
=
1
good_constraint
=
1
flag
=
0
flag
=
0
# Check for overall good agreement: want vdiff less than 4 m/s
# Check for overall good agreement: want vdiff less than 4 m/s
vdiff
=
np
.
sqrt
((
amv_uwind
-
sat_wind_best_fit_u
)
**
2
+
(
amv_vwind
-
sat_wind_best_fit_v
)
**
2
)
vdiff
=
np
.
sqrt
((
fcst_uwind
-
sat_wind_best_fit_u
)
**
2
+
(
fcst_vwind
-
sat_wind_best_fit_v
)
**
2
)
if
vdiff
>
4.0
:
min_vdiff
=
min
(
vdiff
)
if
min_vdiff
>
4.0
:
good_constraint
=
0
good_constraint
=
0
flag
=
2
flag
=
2
...
@@ -1099,7 +1102,7 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
...
@@ -1099,7 +1102,7 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
if
good_constraint
==
1
:
if
good_constraint
==
1
:
mm
=
np
.
where
(
fcst_alt
>
(
sat_wind_best_fit_alt
+
constraint_half_width
))[
0
]
mm
=
np
.
where
(
fcst_alt
>
(
sat_wind_best_fit_alt
+
constraint_half_width
))[
0
]
nn
=
np
.
where
(
fcst_alt
<
(
sat_wind_best_fit_alt
-
constraint_half_width
))[
0
]
nn
=
np
.
where
(
fcst_alt
<
(
sat_wind_best_fit_alt
-
constraint_half_width
))[
0
]
if
(
np
.
sum
(
v
ec_
diff
[
mm
]
<
(
vdiff
+
2.0
))
+
np
.
sum
(
v
ec_
diff
[
nn
]
<
(
vdiff
+
2.0
)))
>
0
:
if
(
np
.
sum
(
vdiff
[
mm
]
<
(
min_
vdiff
+
2.0
))
+
np
.
sum
(
vdiff
[
nn
]
<
(
min_
vdiff
+
2.0
)))
>
0
:
good_constraint
=
0
good_constraint
=
0
flag
=
1
flag
=
1
...
@@ -1117,7 +1120,7 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
...
@@ -1117,7 +1120,7 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs
print
(
'
Good Constraint: {0}
'
.
format
(
good_constraint
))
print
(
'
Good Constraint: {0}
'
.
format
(
good_constraint
))
print
(
'
Minimum Vector Difference: {0}
'
.
format
(
vec_diff
[
imin
]))
print
(
'
Minimum Vector Difference: {0}
'
.
format
(
vec_diff
[
imin
]))
print
(
'
Vector Difference Profile:
'
)
print
(
'
Vector Difference Profile:
'
)
print
(
v
ec_
diff
)
print
(
vdiff
)
print
(
'
Altitude Profile:
'
)
print
(
'
Altitude Profile:
'
)
print
(
fcst_alt
)
print
(
fcst_alt
)
...
...
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