Exemplo n.º 1
0
 def test_fls_algorithm_no_cth_use_clusters(self):
     self.input.pop('cth')
     self.input['single'] = False
     flsalgo = DayFogLowStratusAlgorithm(**self.input)
     ret, mask = flsalgo.run()
     self.assertEqual(flsalgo.ir108.shape, (141, 298))
     self.assertEqual(ret.shape, (141, 298))
     self.assertEqual(flsalgo.shape, (141, 298))
     self.assertEqual(np.ma.is_mask(flsalgo.mask), True)
Exemplo n.º 2
0
 def test_fls_algorithm_other(self):
     flsalgo = DayFogLowStratusAlgorithm(**self.input2)
     ret, mask = flsalgo.run()
     self.assertEqual(flsalgo.ir108.shape, (141, 298))
     self.assertEqual(ret.shape, (141, 298))
     self.assertEqual(flsalgo.shape, (141, 298))
     self.assertEqual(np.ma.is_mask(flsalgo.mask), True)
     cthdiff = flsalgo.cluster_cth - self.input['elev'].squeeze()
     self.assertLessEqual(np.nanmax(cthdiff), 1000)
Exemplo n.º 3
0
    def test_fls_algorithm_other(self):
        flsalgo = DayFogLowStratusAlgorithm(**self.input2)
        ret, mask = flsalgo.run()
        self.assertEqual(flsalgo.ir108.shape, (141, 298))
        self.assertEqual(ret.shape, (141, 298))
        self.assertEqual(flsalgo.shape, (141, 298))
        self.assertEqual(np.ma.is_mask(flsalgo.mask), True)
        cthdiff = flsalgo.cluster_cth - self.input['elev'].squeeze()
        self.assertLessEqual(np.nanmax(cthdiff), 1000)

        # Plot result with added station data
        result_img = flsalgo.plot_result(save=True, resize=1)
        add_synop.add_to_image(result_img,
                               area_def,
                               self.input2['time'],
                               stationfile2,
                               bgimg=self.input2['ir108'])
Exemplo n.º 4
0
 def setUp(self):
     # Define artificial test data with low standard deviation
     flsalgo = DayFogLowStratusAlgorithm()
     self.low_sd_ir = 1.0 * np.random.randn(10, 10) + 260
     self.low_sd_mask = np.random.randint(2, size=(10, 10))
     self.low_sd_ir_masked = np.ma.masked_where(self.low_sd_mask,
                                                self.low_sd_ir)
     self.low_sd_cluster = np.ma.masked_invalid(np.ones((10, 10)))
     self.low_sd_clusterma = flsalgo.get_cloud_cluster(self.low_sd_mask)
     # Define artificial test data with high standard deviation
     self.high_sd_ir = 30.0 * np.random.randn(10, 10) + 260
     self.high_sd_mask = np.random.randint(2, size=(10, 10))
     self.high_sd_ir_masked = np.ma.masked_where(self.high_sd_mask,
                                                 self.high_sd_ir)
     self.high_sd_cluster = np.ma.masked_invalid(np.ones((10, 10)))
     self.high_sd_clusterma = flsalgo.get_cloud_cluster(self.high_sd_mask)
     # Define artificial test data with oversized cloud cluster
     self.large_ir = 1.0 * np.random.randn(150, 150) + 260
     self.large_mask = np.zeros((150, 150))
     self.large_mask[0, 0] = 1
     self.large_masked = np.ma.masked_where(self.large_mask, self.large_ir)
     self.large_clusterma = flsalgo.get_cloud_cluster(self.large_mask)
Exemplo n.º 5
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
        }