diff options
author | Paul Garlick <pgarlick@tourbillion-technology.com> | 2020-07-10 13:48:52 +0100 |
---|---|---|
committer | Paul Garlick <pgarlick@tourbillion-technology.com> | 2020-07-10 13:48:52 +0100 |
commit | ebba7a48fa412198bd4c82818799e2e3b559c4c2 (patch) | |
tree | ba7965eb93b402b648a1c9b6e24420e675e47cbd | |
parent | 3f85ee2f0e41d1f2e8771c7f3d7ee8ac12f09ba3 (diff) | |
download | fullSWOF-utils-ebba7a48fa412198bd4c82818799e2e3b559c4c2.tar.gz |
python: slope.py: Use maximum y-value in polyfit and plot functions.
* python/slope.py (plot_curve)[MY]: New argument.
-rwxr-xr-x | python/slope.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/python/slope.py b/python/slope.py index cd1dea7..da6d314 100755 --- a/python/slope.py +++ b/python/slope.py @@ -122,10 +122,11 @@ def detach_display(): fig.canvas.callbacks.disconnect(cid) #print(xMarker) -def plot_curve(PX): +def plot_curve(MY, PX): """ Fit straight line to channel elevation data. Pixel size PX is - used to convert pixel indices to co-ordinate values. + used to convert pixel indices to co-ordinate values. The maximum + co-ordinate value in the y-direction is MY. """ # sort markers by y value #yx = list(zip(yMarker, xMarker)) @@ -160,13 +161,14 @@ def plot_curve(PX): # Add to list. Repeat. # Fit with polyfit - m, c = np.polyfit([499.75 - y*PX for y in ych], zch, 1) + m, c = np.polyfit([MY - y*PX for y in ych], zch, 1) print('gradient =', m, 'intercept =', c) + print('MY =', MY) fig, ax = plt.subplots() - line1, = ax.plot([499.75 - y*PX for y in ych], zch) - line2, = ax.plot([499.75 - y*PX for y in ych], - [c + m*499.75 - m*y*PX for y in ych], '--') + line1, = ax.plot([MY - y*PX for y in ych], zch) + line2, = ax.plot([MY - y*PX for y in ych], + [c + m*MY - m*y*PX for y in ych], '--') ax.set_xlabel('Distance / m') ax.set_ylabel('Height / m') ax.set_title('Channel profile') @@ -210,7 +212,7 @@ while (True): elif(input_str == "m"): detach_display() elif(input_str == "p"): - plot_curve(DY) + plot_curve(ytp[-1], DY) elif(input_str == "s"): save_xyz() |