|
19 | 19 | Test tc_tracks module. |
20 | 20 | """ |
21 | 21 |
|
22 | | -import tempfile |
23 | 22 | import unittest |
24 | 23 | from datetime import datetime as dt |
25 | 24 |
|
@@ -661,8 +660,13 @@ def test_from_simulations_storm(self): |
661 | 660 | self.assertEqual(len(tc_track.data), 0) |
662 | 661 |
|
663 | 662 | def test_from_FAST(self): |
664 | | - """test the correct import of netcdf files from FAST model and the conversion to a |
665 | | - different xr.array structure compatible with CLIMADA.""" |
| 663 | + """Test the correct import of netcdf files from FAST model and the conversion to a |
| 664 | + different xr.array structure compatible with CLIMADA. |
| 665 | +
|
| 666 | + The test fixture contains 5 tracks across 2 years. The regression check |
| 667 | + ``len(tc_track.data) == 5`` ensures that tracks are not multiplied by the |
| 668 | + ``year`` dimension (the bug would produce 5 × 2 = 10 tracks instead). |
| 669 | + """ |
666 | 670 |
|
667 | 671 | tc_track = tc.TCTracks.from_FAST(TEST_TRACK_FAST) |
668 | 672 |
|
@@ -705,70 +709,6 @@ def test_from_FAST(self): |
705 | 709 | self.assertEqual(tc_track.data[0].environmental_pressure.data[0], 1010) |
706 | 710 | self.assertEqual(tc_track.data[0].basin[0], "NA") |
707 | 711 |
|
708 | | - def test_from_FAST_not_multiplied_by_year_dim(self): |
709 | | - """Regression test: FAST tracks must not be repeated across `year` dimension.""" |
710 | | - with tempfile.TemporaryDirectory() as tmpdir: |
711 | | - ds = xr.Dataset( |
712 | | - { |
713 | | - "lon_trks": ( |
714 | | - ("n_trk", "time"), |
715 | | - np.array( |
716 | | - [ |
717 | | - [290.0, 291.0, 292.0], |
718 | | - [300.0, 301.0, 302.0], |
719 | | - ], |
720 | | - dtype=float, |
721 | | - ), |
722 | | - ), |
723 | | - "lat_trks": ( |
724 | | - ("n_trk", "time"), |
725 | | - np.array( |
726 | | - [ |
727 | | - [10.0, 10.5, 11.0], |
728 | | - [15.0, 15.5, 16.0], |
729 | | - ], |
730 | | - dtype=float, |
731 | | - ), |
732 | | - ), |
733 | | - "vmax_trks": ( |
734 | | - ("n_trk", "time"), |
735 | | - np.array( |
736 | | - [ |
737 | | - [20.0, 21.0, 22.0], |
738 | | - [25.0, 26.0, 27.0], |
739 | | - ], |
740 | | - dtype=float, |
741 | | - ), |
742 | | - ), |
743 | | - "tc_month": ("n_trk", np.array([8, 9], dtype=np.int64)), |
744 | | - "tc_basins": ("n_trk", np.array(["NA", "NA"], dtype="<U2")), |
745 | | - "tc_years": ("n_trk", np.array([1998, 1999], dtype=np.int64)), |
746 | | - "seeds_per_month": ( |
747 | | - ("year", "basin", "month"), |
748 | | - np.zeros((4, 1, 12), dtype=float), |
749 | | - ), |
750 | | - }, |
751 | | - coords={ |
752 | | - "n_trk": ("n_trk", np.array([0, 1], dtype=np.int64)), |
753 | | - "time": ("time", np.array([0, 10800, 21600], dtype=float)), |
754 | | - "year": ( |
755 | | - "year", |
756 | | - np.array([1998, 1999, 2000, 2001], dtype=np.int64), |
757 | | - ), |
758 | | - "basin": ("basin", np.array(["NA"], dtype="<U2")), |
759 | | - "month": ("month", np.arange(1, 13, dtype=np.int64)), |
760 | | - }, |
761 | | - ) |
762 | | - |
763 | | - path = DATA_DIR.joinpath(tmpdir, "fast_regression.nc") |
764 | | - ds.to_netcdf(path) |
765 | | - |
766 | | - tc_track = tc.TCTracks.from_FAST(DATA_DIR.joinpath(tmpdir)) |
767 | | - |
768 | | - self.assertEqual(tc_track.size, 2) |
769 | | - self.assertEqual(tc_track.data[0].time.dt.year.values[0], 1998) |
770 | | - self.assertEqual(tc_track.data[1].time.dt.year.values[0], 1999) |
771 | | - |
772 | 712 | def test_to_geodataframe_points(self): |
773 | 713 | """Conversion of TCTracks to GeoDataFrame using Points.""" |
774 | 714 | tc_track = tc.TCTracks.from_processed_ibtracs_csv(TEST_TRACK) |
|
0 commit comments