modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
520 stars 314 forks source link

Still about plot_pathline in plot_crosssection #1108

Closed wsc1008-cugb closed 3 years ago

wsc1008-cugb commented 3 years ago

I want to use the "plot_pathline" to plot the CrossSection result, which from 0 layer to bottom. I have used the latest version of flopy, and try an example which is similar with the flopy3_modpath6_example.ipynb, there is such error:

`fig = plt.figure(figsize=(80, 25))

ax = fig.add_subplot(1, 1, 1, aspect='equal')

mx = flopy.plot.PlotCrossSection(ax=ax, model=swt, line={'row': 0})

ibound = mx.plot_ibound()

grid = mx.plot_grid(color='0.3', alpha=0.1)

quadmesh = mx.plot_bc('WEL', kper=4)

contour_set = mx.contour_array(hds, levels=np.arange(np.min(hds),np.max(hds),0.5), colors='b')

plt.clabel(contour_set, inline=True, fontsize=35)

mx.plot_endpoint(well_epd, direction='starting', colorbar=True)

for now, each particle must be plotted individually

(plot_pathline() will plot a single line for recarray with multiple particles)

for pid in np.unique(well_pathlines.particleid):

modelmap.plot_pathline(pthobj.get_data(pid), layer='all', colors='red');

mx.plot_pathline(well_pathlines, method='cell', colors='red')`

image

jlarsen-usgs commented 3 years ago

I'll take a look at this.

jlarsen-usgs commented 3 years ago

@wsc1008-cugb

the IndexError message shows changes to the code that does not match the source code within the flopy development repository.

lines 2759 and 2760 within the repository are:

nmin = np.min(v_norm[cell])
nmax = np.max(v_norm[cell])

instead of

nmin = np.min(v_norm[cell] + 1)
nmax = np.max(v_norn[cell] + 1)

Please update your version of flopy to the most recent repo version using

pip install -U https://github.com/modflowpy/flopy/zipball/develop
wsc1008-cugb commented 3 years ago

@wsc1008-cugb

the IndexError message shows changes to the code that does not match the source code within the flopy development repository.

lines 2759 and 2760 within the repository are:

nmin = np.min(v_norm[cell])
nmax = np.max(v_norm[cell])

instead of

nmin = np.min(v_norm[cell] + 1)
nmax = np.max(v_norn[cell] + 1)

Please update your version of flopy to the most recent repo version using

pip install -U https://github.com/modflowpy/flopy/zipball/develop

Thank you, But sorry, I have tried many times, it still doesn't work.

jlarsen-usgs commented 3 years ago

@wsc1008-cugb

Unfortunately, the copy of your source code does not match that in the flopy repo based on the error message. If you remove the "+ 1" from 2759 and 2760 of plotutil.py you should not get this error. Flopy uses a zero based indexing scheme, the "+ 1" is causing your error.

wsc1008-cugb commented 3 years ago

@wsc1008-cugb

Unfortunately, the copy of your source code does not match that in the flopy repo based on the error message. If you remove the "+ 1" from 2759 and 2760 of plotutil.py you should not get this error. Flopy uses a zero based indexing scheme, the "+ 1" is causing your error.

I‘m so sorry to bother you agian, I mistook the image at first. I have tried without any change at the beginning, it didn't work. So then I added the "+1" and "-1" at 2759 and 2760 to make it work, but I failed agian. Here is the first time I tried. There is the same error.

image

jlarsen-usgs commented 3 years ago

@wsc1008-cugb Thanks for the clarification. I've recreated the issue and found that the modpath intersection method is not handling layered data correctly. I'm currently working on a fix for this.

wsc1008-cugb commented 3 years ago

@jlarsen-usgs Thank you very much, it works!