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
0b2349b8
Commit
0b2349b8
authored
1 year ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
8b46fd60
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/util/infer_cloud_fraction.py
+17
-8
17 additions, 8 deletions
modules/util/infer_cloud_fraction.py
with
17 additions
and
8 deletions
modules/util/infer_cloud_fraction.py
+
17
−
8
View file @
0b2349b8
from
util.geos_nav
import
get_navigation
from
util.geos_nav
import
get_navigation
from
util.setup_cloud_
fraction
import
model_path
from
util.setup_cloud_
products
import
model_path
_cld_frac
,
model_path_cld_opd
from
aeolus.datasource
import
CLAVRx
from
aeolus.datasource
import
CLAVRx
import
os
import
os
from
deeplearning.cloud_fraction_fcn_abi
import
SRCNN
from
deeplearning.cloud_fraction_fcn_abi
import
SRCNN
as
SRCNN_CLD_FRAC
from
deeplearning.cloud_opd_fcn_abi
import
SRCNN
as
SRCNN_CLD_OPD
from
util.util
import
get_cartopy_crs
,
write_cld_frac_file_nc4
from
util.util
import
get_cartopy_crs
,
write_cld_frac_file_nc4
import
numpy
as
np
import
numpy
as
np
import
time
import
time
...
@@ -10,8 +11,11 @@ import time
...
@@ -10,8 +11,11 @@ import time
def
infer_cloud_fraction
(
clvrx_path
,
output_dir
,
full_disk
=
True
,
satellite
=
'
GOES16
'
,
domain
=
'
FD
'
,
pattern
=
None
):
def
infer_cloud_fraction
(
clvrx_path
,
output_dir
,
full_disk
=
True
,
satellite
=
'
GOES16
'
,
domain
=
'
FD
'
,
pattern
=
None
):
# -- location of the trained model
# -- location of the trained model
ckpt_dir_s
=
os
.
listdir
(
model_path
)
ckpt_dir_s
=
os
.
listdir
(
model_path_cld_frac
)
ckpt_dir
=
model_path
+
ckpt_dir_s
[
0
]
ckpt_dir_cld_frac
=
model_path_cld_frac
+
ckpt_dir_s
[
0
]
ckpt_dir_s
=
os
.
listdir
(
model_path_cld_opd
)
ckpt_dir_cld_opd
=
model_path_cld_opd
+
ckpt_dir_s
[
0
]
# -- Navigation parameters
# -- Navigation parameters
geos
,
xlen
,
xmin
,
xmax
,
ylen
,
ymin
,
ymax
=
get_cartopy_crs
(
satellite
,
domain
)
geos
,
xlen
,
xmin
,
xmax
,
ylen
,
ymin
,
ymax
=
get_cartopy_crs
(
satellite
,
domain
)
...
@@ -22,8 +26,11 @@ def infer_cloud_fraction(clvrx_path, output_dir, full_disk=True, satellite='GOES
...
@@ -22,8 +26,11 @@ def infer_cloud_fraction(clvrx_path, output_dir, full_disk=True, satellite='GOES
y_rad
=
ll
*
nav
.
LFAC
+
nav
.
LOFF
y_rad
=
ll
*
nav
.
LFAC
+
nav
.
LOFF
# -- Create a model instance and initialize with trained model above
# -- Create a model instance and initialize with trained model above
nn
=
SRCNN
()
nn_cld_frac
=
SRCNN_CLD_FRAC
()
nn
.
setup_inference
(
ckpt_dir
)
nn_cld_frac
.
setup_inference
(
ckpt_dir_cld_frac
)
nn_cld_opd
=
SRCNN_CLD_OPD
()
nn_cld_opd
.
setup_inference
(
ckpt_dir_cld_opd
)
if
pattern
is
not
None
:
if
pattern
is
not
None
:
clvrx_ds
=
CLAVRx
(
clvrx_path
,
pattern
=
pattern
)
clvrx_ds
=
CLAVRx
(
clvrx_path
,
pattern
=
pattern
)
...
@@ -36,9 +43,11 @@ def infer_cloud_fraction(clvrx_path, output_dir, full_disk=True, satellite='GOES
...
@@ -36,9 +43,11 @@ def infer_cloud_fraction(clvrx_path, output_dir, full_disk=True, satellite='GOES
t0
=
time
.
time
()
t0
=
time
.
time
()
if
full_disk
:
if
full_disk
:
cld_frac
=
nn
.
run_inference_full_disk
(
pname
,
None
)
cld_frac
=
nn_cld_frac
.
run_inference_full_disk
(
pname
,
None
)
cld_opd
=
nn_cld_opd
.
run_inference_full_disk
(
pname
,
None
)
else
:
else
:
cld_frac
=
nn
.
run_inference
(
pname
,
None
)
cld_frac
=
nn_cld_frac
.
run_inference
(
pname
,
None
)
cld_opd
=
nn_cld_opd
.
run_inference
(
pname
,
None
)
write_cld_frac_file_nc4
(
clvrx_str_time
,
out_file
,
cld_frac
,
x_rad
,
y_rad
,
None
,
None
,
write_cld_frac_file_nc4
(
clvrx_str_time
,
out_file
,
cld_frac
,
x_rad
,
y_rad
,
None
,
None
,
satellite
=
satellite
,
domain
=
domain
,
has_time
=
True
)
satellite
=
satellite
,
domain
=
domain
,
has_time
=
True
)
...
...
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