Skip to content

Commit

Permalink
Merge pull request #62 from ninahakansson/fix_wavelenght_attribute_se…
Browse files Browse the repository at this point in the history
…viri

Change wavelenght format to match pps-level1c
  • Loading branch information
ninahakansson committed Jun 21, 2021
2 parents 104ec07 + 3728fa5 commit 322bb17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions level1c4pps/seviri2pps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions level1c4pps/tests/test_seviri2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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__
Expand Down Expand Up @@ -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."""

Expand Down

0 comments on commit 322bb17

Please sign in to comment.