def test_load_and_calibrate_with_rotation(self, mocked_scene):
     scene = get_fake_scene()
     scene.load = mock.MagicMock()
     mocked_scene.return_value = scene
     filenames = ['MSG4-SEVI-MSG15-1234-NA-20190409121243.927000000Z']
     res = seviri2pps.load_and_calibrate(
         filenames, apply_sun_earth_distance_correction=False, rotate=True)
     scene.load.assert_called_with(mock.ANY, upper_right_corner='NE')
     self.assertTrue(res.attrs['image_rotated'])
    def test_load_and_calibrate(self, mocked_scene):
        """Test loading and calibrating the data."""

        mocked_scene.return_value = get_fake_scene()

        # Load and calibrate
        filenames = ['MSG4-SEVI-MSG15-1234-NA-20190409121243.927000000Z']
        res = seviri2pps.load_and_calibrate(
            filenames, apply_sun_earth_distance_correction=False, rotate=False)

        # Compare results and expectations
        vis006_exp = xr.DataArray(
            [[1.07025268, 2.14050537], [3.21075805, 4.28101074]],
            dims=('y', 'x'))
        ir_108_exp = xr.DataArray([[5, 6], [7, 8]], dims=('y', 'x'))
        xr.testing.assert_allclose(res['VIS006'], vis006_exp)
        xr.testing.assert_equal(res['IR_108'], ir_108_exp)
        self.assertFalse(
            res['VIS006'].attrs['sun_earth_distance_correction_applied'], )
Esempio n. 3
0
    def test_load_and_calibrate(self, mocked_scene):
        """Test loading and calibrating the data."""

        # Create test scene
        scene = Scene()
        start_time = dt.datetime(2020, 1, 1, 12)
        scene['VIS006'] = xr.DataArray(
            [[1, 2], [3, 4]],
            dims=('y', 'x'),
            attrs={
                'calibration': 'reflectance',
                'sun_earth_distance_correction_applied': True,
                'start_time': start_time
            })
        scene['IR_108'] = xr.DataArray([[5, 6], [7, 8]],
                                       dims=('y', 'x'),
                                       attrs={
                                           'calibration':
                                           'brightness_temperature',
                                           'start_time': start_time
                                       })
        scene.attrs['sensor'] = {'seviri'}
        mocked_scene.return_value = scene

        # Load and calibrate
        filenames = ['MSG4-SEVI-MSG15-1234-NA-20190409121243.927000000Z']
        res = seviri2pps.load_and_calibrate(
            filenames, apply_sun_earth_distance_correction=False)

        # Compare results and expectations
        vis006_exp = xr.DataArray(
            [[1.07025268, 2.14050537], [3.21075805, 4.28101074]],
            dims=('y', 'x'))
        ir_108_exp = xr.DataArray([[5, 6], [7, 8]], dims=('y', 'x'))
        xr.testing.assert_allclose(res['VIS006'], vis006_exp)
        xr.testing.assert_equal(res['IR_108'], ir_108_exp)
        self.assertFalse(
            res['VIS006'].attrs['sun_earth_distance_correction_applied'], )