Exemple #1
0
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)
Exemple #2
0
def DrivenG(plot=False, printA=False):
    plt.close('all')

    D = np.load(nppath + 'driven.npy')
    X, Y = D[:, 0] / 1000, (D[:, 1] - eq2) * C.val  # data
    data = dp.data(X, Y, '-', 'b', 'data')  # data

    i_1 = dg.maxima(X, Y, 2.87, 25)
    x1, y1 = X[i_1], Y[i_1]
    d1 = dp.data([x1], [y1], '*', 'r', '$X[t_0],\ Y[t_0]$')

    X2 = X[i_1:]
    Y2 = Y[i_1:]
    Y2_env, Y2_man, Y2_fit, par_f = dampedWave(X2, Y2, par_m)
    d2_man = dp.data(X2, Y2_man, '--', 'm', 'manual fit')
    d2_env = dp.data(X2, Y2_env, '--', 'c', 'upper envelope')
    d2_fit = dp.data(X2, Y2_fit, '-', 'r', 'least-square fit')

    n1 = '$\\theta_e + A e^{-\\gamma t} \cos{\\omega t}$'
    n2 = '$\\theta_e$ = %s $\pm$ %s mRad' % (round(par_f[0], 1), .1)
    n3 = 'A = %s $\pm$ %s mRad' % (round(par_f[1], 1), .2)
    n4 = '$\\gamma$ = %s $\pm$ %s (10$^3$ s)$^{-1}$' % (round(par_f[2], 1), .1)
    n5 = '$\\omega$ = %s $\pm$ %s (10$^3$ s)$^{-1}$' % (round(par_f[3], 1), .2)
    note = dp.note(n1 + '\n' + n2 + '\n' + n3 + '\n' + n4 + '\n' + n5, 4, -10,
                   'r')

    theta_d = theta_driven(X2, Y2, y1, printA=True)
    G_d = dg.var('G_d', G(theta_d.val), G_d_err(k, theta_d, R, M_m, m_m, d),
                 'N m^2 kg^-2')
    dg.printvar(G_d)
    print(G_d.val, G_d.err)

    if plot == True:
        ax = dp.ax([data, d1, d2_env, d2_man, d2_fit], 111,
                   'time [$10^3$ sec]', '$\\theta_{laser}$ [mRad]',
                   'Driven Measurement')
        ax.notes = [note]

        dp.plot([ax])  #, name=gp+'0_4_DrivenG')

    if printA == True:
        print("Driven G Results:")

    return theta_d
Exemple #3
0
def DrivenG(N=13, plot=False, printA=False):
    plt.close('all')

    D = np.load(nppath + 'driven.npy')
    X, Y = D[:, 0] / 1000, (D[:, 1] - eq2) * C.val  # data
    data = dp.data(X, Y, '-', 'b', 'data')  # data

    i_1 = dg.maxima(X, Y, 2.87, 25)
    x1, y1 = X[i_1], Y[i_1]
    d1 = dp.data([x1], [y1], '*', 'r', '$X[t_0],\ Y[t_0]$')

    X2 = X[i_1:]
    Y2 = Y[i_1:]
    Y2_env, Y2_man, Y2_fit, par_f = dampedWave(X2, Y2, par_m)
    d2_man = dp.data(X2, Y2_man, '--', 'm', 'manual fit')
    d2_env = dp.data(X2, Y2_env, '--', 'c', 'upper envelope')
    d2_fit = dp.data(X2, Y2_fit, '-', 'r', 'least-square fit')

    n1 = '$\\theta_e + A e^{-\\gamma t} \cos{\\omega t}$'
    n2 = '$\\theta_e$ = %s $\pm$ %s mRad' % (round(par_f[0], 1), .1)
    n3 = 'A = %s $\pm$ %s mRad' % (round(par_f[1], 1), .2)
    n4 = '$\\gamma$ = %s $\pm$ %s (10$^3$ s)$^{-1}$' % (round(par_f[2], 1), .1)
    n5 = '$\\omega$ = %s $\pm$ %s (10$^3$ s)$^{-1}$' % (round(par_f[3], 1), .2)
    note = dp.note(n1 + '\n' + n2 + '\n' + n3 + '\n' + n4 + '\n' + n5, 4, -10,
                   'r')

    ext, theta_d = theta_driven(X, Y, 6, N=N)

    d2_ext = dp.data(ext[:, 0], ext[:, 1], '*', 'g', '$\\theta_n$')

    if plot == True:
        ax = dp.ax([data, d1, d2_env, d2_man, d2_fit, d2_ext], 111,
                   'time [$10^3$ sec]', '$\\theta_{laser}$ [mRad]',
                   'Driven Measurement')
        ax.notes = [note]

        dp.plot([ax], name=gp + '0_4_DrivenG')

    if printA == True:
        print("fitting parameters")
        print(par_f)

    return theta_d
Exemple #4
0
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