Example #1
0
    def test_adaptive_dnb(self, c01, c02):
        """Test the 'adaptive_dnb' compositor."""
        from satpy.composites.viirs import AdaptiveDNB

        comp = AdaptiveDNB('adaptive_dnb',
                           prerequisites=('dnb', ),
                           standard_name='toa_outgoing_radiance_per_'
                           'unit_wavelength')
        res = comp((c01, c02))
        assert isinstance(res, xr.DataArray)
        assert isinstance(res.data, da.Array)
        assert res.attrs['name'] == 'adaptive_dnb'
        assert res.attrs['standard_name'] == 'equalized_radiance'
        data = res.compute()
        np.testing.assert_allclose(data.data, 0.999, rtol=1e-4)
Example #2
0
    def test_adaptive_dnb(self):
        """Test the 'adaptive_dnb' compositor."""
        import dask.array as da
        import numpy as np
        import xarray as xr
        from pyresample.geometry import AreaDefinition

        from satpy.composites.viirs import AdaptiveDNB
        rows = 5
        cols = 10
        area = AreaDefinition('test', 'test', 'test', {
            'proj': 'eqc',
            'lon_0': 0.0,
            'lat_0': 0.0
        }, cols, rows, (-20037508.34, -10018754.17, 20037508.34, 10018754.17))

        comp = AdaptiveDNB('adaptive_dnb',
                           prerequisites=('dnb', ),
                           standard_name='toa_outgoing_radiance_per_'
                           'unit_wavelength')
        dnb = np.zeros((rows, cols)) + 0.25
        dnb[3, :] += 0.25
        dnb[4:, :] += 0.5
        dnb = da.from_array(dnb, chunks=25)
        c01 = xr.DataArray(dnb,
                           dims=('y', 'x'),
                           attrs={
                               'name': 'DNB',
                               'area': area
                           })
        sza = np.zeros((rows, cols)) + 70.0
        sza[:, 3] += 20.0
        sza[:, 4:] += 45.0
        sza = da.from_array(sza, chunks=25)
        c02 = xr.DataArray(sza,
                           dims=('y', 'x'),
                           attrs={
                               'name': 'solar_zenith_angle',
                               'area': area
                           })
        res = comp((c01, c02))
        self.assertIsInstance(res, xr.DataArray)
        self.assertIsInstance(res.data, da.Array)
        self.assertEqual(res.attrs['name'], 'adaptive_dnb')
        self.assertEqual(res.attrs['standard_name'], 'equalized_radiance')
        data = res.compute()
        np.testing.assert_allclose(data.data, 0.999, rtol=1e-4)