1
- import math
2
1
import os
3
2
import shutil
4
- from traceback import format_exc
5
- from warnings import warn
6
3
7
4
import numpy as np
8
5
import pytest
13
10
import flopy
14
11
from flopy .discretization .structuredgrid import StructuredGrid
15
12
from flopy .discretization .vertexgrid import VertexGrid
16
- from flopy .utils .datautil import DatumUtil
17
13
from flopy .utils .gridutil import get_disv_kwargs
18
14
from flopy .utils .model_netcdf import create_dataset
19
15
@@ -47,13 +43,6 @@ def compare_netcdf(base, gen, projection=False, update=None):
47
43
else :
48
44
attr = "crs_wkt"
49
45
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
57
46
continue
58
47
59
48
compare_netcdf_var (
@@ -143,7 +132,6 @@ def test_load_gwfsto01(function_tmpdir, example_data_path):
143
132
144
133
# load example
145
134
sim = flopy .mf6 .MFSimulation .load (sim_ws = base_path )
146
- # gwf = sim.get_model("gwf_sto01")
147
135
148
136
# set simulation path and write simulation
149
137
sim .set_sim_path (test_path )
@@ -902,10 +890,6 @@ def test_disv01b(function_tmpdir, example_data_path):
902
890
903
891
nlay , nrow , ncol = 3 , 3 , 3
904
892
ncpl = nrow * ncol
905
- # delr = 10.0
906
- # delc = 10.0
907
- # xoff = 100000000.0
908
- # yoff = 100000000.0
909
893
910
894
vertices = [
911
895
(0 , 1.0000000e08 , 1.0000003e08 ),
@@ -1244,8 +1228,25 @@ def test_utlncf_create(function_tmpdir, example_data_path):
1244
1228
"test_utlncf_create" : {
1245
1229
"base_sim_dir" : "disv01b" ,
1246
1230
"netcdf_output_file" : "disv01b.in.nc" ,
1231
+ "netcdf_type" : "mesh2d" ,
1247
1232
},
1248
1233
}
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
+
1249
1250
ws = function_tmpdir / "ws"
1250
1251
for dirname , test in tests .items ():
1251
1252
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):
1255
1256
test_path = os .path .join (ws , f"{ dirname } _test" )
1256
1257
shutil .copytree (data_path , base_path )
1257
1258
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" ])
1260
1293
1261
1294
# set simulation path and write simulation
1262
1295
sim .set_sim_path (test_path )
0 commit comments