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
3325c933
Commit
3325c933
authored
6 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
b865ac43
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/acspo_validate.py
+18
-9
18 additions, 9 deletions
modules/util/acspo_validate.py
with
18 additions
and
9 deletions
modules/util/acspo_validate.py
+
18
−
9
View file @
3325c933
...
...
@@ -5,7 +5,7 @@ import xarray as xr
from
util.util
import
get_grid_values_all
def
acspo_validate
(
oper_file
,
cspp_file
,
outfile
=
None
):
def
acspo_validate
(
oper_file
,
cspp_file
,
outfile
_nc
=
None
):
h5f_oper
=
h5py
.
File
(
oper_file
,
'
r
'
)
h5f_cspp
=
h5py
.
File
(
cspp_file
,
'
r
'
)
...
...
@@ -29,8 +29,8 @@ def acspo_validate(oper_file, cspp_file, outfile=None):
l2p_flags_oper
=
get_grid_values_all
(
h5f_oper
,
'
l2p_flags
'
)[
0
,
]
# generate a ndarray of boolean
cspp_clear
=
(
l2p_flags_cspp
&
(
1
<<
15
))
!
=
0
oper_clear
=
(
l2p_flags_oper
&
(
1
<<
15
))
!
=
0
cspp_clear
=
(
l2p_flags_cspp
&
(
1
<<
15
))
=
=
0
oper_clear
=
(
l2p_flags_oper
&
(
1
<<
15
))
=
=
0
start_idx_oper
=
-
1
stop_idx_oper
=
-
1
...
...
@@ -54,16 +54,23 @@ def acspo_validate(oper_file, cspp_file, outfile=None):
lat_cspp
=
lat_cspp
[
start_idx_cspp
:
stop_idx_cspp
,
:]
lon_oper
=
lon_oper
[
start_idx_oper
:
stop_idx_oper
,
:]
lat_oper
=
lat_oper
[
start_idx_oper
:
stop_idx_oper
,
:]
cspp_clear
=
cspp_clear
[
start_idx_
oper
:
stop_idx_
oper
,
:]
cspp_clear
=
cspp_clear
[
start_idx_
cspp
:
stop_idx_
cspp
,
:]
oper_clear
=
oper_clear
[
start_idx_oper
:
stop_idx_oper
,
:]
overlap_shape
=
lon_cspp
.
shape
print
(
'
overlap shape, size:
'
,
overlap_shape
,
np
.
size
(
lon_cspp
))
# check lon/lat arrays
print
(
np
.
sum
(
np
.
isclose
(
lon_cspp
,
lon_oper
,
rtol
=
0.001
)))
print
(
np
.
sum
(
np
.
isclose
(
lat_cspp
,
lat_oper
,
rtol
=
0.001
)))
sst_cspp
=
sst_cspp
[
start_idx_cspp
:
stop_idx_cspp
,
:].
flatten
()
sst_oper
=
sst_oper
[
start_idx_oper
:
stop_idx_oper
,
:].
flatten
()
sst_cspp_2d
=
sst_cspp
[
start_idx_cspp
:
stop_idx_cspp
,
:]
sst_oper_2d
=
sst_oper
[
start_idx_oper
:
stop_idx_oper
,
:]
sst_cspp_2d
=
np
.
where
(
cspp_clear
,
sst_cspp_2d
,
np
.
nan
)
sst_oper_2d
=
np
.
where
(
oper_clear
,
sst_oper_2d
,
np
.
nan
)
sst_cspp
=
sst_cspp_2d
.
flatten
()
sst_oper
=
sst_oper_2d
.
flatten
()
oper_clear
=
oper_clear
.
flatten
()
cspp_clear
=
cspp_clear
.
flatten
()
both_clear
=
oper_clear
&
cspp_clear
...
...
@@ -95,12 +102,14 @@ def acspo_validate(oper_file, cspp_file, outfile=None):
'
oper_lat
'
:
xr
.
DataArray
([
valid_lat_oper
],
coords
=
None
,
dims
=
None
,
name
=
'
oper_lat
'
),
'
oper_lon
'
:
xr
.
DataArray
([
valid_lon_oper
],
coords
=
None
,
dims
=
None
,
name
=
'
oper_lon
'
),
})
if
outfile
is
not
None
:
xarray_data
.
to_netcdf
(
'
/Users/tomrink/
sst_values.
nc
'
)
if
outfile
_nc
is
not
None
:
xarray_data
.
to_netcdf
(
'
/Users/tomrink/
outfile_
nc
'
)
print
(
'
fraction approx equal:
'
,
np
.
sum
(
np
.
isclose
(
valid_sst_cspp
,
valid_sst_oper
,
rtol
=
0.001
))
/
np
.
sum
(
both_valid
))
# print(np.histogram((sst_cspp[both_valid] - sst_oper[both_valid]), bins=10))
h5f_oper
.
close
()
h5f_cspp
.
close
()
\ No newline at end of file
h5f_cspp
.
close
()
return
sst_cspp_2d
,
sst_oper_2d
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