Skip to content

Commit

Permalink
replace export_netcdf input tag with type specific fileout tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mjreno authored and mjreno committed Dec 13, 2024
1 parent 4161555 commit f336aa7
Show file tree
Hide file tree
Showing 23 changed files with 775 additions and 111 deletions.
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwe_cnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwe = sim.gwe[0]
gwe.name_file.export_netcdf = export
gwe.dis.export_array_netcdf = True
gwe.ic.export_array_netcdf = True
gwe.cnd.export_array_netcdf = True

name = "gwe-" + cases[idx]

if export == "ugrid":
gwe.name_file.nc_mesh2d_filerecord = f"{name}.nc"
elif export == "structured":
gwe.name_file.nc_structured_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwe.dis,
Expand All @@ -59,10 +63,15 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{name}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{name}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {name}.nc\n")
f.write(f" NETCDF FILEIN {name}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
9 changes: 7 additions & 2 deletions autotest/test_netcdf_gwf_disv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.disv.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True

name = cases[idx]

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(gwf.disv, ogc_wkt=wkt, filename=f"{name}.disv.ncf")

Expand All @@ -76,9 +78,12 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{name}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"

with open(test.workspace / f"{name}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {name}.nc\n")
f.write(f" NETCDF FILEIN {name}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwf_lak_wetlakbedarea02.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.dis.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True
Expand All @@ -42,6 +41,11 @@ def build_models(idx, test, export, gridded_input):
name = cases[idx]
gwfname = "gwf-" + name

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{gwfname}.nc"
elif export == "structured":
gwf.name_file.nc_structured_filerecord = f"{gwfname}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwf.dis,
Expand All @@ -63,11 +67,16 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{gwfname}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{gwfname}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(" NEWTON\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {gwfname}.nc\n")
f.write(f" NETCDF FILEIN {gwfname}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwf_rch01.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.dis.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True
gwf.rch.export_array_netcdf = True

name = "rch"

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc"
elif export == "structured":
gwf.name_file.nc_structured_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwf.dis,
Expand All @@ -60,10 +64,15 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{name}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{name}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {name}.nc\n")
f.write(f" NETCDF FILEIN {name}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
14 changes: 11 additions & 3 deletions autotest/test_netcdf_gwf_rch03.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.dis.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True
gwf.rch.export_array_netcdf = True
print(gwf.rch)

# name = "gwf-" + cases[idx]
name = "rch"

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc"
elif export == "structured":
gwf.name_file.nc_structured_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwf.dis,
Expand All @@ -62,10 +65,15 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{name}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{name}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {name}.nc\n")
f.write(f" NETCDF FILEIN {name}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwf_sto01.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.dis.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True
gwf.sto.export_array_netcdf = True

name = cases[idx]

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc"
elif export == "structured":
gwf.name_file.nc_structured_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwf.dis,
Expand All @@ -70,11 +74,16 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"gwf_sto01.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / "gwf_sto01.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(" NEWTON\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT gwf_sto01.nc\n")
f.write(f" NETCDF FILEIN gwf_sto01.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwf_vsc03_sfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwf = sim.gwf[0]
gwf.name_file.export_netcdf = export
gwf.dis.export_array_netcdf = True
gwf.ic.export_array_netcdf = True
gwf.npf.export_array_netcdf = True
Expand All @@ -43,6 +42,11 @@ def build_models(idx, test, export, gridded_input):

name = "gwf-" + cases[idx]

if export == "ugrid":
gwf.name_file.nc_mesh2d_filerecord = f"{name}.nc"
elif export == "structured":
gwf.name_file.nc_structured_filerecord = f"{name}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwf.dis,
Expand All @@ -63,11 +67,16 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{name}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{name}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(" NEWTON\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {name}.nc\n")
f.write(f" NETCDF FILEIN {name}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwt_dsp01.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwt = sim.gwt[0]
gwt.name_file.export_netcdf = export
gwt.dis.export_array_netcdf = True
gwt.ic.export_array_netcdf = True
gwt.dsp.export_array_netcdf = True

# output control
gwtname = "gwt_" + cases[idx]

if export == "ugrid":
gwt.name_file.nc_mesh2d_filerecord = f"{gwtname}.nc"
elif export == "structured":
gwt.name_file.nc_structured_filerecord = f"{gwtname}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwt.dis,
Expand Down Expand Up @@ -58,10 +62,15 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{gwtname}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{gwtname}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(" SAVE_FLOWS\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {gwtname}.nc\n")
f.write(f" NETCDF FILEIN {gwtname}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
13 changes: 11 additions & 2 deletions autotest/test_netcdf_gwt_prudic2004t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ def build_models(idx, test, export, gridded_input):
sim, dummy = build(idx, test)
sim.tdis.start_date_time = "2041-01-01T00:00:00-05:00"
gwt = sim.gwt[0]
gwt.name_file.export_netcdf = export
gwt.dis.export_array_netcdf = True
gwt.ic.export_array_netcdf = True
gwt.dsp.export_array_netcdf = True

name = cases[idx]
gwtname = "gwt_" + name

if export == "ugrid":
gwt.name_file.nc_mesh2d_filerecord = f"{gwtname}.nc"
elif export == "structured":
gwt.name_file.nc_structured_filerecord = f"{gwtname}.nc"

# netcdf config
ncf = flopy.mf6.ModflowUtlncf(
gwt.dis,
Expand All @@ -49,9 +53,14 @@ def check_output(idx, test, export, gridded_input):
nc_fname = f"{gwtname}.{export}.nc"
os.rename(test.workspace / input_fname, test.workspace / nc_fname)

if export == "ugrid":
fileout_tag = "NETCDF_MESH2D"
elif export == "structured":
fileout_tag = "NETCDF_STRUCTURED"

with open(test.workspace / f"{gwtname}.nam", "w") as f:
f.write("BEGIN options\n")
f.write(f" EXPORT_NETCDF {export}\n")
f.write(f" {fileout_tag} FILEOUT {gwtname}.nc\n")
f.write(f" NETCDF FILEIN {gwtname}.{export}.nc\n")
f.write("END options\n\n")
f.write("BEGIN packages\n")
Expand Down
Loading

0 comments on commit f336aa7

Please sign in to comment.