Ejemplo n.º 1
0
 def test_calibration_is_smooth(self):
     """Test that calibration is smooth in time."""
     coefs1 = calib.get_calibration(platform='MSG3',
                                    time=dt.datetime(2018, 1, 18, 23, 59))
     coefs2 = calib.get_calibration(platform='MSG3',
                                    time=dt.datetime(2018, 1, 19))
     self._assert_coefs_close(coefs1, coefs2, atol=1e-4)
Ejemplo n.º 2
0
 def test_clip_at_time_coverage_bounds(self, coverage_boundary,
                                       outside_coverage):
     """Test clipping beyond time coverage of the calibration dataset."""
     coefs1 = calib.get_calibration(platform='MSG1', time=coverage_boundary)
     coefs2 = calib.get_calibration(platform='MSG1',
                                    time=outside_coverage,
                                    clip=True)
     self._assert_coefs_close(coefs1, coefs2)
Ejemplo n.º 3
0
def load_and_calibrate(filenames, apply_sun_earth_distance_correction, rotate,
                       clip_calib):
    """Load and calibrate data.

    Uses inter-calibration coefficients from Meirink et al.

    Args:
        filenames: List of data files
        apply_sun_earth_distance_correction: If True, apply sun-earth-distance-
            correction to visible channels.
        rotate: Rotate image so that pixel (0, 0) is N-W.
        clip_calib: If True, do not extrapolate calibration coefficients beyond
            the time coverage of the calibration dataset. Instead, clip at the
            boundaries.

    Returns:
        Satpy scene holding calibrated channels
    """
    # Parse filenames
    parser = SEVIRIFilenameParser()
    file_format, info = parser.parse(os.path.basename(filenames[0]))

    calib_coefs = get_calibration(platform=info['platform_shortname'],
                                  time=info['start_time'],
                                  clip=clip_calib)
    scn_ = _create_scene(file_format, filenames, calib_coefs)
    _check_is_seviri_data(scn_)
    _load_bands(scn_, rotate)
    _update_scene_attrs(scn_, {'image_rotated': rotate})

    if not apply_sun_earth_distance_correction:
        remove_sun_earth_distance_correction(scn_)

    return scn_
Ejemplo n.º 4
0
 def test_get_calibration_can_handle_both_date_and_time(self, time):
     """Test MODIS-intercalibrated gain and offset for specific date."""
     coefs = calib.get_calibration(platform='MSG3', time=time)
     REF = {
         'VIS006': {
             'gain': 0.023689275200000002,
             'offset': -1.2081530352
         },
         'VIS008': {
             'gain': 0.029757990399999996,
             'offset': -1.5176575103999999
         },
         'IR_016': {
             'gain': 0.0228774688,
             'offset': -1.1667509087999999
         }
     }
     self._assert_coefs_close(coefs, REF)
Ejemplo n.º 5
0
 def test_fails_with_invalid_time(self):
     """Test that calibration fails with timestamps < reference time."""
     with pytest.raises(ValueError):
         calib.get_calibration(platform='MSG1',
                               time=dt.datetime(1999, 1, 1))
Ejemplo n.º 6
0
 def test_get_calibration(self, platform, timestamp, expected):
     """Test MODIS-intercalibrated gain and offset for specific time."""
     coefs = calib.get_calibration(platform=platform, time=timestamp)
     self._assert_coefs_close(coefs, expected)