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
0c70c961
Commit
0c70c961
authored
1 year ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
488f4d81
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/deeplearning/cloud_opd_fcn_abi.py
+34
-32
34 additions, 32 deletions
modules/deeplearning/cloud_opd_fcn_abi.py
with
34 additions
and
32 deletions
modules/deeplearning/cloud_opd_fcn_abi.py
+
34
−
32
View file @
0c70c961
...
...
@@ -852,21 +852,20 @@ class SRCNN:
refl_lo
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_min_sub
'
)
refl_hi
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_max_sub
'
)
refl_std
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_stddev_sub
'
)
cp
=
get_grid_values_all
(
h5f
,
label_param
)
# lons = get_grid_values_all(h5f, 'longitude')
# lats = get_grid_values_all(h5f, 'latitude')
cp
=
get_grid_values_all
(
h5f
,
'
cloud_probability
'
)
opd
=
get_grid_values_all
(
h5f
,
label_param
)
cld_frac
=
self
.
run_inference_
(
bt
,
refl
,
refl_lo
,
refl_hi
,
refl_std
,
cp
)
cld
y
_frac
_opd
=
self
.
run_inference_
(
bt
,
refl
,
refl_lo
,
refl_hi
,
refl_std
,
cp
,
opd
)
cld_frac_out
=
np
.
zeros
((
y_len
,
x_len
),
dtype
=
np
.
int8
)
cld
y
_frac_
opd_
out
=
np
.
zeros
((
y_len
,
x_len
),
dtype
=
np
.
int8
)
border
=
int
((
KERNEL_SIZE
-
1
)
/
2
)
cld_frac_out
[
border
:
y_len
-
border
,
border
:
x_len
-
border
]
=
cld_frac
[
0
,
:,
:]
cld
y
_frac_
opd_
out
[
border
:
y_len
-
border
,
border
:
x_len
-
border
]
=
cld
y
_frac
_opd
[
0
,
:,
:]
# Use this hack for now.
off_earth
=
(
bt
<=
161.0
)
night
=
np
.
isnan
(
refl
)
cld_frac_out
[
off_earth
]
=
-
1
cld_frac_out
[
np
.
invert
(
off_earth
)
&
night
]
=
-
1
cld
y
_frac_
opd_
out
[
off_earth
]
=
-
1
cld
y
_frac_
opd_
out
[
np
.
invert
(
off_earth
)
&
night
]
=
-
1
# --- Make a DataArray ----------------------------------------------------
# var_names = ['cloud_fraction', 'temp_11_0um', 'refl_0_65um']
...
...
@@ -882,10 +881,10 @@ class SRCNN:
h5f
.
close
()
if
out_file
is
not
None
:
np
.
save
(
out_file
,
(
cld_frac_out
,
bt
,
refl
,
cp
))
np
.
save
(
out_file
,
(
cld
y
_frac_
opd_
out
,
bt
,
refl
,
cp
))
else
:
# return [cld_frac_out, bt, refl, cp, lons, lats]
return
cld_frac_out
return
cld
y
_frac_
opd_
out
def
run_inference_full_disk
(
self
,
in_file
,
out_file
):
gc
.
collect
()
...
...
@@ -900,7 +899,8 @@ class SRCNN:
refl_lo
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_min_sub
'
)
refl_hi
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_max_sub
'
)
refl_std
=
get_grid_values_all
(
h5f
,
'
refl_0_65um_nom_stddev_sub
'
)
cp
=
get_grid_values_all
(
h5f
,
label_param
)
cp
=
get_grid_values_all
(
h5f
,
'
cloud_probability
'
)
opd
=
get_grid_values_all
(
h5f
,
label_param
)
t1
=
time
.
time
()
print
(
'
read time:
'
,
(
t1
-
t0
))
...
...
@@ -910,6 +910,7 @@ class SRCNN:
refl_hi_nh
=
refl_hi
[
0
:
h_y_len
+
1
,
:]
refl_std_nh
=
refl_std
[
0
:
h_y_len
+
1
,
:]
cp_nh
=
cp
[
0
:
h_y_len
+
1
,
:]
opd_nh
=
opd
[
0
:
h_y_len
+
1
,
:]
bt_sh
=
bt
[
h_y_len
-
1
:
y_len
,
:]
refl_sh
=
refl
[
h_y_len
-
1
:
y_len
,
:]
...
...
@@ -917,23 +918,24 @@ class SRCNN:
refl_hi_sh
=
refl_hi
[
h_y_len
-
1
:
y_len
,
:]
refl_std_sh
=
refl_std
[
h_y_len
-
1
:
y_len
,
:]
cp_sh
=
cp
[
h_y_len
-
1
:
y_len
,
:]
opd_sh
=
opd
[
h_y_len
-
1
:
y_len
,
:]
t0
=
time
.
time
()
cld_frac_nh
=
self
.
run_inference_
(
bt_nh
,
refl_nh
,
refl_lo_nh
,
refl_hi_nh
,
refl_std_nh
,
cp_nh
)
cld_frac_sh
=
self
.
run_inference_
(
bt_sh
,
refl_sh
,
refl_lo_sh
,
refl_hi_sh
,
refl_std_sh
,
cp_sh
)
cld
y
_frac_
opd_
nh
=
self
.
run_inference_
(
bt_nh
,
refl_nh
,
refl_lo_nh
,
refl_hi_nh
,
refl_std_nh
,
cp_nh
,
opd_nh
)
cld
y
_frac_
opd_
sh
=
self
.
run_inference_
(
bt_sh
,
refl_sh
,
refl_lo_sh
,
refl_hi_sh
,
refl_std_sh
,
cp_sh
,
opd_sh
)
t1
=
time
.
time
()
print
(
'
inference time:
'
,
(
t1
-
t0
))
cld_frac_out
=
np
.
zeros
((
y_len
,
x_len
),
dtype
=
np
.
int8
)
cld
y
_frac_
opd_
out
=
np
.
zeros
((
y_len
,
x_len
),
dtype
=
np
.
int8
)
border
=
int
((
KERNEL_SIZE
-
1
)
/
2
)
cld_frac_out
[
border
:
h_y_len
,
border
:
x_len
-
border
]
=
cld_frac_nh
[
0
,
:,
:]
cld_frac_out
[
h_y_len
:
y_len
-
border
,
border
:
x_len
-
border
]
=
cld_frac_sh
[
0
,
:,
:]
cld
y
_frac_
opd_
out
[
border
:
h_y_len
,
border
:
x_len
-
border
]
=
cld
y
_frac_
opd_
nh
[
0
,
:,
:]
cld
y
_frac_
opd_
out
[
h_y_len
:
y_len
-
border
,
border
:
x_len
-
border
]
=
cld
y
_frac_
opd_
sh
[
0
,
:,
:]
# Use this hack for now.
off_earth
=
(
bt
<=
161.0
)
night
=
np
.
isnan
(
refl
)
cld_frac_out
[
off_earth
]
=
-
1
cld_frac_out
[
np
.
invert
(
off_earth
)
&
night
]
=
-
1
cld
y
_frac_
opd_
out
[
off_earth
]
=
-
1
cld
y
_frac_
opd_
out
[
np
.
invert
(
off_earth
)
&
night
]
=
-
1
# --- Make DataArray -------------------------------------------------
# var_names = ['cloud_fraction', 'temp_11_0um', 'refl_0_65um']
...
...
@@ -949,26 +951,26 @@ class SRCNN:
h5f
.
close
()
if
out_file
is
not
None
:
np
.
save
(
out_file
,
(
cld_frac_out
,
bt
,
refl
,
cp
))
np
.
save
(
out_file
,
(
cld
y
_frac_
opd_
out
,
bt
,
refl
,
cp
))
else
:
# return [cld_frac_out, bt, refl, cp, lons, lats]
return
cld_frac_out
def
run_inference_
(
self
,
bt
,
refl
,
refl_lo
,
refl_hi
,
refl_std
,
cp
):
bt
=
normalize
(
bt
,
'
temp_11_0um_nom
'
,
mean_std_dct
)
refl
=
normalize
(
refl
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_lo
=
normalize
(
refl_lo
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_hi
=
normalize
(
refl_hi
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_std
=
np
.
where
(
np
.
isnan
(
refl_std
),
0
,
refl_std
)
return
cldy_frac_opd_out
def
run_inference_
(
self
,
bt
,
refl
,
refl_lo
,
refl_hi
,
refl_std
,
cp
,
opd
):
bt
=
scale
(
bt
,
'
temp_11_0um_nom
'
,
mean_std_dct
)
refl
=
scale
(
refl
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_lo
=
scale
(
refl_lo
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_hi
=
scale
(
refl_hi
,
'
refl_0_65um_nom
'
,
mean_std_dct
)
refl_rng
=
refl_hi
-
refl_lo
refl_std
=
scale2
(
refl_std
,
0.0
,
30.0
)
cp
=
np
.
where
(
np
.
isnan
(
cp
),
0
,
cp
)
opd
=
scale
(
opd
,
label_param
,
mean_std_dct
)
data
=
np
.
stack
([
bt
,
refl
,
refl
_lo
,
refl_
hi
,
refl_std
,
cp
],
axis
=
2
)
data
=
np
.
stack
([
bt
,
cp
,
refl
,
refl_
rng
,
refl_std
,
opd
],
axis
=
2
)
data
=
np
.
expand_dims
(
data
,
axis
=
0
)
probs
=
self
.
do_inference
(
data
)
cld_frac
=
probs
.
argmax
(
axis
=
3
)
cld_frac
=
cld_frac
.
astype
(
np
.
int8
)
opd
=
self
.
do_inference
(
data
)
return
cld_frac
return
opd
def
run_restore_static
(
directory
,
ckpt_dir
,
out_file
=
None
):
...
...
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