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
221e4294
Commit
221e4294
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
new method 'check_oblique', improved get_grid_values_all
parent
cf5b3d46
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/util/util.py
+37
-9
37 additions, 9 deletions
modules/util/util.py
with
37 additions
and
9 deletions
modules/util/util.py
+
37
−
9
View file @
221e4294
...
...
@@ -205,24 +205,52 @@ def is_night(solzen, test_angle=100.0):
return
True
def
get_grid_values_all
(
h5f
,
grid_name
,
scale_factor_name
=
'
scale_factor
'
,
add_offset_name
=
'
add_offset
'
):
def
check_oblique
(
satzen
,
test_angle
=
70.0
):
satzen
=
satzen
.
flatten
()
satzen
=
satzen
[
np
.
invert
(
np
.
isnan
(
satzen
))]
if
len
(
satzen
)
==
0
or
np
.
sum
(
satzen
>=
test_angle
)
<
len
(
satzen
):
return
False
else
:
return
True
def
get_grid_values_all
(
h5f
,
grid_name
,
scale_factor_name
=
'
scale_factor
'
,
add_offset_name
=
'
add_offset
'
,
fill_value_name
=
'
_FillValue
'
,
range_name
=
'
actual_range
'
):
hfds
=
h5f
[
grid_name
]
attrs
=
hfds
.
attrs
grd_vals
=
hfds
[:,:]
grd_vals
=
np
.
where
(
grd_vals
==
-
999
,
np
.
nan
,
grd_vals
)
grd_vals
=
np
.
where
(
grd_vals
==
-
127
,
np
.
nan
,
grd_vals
)
grd_vals
=
np
.
where
(
grd_vals
==
-
32768
,
np
.
nan
,
grd_vals
)
if
attrs
is
None
:
return
grd_vals
raise
GenericException
(
'
No attributes object for:
'
+
grid_name
)
grd_vals
=
hfds
[:,]
if
scale_factor_name
is
not
None
:
scale_factor
=
attrs
.
get
(
scale_factor_name
)[
0
]
attr
=
attrs
.
get
(
scale_factor_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
scale_factor_name
+
'
not found for variable:
'
+
grid_name
)
scale_factor
=
attr
[
0
]
grd_vals
=
grd_vals
*
scale_factor
if
add_offset_name
is
not
None
:
add_offset
=
attrs
.
get
(
add_offset_name
)[
0
]
attr
=
attrs
.
get
(
add_offset_name
)
if
attr
is
None
:
raise
GenericException
(
'
Attribute:
'
+
add_offset_name
+
'
not found for variable:
'
+
grid_name
)
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 variable:
'
+
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 variable:
'
+
grid_name
)
fill_value
=
attr
[
0
]
grd_vals
=
np
.
where
(
grd_vals
==
fill_value
,
np
.
nan
,
grd_vals
)
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