@@ -921,7 +921,7 @@ def _remap_nodes(self, array):
921
921
array = np .ravel (array )
922
922
923
923
idomain = self ._modelgrid .idomain .reshape ((- 1 , self ._ncpl ))
924
- mkeys = np .unique (array )
924
+ mkeys = [ int ( i ) for i in np .unique (array )]
925
925
bad_keys = []
926
926
for mkey in mkeys :
927
927
count = 0
@@ -980,7 +980,7 @@ def _remap_nodes(self, array):
980
980
except TypeError :
981
981
xverts , yverts = None , None
982
982
983
- for m in np . unique ( array ) :
983
+ for m in mkeys :
984
984
cells = np .asarray (array == m ).nonzero ()[0 ]
985
985
mapping = np .zeros ((len (cells ),), dtype = int )
986
986
mapping [:] = cells
@@ -1002,12 +1002,12 @@ def _remap_nodes(self, array):
1002
1002
self ._offsets [m ] = {"xorigin" : None , "yorigin" : None }
1003
1003
1004
1004
new_ncpl = {}
1005
- for m in np . unique ( array ) :
1005
+ for m in mkeys :
1006
1006
new_ncpl [m ] = 1
1007
1007
for i in grid_info [m ][0 ]:
1008
1008
new_ncpl [m ] *= i
1009
1009
1010
- for mdl in np . unique ( array ) :
1010
+ for mdl in mkeys :
1011
1011
mnodes = np .asarray (array == mdl ).nonzero ()[0 ]
1012
1012
mg_info = grid_info [mdl ]
1013
1013
if mg_info is not None :
@@ -1021,10 +1021,10 @@ def _remap_nodes(self, array):
1021
1021
self ._node_map [onode ] = (mdl , nnode )
1022
1022
1023
1023
new_connections = {
1024
- i : {"internal" : {}, "external" : {}} for i in np . unique ( array )
1024
+ i : {"internal" : {}, "external" : {}} for i in mkeys
1025
1025
}
1026
- exchange_meta = {i : {} for i in np . unique ( array ) }
1027
- usg_meta = {i : {} for i in np . unique ( array ) }
1026
+ exchange_meta = {i : {} for i in mkeys }
1027
+ usg_meta = {i : {} for i in mkeys }
1028
1028
for node , conn in self ._connection .items ():
1029
1029
mdl , nnode = self ._node_map [node ]
1030
1030
for ix , cnode in enumerate (conn ):
@@ -1173,8 +1173,9 @@ def _map_verts_iverts(self, array):
1173
1173
if iverts is None :
1174
1174
return
1175
1175
1176
- ivlut = {mkey : {} for mkey in np .unique (array )}
1177
- for mkey in np .unique (array ):
1176
+ mkeys = [int (i ) for i in np .unique (array )]
1177
+ ivlut = {mkey : {} for mkey in mkeys }
1178
+ for mkey in mkeys :
1178
1179
new_iv = 0
1179
1180
new_iverts = []
1180
1181
new_verts = []
@@ -1217,7 +1218,7 @@ def _create_sln_tdis(self):
1217
1218
new_sim : MFSimulation object
1218
1219
"""
1219
1220
for pak in self ._sim .sim_package_list :
1220
- if pak .package_abbr in ("gwfgwt" , "gwfgwf" , "gwfgwe" ):
1221
+ if pak .package_abbr in ("gwfgwt" , "gwfgwf" , "gwfgwe" , "utlats" ):
1221
1222
continue
1222
1223
pak_cls = PackageContainer .package_factory (pak .package_abbr , "" )
1223
1224
signature = inspect .signature (pak_cls )
@@ -1226,7 +1227,11 @@ def _create_sln_tdis(self):
1226
1227
if key in ("simulation" , "loading_package" , "pname" , "kwargs" ):
1227
1228
continue
1228
1229
elif key == "ats_perioddata" :
1229
- continue
1230
+ data = getattr (pak , "ats" )
1231
+ if len (data ._packages ) > 0 :
1232
+ data = data ._packages [0 ].perioddata .array
1233
+ d [key ] = data
1234
+
1230
1235
else :
1231
1236
data = getattr (pak , key )
1232
1237
if hasattr (data , "array" ):
@@ -1273,7 +1278,7 @@ def _remap_cell2d(self, item, cell2d, mapped_data):
1273
1278
1274
1279
return mapped_data
1275
1280
1276
- def _remap_filerecords (self , item , value , mapped_data ):
1281
+ def _remap_filerecords (self , item , value , mapped_data , namfile = False ):
1277
1282
"""
1278
1283
Method to create new file record names and map them to their
1279
1284
associated models
@@ -1299,15 +1304,16 @@ def _remap_filerecords(self, item, value, mapped_data):
1299
1304
"obs_filerecord" ,
1300
1305
"concentration_filerecord" ,
1301
1306
"ts_filerecord" ,
1302
- "temperature_filerecord"
1307
+ "temperature_filerecord" ,
1308
+ "nc_mesh2d_filerecord"
1303
1309
):
1304
1310
value = value .array
1305
1311
if value is None :
1306
1312
pass
1307
1313
else :
1308
1314
value = value [0 ][0 ]
1309
1315
for mdl in mapped_data .keys ():
1310
- if mapped_data [mdl ]:
1316
+ if mapped_data [mdl ] or namfile :
1311
1317
new_val = value .split ("." )
1312
1318
new_val = f"{ '.' .join (new_val [0 :- 1 ])} _{ mdl :0{self ._fdigits }d} .{ new_val [- 1 ]} "
1313
1319
mapped_data [mdl ][item ] = new_val
@@ -2580,7 +2586,10 @@ def _remap_ssm(self, package, mapped_data):
2580
2586
continue
2581
2587
records .append (tuple (rec ))
2582
2588
2583
- mapped_data [mkey ]["sources" ] = records
2589
+ if records :
2590
+ mapped_data [mkey ]["sources" ] = records
2591
+ else :
2592
+ mapped_data [mkey ]["sources" ] = None
2584
2593
2585
2594
return mapped_data
2586
2595
@@ -3793,20 +3802,28 @@ def split_model(self, array):
3793
3802
)
3794
3803
self ._create_sln_tdis ()
3795
3804
3796
- nam_options = {}
3805
+ nam_options = {mkey : {} for mkey in self ._new_ncpl .keys ()}
3806
+ # todo: change this to model by model options bc nc_filerecord stuff
3797
3807
for item , value in self ._model .name_file .blocks [
3798
3808
"options"
3799
3809
].datasets .items ():
3800
3810
if item == "list" :
3801
3811
continue
3802
- nam_options [item ] = value .array
3812
+ if value .array is None :
3813
+ continue
3814
+ if item .endswith ("_filerecord" ):
3815
+ self ._remap_filerecords (item , value , nam_options , namfile = True )
3816
+ else :
3817
+ for mkey in self ._new_ncpl .keys ():
3818
+ nam_options [mkey ][item ] = value .array
3803
3819
self ._model_dict = {}
3820
+ # todo: trap the nc_mesh2d_filerecord stuff...
3804
3821
for mkey in self ._new_ncpl .keys ():
3805
3822
mdl_cls = PackageContainer .model_factory (self ._model_type )
3806
3823
self ._model_dict [mkey ] = mdl_cls (
3807
3824
self ._new_sim ,
3808
3825
modelname = f"{ self ._modelname } _{ mkey :0{self ._fdigits }d} " ,
3809
- ** nam_options ,
3826
+ ** nam_options [ mkey ] ,
3810
3827
)
3811
3828
3812
3829
for package in self ._model .packagelist :
0 commit comments