Ejemplo n.º 1
0
def combine():

    C = constants_old.const()
    filename = 'log_combine_coef.txt'

    """ Combine the results of the coefficient determination"""
    # coeff is the combined vector of coefficients as calculated by the
    # orthogonal regression
    coef = np.zeros((C['cmax'], 10), dtype='complex128')

    c = 0
    for tnum in xrange(C['integrate_njobs']):

        fn.WP(str(tnum), filename)

        # load partially filled coefficient arrays from each file
        f = h5py.File(C['integrate_output'] % str(tnum).zfill(5), 'r')
        coef_prt = f.get('coef_prt')[...]
        f.close()

        clen = coef_prt.shape[0]

        coef[c:c+clen, :] = coef_prt
        c += clen

    # save the coefficients file
    f = h5py.File(C['combinecoef_coef'], 'w')
    f.create_dataset('coef', data=coef)
    f.close()

    rrr = np.hstack([np.arange(coef.shape[0])[:, None],
                     coef[:, 0].real[:, None]])
    print np.round(rrr, 1)
Ejemplo n.º 2
0
def calculate():

    C = constants_old.const()

    filename = 'Xcalc_log_cos.txt'

    """ Load info from collected simulation info file """

    f = h5py.File(C['combineread_output'], 'r')
    var_set = f.get('var_set')

    theta = var_set[:, 0]

    f.close

    f = h5py.File(C['Xcalccos_output'], 'a')

    """Evalute the cosine basis functions for theta"""

    st = time.time()

    for q in xrange(C['N_q']):

        vec = np.cos(q*np.pi*theta/C['L_th'])

        set_id = 'q_%s' % str(q).zfill(5)
        f.create_dataset(set_id, data=vec)
        fn.WP(set_id, filename)

    msg = "Cosine basis evaluation for theta complete: %ss" \
        % np.round(time.time()-st, 3)
    fn.WP(msg, filename)

    f.close()
Ejemplo n.º 3
0
def combine():

    C = constants_old.const()

    filename = 'log_Xcalc_combine.txt'

    f_master = h5py.File(C['combineXcalc_output'], 'w')
    """load the cosine basis evaluations"""
    f_cos = h5py.File(C['Xcalccos_output'], 'r')

    for name in f_cos.keys():
        fn.WP(name, filename)
        tmp = f_cos.get(name)[...]
        f_master.create_dataset(name, data=tmp)
        del tmp

    f_cos.close()
    """load the GSH basis evaluations"""
    for jobnum in xrange(C['XcalcGSH_njobs']):

        f_gsh = h5py.File(C['XcalcGSH_output'] % str(jobnum).zfill(5), 'r')

        for name in f_gsh.keys():
            fn.WP(name, filename)
            tmp = f_gsh.get(name)[...]
            f_master.create_dataset(name, data=tmp)
            del tmp

        f_gsh.close()

    f_master.close()
Ejemplo n.º 4
0
import numpy as np
import db_functions as fn
import gsh_cub_tri_L0_24 as gsh
import h5py
import time
import sys
import constants_old

tnum = np.int64(sys.argv[1])
C = constants_old.const()
filename = 'log_integrate_parallel_%s.txt' % str(tnum).zfill(5)
"""calculate basis function indices"""

# cmax: total number of permutations of basis functions
fn.WP(str(C['cmax']), filename)

# cmat is the matrix containing all permutations of basis function indices
cmat = np.unravel_index(np.arange(C['cmax']), C['N_tuple'])
cmat = np.array(cmat).T
"""deal with the parallelization of this operation specifically pick range
of indxmat to calculate"""

# n_ii: number integrations per job
n_ii = np.int64(np.ceil(np.float(C['cmax']) / C['integrate_njobs']))
fn.WP(str(n_ii), filename)

ii_stt = tnum * n_ii  # start index
ii_end = ii_stt + n_ii  # end index
if ii_end > C['cmax']:
    ii_end = C['cmax']