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
819c6a8b
Commit
819c6a8b
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
b36c2816
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/util.py
+25
-5
25 additions, 5 deletions
modules/util/util.py
with
25 additions
and
5 deletions
modules/util/util.py
+
25
−
5
View file @
819c6a8b
...
@@ -513,6 +513,7 @@ taiwain_extent = [-3342, -502, 1470, 3510] # GEOS coordinates, not line, elem
...
@@ -513,6 +513,7 @@ taiwain_extent = [-3342, -502, 1470, 3510] # GEOS coordinates, not line, elem
# ------------ This code will not be needed when we implement a Fully Connected CNN -----------------------------------
# ------------ This code will not be needed when we implement a Fully Connected CNN -----------------------------------
# Generate and return tiles of name_list parameters
def
make_for_full_domain_predict
(
h5f
,
name_list
=
None
,
satellite
=
'
GOES16
'
,
domain
=
'
FD
'
):
def
make_for_full_domain_predict
(
h5f
,
name_list
=
None
,
satellite
=
'
GOES16
'
,
domain
=
'
FD
'
):
w_x
=
16
w_x
=
16
w_y
=
16
w_y
=
16
...
@@ -560,6 +561,29 @@ def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain
...
@@ -560,6 +561,29 @@ def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain
grd_dct
[
ds_name
]
=
np
.
stack
(
grd_dct_n
[
ds_name
])
grd_dct
[
ds_name
]
=
np
.
stack
(
grd_dct_n
[
ds_name
])
return
grd_dct
,
ll
,
cc
return
grd_dct
,
ll
,
cc
def
make_for_full_domain_predict2
(
h5f
,
satellite
=
'
GOES16
'
,
domain
=
'
FD
'
):
w_x
=
16
w_y
=
16
i_0
=
0
j_0
=
0
s_x
=
w_x
s_y
=
w_y
geos
,
xlen
,
xmin
,
xmax
,
ylen
,
ymin
,
ymax
=
get_cartopy_crs
(
satellite
,
domain
)
if
satellite
==
'
H08
'
:
xlen
=
taiwan_lenx
ylen
=
taiwan_leny
i_0
=
taiwan_i0
j_0
=
taiwan_j0
solzen
=
get_grid_values
(
h5f
,
'
solar_zenith_angle
'
,
j_0
,
i_0
,
num_j
=
ylen
,
num_i
=
xlen
)
satzen
=
get_grid_values
(
h5f
,
'
sensor_zenith_angle
'
,
j_0
,
i_0
,
num_j
=
ylen
,
num_i
=
xlen
)
solzen
=
solzen
[
0
:
ylen
:
s_y
,
0
:
xlen
:
s_x
]
satzen
=
satzen
[
0
:
ylen
:
s_y
,
0
:
xlen
:
s_x
]
return
solzen
,
satzen
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
...
@@ -571,7 +595,7 @@ flt_level_ranges_str[3] = '6000_8000'
...
@@ -571,7 +595,7 @@ flt_level_ranges_str[3] = '6000_8000'
flt_level_ranges_str
[
4
]
=
'
8000_15000
'
flt_level_ranges_str
[
4
]
=
'
8000_15000
'
def
write_icing_file
(
clvrx_str_time
,
output_dir
,
preds_dct
,
probs_dct
,
x
,
y
,
lons
,
lats
,
lat_range
=
[
-
63.0
,
63.0
]
):
def
write_icing_file
(
clvrx_str_time
,
output_dir
,
preds_dct
,
probs_dct
,
x
,
y
,
lons
,
lats
):
outfile_name
=
output_dir
+
'
icing_prediction_
'
+
clvrx_str_time
+
'
.h5
'
outfile_name
=
output_dir
+
'
icing_prediction_
'
+
clvrx_str_time
+
'
.h5
'
h5f_out
=
h5py
.
File
(
outfile_name
,
'
w
'
)
h5f_out
=
h5py
.
File
(
outfile_name
,
'
w
'
)
...
@@ -581,8 +605,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon
...
@@ -581,8 +605,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon
flt_lvls
=
list
(
preds_dct
.
keys
())
flt_lvls
=
list
(
preds_dct
.
keys
())
for
flvl
in
flt_lvls
:
for
flvl
in
flt_lvls
:
preds
=
preds_dct
[
flvl
]
preds
=
preds_dct
[
flvl
]
keep
=
np
.
logical_or
(
lats
<
lat_range
[
0
],
lats
>
lat_range
[
1
])
np
.
where
(
keep
,
preds
,
-
1
)
icing_pred_ds
=
h5f_out
.
create_dataset
(
'
icing_prediction_level_
'
+
flt_level_ranges_str
[
flvl
],
data
=
preds
,
dtype
=
'
i2
'
)
icing_pred_ds
=
h5f_out
.
create_dataset
(
'
icing_prediction_level_
'
+
flt_level_ranges_str
[
flvl
],
data
=
preds
,
dtype
=
'
i2
'
)
icing_pred_ds
.
attrs
.
create
(
'
coordinates
'
,
data
=
'
y x
'
)
icing_pred_ds
.
attrs
.
create
(
'
coordinates
'
,
data
=
'
y x
'
)
icing_pred_ds
.
attrs
.
create
(
'
grid_mapping
'
,
data
=
'
Projection
'
)
icing_pred_ds
.
attrs
.
create
(
'
grid_mapping
'
,
data
=
'
Projection
'
)
...
@@ -592,8 +614,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon
...
@@ -592,8 +614,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon
for
flvl
in
flt_lvls
:
for
flvl
in
flt_lvls
:
probs
=
probs_dct
[
flvl
]
probs
=
probs_dct
[
flvl
]
keep
=
np
.
logical_or
(
lats
<
lat_range
[
0
],
lats
>
lat_range
[
1
])
np
.
where
(
keep
,
probs
,
-
1.0
)
icing_prob_ds
=
h5f_out
.
create_dataset
(
'
icing_probability_level_
'
+
flt_level_ranges_str
[
flvl
],
data
=
probs
,
dtype
=
'
f4
'
)
icing_prob_ds
=
h5f_out
.
create_dataset
(
'
icing_probability_level_
'
+
flt_level_ranges_str
[
flvl
],
data
=
probs
,
dtype
=
'
f4
'
)
icing_prob_ds
.
attrs
.
create
(
'
coordinates
'
,
data
=
'
y x
'
)
icing_prob_ds
.
attrs
.
create
(
'
coordinates
'
,
data
=
'
y x
'
)
icing_prob_ds
.
attrs
.
create
(
'
grid_mapping
'
,
data
=
'
Projection
'
)
icing_prob_ds
.
attrs
.
create
(
'
grid_mapping
'
,
data
=
'
Projection
'
)
...
...
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