You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Not sure if this can yet be qualified as bug, or is simply still under active development and I'm a bit early in posting this, but I noticed that ParticleData.to_prp() returns global coordinates. PRT6 currently expects model coordinates for the input. This isn't caught in the tests as as far as I could see, as no PRT6 models are run using a grid with offsets (in both flopy and modflow6 repos).
I saw other options for specifying model coordinates are under review in Modflow6, which might also solve this issue by allowing computation with global coordinates: MODFLOW-USGS/modflow6#1901. Nevertheless, it might be nice to have both global and model coordinate options in to_prp().
EDIT: just noticed issue #2388. If vertices are specified in model coordinates, that would also solve this issue.
Expected behavior
Perhaps the option of returning global or model coordinates could be added to to_prp()? Something like the code below could do the trick. I used the term model_coords since in modpath local signifies a location within a cell.
If this is something you would want to support, Id be happy to submit a PR with this small change, let me know!
# class ParticleData:# ...defto_coords(self, grid, localz=False, model_coords=True) ->Iterator[tuple]: # <-- add model_coords=True# ...defcvt_xy(p, vs):
mn, mx=min(vs), max(vs)
span=mx-mnreturnmn+span*pifgrid.grid_type=="structured":
ifnothasattr(self.particledata, "k"):
raiseValueError(
"Particle representation is not structured but grid is"
)
defcvt_z(p, k, i, j):
mn, mx= (
grid.botm[k, i, j],
grid.top[i, j] ifk==0elsegrid.botm[k-1, i, j],
)
span=mx-mnreturnmn+span*pdefconvert(row, model_coords=True) ->tuple[float, float, float]: # <-- add model_coordsverts=grid.get_cell_vertices(row.i, row.j)
ifmodel_coords:
xs, ys=grid.get_local_coords(*np.array(verts).T) # <--convert global coords to model coordselse:
xs, ys=list(zip(*verts))
return [
cvt_xy(row.localx, xs),
cvt_xy(row.localy, ys),
row.localziflocalzelsecvt_z(row.localz, row.k, row.i, row.j),
]
else:
ifhasattr(self.particledata, "k"):
raiseValueError(
"Particle representation is structured but grid is not"
)
defcvt_z(p, nn):
k, j=grid.get_lni([nn])[0]
mn, mx= (
grid.botm[k, j],
grid.top[j] ifk==0elsegrid.botm[k-1, j],
)
span=mx-mnreturnmn+span*pdefconvert(row, model_coords=True) ->tuple[float, float, float]: # <-- add model_coordsverts=grid.get_cell_vertices(row.node)
ifmodel_coords:
xs, ys=grid.get_local_coords(*np.array(verts).T) # <--convert global coords to model coordselse:
xs, ys=list(zip(*verts))
return [
cvt_xy(row.localx, xs),
cvt_xy(row.localy, ys),
row.localziflocalzelsecvt_z(row.localz, row.node),
]
fortinself.particledata.itertuples():
yieldconvert(t, model_coords=model_coords)
defto_prp(self, grid, localz=False, model_coords=True) ->Iterator[tuple]: # <-- add model_coords# ...fori, (t, c) inenumerate(
zip(
self.particledata.itertuples(index=False),
self.to_coords(grid, localz, model_coords=model_coords), # <-- pass model_coords
)
):
row= [i] # release point index (irpt)if"node"inself.particledata:
k, j=grid.get_lni([t.node])[0]
row.extend([(k, j)])
else:
row.extend([t.k, t.i, t.j])
row.extend(c)
yieldtuple(row)
The text was updated successfully, but these errors were encountered:
@dbrakenhoff thanks a lot for catching this — this should probably convert to model coords by default, since that's PRT's expectation... so maybe we can invert the flag? maybe global_xy to match MODFLOW-USGS/modflow6#1901? since the z coordinate is considered separately. please do feel free to submit!
Describe the bug
Not sure if this can yet be qualified as bug, or is simply still under active development and I'm a bit early in posting this, but I noticed that
ParticleData.to_prp()
returns global coordinates. PRT6 currently expects model coordinates for the input. This isn't caught in the tests as as far as I could see, as no PRT6 models are run using a grid with offsets (in both flopy and modflow6 repos).I saw other options for specifying model coordinates are under review in Modflow6, which might also solve this issue by allowing computation with global coordinates: MODFLOW-USGS/modflow6#1901. Nevertheless, it might be nice to have both global and model coordinate options in
to_prp()
.EDIT: just noticed issue #2388. If vertices are specified in model coordinates, that would also solve this issue.
To Reproduce
Expected behavior
Perhaps the option of returning global or model coordinates could be added to
to_prp()
? Something like the code below could do the trick. I used the term model_coords since in modpath local signifies a location within a cell.If this is something you would want to support, Id be happy to submit a PR with this small change, let me know!
The text was updated successfully, but these errors were encountered: