From 3436286512f243b4fec352ca2cb8cdaea2421a1a Mon Sep 17 00:00:00 2001 From: Mares2022 Date: Thu, 13 Jul 2023 13:06:06 +0200 Subject: [PATCH] Correct netCDF files to be compatible with Delft-fiat Correct netCDF files to be compatible with Delft-fiat --- hydromt_fiat/fiat.py | 18 +++++++++++------- tests/test_hazard.py | 21 +++------------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index 755cc283..8db8565b 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -370,21 +370,25 @@ def setup_hazard( # result_list = list(sfincs_model.results.keys()) # sfincs_model.write_raster("results.zsmax", compress="LZW") da = sfincs_model.results["zsmax"] - + # da = da.squeeze('timemax').drop('timemax') + da = da.isel(timemax=0).drop('timemax') + else: if not self.region.empty: - da = self.data_catalog.get_rasterdataset( - da_map_fn, geom=self.region - ) + # da = self.data_catalog.get_rasterdataset( + # da_map_fn, geom=self.region + # ) + da = self.data_catalog.get_rasterdataset(da_map_fn) else: da = self.data_catalog.get_rasterdataset(da_map_fn) - - da.encoding["_FillValue"] = None # reading from the datacatalog else: if not self.region.empty: + # da = self.data_catalog.get_rasterdataset( + # name_catalog, variables=da_name, geom=self.region + # ) da = self.data_catalog.get_rasterdataset( - name_catalog, variables=da_name, geom=self.region + name_catalog, variables=da_name ) else: da = self.data_catalog.get_rasterdataset( diff --git a/tests/test_hazard.py b/tests/test_hazard.py index 7a0b421c..b5b942cb 100644 --- a/tests/test_hazard.py +++ b/tests/test_hazard.py @@ -18,7 +18,6 @@ } -@pytest.mark.skip(reason="Not correctly implemented yet") @pytest.mark.parametrize("case", list(_cases.keys())) def test_hazard(case): # Read model in examples folder. @@ -39,25 +38,11 @@ def test_hazard(case): nodata = configread(config_fn)["setup_hazard"]["nodata"] var = configread(config_fn)["setup_hazard"]["var"] chunks = configread(config_fn)["setup_hazard"]["chunks"] - configread(config_fn)["setup_hazard"]["maps_id"] configread(config_fn)["setup_hazard"]["name_catalog"] configread(config_fn)["setup_hazard"]["risk_output"] configread(config_fn)["setup_config"]["hazard_type"] - param_lst, params = get_lists( - map_fn, - map_type, - chunks, - rp, - crs, - nodata, - var, - ) - - check_parameters( - param_lst, - params, - hyfm, - ) + params = check_parameters_type(map_fn, map_type, rp, crs, nodata, var, chunks) + check_parameters_size(params) - assert hyfm + assert params