|
|
@ -316,8 +316,15 @@ def slope_from_profile(
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# Need all data to get the slope
|
|
|
|
# Need all data to get the slope
|
|
|
|
if any([x is None for x in [profile_x, profile_z, top_elevation, btm_elevation]]):
|
|
|
|
# Check validity of profile arrays and return None if data is not good
|
|
|
|
return None
|
|
|
|
for profile in [profile_x, profile_z]:
|
|
|
|
|
|
|
|
if all(np.isnan(profile)) or all(x is None for x in profile):
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check validity of elevation values
|
|
|
|
|
|
|
|
for ele in [top_elevation, btm_elevation]:
|
|
|
|
|
|
|
|
if np.isnan(ele) or ele is None:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
end_points = {"top": {"z": top_elevation}, "btm": {"z": btm_elevation}}
|
|
|
|
end_points = {"top": {"z": top_elevation}, "btm": {"z": btm_elevation}}
|
|
|
|
|
|
|
|
|
|
|
@ -377,6 +384,11 @@ def slope_from_profile(
|
|
|
|
True if end_points["top"]["x"] < pts < end_points["btm"]["x"] else False
|
|
|
|
True if end_points["top"]["x"] < pts < end_points["btm"]["x"] else False
|
|
|
|
for pts in profile_x
|
|
|
|
for pts in profile_x
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Need at least two points to do linear regression
|
|
|
|
|
|
|
|
if sum(profile_mask) < 2:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
slope_x = np.array(profile_x)[profile_mask].tolist()
|
|
|
|
slope_x = np.array(profile_x)[profile_mask].tolist()
|
|
|
|
slope_z = np.array(profile_z)[profile_mask].tolist()
|
|
|
|
slope_z = np.array(profile_z)[profile_mask].tolist()
|
|
|
|
slope, _, _, _, _ = stats.linregress(slope_x, slope_z)
|
|
|
|
slope, _, _, _, _ = stats.linregress(slope_x, slope_z)
|
|
|
|