From a74e62d2a869f9d046f19e7b076e4d9adbd332aa Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Tue, 23 Nov 2021 11:08:01 -0800 Subject: [PATCH 1/2] fix(plot_pathline): sort projected pathline points by travel time instead of cell order modflowpy#1302 --- flopy/plot/crosssection.py | 5 +++-- flopy/plot/plotutil.py | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/flopy/plot/crosssection.py b/flopy/plot/crosssection.py index 8203d2474e..a1c8dcd00c 100644 --- a/flopy/plot/crosssection.py +++ b/flopy/plot/crosssection.py @@ -1069,8 +1069,9 @@ def plot_pathline( markers = [] for _, arr in plines.items(): arr = np.array(arr) - arr = arr[arr[:, 0].argsort()] - linecol.append(arr) + # sort by travel time + arr = arr[arr[:, -1].argsort()] + linecol.append(arr[:, :-1]) if marker is not None: for xy in arr[::markerevery]: markers.append(xy) diff --git a/flopy/plot/plotutil.py b/flopy/plot/plotutil.py index 8654e8d874..283ced0268 100644 --- a/flopy/plot/plotutil.py +++ b/flopy/plot/plotutil.py @@ -2681,9 +2681,7 @@ def intersect_modpath_with_crosssection( nppts = {} for cell, verts in projpts.items(): - tcell = cell - while tcell >= ncpl: - tcell -= ncpl + tcell = cell % ncpl zmin = np.min(np.array(verts)[:, 1]) zmax = np.max(np.array(verts)[:, 1]) nmin = np.min(v_norm[tcell]) @@ -2807,7 +2805,7 @@ def reproject_modpath_to_crosssection( rec[xp] = x rec[yp] = y pid = rec["particleid"][0] - pline = list(zip(rec[proj], rec[zp])) + pline = list(zip(rec[proj], rec[zp], rec['time'])) if pid not in ptdict: ptdict[pid] = pline else: @@ -2825,7 +2823,7 @@ def reproject_modpath_to_crosssection( rec[xp] = x rec[yp] = y pid = rec["particleid"][0] - pline = list(zip(rec[proj], rec[zp])) + pline = list(zip(rec[proj], rec[zp], rec['time'])) if pid not in ptdict: ptdict[pid] = pline else: From 7985d273c44ecb8d66b5ca3081a9e069f6af9627 Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Tue, 23 Nov 2021 11:13:17 -0800 Subject: [PATCH 2/2] Linting --- flopy/plot/plotutil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flopy/plot/plotutil.py b/flopy/plot/plotutil.py index 283ced0268..478ee3ee82 100644 --- a/flopy/plot/plotutil.py +++ b/flopy/plot/plotutil.py @@ -2805,7 +2805,7 @@ def reproject_modpath_to_crosssection( rec[xp] = x rec[yp] = y pid = rec["particleid"][0] - pline = list(zip(rec[proj], rec[zp], rec['time'])) + pline = list(zip(rec[proj], rec[zp], rec["time"])) if pid not in ptdict: ptdict[pid] = pline else: @@ -2823,7 +2823,7 @@ def reproject_modpath_to_crosssection( rec[xp] = x rec[yp] = y pid = rec["particleid"][0] - pline = list(zip(rec[proj], rec[zp], rec['time'])) + pline = list(zip(rec[proj], rec[zp], rec["time"])) if pid not in ptdict: ptdict[pid] = pline else: