Good Afternoon,
I am working with a USG model that I have loaded into flopy. The model has loaded successfully, and I can extract data such as iverts, top, and bottom elevations for the cells. However, when I try to extract the cell centers (xcellcenters, ycellcenters, zcellcenters), I get the following error (I am including the section from unstructuredgrid.py that throws the error):
def _build_grid_geometry_info(self):
cache_index_cc = "cellcenters"
cache_index_vert = "xyzgrid"
---->vertexdict = {int(v[0]): [v[1], v[2]] for v in self._vertices}
xcenters = self._xc
ycenters = self._yc
xvertices = []
yvertices = []
# build xy vertex and cell center info
for iverts in self.iverts:
xcellvert = []
ycellvert = []
for ix in iverts:
xcellvert.append(vertexdict[ix][0])
ycellvert.append(vertexdict[ix][1])
xvertices.append(xcellvert)
yvertices.append(ycellvert)
zvertices, zcenters = self._zcoords()
if self._has_ref_coordinates:
# transform x and y
xcenters, ycenters = self.get_coords(xcenters, ycenters)
xvertxform = []
yvertxform = []
# vertices are a list within a list
for xcellvertices, ycellvertices in zip(xvertices, yvertices):
xcellvertices, ycellvertices = self.get_coords(
xcellvertices, ycellvertices
)
xvertxform.append(xcellvertices)
yvertxform.append(ycellvertices)
xvertices = xvertxform
yvertices = yvertxform
self._cache_dict[cache_index_cc] = CachedData([xcenters, ycenters, zcenters])
self._cache_dict[cache_index_vert] = CachedData(
[xvertices, yvertices, zvertices]
)
TypeError: 'NoneType' object is not iterable
It seems that unstructuredgrid.py is look for a 3D array of vertices, and the model does not have that so it is returning a None type for self._vertices.
Likewise, if I run the code:
if grid.xcellcenters is not None:
x_coords = grid.xcellcenters
else:
print("xcellcenters is None")
It returns the same error, without returning the print statement. This leads me to believe that there is a mismatch between the unstructuredgrid.py file and the USG grid structure (using 1D array of nodes), but perhaps this is unlikely as these packages have been in use for a while now...
I believe the model has loaded correctly, is initialized, and is placed in space with set_coord_info.
Any help or input is appreciated.