Пример #1
0
    def test_get_dataset(self, *mocks):
        fh = HRITGOMSFileHandler()
        fh.platform_name = 'Electro'
        fh.mda = {
            'projection_parameters': {
                'SSP_longitude': 0.0
            },
            'orbital_parameters': {
                'satellite_nominal_longitude': 0.5
            }
        }
        info = {'units': 'm', 'standard_name': 'electro', 'wavelength': 5.0}
        output = fh.get_dataset(resser(), info)

        # Check that 'calibrate' is called
        mocks[1].assert_called()

        # Check that the correct attributes are returned
        attrs_exp = info.copy()
        attrs_exp.update({
            'orbital_parameters': {
                'satellite_nominal_longitude': 0.5,
                'satellite_nominal_latitude': 0.0,
                'projection_longitude': 0.0,
                'projection_latitude': 0.0,
                'projection_altitude': 35785831.00
            },
            'platform_name': 'Electro',
            'sensor': 'msu-gs'
        })
        self.assertDictContainsSubset(attrs_exp, output.attrs)
Пример #2
0
    def test_get_area_def(self, *mocks):

        example_area_ext = (-5566748.0802, -1854249.1809,
                            5570748.6178, 2000.2688)

        fh = HRITGOMSFileHandler()
        fh.mda = {'cfac': 10231753, 'lfac': 10231753,
                  'coff': 1392.0, 'loff': 0.0, 'number_of_lines': 464,
                  'number_of_columns': 2784,
                  'projection_parameters': {'SSP_longitude': 0.0}}
        area = fh.get_area_def(True)

        self.assertTrue(np.allclose(np.array(area.area_extent),
                        np.array(example_area_ext)))
Пример #3
0
    def test_get_dataset(self, *mocks):
        fh = HRITGOMSFileHandler()
        fh.platform_name = 'Electro'
        fh.mda = {'projection_parameters': {'SSP_longitude': 0.0}}
        key = 0
        info = {'units': 'm', 'standard_name': 'electro', 'wavelength': 5.0}
        output = fh.get_dataset(resser(), info)

        # Check that 'calibrate' is called
        mocks[1].assert_called()

        # Check that the correct attributes are returned
        for key in info:
            self.assertEqual(output.attrs[key], info[key])
Пример #4
0
    def test_calibrate(self, *mocks):
        """Test calibrate."""
        lut = np.linspace(1e6, 1.6e6, num=1024).astype(np.int32)
        lut = np.tile(lut, (10, 1))
        fh = HRITGOMSFileHandler()
        fh.prologue = {'ImageCalibration': lut}
        fh.chid = 1

        # Set up test input data

        counts = DataArray(
            da.linspace(1, 1023, 25, chunks=5, dtype=np.uint16).reshape(5, 5))

        # Test that calibration fails if given a silly mode
        self.assertRaises(NotImplementedError, fh.calibrate, counts,
                          'nonsense')

        # Test that 'counts' calibration returns identical values to input
        out = fh.calibrate(counts, 'counts')
        self.assertTrue(np.all(out.values == counts.values))

        # Test that 'radiance' calibrates successfully
        out = fh.calibrate(counts, 'radiance')
        self.assertTrue(np.allclose(out.values, lut[0, counts] / 1000.))

        # Test that 'brightness_temperature' calibrates successfully
        out = fh.calibrate(counts, 'brightness_temperature')
        self.assertTrue(np.allclose(out.values, lut[0, counts] / 1000.))
Пример #5
0
    def test_get_dataset(self, calibrate_mock, *mocks):
        """Test get dataset."""
        key = make_dataid(name='CH1', calibration='counts')
        fake_array = mock.MagicMock()
        fake_array.attrs = dict()
        calibrate_mock.return_value = fake_array
        fh = HRITGOMSFileHandler()
        fh.platform_name = 'Electro'
        fh.mda = {
            'projection_parameters': {
                'SSP_longitude': 0.0
            },
            'orbital_parameters': {
                'satellite_nominal_longitude': 0.5
            }
        }
        info = {'units': 'm', 'standard_name': 'electro', 'wavelength': 5.0}
        output = fh.get_dataset(key, info)

        # Check that 'calibrate' is called
        calibrate_mock.assert_called()

        # Check that the correct attributes are returned
        attrs_exp = info.copy()
        attrs_exp.update({
            'orbital_parameters': {
                'satellite_nominal_longitude': 0.5,
                'satellite_nominal_latitude': 0.0,
                'projection_longitude': 0.0,
                'projection_latitude': 0.0,
                'projection_altitude': 35785831.00
            },
            'platform_name': 'Electro',
            'sensor': 'msu-gs'
        })
        assert dict(output.attrs, **attrs_exp) == output.attrs