Ejemplo n.º 1
0
 def calibrate(self, data, dataset_id):
     """Calibrate the data."""
     tic = datetime.now()
     channel_name = dataset_id['name']
     calib = SEVIRICalibrationHandler(
         platform_id=self.platform_id,
         channel_name=channel_name,
         coefs=self._get_calib_coefs(channel_name),
         calib_mode=self.calib_mode,
         scan_time=self.start_time)
     res = calib.calibrate(data, dataset_id['calibration'])
     logger.debug("Calibration time " + str(datetime.now() - tic))
     return res
Ejemplo n.º 2
0
    def setUp(self):
        """Setup the SEVIRI Calibration handler for testing."""

        hdr = {}
        hdr['15_DATA_HEADER'] = {}
        hdr['15_DATA_HEADER']['RadiometricProcessing'] = {
            'Level15ImageCalibration': CAL_DTYPE}

        hdr['15_DATA_HEADER']['ImageDescription'] = {}
        hdr['15_DATA_HEADER']['ImageDescription']['Level15ImageProduction'] = {
            'PlannedChanProcessing': CALIBRATION_TYPE}

        self.handler = SEVIRICalibrationHandler()
        self.handler.platform_id = PLATFORM_ID
Ejemplo n.º 3
0
 def calibrate(self, data, calibration):
     """Calibrate the data."""
     tic = datetime.now()
     calib = SEVIRICalibrationHandler(
         platform_id=self.platform_id,
         channel_name=self.channel_name,
         coefs=self._get_calib_coefs(self.channel_name),
         calib_mode=self.calib_mode,
         scan_time=self.start_time
     )
     res = calib.calibrate(data, calibration)
     if calibration in ['radiance', 'reflectance', 'brightness_temperature']:
         res = self._mask_bad_quality(res)
     logger.debug("Calibration time " + str(datetime.now() - tic))
     return res
Ejemplo n.º 4
0
    def calibrate(self, dataset, dataset_id):
        """Calibrate the data."""
        channel = dataset_id['name']
        calibration = dataset_id['calibration']

        if dataset_id['calibration'] == 'counts':
            dataset.attrs['_FillValue'] = 0

        calib = SEVIRICalibrationHandler(platform_id=int(self.platform_id),
                                         channel_name=channel,
                                         coefs=self._get_calib_coefs(
                                             dataset, channel),
                                         calib_mode='NOMINAL',
                                         scan_time=self.start_time)

        return calib.calibrate(dataset, calibration)
Ejemplo n.º 5
0
class TestSEVIRICalibrationHandler(unittest.TestCase):
    """Test the SEVIRICalibrationHandler class in the msg_base module"""
    def setUp(self):
        """Setup the SEVIRI Calibration handler for testing."""

        hdr = {}
        hdr['15_DATA_HEADER'] = {}
        hdr['15_DATA_HEADER']['RadiometricProcessing'] = {
            'Level15ImageCalibration': CAL_DTYPE
        }

        hdr['15_DATA_HEADER']['ImageDescription'] = {}
        hdr['15_DATA_HEADER']['ImageDescription']['Level15ImageProduction'] = {
            'PlannedChanProcessing': CALIBRATION_TYPE
        }

        self.handler = SEVIRICalibrationHandler()
        self.handler.platform_id = PLATFORM_ID

    def test_convert_to_radiance(self):
        """Test the conversion from counts to radiance method"""

        data = COUNTS_INPUT
        gain = GAIN
        offset = OFFSET
        result = self.handler._convert_to_radiance(data, gain, offset)
        assertNumpyArraysEqual(result, RADIANCES_OUTPUT)

    def test_ir_calibrate(self):

        result = self.handler._ir_calibrate(RADIANCES_OUTPUT, CHANNEL_NAME,
                                            CAL_TYPE1)
        assertNumpyArraysEqual(result, TBS_OUTPUT1)

        result = self.handler._ir_calibrate(RADIANCES_OUTPUT, CHANNEL_NAME,
                                            CAL_TYPE2)
        assertNumpyArraysEqual(result, TBS_OUTPUT2)

    def test_vis_calibrate(self):

        result = self.handler._vis_calibrate(VIS008_RADIANCE,
                                             VIS008_SOLAR_IRRADIANCE)
        assertNumpyArraysEqual(result, VIS008_REFLECTANCE)

    def tearDown(self):
        pass
 def test_init(self):
     """Test initialization of the calibration handler."""
     with pytest.raises(ValueError):
         SEVIRICalibrationHandler(platform_id=None,
                                  channel_name=None,
                                  coefs=None,
                                  calib_mode='invalid',
                                  scan_time=None)
 def _get_calibration_handler(self, calib_mode='NOMINAL', ext_coefs=None):
     """Provide a calibration handler."""
     return SEVIRICalibrationHandler(platform_id=324,
                                     channel_name='IR_108',
                                     coefs={
                                         'coefs': {
                                             'NOMINAL': {
                                                 'gain': 10,
                                                 'offset': -1
                                             },
                                             'GSICS': {
                                                 'gain': 20,
                                                 'offset': -2
                                             },
                                             'EXTERNAL': ext_coefs or {}
                                         },
                                         'radiance_type': 1
                                     },
                                     calib_mode=calib_mode,
                                     scan_time=None)