def AuxTwo( t1, t2, type_t, X_data, Y_data, dx ): # approximate times of applicable static measurement (turning points on either end) # t1 is approximate time of first turning point # t2 is approximate time of the last turning point # type_t specifies t1 and t2 as either maxima or dg.Minima # X_data is the time array of data # Y_data is the theta_laser array of data # dx is the range to test for true turning point if type_t == 'maxima': imin, xmin, ymin = dg.maxima(X_data, Y_data, t1, dx, ret='all') imax, xmax, ymax = dg.maxima(X_data, Y_data, t2, dx, ret='all') if type_t == 'minima': imin, xmin, ymin = dg.minima(X_data, Y_data, t1, dx, ret='all') imax, xmax, ymax = dg.minima(X_data, Y_data, t2, dx, ret='all') av_y = np.average(Y_data[imin:imax]) Y_av = [] for i in range(len(X_data[imin:imax])): Y_av.append(av_y) return xmin, ymin, xmax, ymax, np.array(X_data[imin:imax]), np.array(Y_av)
def theta_driven(X, Y, theta_1, printA=False): x1 = np.e**(-(gamma.val * T.av) / 2) t_max_approx = np.array([3.26, 3.64, 4.04, 4.41, 4.79, 5.17]) # 2.87 t_min_approx = np.array([3.06, 3.44, 3.82, 4.20, 4.59, 4.98]) # 5.36 i_max, i_min = [0], [] for t in t_max_approx: i_max.append(dg.maxima(X, Y, t, 25)) for t in t_min_approx: i_min.append(dg.minima(X, Y, t, 25)) i_ext = np.hstack((np.array(i_max), np.array(i_min))) i_ext = np.sort(i_ext) THETA = Y[i_ext] N = len(THETA) # needs work def theta_n(n, x): return theta_e.val + (theta_1 - theta_e.val) * (-x)**(n - 1) THETA2 = [] for n in np.arange(1, N + 1): THETA2.append(theta_n(n, x1)) THETA2 = np.array(THETA2) Xs = [] for i in np.arange(1, N - 2): Xs.append(-(THETA[i + 2] - THETA[i + 1]) / (THETA[i + 1] - THETA[i])) x2 = dg.var('x2', Xs, 'std', 'mRad') x3_val = 1 - (THETA[1] - THETA[11]) / ( THETA[1] - THETA[2] + THETA[3] - THETA[4] + THETA[5] - THETA[6] + THETA[7] - THETA[8] + THETA[9] - THETA[10]) def x3_err(theta_err): return theta_err * (1 - x3_val) * np.sqrt( (13 - 1) * (1 - x3_val)**2 + 2 * x3_val) / abs(THETA[0] - THETA[12]) x3 = dg.var('x3', x3_val, np.average(x3_err(theta_laser_err(THETA, .05, C))), None) theta_d_val = ( (1 - x3.val) * (THETA[0] - THETA[1] + THETA[2] - THETA[3] + THETA[4] - THETA[5] + THETA[6] - THETA[7] + THETA[8] - THETA[9] + THETA[10] - THETA[11] + THETA[12]) - THETA[0] + THETA[12]) / ((13 - 1) * (1 + x3.val)) err1 = np.average(theta_laser_err(THETA, .05, C)) * np.sqrt( (13 - 1) * (1 - x3.val)**2 + 2 * x3.val) / ((13 - 1) * (1 + x3.val)) err2 = x3.err * ( 2 * (THETA[0] - THETA[1] + THETA[2] - THETA[3] + THETA[4] - THETA[5] + THETA[6] - THETA[7] + THETA[8] - THETA[9] + THETA[10] - THETA[11]) + (THETA[12] - THETA[1])) / ((13 - 1) * (1 + x3.val)**2) theta_d_err = np.sqrt(err1**2 + err2**2) theta_d = dg.var('theta_d', theta_d_val, theta_d_err, 'mRad') if printA == True: print(theta_d.name, theta_d.val, theta_d.err, theta_d.units) return theta_d