Esempio n. 1
0
phi = np.float64(ep_set[:, 2])
phi2 = np.float64(ep_set[:, 3])
et_norm = ep_set[:, 4]

f.close

f = h5py.File('pre_fourier_p%s_q%s.hdf5' % (p, q), 'a')

L_th = (2. * np.pi) / 3.
p_vec = np.zeros(p + 1)
p_vec[p] = 1
N_L = 15

st = time.time()

for L in xrange(N_L):

    vec, cmat = gsh.gsh(phi1, phi, phi2, L)
    vec *= leg.legval(et_norm, p_vec)
    vec *= np.real(np.exp((1j * 2. * np.pi * np.float(q) * theta) / L_th))

    set_id = 'set_%s_%s_%s' % (L, p, q)
    f.create_dataset(set_id, data=vec)

    tmp = np.array([L, p, q])
    print tmp

print "basis evaluation complete: %ss" % np.round(time.time() - st, 3)

f.close()
N_p = 8
N_q = 8

cmax = N_L*N_p*N_q
cvec = np.zeros([cmax, 3])

st = time.time()

for c in xrange(cmax):

    [L, p, q] = np.unravel_index(c, [N_L, N_p, N_q])

    p_vec = np.zeros(N_p)
    p_vec[p] = 1

    vec, cmat = gsh.gsh(np.transpose(e_angles), L)
    vec *= leg.legval(et_norm, p_vec)
    vec *= np.real(np.exp((1j*2.*np.pi*np.float(q)*theta)/L_th))

    set_id = 'set_%s_%s_%s' % (L, p, q)
    f.create_dataset(set_id, data=vec)

    tmp = np.array([L, p, q])
    print tmp
    cvec[c, :] = tmp

f.create_dataset('cvec', data=cvec)

print "basis evaluation complete: %ss" % np.round(time.time()-st, 3)

f.close()
# N_L = np.max(coeff_vec[:,0])+1
# N_p = np.max(coeff_vec[:,1])+1
# N_q = np.max(coeff_vec[:,2])+1

interp_vec = np.zeros(ep_set.shape[0])

st = time.time()

for ii in xrange(coeff_vec.shape[0]):
    L, p, q = coeff_vec[ii, :3]

    p_vec = np.zeros(p + 1)
    p_vec[p] = 1

    vec = gsh.gsh(phi1, phi, phi2, L) * \
        leg.legval(et_norm, p_vec) * \
        np.real(np.exp((1j*2*np.pi*q*theta)/L_th))

    interp_vec += vec

end = time.time()
n_interp = ep_set.shape[0]
time_per_interp = np.round((end - st) / n_interp, 7)

print "interpolation time per input set: %ss" % time_per_interp

error = np.abs(Y - interp_vec) * 1E6

print "mean interpolation error: %s (ep in ppm)" % np.mean(error)
print "max interpolation error: %s (ep in ppm)" % np.max(error)
Esempio n. 4
0
vec = np.zeros(theta.size, dtype='complex128')

for ii in xrange(cmax):
# for ii in xrange(10):

    if np.mod(ii, 100) == 0:
        fn.WP(str(ii), filename)

    L, p, q = cmat[ii, :]

    p_vec = np.zeros(p+1)
    p_vec[p] = 1

    tmp = np.zeros(theta.size, dtype='complex128')

    tmp[:], null = gsh.gsh(phi1, phi, phi2, L)
    tmp[:] *= leg.legval(fn.real2comm(et_norm, a, b), p_vec)
    tmp[:] *= np.real(np.exp((1j*2.*np.pi*np.float64(q)*theta)/L_th))
    tmp[:] *= coeff[ii]

    vec[:] += tmp

Ttime = np.round(time.time()-st, 3)
msg = "total interpolation time: %ss" % Ttime
fn.WP(msg, filename)
msg = "interpolation time per point: %s" % (Ttime/theta.size)
fn.WP(msg, filename)

msg = str(vec.shape)
fn.WP(msg, filename)