diff --git a/autotest/test_netcdf_gwe_cnd.py b/autotest/test_netcdf_gwe_cnd.py index f7eaf2759b8..829bc78ace1 100644 --- a/autotest/test_netcdf_gwe_cnd.py +++ b/autotest/test_netcdf_gwe_cnd.py @@ -24,7 +24,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -59,7 +59,7 @@ def check_output(idx, test, export, gridded_input): name = "gwe-" + test.name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{name}.nc") as ds: + with nc.Dataset(test.workspace / f"{name}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf": diff --git a/autotest/test_netcdf_gwf_disv.py b/autotest/test_netcdf_gwf_disv.py index 6d41f5c526a..121090657f8 100644 --- a/autotest/test_netcdf_gwf_disv.py +++ b/autotest/test_netcdf_gwf_disv.py @@ -14,7 +14,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") wkt = ( 'PROJCS["NAD83 / UTM zone 18N", ' @@ -54,7 +54,15 @@ def build_models(idx, test, export, gridded_input): gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc" # netcdf config - ncf = flopy.mf6.ModflowUtlncf(gwf.disv, wkt=wkt, filename=f"{name}.disv.ncf") + ncf = flopy.mf6.ModflowUtlncf( + gwf.disv, + deflate=9, + shuffle=True, + chunk_time=1, + chunk_face=3, + wkt=wkt, + filename=f"{name}.disv.ncf", + ) # output control oc = flopy.mf6.ModflowGwfoc( @@ -74,8 +82,14 @@ def check_output(idx, test, export, gridded_input): name = test.name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{name}.nc") as ds: + with nc.Dataset(test.workspace / f"{name}.nc") as ds: assert ds.data_model == "NETCDF4" + cmpr = ds.variables["head_l1"].filters() + chnk = ds.variables["head_l1"].chunking() + assert cmpr["shuffle"] + assert cmpr["complevel"] == 9 + assert chnk == [1, 3] + assert ds.variables["projection"].getncattr("wkt").lower() == wkt.lower() if gridded_input == "netcdf": # re-run the simulation with model netcdf input diff --git a/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py b/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py index c0641292b03..afc94df4abd 100644 --- a/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py +++ b/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py @@ -24,7 +24,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -63,7 +63,7 @@ def check_output(idx, test, export, gridded_input): gwfname = "gwf-" + name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{gwfname}.nc") as ds: + with nc.Dataset(test.workspace / f"{gwfname}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf": diff --git a/autotest/test_netcdf_gwf_rch01.py b/autotest/test_netcdf_gwf_rch01.py index 76f02091717..f89c0b4853a 100644 --- a/autotest/test_netcdf_gwf_rch01.py +++ b/autotest/test_netcdf_gwf_rch01.py @@ -24,7 +24,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -60,7 +60,7 @@ def check_output(idx, test, export, gridded_input): name = "rch" # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{name}.nc") as ds: + with nc.Dataset(test.workspace / f"{name}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf": diff --git a/autotest/test_netcdf_gwf_rch03.py b/autotest/test_netcdf_gwf_rch03.py index fa91ccece64..7b9b7dd74d7 100644 --- a/autotest/test_netcdf_gwf_rch03.py +++ b/autotest/test_netcdf_gwf_rch03.py @@ -24,7 +24,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -61,7 +61,7 @@ def check_output(idx, test, export, gridded_input): name = "rch" # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{name}.nc") as ds: + with nc.Dataset(test.workspace / f"{name}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf": diff --git a/autotest/test_netcdf_gwf_sto01.py b/autotest/test_netcdf_gwf_sto01.py index b591f91abce..38fa7a1e69e 100644 --- a/autotest/test_netcdf_gwf_sto01.py +++ b/autotest/test_netcdf_gwf_sto01.py @@ -12,7 +12,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") htol = [None for _ in range(len(cases))] @@ -53,15 +53,28 @@ def build_models(idx, test, export, gridded_input): if export == "ugrid": gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc" + ncf = flopy.mf6.ModflowUtlncf( + gwf.dis, + deflate=5, + shuffle=True, + chunk_time=1, + chunk_face=10, + wkt=wkt, + filename=f"{name}.dis.ncf", + ) elif export == "structured": gwf.name_file.nc_structured_filerecord = f"{name}.nc" - - # netcdf config - ncf = flopy.mf6.ModflowUtlncf( - gwf.dis, - wkt=wkt, - filename=f"{name}.dis.ncf", - ) + ncf = flopy.mf6.ModflowUtlncf( + gwf.dis, + deflate=5, + shuffle=True, + chunk_time=1, + chunk_z=1, + chunk_y=5, + chunk_x=5, + wkt=wkt, + filename=f"{name}.dis.ncf", + ) return sim, dummy @@ -70,8 +83,22 @@ def check_output(idx, test, export, gridded_input): from test_gwf_sto01 import check_output as check # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / "gwf_sto01.nc") as ds: + with nc.Dataset(test.workspace / "gwf_sto01.nc") as ds: assert ds.data_model == "NETCDF4" + if export == "structured": + cmpr = ds.variables["head"].filters() + chnk = ds.variables["head"].chunking() + assert chnk == [1, 1, 5, 5] + assert ( + ds.variables["projection"].getncattr("crs_wkt").lower() == wkt.lower() + ) + elif export == "ugrid": + cmpr = ds.variables["head_l1"].filters() + chnk = ds.variables["head_l1"].chunking() + assert chnk == [1, 10] + assert ds.variables["projection"].getncattr("wkt").lower() == wkt.lower() + assert cmpr["shuffle"] + assert cmpr["complevel"] == 5 if gridded_input == "netcdf": # re-run the simulation with model netcdf input diff --git a/autotest/test_netcdf_gwf_vsc03_sfr.py b/autotest/test_netcdf_gwf_vsc03_sfr.py index 8ee0d0fe95a..97a7fcc0b13 100644 --- a/autotest/test_netcdf_gwf_vsc03_sfr.py +++ b/autotest/test_netcdf_gwf_vsc03_sfr.py @@ -24,7 +24,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -63,7 +63,7 @@ def check_output(idx, test, export, gridded_input): name = "gwf-" + test.name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{name}.nc") as ds: + with nc.Dataset(test.workspace / f"{name}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf": diff --git a/autotest/test_netcdf_gwt_dsp01.py b/autotest/test_netcdf_gwt_dsp01.py index 410d7c4d6f1..621b359d3c8 100644 --- a/autotest/test_netcdf_gwt_dsp01.py +++ b/autotest/test_netcdf_gwt_dsp01.py @@ -12,7 +12,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -30,14 +30,26 @@ def build_models(idx, test, export, gridded_input): if export == "ugrid": gwt.name_file.nc_mesh2d_filerecord = f"{gwtname}.nc" + ncf = flopy.mf6.ModflowUtlncf( + gwt.dis, + deflate=3, + shuffle=False, + chunk_time=1, + chunk_face=5, + filename=f"{gwtname}.dis.ncf", + ) elif export == "structured": gwt.name_file.nc_structured_filerecord = f"{gwtname}.nc" - - # netcdf config - ncf = flopy.mf6.ModflowUtlncf( - gwt.dis, - filename=f"{gwtname}.dis.ncf", - ) + ncf = flopy.mf6.ModflowUtlncf( + gwt.dis, + deflate=3, + shuffle=False, + chunk_time=1, + chunk_z=1, + chunk_y=1, + chunk_x=20, + filename=f"{gwtname}.dis.ncf", + ) oc = flopy.mf6.ModflowGwtoc( gwt, @@ -58,8 +70,18 @@ def check_output(idx, test, export, gridded_input): gwtname = "gwt_" + name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{gwtname}.nc") as ds: + with nc.Dataset(test.workspace / f"{gwtname}.nc") as ds: assert ds.data_model == "NETCDF4" + if export == "structured": + cmpr = ds.variables["concentration"].filters() + chnk = ds.variables["concentration"].chunking() + assert chnk == [1, 1, 1, 20] + elif export == "ugrid": + cmpr = ds.variables["concentration_l1"].filters() + chnk = ds.variables["concentration_l1"].chunking() + assert chnk == [1, 5] + assert not cmpr["shuffle"] + assert cmpr["complevel"] == 3 if gridded_input == "netcdf": # re-run the simulation with model netcdf input diff --git a/autotest/test_netcdf_gwt_prudic2004t2.py b/autotest/test_netcdf_gwt_prudic2004t2.py index 0f6c2b56a01..90253c97000 100644 --- a/autotest/test_netcdf_gwt_prudic2004t2.py +++ b/autotest/test_netcdf_gwt_prudic2004t2.py @@ -12,7 +12,7 @@ xa = pytest.importorskip("xarray") xu = pytest.importorskip("xugrid") -netcdf4 = pytest.importorskip("netCDF4") +nc = pytest.importorskip("netCDF4") def build_models(idx, test, export, gridded_input): @@ -49,7 +49,7 @@ def check_output(idx, test, export, gridded_input): gwtname = "gwt_" + name # verify format of generated netcdf file - with netcdf4.Dataset(test.workspace / f"{gwtname}.nc") as ds: + with nc.Dataset(test.workspace / f"{gwtname}.nc") as ds: assert ds.data_model == "NETCDF4" if gridded_input == "netcdf":