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
b5b2d983
"aosstower/git@gitlab.ssec.wisc.edu:metobs/AossTower.git" did not exist on "79ed4ba46b1f86e9e0385581f2e97a8b2dd83409"
Commit
b5b2d983
authored
10 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
0a25baaf
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/icing/util.py
+27
-46
27 additions, 46 deletions
modules/icing/util.py
with
27 additions
and
46 deletions
modules/icing/util.py
+
27
−
46
View file @
b5b2d983
...
@@ -359,14 +359,14 @@ def prepare_evaluate1x1(h5f, name_list, satellite='GOES16', domain='FD', res_fac
...
@@ -359,14 +359,14 @@ def prepare_evaluate1x1(h5f, name_list, satellite='GOES16', domain='FD', res_fac
ll
=
[(
offset
+
j_0
)
+
j
*
s_y
for
j
in
range
(
n_y
)]
ll
=
[(
offset
+
j_0
)
+
j
*
s_y
for
j
in
range
(
n_y
)]
cc
=
[(
offset
+
i_0
)
+
i
*
s_x
for
i
in
range
(
n_x
)]
cc
=
[(
offset
+
i_0
)
+
i
*
s_x
for
i
in
range
(
n_x
)]
grd_
dct_n
=
{
name
:
[]
for
name
in
name_list
}
grd_
s
=
[]
cnt_a
=
0
cnt_a
=
0
for
ds_name
in
name_list
:
for
ds_name
in
name_list
:
fill_value
,
fill_value_name
=
get_fill_attrs
(
ds_name
)
fill_value
,
fill_value_name
=
get_fill_attrs
(
ds_name
)
gvals
=
get_grid_values
(
h5f
,
ds_name
,
j_0
,
i_0
,
None
,
num_j
=
ylen
,
num_i
=
xlen
,
fill_value_name
=
fill_value_name
,
fill_value
=
fill_value
)
gvals
=
get_grid_values
(
h5f
,
ds_name
,
j_0
,
i_0
,
None
,
num_j
=
ylen
,
num_i
=
xlen
,
fill_value_name
=
fill_value_name
,
fill_value
=
fill_value
)
if
gvals
is
not
None
:
if
gvals
is
not
None
:
grd_
dct_n
[
ds_name
]
=
gvals
.
flatten
()
grd_
s
.
append
(
gvals
.
flatten
()
)
cnt_a
+=
1
cnt_a
+=
1
if
cnt_a
>
0
and
cnt_a
!=
len
(
name_list
):
if
cnt_a
>
0
and
cnt_a
!=
len
(
name_list
):
...
@@ -379,7 +379,9 @@ def prepare_evaluate1x1(h5f, name_list, satellite='GOES16', domain='FD', res_fac
...
@@ -379,7 +379,9 @@ def prepare_evaluate1x1(h5f, name_list, satellite='GOES16', domain='FD', res_fac
satzen
=
satzen
[
0
:
n_y
*
s_y
:
s_y
,
0
:
n_x
*
s_x
:
s_x
]
satzen
=
satzen
[
0
:
n_y
*
s_y
:
s_y
,
0
:
n_x
*
s_x
:
s_x
]
cldmsk
=
cldmsk
[
0
:
n_y
*
s_y
:
s_y
,
0
:
n_x
*
s_x
:
s_x
]
cldmsk
=
cldmsk
[
0
:
n_y
*
s_y
:
s_y
,
0
:
n_x
*
s_x
:
s_x
]
return
grd_dct_n
,
solzen
.
flatten
(),
satzen
.
flatten
(),
cldmsk
.
flatten
(),
ll
,
cc
varX
=
np
.
stack
(
grd_s
,
axis
=
1
)
return
varX
,
solzen
.
flatten
(),
satzen
.
flatten
(),
cldmsk
.
flatten
(),
ll
,
cc
flt_level_ranges_str
=
{
k
:
None
for
k
in
range
(
6
)}
flt_level_ranges_str
=
{
k
:
None
for
k
in
range
(
6
)}
...
@@ -1492,8 +1494,10 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
...
@@ -1492,8 +1494,10 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
# use_flight_altitude=use_flight_altitude)
# use_flight_altitude=use_flight_altitude)
# load parameter stats and model from disk
# load parameter stats and model from disk
stdSclr
=
joblib
.
load
(
'
/home/rink/stdSclr_4.pkl
'
)
stdSclr_day
=
joblib
.
load
(
'
/home/rink/stdSclr_4_day.pkl
'
)
model
=
joblib
.
load
(
'
/home/rink/icing_gbm.pkl
'
)
day_model
=
joblib
.
load
(
'
/home/rink/icing_gbm_day.pkl
'
)
stdSclr_nght
=
joblib
.
load
(
'
/home/rink/stdSclr_4_nght.pkl
'
)
nght_model
=
joblib
.
load
(
'
/home/rink/icing_gbm_nght.pkl
'
)
if
use_flight_altitude
is
True
:
if
use_flight_altitude
is
True
:
flight_levels
=
[
0
,
1
,
2
,
3
,
4
]
flight_levels
=
[
0
,
1
,
2
,
3
,
4
]
...
@@ -1518,7 +1522,8 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
...
@@ -1518,7 +1522,8 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
# train_params = day_train_params
# train_params = day_train_params
# elif day_night == 'NIGHT':
# elif day_night == 'NIGHT':
# train_params = nght_train_params
# train_params = nght_train_params
train_params
=
[
'
cld_temp_acha
'
,
'
supercooled_cloud_fraction
'
,
'
cld_reff_dcomp
'
,
'
cld_opd_dcomp
'
]
day_train_params
=
[
'
cld_temp_acha
'
,
'
supercooled_cloud_fraction
'
,
'
cld_reff_dcomp
'
,
'
cld_opd_dcomp
'
]
nght_train_params
=
[
'
cld_temp_acha
'
,
'
supercooled_cloud_fraction
'
,
'
cld_reff_acha
'
,
'
cld_opd_acha
'
]
if
satellite
==
'
H08
'
:
if
satellite
==
'
H08
'
:
clvrx_ds
=
CLAVRx_H08
(
clvrx_dir
)
clvrx_ds
=
CLAVRx_H08
(
clvrx_dir
)
...
@@ -1551,62 +1556,38 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
...
@@ -1551,62 +1556,38 @@ def run_icing_predict_image_1x1(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ou
keep_lons
=
None
keep_lons
=
None
keep_lats
=
None
keep_lats
=
None
data_dct
,
solzen
,
satzen
,
cldmsk
,
ll
,
cc
=
prepare_evaluate1x1
(
h5f
,
name_list
=
train_params
,
satellite
=
satellite
,
domain
=
domain
,
offset
=
8
)
varX_day
,
solzen
,
satzen
,
cldmsk
,
ll
,
cc
=
prepare_evaluate1x1
(
h5f
,
name_list
=
day_train_params
,
satellite
=
satellite
,
domain
=
domain
,
offset
=
8
)
varX_ngth
,
solzen
,
satzen
,
cldmsk
,
ll
,
cc
=
prepare_evaluate1x1
(
h5f
,
name_list
=
nght_train_params
,
satellite
=
satellite
,
domain
=
domain
,
offset
=
8
)
num_elems
=
len
(
cc
)
num_elems
=
len
(
cc
)
num_lines
=
len
(
ll
)
num_lines
=
len
(
ll
)
day_idxs
=
solzen
<
80.0
day_idxs
=
solzen
<
80.0
day_idxs
=
day_idxs
.
flatten
()
num_day_tiles
=
np
.
sum
(
day_idxs
)
num_day_tiles
=
np
.
sum
(
day_idxs
)
nght_idxs
=
solzen
>
100.0
nght_idxs
=
solzen
>
100.0
nght_idxs
=
nght_idxs
.
flatten
()
num_nght_tiles
=
np
.
sum
(
nght_idxs
)
num_nght_tiles
=
np
.
sum
(
nght_idxs
)
# initialize output arrays
cldy_idxs
=
cldmsk
>=
2
probs_2d_dct
=
{
flvl
:
None
for
flvl
in
flight_levels
}
num_cldy_tiles
=
np
.
sum
(
cldy_idxs
)
preds_2d_dct
=
{
flvl
:
None
for
flvl
in
flight_levels
}
for
flvl
in
flight_levels
:
fd_preds
=
np
.
zeros
(
num_lines
*
num_elems
,
dtype
=
np
.
int8
)
fd_preds
=
np
.
zeros
(
num_lines
*
num_elems
,
dtype
=
np
.
int8
)
fd_probs
=
np
.
zeros
(
num_lines
*
num_elems
,
dtype
=
np
.
float32
)
fd_preds
[:]
=
-
1
fd_preds
[:]
=
-
1
fd_probs
=
np
.
zeros
(
num_lines
*
num_elems
,
dtype
=
np
.
float32
)
fd_probs
[:]
=
-
1.0
fd_probs
[:]
=
-
1.0
preds_2d_dct
[
flvl
]
=
fd_preds
probs_2d_dct
[
flvl
]
=
fd_probs
if
(
day_night
==
'
AUTO
'
or
day_night
==
'
DAY
'
)
and
num_day_tiles
>
0
:
if
(
day_night
==
'
AUTO
'
or
day_night
==
'
DAY
'
)
and
num_day_tiles
>
0
:
for
flvl
in
flight_levels
:
varX_std
=
stdSclr_day
.
transform
(
varX_day
)
preds
=
preds_day_dct
[
flvl
].
flatten
()
probs
=
day_model
.
predict_proba
(
varX_std
)
probs
=
probs_day_dct
[
flvl
].
flatten
()
fd_probs
[:]
=
probs
[
day_idxs
]
fd_preds
=
preds_2d_dct
[
flvl
]
fd_probs
=
probs_2d_dct
[
flvl
]
fd_preds
[
day_idxs
]
=
preds
[
day_idxs
]
fd_probs
[
day_idxs
]
=
probs
[
day_idxs
]
if
(
day_night
==
'
AUTO
'
or
day_night
==
'
NIGHT
'
)
and
num_nght_tiles
>
0
:
if
(
day_night
==
'
AUTO
'
or
day_night
==
'
NIGHT
'
)
and
num_nght_tiles
>
0
:
for
flvl
in
flight_levels
:
varX_std
=
stdSclr_nght
.
transform
(
varX_ngth
)
preds
=
preds_nght_dct
[
flvl
].
flatten
()
probs
=
nght_model
.
predict_proba
(
varX_std
)
probs
=
probs_nght_dct
[
flvl
].
flatten
()
fd_probs
[:]
=
probs
[
nght_idxs
]
fd_preds
=
preds_2d_dct
[
flvl
]
fd_probs
=
probs_2d_dct
[
flvl
]
fd_preds
[
nght_idxs
]
=
preds
[
nght_idxs
]
fd_probs
[
nght_idxs
]
=
probs
[
nght_idxs
]
for
flvl
in
flight_levels
:
max_prob
=
fd_probs
.
reshape
((
num_lines
,
num_elems
))
fd_preds
=
preds_2d_dct
[
flvl
]
fd_probs
=
probs_2d_dct
[
flvl
]
preds_2d_dct
[
flvl
]
=
fd_preds
.
reshape
((
num_lines
,
num_elems
))
probs_2d_dct
[
flvl
]
=
fd_probs
.
reshape
((
num_lines
,
num_elems
))
prob_s
=
[]
for
flvl
in
flight_levels
:
probs
=
probs_2d_dct
[
flvl
]
prob_s
.
append
(
probs
)
prob_s
=
np
.
stack
(
prob_s
,
axis
=-
1
)
max_prob
=
np
.
max
(
prob_s
,
axis
=
2
)
max_prob
=
np
.
where
(
max_prob
<
0.5
,
np
.
nan
,
max_prob
)
make_icing_image
(
h5f
,
max_prob
,
None
,
None
,
clvrx_str_time
,
satellite
,
domain
,
make_icing_image
(
h5f
,
max_prob
,
None
,
None
,
clvrx_str_time
,
satellite
,
domain
,
ice_lons_vld
=
keep_lons
,
ice_lats_vld
=
keep_lats
,
extent
=
extent
)
ice_lons_vld
=
keep_lons
,
ice_lats_vld
=
keep_lats
,
extent
=
extent
)
...
...
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