diff --git a/level1c4pps/seviri2pps_lib.py b/level1c4pps/seviri2pps_lib.py index 7672dfa..6a94f17 100644 --- a/level1c4pps/seviri2pps_lib.py +++ b/level1c4pps/seviri2pps_lib.py @@ -260,6 +260,9 @@ def set_attrs(scene): idtag = PPS_TAGNAMES[band] scene[band].attrs['id_tag'] = idtag scene[band].attrs['description'] = 'SEVIRI ' + str(band) + scene[band].attrs['wavelength'] = [scene[band].attrs['wavelength'].min, + scene[band].attrs['wavelength'].central, + scene[band].attrs['wavelength'].max] if 'sun_earth_distance_correction_factor' not in scene[band].attrs: scene[band].attrs['sun_earth_distance_correction_applied'] = False scene[band].attrs['sun_earth_distance_correction_factor'] = 1.0 diff --git a/level1c4pps/tests/test_seviri2pps.py b/level1c4pps/tests/test_seviri2pps.py index 6a75c3b..0acfee8 100644 --- a/level1c4pps/tests/test_seviri2pps.py +++ b/level1c4pps/tests/test_seviri2pps.py @@ -34,6 +34,7 @@ import level1c4pps.seviri2pps_lib as seviri2pps import level1c4pps.calibration_coefs as calib +from satpy.dataset.dataid import WavelengthRange def get_fake_scene(): @@ -45,14 +46,16 @@ def get_fake_scene(): dims=('y', 'x'), attrs={'calibration': 'reflectance', 'sun_earth_distance_correction_applied': True, - 'start_time': start_time} + 'start_time': start_time, + 'wavelength': WavelengthRange(0.56, 0.635, 0.71)} ) scene['IR_108'] = xr.DataArray( [[5, 6], [7, 8]], dims=('y', 'x'), attrs={'calibration': 'brightness_temperature', - 'start_time': start_time} + 'start_time': start_time, + 'wavelength': WavelengthRange(9.8, 10.8, 11.8)} ) scene.attrs['sensor'] = {'seviri'} return scene @@ -196,8 +199,9 @@ def get_observer_look_patched(lon, lat, alt, *args): def test_set_attrs(self): """Test setting scene attributes.""" seviri2pps.BANDNAMES = ['VIS006', 'IR_108'] - vis006 = mock.MagicMock(attrs={}) + vis006 = mock.MagicMock(attrs={'wavelength': WavelengthRange(0.56, 0.635, 0.71)}) ir108 = mock.MagicMock(attrs={'platform_name': 'myplatform', + 'wavelength': WavelengthRange(9.8, 10.8, 11.8), 'orbital_parameters': {'orb_a': 1, 'orb_b': 2}, 'georef_offset_corrected': True}) @@ -245,11 +249,13 @@ def test_update_coords(self, get_mean_acq_time): dims=('x',), coords={'acq_time': ('x', [0, 0, 0])}, attrs={'area': 'myarea', + 'wavelength': WavelengthRange(0.56, 0.635, 0.71), 'start_time': dt.datetime(2009, 7, 1, 0)}) ir_108 = xr.DataArray(data=[4, 5, 6], dims=('x',), coords={'acq_time': ('x', [0, 0, 0])}, - attrs={'start_time': dt.datetime(2009, 7, 1, 1)}) + attrs={'start_time': dt.datetime(2009, 7, 1, 1), + 'wavelength': WavelengthRange(9.8, 10.8, 11.8)}) scene_dict = {'VIS006': vis006.copy(), 'IR_108': ir_108.copy()} scene = mock.MagicMock(attrs={}) scene.__getitem__.side_effect = scene_dict.__getitem__ @@ -483,6 +489,7 @@ def test_set_nominal_scan_time(self): self.assertEqual(arr.attrs['start_time'], start_time) self.assertEqual(arr.attrs['end_time'], end_time) + class TestCalibration(unittest.TestCase): """Test SEVIRI calibration."""