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
0d83dbd4
Commit
0d83dbd4
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
check on unscaled first in get_grid_values
parent
5e53a9e5
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
+20
-17
20 additions, 17 deletions
modules/util/util.py
with
20 additions
and
17 deletions
modules/util/util.py
+
20
−
17
View file @
0d83dbd4
...
...
@@ -496,7 +496,7 @@ def get_cartopy_crs(satellite, domain):
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
):
fill_value_name
=
'
_FillValue
'
,
valid_range_name
=
'
valid_range
'
,
actual_
range_name
=
'
actual_range
'
,
fill_value
=
None
):
hfds
=
h5f
[
grid_name
]
attrs
=
hfds
.
attrs
if
attrs
is
None
:
...
...
@@ -522,9 +522,25 @@ def get_grid_values(h5f, grid_name, j_c, i_c, half_width, num_j=None, num_i=None
grd_vals
=
hfds
[
j_l
:
j_r
,
i_l
:
i_r
]
if
fill_value
is
not
None
:
if
fill_value_name
is
not
None
:
attr
=
attrs
.
get
(
fill_value_name
)
if
attr
is
not
None
:
if
np
.
isscalar
(
attr
):
fill_value
=
attr
else
:
fill_value
=
attr
[
0
]
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
elif
fill_value
is
not
None
:
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
if
valid_range_name
is
not
None
:
attr
=
attrs
.
get
(
valid_range_name
)
if
attr
is
not
None
:
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
)
if
scale_factor_name
is
not
None
:
attr
=
attrs
.
get
(
scale_factor_name
)
if
attr
is
not
None
:
...
...
@@ -547,26 +563,13 @@ def get_grid_values(h5f, grid_name, j_c, i_c, half_width, num_j=None, num_i=None
else
:
print
(
'
Attribute:
'
+
add_offset_name
+
'
not found for dataset:
'
+
grid_name
)
if
range_name
is
not
None
:
attr
=
attrs
.
get
(
range_name
)
if
actual_
range_name
is
not
None
:
attr
=
attrs
.
get
(
actual_
range_name
)
if
attr
is
not
None
:
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
)
else
:
print
(
'
Attribute:
'
+
range_name
+
'
not found for dataset:
'
+
grid_name
)
elif
fill_value_name
is
not
None
:
attr
=
attrs
.
get
(
fill_value_name
)
if
attr
is
not
None
:
if
np
.
isscalar
(
attr
):
fill_value
=
attr
else
:
fill_value
=
attr
[
0
]
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
else
:
print
(
'
Attribute:
'
+
fill_value_name
+
'
not found for dataset:
'
+
grid_name
)
return
grd_vals
...
...
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