diff options
-rwxr-xr-x | python/slope.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/python/slope.py b/python/slope.py index 0bf99b3..cd1dea7 100755 --- a/python/slope.py +++ b/python/slope.py @@ -122,7 +122,11 @@ def detach_display(): fig.canvas.callbacks.disconnect(cid) #print(xMarker) -def plot_curve(): +def plot_curve(PX): + """ + Fit straight line to channel elevation data. Pixel size PX is + used to convert pixel indices to co-ordinate values. + """ # sort markers by y value #yx = list(zip(yMarker, xMarker)) #yx.sort() @@ -156,13 +160,13 @@ def plot_curve(): # Add to list. Repeat. # Fit with polyfit - m, c = np.polyfit([499.75 - y*0.5 for y in ych], zch, 1) + m, c = np.polyfit([499.75 - y*PX for y in ych], zch, 1) print('gradient =', m, 'intercept =', c) fig, ax = plt.subplots() - line1, = ax.plot([499.75 - y*0.5 for y in ych], zch) - line2, = ax.plot([499.75 - y*0.5 for y in ych], - [c + m*499.75 - m*y*0.5 for y in ych], '--') + 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], '--') ax.set_xlabel('Distance / m') ax.set_ylabel('Height / m') ax.set_title('Channel profile') @@ -206,7 +210,7 @@ while (True): elif(input_str == "m"): detach_display() elif(input_str == "p"): - plot_curve() + plot_curve(DY) elif(input_str == "s"): save_xyz() |