Exemplo n.º 1
0
    """

    et = dset[:, 7:13]
    ep = dset[:, 13:19]

    # check that et is traceless
    et_tr = et[:, 0] + et[:, 1] + et[:, 2]

    et_tr_max = np.max(np.abs(et_tr))

    if et_tr_max > 1E-4:
        print ii
        print et_tr_max

    # calculate the norm of et
    et_norm = np.sqrt(et[:, 0]**2 + et[:, 1]**2 + et[:, 2]**2 + et[:, 3]**2 +
                      et[:, 4]**2 + et[:, 5]**2)

    # check that this curve is represented well with legendre polynomial

    ep11 = ep[:, 0]

    nodes, weights, rootsamp = lif.get_nodes(et_norm, ep11, a, b, N)

    eindx = np.int16(np.round((180. / (3. * np.pi)) * euler[ii, :]))

    ep_set[eindx[0], eindx[1], eindx[2], :] = rootsamp

f_mwp.close()
f_nhp.close()
# numbers of nodes
leg_set = np.array([4, 5, 6, 7, 8, 9, 10, 15, 20])
leg_error = np.zeros([leg_set.size, 9])

c = 0

for N in leg_set:
    mean_err = np.zeros(N_samp * n_th)
    max_err = np.zeros(N_samp * n_th)

    for ii in xrange(N_samp * n_th):

        xvar = alldata[ii, 4:45]
        yvar = alldata[ii, 45:86]

        xnode, ynode, weights = leg.get_nodes(etvec, yvar, a, b, N)

        coeff_set = leg.get_coeff(xnode, ynode, weights, N)

        ytest = leg.get_interp(xvar, coeff_set, a, b)

        # calculate error in this approach based on sampled values
        error = 100 * np.abs((yvar - ytest) / xvar)

        # if N == 6 and ii > .3*N_samp*n_th:
        #     print np.mean(error)
        #     plt.figure(num=1, figsize=[10, 6])
        #     plt.plot(xvar, yvar, 'bx')
        #     plt.plot(etvec, ytest, 'r')
        #     plt.show()