Beispiel #1
0
    def test_lcth_algorithm_real(self):
        # Compute cloud mask
        cloudfilter = CloudFilter(self.input['ir108'], **self.input)
        cloudfilter.apply()
        snowfilter = SnowFilter(cloudfilter.result, **self.input)
        snowfilter.apply()
        icefilter = IceCloudFilter(snowfilter.result, **self.input)
        icefilter.apply()
        cirrusfilter = CirrusCloudFilter(icefilter.result, **self.input)
        cirrusfilter.apply()
        waterfilter = WaterCloudFilter(cirrusfilter.result,
                                       cloudmask=cloudfilter.mask,
                                       **self.input)
        ret, mask = waterfilter.apply()

        self.ccl = cloudfilter.ccl
        self.input['ccl'] = self.ccl
        self.input['cloudmask'] = ret.mask

        lcthalgo = LowCloudHeightAlgorithm(**self.input)
        ret, mask = lcthalgo.run()
        self.assertEqual(lcthalgo.ir108.shape, (141, 298))
        self.assertEqual(ret.shape, (141, 298))
        self.assertEqual(lcthalgo.shape, (141, 298))
        self.assertEqual(np.ma.is_mask(lcthalgo.mask), True)
        self.assertLessEqual(round(np.nanmax(lcthalgo.dz), 2), 1524.43)
Beispiel #2
0
    def test_snow_filter(self):
        # Create cloud filter
        testfilter = SnowFilter(self.input['ir108'], **self.input)
        ret, mask = testfilter.apply()

        # Evaluate results
        self.assertAlmostEqual(self.ir108[0, 0], 244.044000086)
        self.assertAlmostEqual(self.vis008[25, 100], 13.40515625)
        self.assertAlmostEqual(testfilter.ndsi[30, 214], 0.12547279)
        self.assertAlmostEqual(testfilter.ndsi[135, 170], 0.62573861)
        self.assertEqual(np.sum(testfilter.mask), 577)
Beispiel #3
0
    def setUp(self):
        # Load test data
        inputs = np.dsplit(testdata, 14)
        self.ir108 = inputs[0]
        self.ir039 = inputs[1]
        self.vis008 = inputs[2]
        self.nir016 = inputs[3]
        self.vis006 = inputs[4]
        self.ir087 = inputs[5]
        self.ir120 = inputs[6]
        self.elev = inputs[7]
        self.cot = inputs[8]
        self.reff = inputs[9]
        self.lwp = inputs[10]
        self.lat = inputs[11]
        self.lon = inputs[12]
        self.cth = inputs[13]

        self.time = datetime(2013, 11, 12, 8, 30, 00)
        self.input = {
            'vis006': self.vis006,
            'vis008': self.vis008,
            'ir108': self.ir108,
            'nir016': self.nir016,
            'ir039': self.ir039,
            'ir120': self.ir120,
            'ir087': self.ir087,
            'lat': self.lat,
            'lon': self.lon,
            'time': self.time,
            'elev': self.elev,
            'cot': self.cot,
            'reff': self.reff,
            'lwp': self.lwp,
            'cth': self.cth,
            'plot': True,
            'save': True,
            'dir': '/tmp/FLS',
            'resize': '5'
        }
        # Create cloud top heights and clusters
        from fogpy.algorithms import DayFogLowStratusAlgorithm as FLS
        # Calculate cloud and snow masks
        cloudfilter = CloudFilter(self.ir108, **self.input)
        ret, self.cloudmask = cloudfilter.apply()
        snowfilter = SnowFilter(cloudfilter.result, **self.input)
        ret, snowmask = snowfilter.apply()
        # Get clusters
        fls = FLS(**self.input)
        self.clusters = FLS.get_cloud_cluster(self.cloudmask, False)
        self.clusters.mask[self.clusters != 120] = True
        self.input = {
            'ir108': self.ir108,
            'lwp': self.lwp,
            'reff': self.reff,
            'elev': self.elev,
            'clusters': self.clusters,
            'cth': self.cth
        }

        # Define small artificial test data
        dim = (2, 2, 1)
        test_ir = np.empty(dim)
        test_ir.fill(260)
        lwp_choice = np.array([0.01, 0.1, 1, 10, 100, 1000])
        test_lwp_choice = np.random.choice(lwp_choice, dim)
        test_lwp_static = np.empty(dim)
        test_lwp_static.fill(94)
        test_reff = np.empty(dim)
        test_reff.fill(10e-6)
        test_cmask = np.empty(dim)
        test_cmask.fill(0)
        test_clusters = np.empty(dim)
        test_clusters.fill(1)
        test_clusters = np.ma.masked_array(test_clusters, test_cmask)
        test_elev = np.empty(dim)
        test_elev.fill(100)
        test_cth = np.empty(dim)
        test_cth.fill(200)
        # Testdata for ground cloud fog
        self.test_lwp1 = {
            'ir108': test_ir,
            'lwp': test_lwp_static,
            'reff': test_reff,
            'elev': test_elev,
            'clusters': test_clusters,
            'cth': test_cth
        }
        # Init with big droplet radius
        # Increase in droplet radius prevend declaration as ground fog
        test_reff = np.empty(dim)
        test_reff.fill(20e-5)
        self.test_lwp2 = {
            'ir108': test_ir,
            'lwp': test_lwp_static,
            'reff': test_reff,
            'elev': test_elev,
            'clusters': test_clusters,
            'cth': test_cth
        }
        # Randomly choose liquid water paths
        test_reff = np.empty(dim)
        test_reff.fill(10e-6)  # Reset radius
        self.test_lwp3 = {
            'ir108': test_ir,
            'lwp': test_lwp_choice,
            'reff': test_reff,
            'elev': test_elev,
            'clusters': test_clusters,
            'cth': test_cth
        }