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
e6ebcedf
Commit
e6ebcedf
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
only read the values we need
parent
e0958869
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
+70
-1
70 additions, 1 deletion
modules/util/util.py
with
70 additions
and
1 deletion
modules/util/util.py
+
70
−
1
View file @
e6ebcedf
...
@@ -411,6 +411,75 @@ def get_cartopy_crs(satellite, domain):
...
@@ -411,6 +411,75 @@ def get_cartopy_crs(satellite, domain):
return
geos
,
xlen
,
xmin
,
xmax
,
ylen
,
ymin
,
ymax
return
geos
,
xlen
,
xmin
,
xmax
,
ylen
,
ymin
,
ymax
def
get_grid_values
(
h5f
,
grid_name
,
j_c
,
i_c
,
half_width
,
num_j
=
None
,
num_i
=
None
,
scale_factor_name
=
'
scale_factor
'
,
add_offset_name
=
'
add_offset
'
,
fill_value_name
=
'
_FillValue
'
,
range_name
=
'
actual_range
'
,
fill_value
=
None
):
hfds
=
h5f
[
grid_name
]
attrs
=
hfds
.
attrs
if
attrs
is
None
:
raise
GenericException
(
'
No attributes object for:
'
+
grid_name
)
ylen
,
xlen
=
hfds
.
shape
if
half_width
is
not
None
:
j_l
=
j_c
-
half_width
i_l
=
i_c
-
half_width
if
j_l
<
0
or
i_l
<
0
:
return
None
j_r
=
j_c
+
half_width
+
1
i_r
=
i_c
+
half_width
+
1
if
j_r
>=
ylen
or
i_r
>=
xlen
:
return
None
else
:
j_l
=
j_c
j_r
=
j_c
+
num_j
+
1
i_l
=
i_c
i_r
=
i_c
+
num_i
+
1
grd_vals
=
hfds
[
j_l
:
j_r
,
i_l
:
i_r
]
if
fill_value
is
not
None
:
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
if
scale_factor_name
is
not
None
:
attr
=
attrs
.
get
(
scale_factor_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
scale_factor_name
+
'
not found for dataset:
'
+
grid_name
)
if
np
.
isscalar
(
attr
):
scale_factor
=
attr
else
:
scale_factor
=
attr
[
0
]
grd_vals
=
grd_vals
*
scale_factor
if
add_offset_name
is
not
None
:
attr
=
attrs
.
get
(
add_offset_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
add_offset_name
+
'
not found for dataset:
'
+
grid_name
)
if
np
.
isscalar
(
attr
):
add_offset
=
attr
else
:
add_offset
=
attr
[
0
]
grd_vals
=
grd_vals
+
add_offset
if
range_name
is
not
None
:
attr
=
attrs
.
get
(
range_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
range_name
+
'
not found for dataset:
'
+
grid_name
)
low
=
attr
[
0
]
high
=
attr
[
1
]
grd_vals
=
np
.
where
(
grd_vals
<
low
,
np
.
nan
,
grd_vals
)
grd_vals
=
np
.
where
(
grd_vals
>
high
,
np
.
nan
,
grd_vals
)
elif
fill_value_name
is
not
None
:
attr
=
attrs
.
get
(
fill_value_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
fill_value_name
+
'
not found for dataset:
'
+
grid_name
)
if
np
.
isscalar
(
attr
):
fill_value
=
attr
else
:
fill_value
=
attr
[
0
]
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
return
grd_vals
# Example GOES file to retrieve GEOS parameters in MetPy form (CONUS)
# Example GOES file to retrieve GEOS parameters in MetPy form (CONUS)
exmp_file_conus
=
'
/Users/tomrink/data/OR_ABI-L1b-RadC-M6C14_G16_s20193140811215_e20193140813588_c20193140814070.nc
'
exmp_file_conus
=
'
/Users/tomrink/data/OR_ABI-L1b-RadC-M6C14_G16_s20193140811215_e20193140813588_c20193140814070.nc
'
# Full Disk
# Full Disk
...
@@ -460,7 +529,7 @@ def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain
...
@@ -460,7 +529,7 @@ def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain
cnt_a
=
0
cnt_a
=
0
for
didx
,
ds_name
in
enumerate
(
name_list
):
for
didx
,
ds_name
in
enumerate
(
name_list
):
gvals
=
get_grid_values
_all
(
h5f
,
ds_name
,
j_0
,
i_0
,
None
,
num_j
=
ylen
,
num_i
=
xlen
)
gvals
=
get_grid_values
(
h5f
,
ds_name
,
j_0
,
i_0
,
None
,
num_j
=
ylen
,
num_i
=
xlen
)
if
gvals
is
not
None
:
if
gvals
is
not
None
:
grd_dct
[
ds_name
]
=
gvals
grd_dct
[
ds_name
]
=
gvals
cnt_a
+=
1
cnt_a
+=
1
...
...
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