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
98910f2e
Commit
98910f2e
authored
4 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
13a5e714
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/acspo_validate.py
+18
-28
18 additions, 28 deletions
modules/util/acspo_validate.py
with
18 additions
and
28 deletions
modules/util/acspo_validate.py
+
18
−
28
View file @
98910f2e
...
...
@@ -5,7 +5,7 @@ import xarray as xr
from
util.util
import
get_grid_values_all
def
acspo_validate
(
oper_file
,
cspp_file
,
rel_tol
=
0.0
1
,
deg_tol
=
0.0002
,
outfile_nc
=
None
):
def
acspo_validate
(
oper_file
,
cspp_file
,
rel_tol
=
0.0
05
,
deg_tol
=
0.0002
,
outfile_nc
=
None
):
h5f_oper
=
h5py
.
File
(
oper_file
,
'
r
'
)
h5f_cspp
=
h5py
.
File
(
cspp_file
,
'
r
'
)
...
...
@@ -13,49 +13,41 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
lon_cspp
=
get_grid_values_all
(
h5f_cspp
,
'
lon
'
)
lat_cspp
=
get_grid_values_all
(
h5f_cspp
,
'
lat
'
)
if
np
.
any
(
np
.
isnan
(
lat_cspp
))
or
np
.
any
(
np
.
isnan
(
lon_cspp
)):
print
(
'
Invalid lat
'
)
print
(
'
Missing CSPP lat or lon
'
)
return
if
np
.
min
(
lat_cspp
)
<
-
90
or
np
.
max
(
lat_cspp
)
>
90
:
print
(
'
Invalid lat
'
)
print
(
'
Invalid CSPP lat
'
)
return
if
np
.
min
(
lon_cspp
)
<
-
180
or
np
.
max
(
lon_cspp
)
>
180
:
print
(
'
Invalid lon
'
)
# ----* Investigate: CSPP and OPER time values don't seem to ever match *-------------------
# dtime_cspp = get_grid_values_all(h5f_cspp, 'sst_dtime')[0, ]
# ref_time_cspp = get_grid_values_all(h5f_cspp, 'time')[0]
print
(
'
cspp shape:
'
,
lat_cspp
.
shape
)
print
(
'
Invalid CSPP lon
'
)
return
cspp_track_len
=
lat_cspp
.
shape
[
0
]
c_idx
=
lat_cspp
.
shape
[
1
]
//
2
print
(
'
cspp shape:
'
,
lat_cspp
.
shape
)
cntr_lon_cspp
=
lon_cspp
[:,
c_idx
]
cntr_lat_cspp
=
lat_cspp
[:,
c_idx
]
# cntr_dtime_cspp = dtime_cspp[::16, c_idx]
sst_cspp
=
get_grid_values_all
(
h5f_cspp
,
'
sea_surface_temperature
'
)[
0
,
]
l2p_flags_cspp
=
get_grid_values_all
(
h5f_cspp
,
'
l2p_flags
'
)[
0
,
]
lon_oper
=
get_grid_values_all
(
h5f_oper
,
'
lon
'
)
lat_oper
=
get_grid_values_all
(
h5f_oper
,
'
lat
'
)
if
np
.
any
(
np
.
isnan
(
lat_cspp
))
or
np
.
any
(
np
.
isnan
(
lon_cspp
)):
print
(
'
Invalid lat
'
)
print
(
'
Missing OPER lon or lat
'
)
return
if
np
.
min
(
lat_cspp
)
<
-
90
or
np
.
max
(
lat_cspp
)
>
90
:
print
(
'
Invalid lat
'
)
print
(
'
Invalid OPER lat
'
)
return
if
np
.
min
(
lon_cspp
)
<
-
180
or
np
.
max
(
lon_cspp
)
>
180
:
print
(
'
Invalid lon
'
)
print
(
'
Invalid OPER lon
'
)
return
# --* See note above on issue with time *-------------------------------------
# dtime_oper = get_grid_values_all(h5f_oper, 'sst_dtime')[0, ]
# ref_time_oper = get_grid_values_all(h5f_oper, 'time')[0]
cntr_lon_oper
=
lon_oper
[:,
c_idx
]
cntr_lat_oper
=
lat_oper
[:,
c_idx
]
# cntr_dtime_oper = dtime_oper[::16, c_idx]
print
(
'
oper shape:
'
,
lat_oper
.
shape
)
oper_track_len
=
lat_oper
.
shape
[
0
]
sst_oper
=
get_grid_values_all
(
h5f_oper
,
'
sea_surface_temperature
'
)[
0
,
]
l2p_flags_oper
=
get_grid_values_all
(
h5f_oper
,
'
l2p_flags
'
)[
0
,
]
# cntr_time_cspp = cntr_dtime_cspp + ref_time_cspp
# cntr_time_oper = cntr_dtime_oper + ref_time_oper
# generate a ndarray of boolean, True: clear or probably clear
cspp_clear
=
(
l2p_flags_cspp
&
(
1
<<
15
))
==
0
oper_clear
=
(
l2p_flags_oper
&
(
1
<<
15
))
==
0
...
...
@@ -64,7 +56,7 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
start_idx_oper
,
stop_idx_oper
=
-
1
,
-
1
start_idx_cspp
,
stop_idx_cspp
=
-
1
,
-
1
# Average latitude spacing: 0.00652 deg
# Average latitude spacing: 0.00652 deg
(VIIRS M-band)
for
k
in
range
(
len
(
cntr_lat_oper
)):
diff
=
np
.
abs
(
cntr_lat_oper
[
k
]
-
cntr_lat_cspp
)
...
...
@@ -76,8 +68,8 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
start_idx_cspp
=
idx_a
[
0
]
break
else
:
print
(
"
weirdness
"
)
b
re
ak
print
(
"
weirdness
: two close points found
"
)
re
turn
if
start_idx_oper
<
0
:
print
(
"
no overlap found
"
)
...
...
@@ -147,8 +139,6 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
h5f_oper
.
close
()
h5f_cspp
.
close
()
return
sst_cspp_2d
,
sst_oper_2d
def
analyze_plot
():
import
h5py
...
...
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