Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MVCM
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Paolo Veglio
MVCM
Commits
d1b0a835
Commit
d1b0a835
authored
2 years ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
Confidence tests added. started working on tests for spectral tests
parent
ef950757
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_conf.py
+56
-0
56 additions, 0 deletions
tests/test_conf.py
tests/test_spectral_tests.py
+44
-0
44 additions, 0 deletions
tests/test_spectral_tests.py
with
100 additions
and
0 deletions
tests/test_conf.py
0 → 100644
+
56
−
0
View file @
d1b0a835
import
os
import
numpy
as
np
import
pytest
import
mvcm.conf
as
conf
@pytest.fixture
def
fixturepath
():
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
fixtures
'
)
@pytest.fixture
def
rad
():
return
np
.
arange
(
260
,
282
)
@pytest.fixture
def
single_threshold
():
return
[
267
,
270
,
273
,
1
]
@pytest.fixture
def
double_threshold
():
return
[
264
,
267
,
270
,
273
,
276
,
279
,
1
]
@pytest.fixture
def
reference_data
(
fixturepath
):
return
os
.
path
.
join
(
fixturepath
,
'
ref_conf.npz
'
)
def
test_single_threshold
(
rad
,
single_threshold
,
reference_data
):
ref_confidence
=
np
.
load
(
reference_data
)[
'
ref_sgl
'
]
ref_confidence_flipped
=
np
.
load
(
reference_data
)[
'
ref_sgl_flipped
'
]
c
=
conf
.
conf_test_new
(
rad
,
single_threshold
)
assert
np
.
all
(
c
==
ref_confidence
)
single_threshold
[
0
:
-
1
]
=
single_threshold
[
-
2
::
-
1
]
c
=
conf
.
conf_test_new
(
rad
,
single_threshold
)
assert
np
.
all
(
c
==
ref_confidence_flipped
)
def
test_double_threshold
(
rad
,
double_threshold
,
reference_data
):
ref_confidence
=
np
.
load
(
reference_data
)[
'
ref_dbl
'
]
ref_confidence_flipped
=
np
.
load
(
reference_data
)[
'
ref_dbl_flipped
'
]
c
=
conf
.
conf_test_dble
(
rad
,
double_threshold
)
print
(
c
)
assert
np
.
all
(
c
==
ref_confidence
)
double_threshold
[
0
:
-
1
]
=
double_threshold
[
-
2
::
-
1
]
c
=
conf
.
conf_test_dble
(
rad
,
double_threshold
)
assert
np
.
all
(
c
==
ref_confidence_flipped
)
This diff is collapsed.
Click to expand it.
tests/test_spectral_tests.py
0 → 100644
+
44
−
0
View file @
d1b0a835
import
os
import
yaml
import
xarray
as
xr
import
numpy
as
np
import
pytest
import
mvcm.spectral_tests
as
tst
@pytest.fixture
def
fixturepath
():
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
fixtures
'
)
@pytest.fixture
def
thresholds_file
(
fixturepath
):
return
os
.
path
.
join
(
fixturepath
,
'
thresholds.mvcm.snpp.v0.0.1.yaml
'
)
@pytest.fixture
def
data_path
():
return
'
/ships19/hercules/pveglio/mvcm_cleanup
'
@pytest.fixture
def
data_file
(
data_path
):
return
os
.
path
.
join
(
data_path
,
'
viirs_data_A2022173.1312.nc
'
)
def
test_11um_test
(
data_file
,
thresholds_file
):
with
open
(
thresholds_file
,
'
r
'
)
as
f
:
cfg_text
=
f
.
read
()
thresholds
=
yaml
.
safe_load
(
cfg_text
)
viirs_data
=
xr
.
open_dataset
(
data_file
)
cmin
=
np
.
ones
(
viirs_data
.
latitude
.
shape
)
for
scene_name
in
[
'
Ocean_Day
'
,
'
Ocean_Night
'
,
'
Polar_Day_Ocean
'
,
'
Polar_Night_Ocean
'
]:
SceneType
=
tst
.
CloudTests
(
data
=
viirs_data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
test_11um
(
'
M15
'
,
cmin
)
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