Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MVCM
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
Paolo Veglio
MVCM
Commits
75e61e48
Commit
75e61e48
authored
1 year ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
added docstrings to test functions
parent
d957c5a1
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
tests/test_spectral_tests.py
+39
-42
39 additions, 42 deletions
tests/test_spectral_tests.py
with
39 additions
and
42 deletions
tests/test_spectral_tests.py
+
39
−
42
View file @
75e61e48
"""
Spectral tests.
"""
import
os
import
numpy
as
np
...
...
@@ -13,47 +14,56 @@ import mvcm.spectral_tests as tst
# CREATE PATHS
@pytest.fixture
def
fixturepath
():
"""
Get fixture path.
"""
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
fixtures
"
)
@pytest.fixture
def
data_path
():
"""
Get data path.
"""
return
"
/ships19/hercules/pveglio/mvcm_cleanup
"
# SET FILENAME FIXTURES
@pytest.fixture
def
thresholds_file
(
fixturepath
):
"""
Set thresholds file name.
"""
return
os
.
path
.
join
(
fixturepath
,
"
thresholds.mvcm.snpp.v0.0.1.yaml
"
)
@pytest.fixture
def
ref_confidence_file
(
data_path
):
"""
Set reference confidence file name.
"""
return
os
.
path
.
join
(
data_path
,
"
ref_confidence.nc
"
)
@pytest.fixture
def
data_file
(
data_path
):
"""
Set data file name.
"""
return
os
.
path
.
join
(
data_path
,
"
viirs_data_A2022173.1312.nc
"
)
# SET DATA FIXTURES
@pytest.fixture
def
thresholds
(
thresholds_file
):
"""
Load thresholds file.
"""
return
yaml
.
safe_load
(
open
(
thresholds_file
))
@pytest.fixture
def
data
(
data_file
):
"""
Load data.
"""
return
xr
.
open_dataset
(
data_file
)
@pytest.fixture
def
ref_confidence
(
ref_confidence_file
):
"""
Load reference data.
"""
return
xr
.
open_dataset
(
ref_confidence_file
)
def
test_11um_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test 11um_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
...
...
@@ -62,9 +72,7 @@ def test_11um_test(data, thresholds, ref_confidence):
"
Polar_Day_Ocean
"
,
"
Polar_Night_Ocean
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
test_11um
(
"
M15
"
,
cmin
)
...
...
@@ -72,12 +80,11 @@ def test_11um_test(data, thresholds, ref_confidence):
def
test_surface_temperature_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test surface_temperature_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Night
"
,
"
Polar_Night_Land
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
surface_temperature_test
(
"
M15
"
,
data
,
cmin
)
...
...
@@ -85,6 +92,7 @@ def test_surface_temperature_test(data, thresholds, ref_confidence):
def
test_sst_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test sst_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Ocean_Day
"
,
...
...
@@ -92,9 +100,7 @@ def test_sst_test(data, thresholds, ref_confidence):
"
Polar_Day_Ocean
"
,
"
Polar_Night_Ocean
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
sst_test
(
"
M15
"
,
"
M16
"
,
cmin
)
...
...
@@ -102,6 +108,7 @@ def test_sst_test(data, thresholds, ref_confidence):
def
test_bt_diff_86_11um
(
data
,
thresholds
,
ref_confidence
):
"""
Tet bt_diff_86_11um function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Ocean_Day
"
,
...
...
@@ -109,9 +116,7 @@ def test_bt_diff_86_11um(data, thresholds, ref_confidence):
"
Polar_Day_Ocean
"
,
"
Polar_Night_Ocean
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
bt_diff_86_11um
(
"
M14-M15
"
,
cmin
)
...
...
@@ -119,6 +124,7 @@ def test_bt_diff_86_11um(data, thresholds, ref_confidence):
def
test_11_12um_diff
(
data
,
thresholds
,
ref_confidence
):
"""
Test 11_12um_diff function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Day
"
,
...
...
@@ -140,9 +146,7 @@ def test_11_12um_diff(data, thresholds, ref_confidence):
"
Day_Snow
"
,
"
Night_Snow
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
test_11_12um_diff
(
"
M15-M16
"
,
cmin
)
...
...
@@ -150,19 +154,20 @@ def test_11_12um_diff(data, thresholds, ref_confidence):
def
test_bt_difference_11_4um_test_ocean
():
"""
Test bt_difference_11_4um_test_ocean function.
"""
pass
def
test_bt_difference_11_4um_test_land
():
"""
Test bt_difference_11_4um_test_land function.
"""
pass
def
test_variability_11um_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test variability_11um_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Polar_Day_Ocean
"
,
"
Polar_Night_Ocean
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
variability_11um_test
(
"
M15
"
,
cmin
)
...
...
@@ -170,6 +175,7 @@ def test_variability_11um_test(data, thresholds, ref_confidence):
def
test_oceanic_stratus_11_4um_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test oceanic_stratus_11_4um_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Day
"
,
...
...
@@ -185,9 +191,7 @@ def test_oceanic_stratus_11_4um_test(data, thresholds, ref_confidence):
"
Polar_Day_Ocean
"
,
"
Polar_Night_Ocean
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
oceanic_stratus_11_4um_test
(
"
M15-M12
"
,
cmin
)
...
...
@@ -195,11 +199,10 @@ def test_oceanic_stratus_11_4um_test(data, thresholds, ref_confidence):
def
test_nir_reflectance_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test nir_reflectance_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Ocean_Day
"
,
"
Polar_Day_Ocean
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
nir_reflectance_test
(
"
M07
"
,
cmin
)
...
...
@@ -207,11 +210,10 @@ def test_nir_reflectance_test(data, thresholds, ref_confidence):
def
test_vis_nir_ratio_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test vis_nir_ratio_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Ocean_Day
"
,
"
Polar_Day_Ocean
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
vis_nir_ratio_test
(
"
M07-M05ratio
"
,
cmin
)
...
...
@@ -219,11 +221,10 @@ def test_vis_nir_ratio_test(data, thresholds, ref_confidence):
def
test_16_21um_reflectance_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test 16_21um_reflectance_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Ocean_Day
"
,
"
Polar_Day_Ocean
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
test_16_21um_reflectance
(
"
M10
"
,
cmin
)
...
...
@@ -231,6 +232,7 @@ def test_16_21um_reflectance_test(data, thresholds, ref_confidence):
def
test_visible_reflectance_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test visible_reflectance_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Day
"
,
...
...
@@ -242,9 +244,7 @@ def test_visible_reflectance_test(data, thresholds, ref_confidence):
"
Polar_Day_Desert
"
,
"
Polar_Day_Desert_Coast
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
visible_reflectance_test
(
"
M128
"
,
cmin
)
...
...
@@ -252,11 +252,10 @@ def test_visible_reflectance_test(data, thresholds, ref_confidence):
def
test_GEMI_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test GEMI_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Day_Desert
"
,
"
Polar_Day_Desert
"
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
gemi_test
(
"
GEMI
"
,
cmin
)
...
...
@@ -264,6 +263,7 @@ def test_GEMI_test(data, thresholds, ref_confidence):
def
test_1_38um_high_clouds_test
(
data
,
thresholds
,
ref_confidence
):
"""
Test 1_38um_high_clouds_test function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Day
"
,
...
...
@@ -278,9 +278,7 @@ def test_1_38um_high_clouds_test(data, thresholds, ref_confidence):
"
Ocean_Day
"
,
"
Polar_Day_Ocean
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
test_1_38um_high_clouds
(
"
M09
"
,
cmin
)
...
...
@@ -288,6 +286,7 @@ def test_1_38um_high_clouds_test(data, thresholds, ref_confidence):
def
test_4_12um_thin_cirrus_btd
(
data
,
thresholds
,
ref_confidence
):
"""
Test 4_12um_thin_cirrus_btd function.
"""
cmin
=
np
.
ones
(
data
.
latitude
.
shape
)
for
scene_name
in
[
"
Land_Night
"
,
...
...
@@ -295,9 +294,7 @@ def test_4_12um_thin_cirrus_btd(data, thresholds, ref_confidence):
"
Polar_Night_Snow
"
,
"
Night_Snow
"
,
]:
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
SceneType
=
tst
.
CloudTests
(
data
=
data
,
scene_name
=
scene_name
,
thresholds
=
thresholds
)
cmin
,
bit
=
SceneType
.
thin_cirrus_4_12um_BTD_test
(
"
M13-M16
"
,
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