From 7896c57d70e8b13bdef8b3d4ea246f74b794cfb6 Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Tue, 19 Nov 2024 11:09:33 +0100 Subject: [PATCH 1/2] Fix so that if swath outlines are attempted on SLSTR an exception is raised Signed-off-by: Adam.Dybbroe --- trollsched/boundary.py | 8 ++++++-- trollsched/tests/test_satpass.py | 28 ++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/trollsched/boundary.py b/trollsched/boundary.py index 555c74d..6df1638 100644 --- a/trollsched/boundary.py +++ b/trollsched/boundary.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2014-2019 PyTroll community +# Copyright (c) 2014-2024 PyTroll community # Author(s): @@ -38,6 +38,10 @@ "avhrr-3": "avhrr", "mwhs-2": "mwhs2"} +class InstrumentNotSupported(Exception): + """Exception to capture cases when instrument are (yet) not supported.""" + pass + class SwathBoundary(Boundary): """Boundaries for satellite overpasses.""" @@ -79,7 +83,7 @@ def get_instrument_and_angle(self, overpass): scan_angle = 55.4 instrument = "avhrr" elif instrument.startswith("slstr"): - instrument = "slstr" + raise InstrumentNotSupported("SLSTR is a conical scanner, and currently not supported!") elif overpass.satellite.name.startswith("aws"): scan_angle = 55.25 instrument = "avhrr" diff --git a/trollsched/tests/test_satpass.py b/trollsched/tests/test_satpass.py index 5ab36a1..59711a0 100644 --- a/trollsched/tests/test_satpass.py +++ b/trollsched/tests/test_satpass.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2018 - 2021 Pytroll-schedule developers +# Copyright (c) 2018 - 2021, 2024 Pytroll-schedule developers # Author(s): @@ -31,6 +31,7 @@ from pyresample.geometry import AreaDefinition, create_area_def from trollsched.boundary import SwathBoundary +from trollsched.boundary import InstrumentNotSupported from trollsched.satpass import Pass LONS1 = np.array([-122.29913729160562, -131.54385362589042, -155.788034272281, @@ -342,6 +343,22 @@ def test_swath_coverage_metop(self): cov = mypass.area_coverage(self.euron1) assert cov == pytest.approx(0.357324, 1e-5) + def test_swath_coverage_slstr_not_supported(self): + """Test Sentinel-3 SLSTR swath coverage - SLSTR is currently not supported!""" + # Sentinel 3A slstr + tstart = datetime(2022, 6, 6, 19, 58, 0) + tend = tstart + timedelta(seconds=60) + + tle1 = "1 41335U 16011A 22156.83983125 .00000043 00000-0 35700-4 0 9996" + tle2 = "2 41335 98.6228 224.3150 0001264 95.7697 264.3627 14.26738650328113" + mypass = Pass('SENTINEL 3A', tstart, tend, instrument='slstr', tle1=tle1, tle2=tle2) + + with pytest.raises(InstrumentNotSupported) as exec_info: + cov = mypass.area_coverage(self.euron1) + + assert str(exec_info.value) == "SLSTR is a conical scanner, and currently not supported!" + + def test_swath_coverage_fy3(self): """Test FY3 coverages.""" tstart = datetime.strptime("2019-01-05T01:01:45", "%Y-%m-%dT%H:%M:%S") @@ -358,15 +375,6 @@ def test_swath_coverage_fy3(self): cov = mypass.area_coverage(self.euron1) assert cov == pytest.approx(0.786836, 1e-5) - # Sentinel 3A slstr - tstart = datetime(2022, 6, 6, 19, 58, 0) - tend = tstart + timedelta(seconds=60) - - tle1 = "1 41335U 16011A 22156.83983125 .00000043 00000-0 35700-4 0 9996" - tle2 = "2 41335 98.6228 224.3150 0001264 95.7697 264.3627 14.26738650328113" - mypass = Pass('SENTINEL 3A', tstart, tend, instrument='slstr', tle1=tle1, tle2=tle2) - cov = mypass.area_coverage(self.euron1) - self.assertAlmostEqual(cov, 0.05305641490480109, 6) def test_arctic_is_not_antarctic(self): """Test that artic and antarctic are not mixed up.""" From fccd0a535dc39acdc9a6b72adb9e67523c76edb2 Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Tue, 19 Nov 2024 13:17:27 +0100 Subject: [PATCH 2/2] Remove line not needed Signed-off-by: Adam.Dybbroe --- trollsched/boundary.py | 1 - 1 file changed, 1 deletion(-) diff --git a/trollsched/boundary.py b/trollsched/boundary.py index 6df1638..188aa00 100644 --- a/trollsched/boundary.py +++ b/trollsched/boundary.py @@ -40,7 +40,6 @@ class InstrumentNotSupported(Exception): """Exception to capture cases when instrument are (yet) not supported.""" - pass class SwathBoundary(Boundary):