diff --git a/imod/tests/fixtures/flow_transport_simulation_fixture.py b/imod/tests/fixtures/flow_transport_simulation_fixture.py index 3f64cf97f..9b40812bd 100644 --- a/imod/tests/fixtures/flow_transport_simulation_fixture.py +++ b/imod/tests/fixtures/flow_transport_simulation_fixture.py @@ -207,10 +207,10 @@ def flow_transport_simulation(): relaxation_factor=0.9, ) - duration = pd.to_timedelta("2000d") + duration = pd.to_timedelta("20d") start = pd.to_datetime("2000-01-01") simulation.create_time_discretization(additional_times=[start, start + duration]) - simulation["time_discretization"]["n_timesteps"] = 100 + simulation["time_discretization"]["n_timesteps"] = 10 return simulation # %% diff --git a/imod/tests/fixtures/mf6_circle_fixture.py b/imod/tests/fixtures/mf6_circle_fixture.py index 42a0f1e5d..eeaa6a856 100644 --- a/imod/tests/fixtures/mf6_circle_fixture.py +++ b/imod/tests/fixtures/mf6_circle_fixture.py @@ -75,7 +75,7 @@ def make_circle_model(): reordering_method=None, relaxation_factor=0.97, ) - simtimes = pd.date_range(start="2000-01-01", end="2001-01-01", freq="W") + simtimes = pd.date_range(start="2000-01-01", end="2000-01-03") simulation.create_time_discretization(additional_times=simtimes) return simulation @@ -158,7 +158,7 @@ def make_circle_model_flow_with_transport_data(species: list[str]): reordering_method=None, relaxation_factor=0.97, ) - simtimes = pd.date_range(start="2000-01-01", end="2001-01-01", freq="W") + simtimes = pd.date_range(start="2000-01-01", end="2000-01-03") simulation.create_time_discretization(simtimes) return simulation @@ -357,7 +357,7 @@ def circle_model_transport(): reordering_method=None, relaxation_factor=0.97, ) - simtimes = pd.date_range(start="2000-01-01", end="2001-01-01", freq="W") + simtimes = pd.date_range(start="2000-01-01", end="2000-01-03") simulation.create_time_discretization(additional_times=simtimes) return simulation @@ -437,7 +437,7 @@ def circle_model_transport_vsc(): reordering_method=None, relaxation_factor=0.97, ) - simtimes = pd.date_range(start="2000-01-01", end="2001-01-01", freq="W") + simtimes = pd.date_range(start="2000-01-01", end="2000-01-03") simulation.create_time_discretization(additional_times=simtimes) return simulation @@ -514,6 +514,6 @@ def circle_model_transport_multispecies_variable_density(): reordering_method=None, relaxation_factor=0.97, ) - simtimes = pd.date_range(start="2000-01-01", end="2001-01-01", freq="W") + simtimes = pd.date_range(start="2000-01-01", end="2000-01-03") simulation.create_time_discretization(additional_times=simtimes) return simulation diff --git a/imod/tests/fixtures/mf6_twri_fixture.py b/imod/tests/fixtures/mf6_twri_fixture.py index 717282173..279bae2b3 100644 --- a/imod/tests/fixtures/mf6_twri_fixture.py +++ b/imod/tests/fixtures/mf6_twri_fixture.py @@ -232,7 +232,7 @@ def transient_twri_model(): save_flows=True, ) simulation.create_time_discretization( - additional_times=pd.date_range("2000-01-01", " 2000-01-31") + additional_times=pd.date_range("2000-01-01", " 2000-01-03") ) return simulation @@ -282,7 +282,7 @@ def transient_unconfined_twri_model(): # Write specific discharges gwf_model["npf"]["save_specific_discharge"] = True simulation.create_time_discretization( - additional_times=pd.date_range("2000-01-01", " 2000-01-31") + additional_times=pd.date_range("2000-01-01", " 2000-01-03") ) return simulation diff --git a/imod/tests/test_mf6/test_mf6_out.py b/imod/tests/test_mf6/test_mf6_out.py index e3b412b10..c61233e6e 100644 --- a/imod/tests/test_mf6/test_mf6_out.py +++ b/imod/tests/test_mf6/test_mf6_out.py @@ -415,7 +415,7 @@ def test_open_cbc__dis_transient(transient_twri_result): "wel_wel", ] for array in cbc.values(): - assert array.shape == (30, 3, 15, 15) + assert array.shape == (2, 3, 15, 15) assert isinstance(array, xr.DataArray) assert isinstance(array.data, dask.array.Array) @@ -457,7 +457,7 @@ def test_open_cbc__dis_transient_unconfined(transient_unconfined_twri_result): "wel_wel", ] for array in cbc.values(): - assert array.shape == (30, 3, 15, 15) + assert array.shape == (2, 3, 15, 15) assert isinstance(array, xr.DataArray) assert isinstance(array.data, dask.array.Array) @@ -479,10 +479,10 @@ def test_open_cbc__disv(circle_result): ] for key, array in cbc.items(): if key in ("chd_chd", "flow-lower-face"): - assert array.shape == (52, 2, 216) + assert array.shape == (2, 2, 216) assert array.dims[-1] == array.ugrid.grid.face_dimension else: - assert array.shape == (52, 2, 342) + assert array.shape == (2, 2, 342) assert array.dims[-1] == array.ugrid.grid.edge_dimension assert isinstance(array, xu.UgridDataArray) assert isinstance(array.data, dask.array.Array) @@ -505,10 +505,10 @@ def test_open_cbc__disv_offset(circle_result__offset_origins): ] for key, array in cbc.items(): if key in ("chd_chd", "flow-lower-face"): - assert array.shape == (52, 2, 216) + assert array.shape == (2, 2, 216) assert array.dims[-1] == array.ugrid.grid.face_dimension else: - assert array.shape == (52, 2, 342) + assert array.shape == (2, 2, 342) assert array.dims[-1] == array.ugrid.grid.edge_dimension assert isinstance(array, xu.UgridDataArray) assert isinstance(array.data, dask.array.Array) @@ -554,10 +554,10 @@ def test_open_cbc__disv_sto(circle_result_sto): ] for key, array in cbc.items(): if key in ("chd_chd", "flow-lower-face", "sto-ss"): - assert array.shape == (52, 2, 216) + assert array.shape == (2, 2, 216) assert array.dims[-1] == array.ugrid.grid.face_dimension else: - assert array.shape == (52, 2, 342) + assert array.shape == (2, 2, 342) assert array.dims[-1] == array.ugrid.grid.edge_dimension assert isinstance(array, xu.UgridDataArray) assert isinstance(array.data, dask.array.Array) diff --git a/imod/tests/test_mf6/test_mf6_simulation.py b/imod/tests/test_mf6/test_mf6_simulation.py index 2fc5f42c9..880bb81cd 100644 --- a/imod/tests/test_mf6/test_mf6_simulation.py +++ b/imod/tests/test_mf6/test_mf6_simulation.py @@ -199,19 +199,21 @@ def test_simulation_open_head(circle_model, tmp_path): modeldir = tmp_path / "circle" simulation.write(modeldir) simulation.run() - head = simulation.open_head() - assert isinstance(head, xu.UgridDataArray) - assert head.dims == ("time", "layer", "mesh2d_nFaces") - assert head.shape == (52, 2, 216) + # open heads without time conversion + head_notime = simulation.open_head() + + assert isinstance(head_notime, xu.UgridDataArray) + assert head_notime.dims == ("time", "layer", "mesh2d_nFaces") + assert head_notime.shape == (2, 2, 216) # open heads with time conversion. head = simulation.open_head( simulation_start_time=datetime(2013, 3, 11, 22, 0, 0), time_unit="w" ) assert head.dims == ("time", "layer", "mesh2d_nFaces") - assert head.shape == (52, 2, 216) - assert str(head.coords["time"].values[()][0]) == "2013-04-29T22:00:00.000000" + assert head.shape == (2, 2, 216) + assert str(head.coords["time"].values[()][0]) == "2013-03-18T22:00:00.000000000" class PathCases: @@ -235,9 +237,10 @@ def test_simulation_write_run_open__different_paths(circle_model, tmp_path, path simulation.write(path) simulation.run() head = simulation.open_head() - # Assert not an empty array is returned + assert isinstance(head, xu.UgridDataArray) - assert head.shape == (52, 2, 216) + assert head.dims == ("time", "layer", "mesh2d_nFaces") + assert head.shape == (2, 2, 216) def test_simulation_open_flow_budget(circle_model, tmp_path): diff --git a/imod/tests/test_mf6/test_multimodel/test_mf6_modelsplitter_transport.py b/imod/tests/test_mf6/test_multimodel/test_mf6_modelsplitter_transport.py index c834c5c81..83f7cea8b 100644 --- a/imod/tests/test_mf6/test_multimodel/test_mf6_modelsplitter_transport.py +++ b/imod/tests/test_mf6/test_multimodel/test_mf6_modelsplitter_transport.py @@ -133,28 +133,28 @@ def test_split_flow_and_transport_model_evaluate_output( submodel_labels = submodel_labels.sel(layer=0, drop=True) # for reference run the original model and load the results - simulation.write(tmp_path / "original", binary=False) + simulation.write(tmp_path / "original") simulation.run() original_conc = simulation.open_concentration() original_head = simulation.open_head() # split the model , run the split model and load the results new_simulation = simulation.split(submodel_labels) - new_simulation.write(tmp_path, binary=False) + new_simulation.write(tmp_path) new_simulation.run() conc = new_simulation.open_concentration() head = new_simulation.open_head() # Compare np.testing.assert_allclose( - head.sel(time=2000)["head"].values, - original_head.sel(time=2000).values, + head.sel(time=20)["head"].values, + original_head.sel(time=20).values, rtol=1e-4, atol=1e-6, ) np.testing.assert_allclose( - conc.sel(time=2000)["concentration"].values, - original_conc.sel(time=2000).values, + conc.sel(time=20)["concentration"].values, + original_conc.sel(time=20).values, rtol=1e-4, atol=1e-6, ) @@ -191,8 +191,8 @@ def test_split_flow_and_transport_model_evaluate_output_with_species( # Compare np.testing.assert_allclose( - conc.sel(time=2000)["concentration"].values, - original_conc.sel(time=2000).values, + conc.sel(time=20)["concentration"].values, + original_conc.sel(time=20).values, rtol=1e-4, atol=1e-6, ) diff --git a/imod/tests/test_mf6/test_multimodel/test_mf6_partitioned_simulation_postprocessing.py b/imod/tests/test_mf6/test_multimodel/test_mf6_partitioned_simulation_postprocessing.py index 82cac94fe..bb94caeda 100644 --- a/imod/tests/test_mf6/test_multimodel/test_mf6_partitioned_simulation_postprocessing.py +++ b/imod/tests/test_mf6/test_multimodel/test_mf6_partitioned_simulation_postprocessing.py @@ -60,38 +60,7 @@ def test_import_heads_structured( assert np.allclose(merged_heads.coords["layer"].values, [1, 2, 3]) assert np.allclose( merged_heads.coords["time"].values, - [ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 11.0, - 12.0, - 13.0, - 14.0, - 15.0, - 16.0, - 17.0, - 18.0, - 19.0, - 20.0, - 21.0, - 22.0, - 23.0, - 24.0, - 25.0, - 26.0, - 27.0, - 28.0, - 29.0, - 30.0, - ], + [1.0, 2.0], ) @@ -106,9 +75,7 @@ def test_import_heads_unstructured(tmp_path, circle_partitioned): # Assert assert np.allclose(merged_heads.coords["layer"].values, [1, 2]) - assert np.allclose( - merged_heads.coords["time"].values, list(np.arange(7.0, 365.0, 7.0)) - ) + assert np.allclose(merged_heads.coords["time"].values, [1.0, 2.0]) assert np.allclose(merged_heads.coords["mesh2d_nFaces"].values, list(range(216))) diff --git a/imod/tests/test_mf6/test_multimodel/test_mf6_partitioning_unstructured.py b/imod/tests/test_mf6/test_multimodel/test_mf6_partitioning_unstructured.py index 4edefa4d3..88eea96c2 100644 --- a/imod/tests/test_mf6/test_multimodel/test_mf6_partitioning_unstructured.py +++ b/imod/tests/test_mf6/test_multimodel/test_mf6_partitioning_unstructured.py @@ -444,14 +444,14 @@ def run_simulation(tmp_path, simulation, species=None): simulation.run() head = simulation.open_head() flow_budget = simulation.open_flow_budget() - flow_budget = flow_budget.sel(time=364) + flow_budget = flow_budget.isel(time=-1) concentration = None transport_budget = None transport_budget = None if has_transport: concentration = simulation.open_concentration() transport_budget = simulation.open_transport_budget(species) - transport_budget = transport_budget.sel(time=364) + transport_budget = transport_budget.isel(time=-1) return head, concentration, flow_budget, transport_budget