1- import math
21import os
32import shutil
4- from traceback import format_exc
5- from warnings import warn
63
74import numpy as np
85import pytest
1310import flopy
1411from flopy .discretization .structuredgrid import StructuredGrid
1512from flopy .discretization .vertexgrid import VertexGrid
16- from flopy .utils .datautil import DatumUtil
1713from flopy .utils .gridutil import get_disv_kwargs
1814from flopy .utils .model_netcdf import create_dataset
1915
@@ -47,13 +43,6 @@ def compare_netcdf(base, gen, projection=False, update=None):
4743 else :
4844 attr = "crs_wkt"
4945 assert attr in xrg .data_vars [varname ].attrs
50-
51- # TODO
52- # crs_b = CRS.from_wkt(da.attrs[attr])
53- # epsg_b = crs_b.to_epsg(min_confidence=90)
54- # crs_g = CRS.from_wkt(xrg.data_vars[varname].attrs[attr])
55- # epsg_g = crs_g.to_epsg(min_confidence=90)
56- # assert epsg_b == epsg_g
5746 continue
5847
5948 compare_netcdf_var (
@@ -143,7 +132,6 @@ def test_load_gwfsto01(function_tmpdir, example_data_path):
143132
144133 # load example
145134 sim = flopy .mf6 .MFSimulation .load (sim_ws = base_path )
146- # gwf = sim.get_model("gwf_sto01")
147135
148136 # set simulation path and write simulation
149137 sim .set_sim_path (test_path )
@@ -902,10 +890,6 @@ def test_disv01b(function_tmpdir, example_data_path):
902890
903891 nlay , nrow , ncol = 3 , 3 , 3
904892 ncpl = nrow * ncol
905- # delr = 10.0
906- # delc = 10.0
907- # xoff = 100000000.0
908- # yoff = 100000000.0
909893
910894 vertices = [
911895 (0 , 1.0000000e08 , 1.0000003e08 ),
@@ -1244,8 +1228,25 @@ def test_utlncf_create(function_tmpdir, example_data_path):
12441228 "test_utlncf_create" : {
12451229 "base_sim_dir" : "disv01b" ,
12461230 "netcdf_output_file" : "disv01b.in.nc" ,
1231+ "netcdf_type" : "mesh2d" ,
12471232 },
12481233 }
1234+
1235+ name = "disv01b"
1236+ nlay = 3
1237+ nrow = 3
1238+ ncol = 3
1239+ delr = 10.0
1240+ delc = 10.0
1241+ top = 0
1242+ botm = [- 10 , - 20 , - 30 ]
1243+ xoff = 100000000.0
1244+ yoff = 100000000.0
1245+ disvkwargs = get_disv_kwargs (nlay , nrow , ncol , delr , delc , top , botm , xoff , yoff )
1246+ idomain = np .ones ((nlay , nrow * ncol ), dtype = int )
1247+ idomain [0 , 1 ] = 0
1248+ disvkwargs ["idomain" ] = idomain
1249+
12491250 ws = function_tmpdir / "ws"
12501251 for dirname , test in tests .items ():
12511252 data_path = os .path .join (data_path_base , dirname , test ["base_sim_dir" ])
@@ -1255,8 +1256,40 @@ def test_utlncf_create(function_tmpdir, example_data_path):
12551256 test_path = os .path .join (ws , f"{ dirname } _test" )
12561257 shutil .copytree (data_path , base_path )
12571258
1258- # load example
1259- sim = flopy .mf6 .MFSimulation .load (sim_ws = base_path )
1259+ # create example
1260+ sim = flopy .mf6 .MFSimulation (
1261+ sim_name = name ,
1262+ version = "mf6" ,
1263+ exe_name = "mf6" ,
1264+ sim_ws = ws ,
1265+ )
1266+ tdis = flopy .mf6 .ModflowTdis (sim , start_date_time = "2041-01-01t00:00:00-05:00" )
1267+ kwargs = {}
1268+ kwargs ["crs" ] = "EPSG:26918"
1269+ gwf = flopy .mf6 .ModflowGwf (sim , modelname = name , ** kwargs )
1270+ ims = flopy .mf6 .ModflowIms (sim , print_option = "SUMMARY" )
1271+ disv = flopy .mf6 .ModflowGwfdisv (gwf , ** disvkwargs )
1272+ ncf = flopy .mf6 .ModflowUtlncf (
1273+ disv ,
1274+ deflate = 9 ,
1275+ shuffle = True ,
1276+ chunk_time = 1 ,
1277+ chunk_face = 3 ,
1278+ filename = f"{ name } .disv.ncf" ,
1279+ )
1280+ ic = flopy .mf6 .ModflowGwfic (gwf , strt = 0.0 )
1281+ npf = flopy .mf6 .ModflowGwfnpf (gwf )
1282+ spd = {0 : [[(0 , 0 ), 1.0 ], [(0 , nrow * ncol - 1 ), 0.0 ]]}
1283+ chd = flopy .mf6 .modflow .mfgwfchd .ModflowGwfchd (gwf , stress_period_data = spd )
1284+ oc = flopy .mf6 .ModflowGwfoc (
1285+ gwf ,
1286+ head_filerecord = f"{ name } .hds" ,
1287+ saverecord = [("HEAD" , "ALL" )],
1288+ )
1289+
1290+ # set path and write simulation
1291+ sim .set_sim_path (test_path )
1292+ sim .write_simulation (netcdf = test ["netcdf_type" ])
12601293
12611294 # set simulation path and write simulation
12621295 sim .set_sim_path (test_path )
0 commit comments