Skip to content

Commit

Permalink
update(_ptr_to_recarray): slice pointers prior to setting data to rec…
Browse files Browse the repository at this point in the history
…array
  • Loading branch information
jlarsen-usgs committed Aug 8, 2023
1 parent e693282 commit 5a63159
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions modflowapi/extensions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,19 @@ def _ptr_to_recarray(self):
return
recarray = np.recarray((self._nbound[0],), self._dtype)
for name, ptr in self._ptrs.items():
if name == "auxvar" and self._naux == 0:
continue
values = np.copy(ptr)
if name in self._boundvars:
for ix, nm in enumerate(self.parent._bound_vars):
recarray[nm][0 : self._nbound[0]] = values[
0 : self._nbound[0], ix
]
values = values[0 : self._nbound[0], ix]
recarray[nm][0 : self._nbound[0]] = values
elif name == "auxvar":
if self._naux[0] == 0:
continue
else:
for ix in range(self._naux[0]):
nm = self._auxnames[ix]
recarray[nm][0 : self._nbound[0]] = values[
0 : self._nbound[0], ix
]
for ix in range(self._naux[0]):
nm = self._auxnames[ix]
values = values[0 : self._nbound[0], ix]
recarray[nm][0 : self._nbound[0]] = values

elif name == "auxname_cst":
pass

Expand All @@ -135,9 +133,8 @@ def _ptr_to_recarray(self):
zip(*np.unravel_index(values, self.parent.model.shape))
)

recarray[name][0 : self._nbound[0]] = values[
0 : self._nbound[0]
]
values = values[0 : self._nbound[0]]
recarray[name][0 : self._nbound[0]] = values

return recarray

Expand Down

0 comments on commit 5a63159

Please sign in to comment.