diff options
| author | Paul Garlick <pgarlick@tourbillion-technology.com> | 2020-07-10 12:45:10 +0100 | 
|---|---|---|
| committer | Paul Garlick <pgarlick@tourbillion-technology.com> | 2020-07-10 12:45:10 +0100 | 
| commit | 3f85ee2f0e41d1f2e8771c7f3d7ee8ac12f09ba3 (patch) | |
| tree | 62006ad6ec4acf0f4fef213c0bf8bccaed1df975 | |
| parent | 1f18c6f43b3c41537548e8c01b0a6fa58bd51f21 (diff) | |
| download | fullSWOF-utils-3f85ee2f0e41d1f2e8771c7f3d7ee8ac12f09ba3.tar.gz | |
python: slope.py: Use cell size in polyfit and plot functions.
* python/slope.py (plot_curve)[PX]: New argument.
| -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() | 
