Skip to content

Commit a170b8e

Browse files
test : Ipmlement test related to the differents coverages
1 parent a2524a2 commit a170b8e

File tree

1 file changed

+78
-37
lines changed

1 file changed

+78
-37
lines changed

satpy/tests/reader_tests/test_fci_l1c_nc.py

+78-37
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@
157157
"CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_"
158158
"20170410113925_20170410113934_N__C_0070_0067.nc"
159159
],
160-
"fdhsi_error": [
161-
"W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FDD--"
162-
"CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_"
163-
"20170410113925_20170410113934_N__C_0070_0067.nc"
164-
],
165160
"fdhsi_iqti": [
166161
"W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--"
167162
"CHK-BODY--MON-NC4_C_EUMT_20240307233956_IQTI_DEV_"
@@ -183,7 +178,14 @@
183178
],
184179
"hrfi_q4": ["W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-HRFI-Q4--"
185180
"CHK-BODY--DIS-NC4E_C_EUMT_20230723025408_IDPFI_DEV"
186-
"_20230722120000_20230722120027_N_JLS_C_0289_0001.nc"]
181+
"_20230722120000_20230722120027_N_JLS_C_0289_0001.nc"],
182+
"hrfi_other_coverage": ["W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-HRFI-xx--"
183+
"CHK-BODY--DIS-NC4E_C_EUMT_20230723025408_IDPFI_DEV"
184+
"_20230722120000_20230722120027_N_JLS_C_0289_0001.nc"],
185+
"fdhsi_other_coverage": ["W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-xx--"
186+
"CHK-BODY--DIS-NC4E_C_EUMT_20230723025408_IDPFI_DEV_"
187+
"20230722120000_20230722120027_N_JLS_C_0289_0001.nc"
188+
],
187189
}
188190

189191

@@ -607,29 +609,28 @@ def FakeFCIFileHandlerFDHSI_fixture():
607609

608610

609611
@pytest.fixture
610-
def FakeFCIFileHandlerFDHSIError_fixture():
611-
"""Get a fixture for the fake FDHSI filehandler, including channel and file names."""
612-
with mocked_basefilehandler(FakeFCIFileHandlerFDHSI):
612+
def FakeFCIFileHandlerFDHSIIQTI_fixture():
613+
"""Get a fixture for the fake FDHSI IQTI filehandler, including channel and file names."""
614+
with mocked_basefilehandler(FakeFCIFileHandlerFDHSIIQTI):
613615
param_dict = {
614616
"filetype": "fci_l1c_fdhsi",
615617
"channels": CHANS_FDHSI,
616-
"filenames": TEST_FILENAMES["fdhsi_error"]
618+
"filenames": TEST_FILENAMES["fdhsi_iqti"]
617619
}
618620
yield param_dict
619621

620622

621623
@pytest.fixture
622-
def FakeFCIFileHandlerFDHSIIQTI_fixture():
623-
"""Get a fixture for the fake FDHSI IQTI filehandler, including channel and file names."""
624-
with mocked_basefilehandler(FakeFCIFileHandlerFDHSIIQTI):
624+
def FakeFCIFileHandlerFDHSIOtherCoverage_fixture():
625+
"""Get a fixture for the fake FDHSI filehandler for coverages not defined, including channel and file names."""
626+
with mocked_basefilehandler(FakeFCIFileHandlerFDHSI):
625627
param_dict = {
626628
"filetype": "fci_l1c_fdhsi",
627629
"channels": CHANS_FDHSI,
628-
"filenames": TEST_FILENAMES["fdhsi_iqti"]
630+
"filenames": TEST_FILENAMES["fdhsi_other_coverage"]
629631
}
630632
yield param_dict
631633

632-
633634
@pytest.fixture
634635
def FakeFCIFileHandlerFDHSIQ4_fixture():
635636
"""Get a fixture for the fake FDHSI Q4 filehandler, including channel and file names."""
@@ -653,6 +654,16 @@ def FakeFCIFileHandlerHRFI_fixture():
653654
}
654655
yield param_dict
655656

657+
@pytest.fixture
658+
def FakeFCIFileHandlerHRFIOtherCoverage_fixture():
659+
"""Get a fixture for the fake HRFI filehandler for coverages not defined, including channel and file names."""
660+
with mocked_basefilehandler(FakeFCIFileHandlerHRFI):
661+
param_dict = {
662+
"filetype": "fci_l1c_hrfi",
663+
"channels": CHANS_HRFI,
664+
"filenames": TEST_FILENAMES["hrfi_other_coverage"]
665+
}
666+
yield param_dict
656667

657668
@pytest.fixture
658669
def FakeFCIFileHandlerHRFIIQTI_fixture():
@@ -709,7 +720,11 @@ class ModuleTestFCIL1cNcReader:
709720
"hrfi_iqti": {"channels": CHANS_HRFI,
710721
"filenames": TEST_FILENAMES["hrfi_iqti"]},
711722
"fdhsi_q4": {"channels": CHANS_FDHSI,
712-
"filenames": TEST_FILENAMES["fdhsi_q4"]}}
723+
"filenames": TEST_FILENAMES["fdhsi_q4"]},
724+
"fdhsi_other_coverage": {"channels": CHANS_FDHSI,
725+
"filenames": TEST_FILENAMES["fdhsi_other_coverage"]},
726+
"hrfi_other_coverage": {"channels": CHANS_HRFI,
727+
"filenames": TEST_FILENAMES["hrfi_other_coverage"]}}
713728

714729
@staticmethod
715730
def _get_type_ter_AF(channel):
@@ -822,7 +837,9 @@ def test_file_pattern(self, reader_configs, filenames):
822837
TEST_FILENAMES["hrfi_q4"][0].replace("BODY", "TRAIL"),
823838
TEST_FILENAMES["fdhsi_q4"][0].replace("BODY", "TRAIL"),
824839
TEST_FILENAMES["fdhsi_iqti"][0].replace("BODY", "TRAIL"),
825-
TEST_FILENAMES["hrfi_iqti"][0].replace("BODY", "TRAIL")])
840+
TEST_FILENAMES["hrfi_iqti"][0].replace("BODY", "TRAIL"),
841+
TEST_FILENAMES["hrfi_other_coverage"][0].replace("BODY", "TRAIL"),
842+
TEST_FILENAMES["fdhsi_other_coverage"][0].replace("BODY", "TRAIL")])
826843
def test_file_pattern_for_TRAIL_file(self, reader_configs, filenames):
827844
"""Test file pattern matching for TRAIL files, which should not be picked up."""
828845
from satpy.readers import load_reader
@@ -832,12 +849,16 @@ def test_file_pattern_for_TRAIL_file(self, reader_configs, filenames):
832849
assert len(files) == 0
833850

834851
@pytest.mark.parametrize("calibration", ["counts", "radiance", "brightness_temperature", "reflectance"])
835-
@pytest.mark.parametrize(("fh_param", "res_type"), [(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), "hdfi"),
836-
(lazy_fixture("FakeFCIFileHandlerHRFI_fixture"), "hrfi"),
837-
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), "hrfi"),
838-
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), "hdfi"),
839-
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), "hrfi"),
840-
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), "hdfi")])
852+
@pytest.mark.parametrize(("fh_param", "res_type"), [
853+
(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), "hdfi"),
854+
(lazy_fixture("FakeFCIFileHandlerHRFI_fixture"), "hrfi"),
855+
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), "hrfi"),
856+
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), "hdfi"),
857+
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), "hrfi"),
858+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), "hdfi"),
859+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture"), "hdfi"),
860+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"), "hrfi"),
861+
])
841862
def test_load_calibration(self, reader_configs, fh_param,
842863
caplog, calibration, res_type):
843864
"""Test loading with counts,radiance,reflectance and bt."""
@@ -915,7 +936,10 @@ def test_load_calibration_af(self, FakeFCIFileHandlerAF_fixture, reader_configs,
915936
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture")),
916937
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture")),
917938
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture")),
918-
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"))])
939+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture")),
940+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
941+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))
942+
])
919943
def test_orbital_parameters_attr(self, reader_configs, fh_param):
920944
"""Test the orbital parameter attribute."""
921945
reader = _get_reader_with_filehandlers(fh_param["filenames"], reader_configs)
@@ -945,7 +969,9 @@ def test_orbital_parameters_attr(self, reader_configs, fh_param):
945969
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["hrfi"]),
946970
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["fdhsi"]),
947971
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["hrfi"]),
948-
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["fdhsi"])
972+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["fdhsi"]),
973+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["fdhsi"]),
974+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"), EXPECTED_POS_INFO_FOR_FILETYPE["hrfi"])
949975
])
950976
def test_get_segment_position_info(self, reader_configs, fh_param, expected_pos_info):
951977
"""Test the segment position info method."""
@@ -969,13 +995,15 @@ def test_not_get_segment_info_called_af(self, FakeFCIFileHandlerAF_fixture, read
969995
gspi.assert_not_called()
970996

971997
@pytest.mark.parametrize("calibration", ["index_map", "pixel_quality"])
972-
@pytest.mark.parametrize(("fh_param", "expected_res_n"), [(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), 16),
973-
(lazy_fixture("FakeFCIFileHandlerHRFI_fixture"), 4),
974-
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), 4),
975-
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), 16),
976-
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), 4),
977-
(
978-
lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), 16)])
998+
@pytest.mark.parametrize(("fh_param", "expected_res_n"), [
999+
(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), 16),
1000+
(lazy_fixture("FakeFCIFileHandlerHRFI_fixture"), 4),
1001+
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), 4),
1002+
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), 16),
1003+
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), 4),
1004+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), 16),
1005+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture"), 16),
1006+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"), 4)])
9791007
def test_load_map_and_pixel(self, reader_configs, fh_param, expected_res_n, calibration):
9801008
"""Test loading of index_map and pixel_quality."""
9811009
reader = _get_reader_with_filehandlers(fh_param["filenames"], reader_configs)
@@ -1023,7 +1051,9 @@ def test_load_map_and_pixel_af(self, FakeFCIFileHandlerAF_fixture, reader_config
10231051
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture")),
10241052
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture")),
10251053
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture")),
1026-
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"))])
1054+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture")),
1055+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
1056+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))])
10271057
def test_load_aux_data(self, reader_configs, fh_param):
10281058
"""Test loading of auxiliary data."""
10291059
from satpy.readers.fci_l1c_nc import AUX_DATA
@@ -1048,6 +1078,8 @@ def test_load_aux_data(self, reader_configs, fh_param):
10481078
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture")),
10491079
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture")),
10501080
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture")),
1081+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
1082+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))
10511083
])
10521084
def test_platform_name(self, reader_configs, fh_param):
10531085
"""Test that platform name is exposed.
@@ -1132,6 +1164,8 @@ def test_count_in_repeat_cycle_rc_period_min_AF(self, FakeFCIFileHandlerAF_fixtu
11321164
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture")),
11331165
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture")),
11341166
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture")),
1167+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
1168+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))
11351169
])
11361170
def test_compute_earth_sun_parameter(self, reader_configs, fh_param):
11371171
"""Test the computation of the sun_earth_parameter."""
@@ -1145,19 +1179,24 @@ def test_compute_earth_sun_parameter_AF(self, FakeFCIFileHandlerAF_fixture, read
11451179
fh_param = FakeFCIFileHandlerAF_fixture
11461180
self._compare_sun_earth_distance(f"{fh_param['filetype']}_{channel}_{resolution}", fh_param, reader_configs)
11471181

1148-
@pytest.mark.parametrize(("fh_param"), [(lazy_fixture("FakeFCIFileHandlerFDHSIError_fixture"))])
1149-
def test_rc_period_min_error(self, reader_configs, fh_param):
1182+
@pytest.mark.parametrize(("fh_param"), [ (lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
1183+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))])
1184+
def test_rc_period_min_log_message_other_coverage(self, reader_configs, fh_param, caplog):
11501185
"""Test the rc_period_min error."""
1151-
with pytest.raises(NotImplementedError):
1186+
with caplog.at_level(logging.DEBUG):
11521187
_get_reader_with_filehandlers(fh_param["filenames"], reader_configs)
1188+
assert any('Coverage "xx" not recognised. Using observation times for nominal times.'
1189+
in message for message in caplog.messages)
11531190

11541191
@pytest.mark.parametrize(("fh_param", "expected_area"), [
11551192
(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), ["mtg_fci_fdss_1km", "mtg_fci_fdss_2km"]),
11561193
(lazy_fixture("FakeFCIFileHandlerHRFI_fixture"), ["mtg_fci_fdss_500m", "mtg_fci_fdss_1km"]),
11571194
(lazy_fixture("FakeFCIFileHandlerHRFIQ4_fixture"), ["mtg_fci_fdss_500m", "mtg_fci_fdss_1km"]),
11581195
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture"), ["mtg_fci_fdss_1km", "mtg_fci_fdss_2km"]),
11591196
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture"), ["mtg_fci_fdss_500m", "mtg_fci_fdss_1km"]),
1160-
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), ["mtg_fci_fdss_1km", "mtg_fci_fdss_2km"])
1197+
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture"), ["mtg_fci_fdss_1km", "mtg_fci_fdss_2km"]),
1198+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture"), ["mtg_fci_fdss_1km", "mtg_fci_fdss_2km"]),
1199+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"), ["mtg_fci_fdss_500m", "mtg_fci_fdss_1km"])
11611200
])
11621201
def test_area_definition_computation(self, reader_configs, fh_param, expected_area):
11631202
"""Test that the geolocation computation is correct."""
@@ -1189,6 +1228,8 @@ def test_area_definition_computation(self, reader_configs, fh_param, expected_ar
11891228
(lazy_fixture("FakeFCIFileHandlerFDHSIQ4_fixture")),
11901229
(lazy_fixture("FakeFCIFileHandlerHRFIIQTI_fixture")),
11911230
(lazy_fixture("FakeFCIFileHandlerFDHSIIQTI_fixture")),
1231+
(lazy_fixture("FakeFCIFileHandlerFDHSIOtherCoverage_fixture")),
1232+
(lazy_fixture("FakeFCIFileHandlerHRFIOtherCoverage_fixture"))
11921233
])
11931234
def test_excs(self, reader_configs, fh_param):
11941235
"""Test that exceptions are raised where expected."""

0 commit comments

Comments
 (0)