From f68363646407cbb90a1a7c18183f6f29e812bc15 Mon Sep 17 00:00:00 2001 From: casadoj Date: Wed, 28 Aug 2024 14:52:45 +0200 Subject: [PATCH] Add test for lfcoords --- tests/test_lfcoords.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_lfcoords.py diff --git a/tests/test_lfcoords.py b/tests/test_lfcoords.py new file mode 100644 index 0000000..6e424d5 --- /dev/null +++ b/tests/test_lfcoords.py @@ -0,0 +1,35 @@ +import unittest +from pathlib import Path +import pandas as pd +import pandas.testing as pdt +from lisfloodutilities.lfcoords import Config +from lilisfloodutilities.lfcoords.finer_grid import coordinates_fine +from llisfloodutilities.lfcoords.coarser_grid import coordinates_coarse + + +class TestCatchStats(unittest.TestCase): + + path = Path('tests/data/lfcoords') + + def test_lfcoords(self): + + # compute test values + cfg = Config(self.path / 'config.yml') + stations_HR = coordinates_fine(cfg, save=False) + test = coordinates_coarse(cfg, stations_HR, save=False) + + + # maps = read_inputmaps(self.path / 'maps') + # masks = read_masks(self.path / 'masks') + # weight = read_pixarea(self.path / 'pixarea_iberian_01min.nc') + # test = catchment_statistics(maps, masks, ['mean', 'std', 'min', 'max', 'count'], weight=weight, output=None).to_pandas() + + # load expected values + expected = pd.read_csv(self.path / 'expected.csv', index_col='id') + expected.index =expected.index.astype(test.index.dtype) + + # check + try: + pdt.assert_frame_equal(test, expected) + except AssertionError as e: + print(e)