def test_generate_prob_storms(self): """ Test the probabilistic storm generator; calls _hist2prob as well as Centroids.set_region_id() """ storms = StormEurope() storms.read_footprints(TEST_NCS) storms_prob = storms.generate_prob_storms() self.assertEqual( np.count_nonzero(storms.centroids.region_id), 6190 # here, we don't rasterise; we check if the centroids lie in a # polygon. that is to say, it's not the majority of a raster pixel, # but the centroid's location that is decisive ) self.assertEqual(storms_prob.size, 60) self.assertEqual(np.count_nonzero(storms_prob.orig), 2) self.assertEqual(storms_prob.centroids.size, 3054) self.assertIsInstance(storms_prob.intensity, sparse.csr.csr_matrix)
def test_generate_prob_storms(self): """Test the probabilistic storm generator; calls _hist2prob as well as Centroids.set_region_id()""" storms = StormEurope() storms.read_footprints(WS_DEMO_NC) storms_prob = storms.generate_prob_storms() self.assertEqual( np.count_nonzero(storms.centroids.region_id), 6402 # here, we don't rasterise; we check if the centroids lie in a # polygon. that is to say, it's not the majority of a raster pixel, # but the centroid's location that is decisive ) self.assertEqual(storms_prob.size, 60) self.assertTrue( np.allclose((1 / storms_prob.frequency).astype(int), 330)) self.assertAlmostEqual(storms.frequency.sum(), storms_prob.frequency.sum()) self.assertEqual(np.count_nonzero(storms_prob.orig), 2) self.assertEqual(storms_prob.centroids.size, 3054) self.assertIsInstance(storms_prob.intensity, sparse.csr.csr_matrix)