Skip to content

add function compute grid cell area

Sign in for the full log view
GitHub Actions / Core / Unit Test Results (3.9) failed Feb 10, 2025 in 0s

1 fail, 715 pass in 9m 9s

716 tests  ±0   715 ✅ ±0   9m 9s ⏱️ +21s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     1 ❌ ±0 

Results for commit 509d60b. ± Comparison against earlier commit 49ebfb2.

Annotations

Check warning on line 0 in climada.hazard.test.test_tc_tracks.TestFuncs

See this annotation in the file changed.

@github-actions github-actions / Core / Unit Test Results (3.9)

test_compute_density_tracks (climada.hazard.test.test_tc_tracks.TestFuncs) failed

tests_xml/tests.xml [took 0s]
Raw output
AssertionError: 3.3161320810734264e-05 != 1
self = <climada.hazard.test.test_tc_tracks.TestFuncs testMethod=test_compute_density_tracks>

    def test_compute_density_tracks(self):
        """Test `compute_track_density` to ensure proper density count."""
        # create track
        track = xr.Dataset(
            {
                "time_step": ("time", np.timedelta64(1, "h") * np.arange(4)),
                "max_sustained_wind": ("time", [10, 20, 30, 20]),
                "central_pressure": ("time", [1, 1, 1, 1]),
                "radius_max_wind": ("time", [1, 1, 1, 1]),
                "environnmental_pressure": ("time", [1, 1, 1, 1]),
                "basin": ("time", ["NA", "NA", "NA", "NA"]),
            },
            coords={
                "time": ("time", pd.date_range("2025-01-01", periods=4, freq="12H")),
                "lat": ("time", [-90, -90, -90, -90]),
                "lon": ("time", [-179, -169, -159, -149]),
            },
            attrs={
                "max_sustained_wind_unit": "m/s",
                "central_pressure_unit": "hPa",
                "name": "storm_0",
                "sid": "0",
                "orig_event_flag": True,
                "data_provider": "FAST",
                "id_no": "0",
                "category": "1",
            },
        )
    
        tc_tracks = tc.TCTracks([track])
    
        hist_abs, *_ = tc.compute_track_density(
            tc_tracks,
            res=10,
            density=False,
        )
        hist_norm, *_ = tc.compute_track_density(tc_tracks, res=10, density=True)
        hist_wind_min, *_ = tc.compute_track_density(
            tc_tracks, res=10, density=False, wind_min=11, wind_max=None
        )
        hist_wind_max, *_ = tc.compute_track_density(
            tc_tracks, res=10, density=False, wind_min=None, wind_max=30
        )
        hist_wind_max, *_ = tc.compute_track_density(
            tc_tracks, res=10, density=False, wind_min=None, wind_max=30
        )
        hist_wind_both, *_ = tc.compute_track_density(
            tc_tracks, res=10, density=False, wind_min=11, wind_max=29
        )
        self.assertEqual(hist_abs.shape, (17, 35))
        self.assertEqual(hist_norm.shape, (17, 35))
        self.assertEqual(hist_abs.sum(), 4)
>       self.assertEqual(hist_norm.sum(), 1)
E       AssertionError: 3.3161320810734264e-05 != 1

climada/hazard/test/test_tc_tracks.py:1257: AssertionError