Chris fix error handle
This commit is contained in:
parent
cf2c826226
commit
fe960d1dea
@ -126,8 +126,8 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
print ('-'*60)
|
print('-'*60)
|
||||||
print ("Running Canny shock finder version {0}".format(VERSION_STRING))
|
print("Running Canny shock finder version {0}".format(VERSION_STRING))
|
||||||
|
|
||||||
# do some basic input checking
|
# do some basic input checking
|
||||||
if not isinstance(sigma, (float, int)):
|
if not isinstance(sigma, (float, int)):
|
||||||
@ -148,7 +148,7 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
start_time = time_list[0]
|
start_time = time_list[0]
|
||||||
|
|
||||||
if post_shock_pressure:
|
if post_shock_pressure:
|
||||||
print ("Using post-shock pressure scaling so the post_suppression_threshold will be calculated using a post-shock pressure estimate.")
|
print("Using post-shock pressure scaling so the post_suppression_threshold will be calculated using a post-shock pressure estimate.")
|
||||||
|
|
||||||
# we need to calculate our post_suppression_threshold here based on the expected post-shock pressure and the
|
# we need to calculate our post_suppression_threshold here based on the expected post-shock pressure and the
|
||||||
# scaling caused by the first order gaussian data based on the maximum of the Gaussian
|
# scaling caused by the first order gaussian data based on the maximum of the Gaussian
|
||||||
@ -178,10 +178,10 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
post_suppression_threshold = post_shock_pressure * gaussian_first_derivative_max
|
post_suppression_threshold = post_shock_pressure * gaussian_first_derivative_max
|
||||||
|
|
||||||
#post_suppression_threshold = 0.5 * post_shock_pressure * gaussian_max/2.0
|
#post_suppression_threshold = 0.5 * post_shock_pressure * gaussian_max/2.0
|
||||||
print ("Calculated post_suppression_threshold is {0}".format(post_suppression_threshold))
|
print("Calculated post_suppression_threshold is {0}".format(post_suppression_threshold))
|
||||||
|
|
||||||
if calculate_automatic_derivative_threshold:
|
if calculate_automatic_derivative_threshold:
|
||||||
print ("Calculating automatic derivative threshold as the user has asked for this.")
|
print("Calculating automatic derivative threshold as the user has asked for this.")
|
||||||
|
|
||||||
# this commented out code here was my original model, based on the actual second derivative of the Gaussian,
|
# this commented out code here was my original model, based on the actual second derivative of the Gaussian,
|
||||||
# but it didn't seem to work too well (it got too small at very high sigma values, i.e. above 6 or so)
|
# but it didn't seem to work too well (it got too small at very high sigma values, i.e. above 6 or so)
|
||||||
@ -199,7 +199,7 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
else:
|
else:
|
||||||
derivative_threshold = post_shock_pressure / 2.5 * np.exp(-6) / 10.0
|
derivative_threshold = post_shock_pressure / 2.5 * np.exp(-6) / 10.0
|
||||||
|
|
||||||
print ("Calculated derivative_threshold is {0}.".format(derivative_threshold))
|
print("Calculated derivative_threshold is {0}.".format(derivative_threshold))
|
||||||
|
|
||||||
# make the input data arrays incase they didn't come in that way...
|
# make the input data arrays incase they didn't come in that way...
|
||||||
time_list = np.array(time_list)
|
time_list = np.array(time_list)
|
||||||
@ -224,14 +224,14 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
first_value_uncertainty = None
|
first_value_uncertainty = None
|
||||||
|
|
||||||
if auto_derivative:
|
if auto_derivative:
|
||||||
print ("Doing auto-derivative!")
|
print("Doing auto-derivative!")
|
||||||
# remove points which have the same gradient on either side
|
# remove points which have the same gradient on either side
|
||||||
for i in range(0,len(first_order_data)-1):
|
for i in range(0,len(first_order_data)-1):
|
||||||
if np.sign(second_order_data[i-1]) == np.sign(second_order_data[i+1]):
|
if np.sign(second_order_data[i-1]) == np.sign(second_order_data[i+1]):
|
||||||
suppressed_data[i] = 0
|
suppressed_data[i] = 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("Not doing auto-derivative!")
|
print("Not doing auto-derivative!")
|
||||||
for i in range(0,len(first_order_data)-1):
|
for i in range(0,len(first_order_data)-1):
|
||||||
|
|
||||||
# check the gradients on either side using the second order data
|
# check the gradients on either side using the second order data
|
||||||
@ -476,7 +476,7 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
|
|||||||
|
|
||||||
mplt.show()
|
mplt.show()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print ("{0}: {1}".format(type(e).__name__, e.message))
|
print (e)
|
||||||
print ("There was an issue plotting the result.")
|
print ("There was an issue plotting the result.")
|
||||||
mplt.close('all')
|
mplt.close('all')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user