Exemplo n.º 1
0
 def test_calc_decay_no_landfall_pass(self):
     """Test _calc_land_decay with no historical tracks with landfall"""
     tc_track = tc.TCTracks()
     tc_track.read_processed_ibtracs_csv(TEST_TRACK_SHORT)
     extent = tc_track.get_extent()
     land_geom = climada.util.coordinates.get_land_geometry(
         extent=extent, resolution=10
     )
     tc.track_land_params(tc_track.data[0], land_geom)
     with self.assertLogs('climada.hazard.tc_tracks_synth', level='INFO') as cm:
         tc_synth._calc_land_decay(tc_track.data, land_geom)
     self.assertIn('No historical track with landfall.', cm.output[0])
    def test_decay_values_andrew_pass(self):
        """Test _decay_values with central pressure function."""
        tc_track = tc.TCTracks()
        tc_track.read_processed_ibtracs_csv(TC_ANDREW_FL)
        s_rel = False
        extent = tc_track.get_extent()
        land_geom = climada.util.coordinates.get_land_geometry(extent=extent,
                                                               resolution=10)
        tc.track_land_params(tc_track.data[0], land_geom)
        v_lf, p_lf, x_val = tc_synth._decay_values(tc_track.data[0], land_geom,
                                                   s_rel)

        ss_category = 6
        s_cell_1 = 1 * [1.0149413347244263]
        s_cell_2 = 8 * [1.047120451927185]
        s_cell = s_cell_1 + s_cell_2
        p_vs_lf_time_relative = [
            1.0149413020277482, 1.018848167539267, 1.037696335078534,
            1.0418848167539267, 1.043979057591623, 1.0450261780104713,
            1.0460732984293193, 1.0471204188481675, 1.0471204188481675
        ]

        self.assertEqual(list(p_lf.keys()), [ss_category])
        self.assertEqual(p_lf[ss_category][0], array.array('f', s_cell))
        self.assertEqual(p_lf[ss_category][1],
                         array.array('f', p_vs_lf_time_relative))

        v_vs_lf_time_relative = [
            0.8846153846153846, 0.6666666666666666, 0.4166666666666667,
            0.2916666666666667, 0.250000000000000, 0.250000000000000,
            0.20833333333333334, 0.16666666666666666, 0.16666666666666666
        ]
        self.assertEqual(list(v_lf.keys()), [ss_category])
        self.assertEqual(v_lf[ss_category],
                         array.array('f', v_vs_lf_time_relative))

        x_val_ref = np.array([
            95.9512939453125, 53.624916076660156, 143.09530639648438,
            225.0262908935547, 312.5832824707031, 427.43109130859375,
            570.1857299804688, 750.3827514648438, 1020.5431518554688
        ])
        self.assertEqual(list(x_val.keys()), [ss_category])
        self.assertTrue(np.allclose(x_val[ss_category], x_val_ref))
Exemplo n.º 3
0
    def test_calc_land_decay_pass(self):
        """Test _calc_land_decay with environmental pressure function."""
        tc_track = tc.TCTracks.from_processed_ibtracs_csv(TC_ANDREW_FL)
        extent = tc_track.get_extent()
        land_geom = climada.util.coordinates.get_land_geometry(extent=extent,
                                                               resolution=10)
        tc.track_land_params(tc_track.data[0], land_geom)
        v_rel, p_rel = tc_synth._calc_land_decay(tc_track.data, land_geom)

        self.assertEqual(7, len(v_rel))
        for i, val in enumerate(v_rel.values()):
            self.assertAlmostEqual(val, 0.0038894834)
            self.assertTrue(i - 1 in v_rel.keys())

        self.assertEqual(7, len(p_rel))
        for i, val in enumerate(p_rel.values()):
            self.assertAlmostEqual(val[0], 1.0598491)
            self.assertAlmostEqual(val[1], 0.0041949237)
            self.assertTrue(i - 1 in p_rel.keys())
Exemplo n.º 4
0
    def test_apply_decay_no_landfall_pass(self):
        """Test _apply_land_decay with no historical tracks with landfall"""
        tc_track = tc.TCTracks()
        tc_track.read_processed_ibtracs_csv(TEST_TRACK_SHORT)
        extent = tc_track.get_extent()
        land_geom = climada.util.coordinates.get_land_geometry(
            extent=extent, resolution=10
        )
        tc.track_land_params(tc_track.data[0], land_geom)
        tc_track.data[0]['orig_event_flag'] = False
        tc_ref = tc_track.data[0].copy()
        tc_synth._apply_land_decay(tc_track.data, dict(), dict(), land_geom)

        self.assertTrue(np.allclose(tc_track.data[0].max_sustained_wind.values,
                                    tc_ref.max_sustained_wind.values))
        self.assertTrue(np.allclose(tc_track.data[0].central_pressure.values,
                                    tc_ref.central_pressure.values))
        self.assertTrue(np.allclose(tc_track.data[0].environmental_pressure.values,
                                    tc_ref.environmental_pressure.values))
        self.assertTrue(np.all(np.isnan(tc_track.data[0].dist_since_lf.values)))
Exemplo n.º 5
0
    def test_apply_decay_pass(self):
        """Test _apply_land_decay against MATLAB reference."""
        v_rel = {
            6: 0.0038950967656296597,
            1: 0.0038950967656296597,
            2: 0.0038950967656296597,
            3: 0.0038950967656296597,
            4: 0.0038950967656296597,
            5: 0.0038950967656296597,
            7: 0.0038950967656296597
        }

        p_rel = {
            6: (1.0499941, 0.007978940084158488),
            1: (1.0499941, 0.007978940084158488),
            2: (1.0499941, 0.007978940084158488),
            3: (1.0499941, 0.007978940084158488),
            4: (1.0499941, 0.007978940084158488),
            5: (1.0499941, 0.007978940084158488),
            7: (1.0499941, 0.007978940084158488)
        }

        tc_track = tc.TCTracks()
        tc_track.read_processed_ibtracs_csv(TC_ANDREW_FL)
        tc_track.data[0]['orig_event_flag'] = False
        extent = tc_track.get_extent()
        land_geom = climada.util.coordinates.get_land_geometry(
            extent=extent, resolution=10
        )
        tc.track_land_params(tc_track.data[0], land_geom)
        tc_synth._apply_land_decay(tc_track.data, v_rel, p_rel, land_geom,
                                   s_rel=True, check_plot=False)

        p_ref = np.array([
            1.010000000000000, 1.009000000000000, 1.008000000000000,
            1.006000000000000, 1.003000000000000, 1.002000000000000,
            1.001000000000000, 1.000000000000000, 1.000000000000000,
            1.001000000000000, 1.002000000000000, 1.005000000000000,
            1.007000000000000, 1.010000000000000, 1.010000000000000,
            1.010000000000000, 1.010000000000000, 1.010000000000000,
            1.010000000000000, 1.007000000000000, 1.004000000000000,
            1.000000000000000, 0.994000000000000, 0.981000000000000,
            0.969000000000000, 0.961000000000000, 0.947000000000000,
            0.933000000000000, 0.922000000000000, 0.930000000000000,
            0.937000000000000, 0.951000000000000, 0.947000000000000,
            0.943000000000000, 0.948000000000000, 0.946000000000000,
            0.941000000000000, 0.937000000000000, 0.955000000000000,
            0.9741457117, 0.99244068917, 1.00086729492, 1.00545853355,
            1.00818354609, 1.00941850023, 1.00986192053, 1.00998400565
        ]) * 1e3

        self.assertTrue(np.allclose(p_ref, tc_track.data[0].central_pressure.values))

        v_ref = np.array([
            0.250000000000000, 0.300000000000000, 0.300000000000000,
            0.350000000000000, 0.350000000000000, 0.400000000000000,
            0.450000000000000, 0.450000000000000, 0.450000000000000,
            0.450000000000000, 0.450000000000000, 0.450000000000000,
            0.450000000000000, 0.400000000000000, 0.400000000000000,
            0.400000000000000, 0.400000000000000, 0.450000000000000,
            0.450000000000000, 0.500000000000000, 0.500000000000000,
            0.550000000000000, 0.650000000000000, 0.800000000000000,
            0.950000000000000, 1.100000000000000, 1.300000000000000,
            1.450000000000000, 1.500000000000000, 1.250000000000000,
            1.300000000000000, 1.150000000000000, 1.150000000000000,
            1.150000000000000, 1.150000000000000, 1.200000000000000,
            1.250000000000000, 1.250000000000000, 1.200000000000000,
            0.9737967353, 0.687255951, 0.4994850556, 0.3551480462, 0.2270548036,
            0.1302099557, 0.0645385918, 0.0225325851
        ]) * 1e2

        self.assertTrue(np.allclose(v_ref, tc_track.data[0].max_sustained_wind.values))

        cat_ref = tc.set_category(tc_track.data[0].max_sustained_wind.values,
                                  tc_track.data[0].max_sustained_wind_unit)
        self.assertEqual(cat_ref, tc_track.data[0].category)