コード例 #1
0
def calibration_procedure(el, H, ns, set_id, step, comp, typ, wrt_file):

    st = time.time()

    f = h5py.File("D_%s%s_s%s.hdf5" % (ns, set_id, step), 'r')
    r_fft = f.get('rfft%s_%s' % (comp, typ))[...]
    M = f.get('M')[...]
    f.close()

    specinfc = np.zeros((H, el**3), dtype='complex64')

    # here we perform the calibration for the scalar FIP

    specinfc[:, 0] = rr.calib(0, M, r_fft, 0, H, el, ns)
    [specinfc[:, 1], p] = rr.calib(1, M, r_fft, 0, H, el, ns)

    # calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib, M=M, r_fft=r_fft, p=p, H=H, el=el, ns=ns)

    specinfc[:, 2:(el**3)] = np.asarray(map(calib_red,
                                            range(2, el**3))).swapaxes(0, 1)

    f = h5py.File("infl_%s%s_s%s.hdf5" % (ns, set_id, step), 'a')
    f.create_dataset('infl%s_%s' % (comp, typ), data=specinfc)
    f.close()

    msg = 'Calibration, component %s: %s seconds' % \
          (comp, np.round((time.time() - st), 3))
    rr.WP(msg, wrt_file)
コード例 #2
0
def calibration_procedure(el,ns,H,set_id,wrt_file):

    M = np.load('M_%s%s.npy' %(ns,set_id))
    r_fft = np.load('r_fft_%s%s.npy' %(ns,set_id))
    
    start = time.time()
    
    specinfc = np.zeros((H,el**3),dtype = 'complex64')
    
    ## here we perform the calibration for the scalar FIP
    
    specinfc[:,0] = rr.calib(0,M,r_fft,0,H,el,ns)
    [specinfc[:,1],p] = rr.calib(1,M,r_fft,0,H,el,ns)
    
    ## calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib,M=M,r_fft=r_fft,
                        p=p,H=H,el=el,ns=ns)
                        
    specinfc[:,2:(el**3)] = np.asarray(map(calib_red,range(2,el**3))).swapaxes(0,1)
     
    
    np.save('specinfc_%s%s' %(ns,set_id),specinfc)
    
    end = time.time()
    timeE = np.round((end - start),3)
    msg = 'Calibration: %s seconds' %(timeE)
    rr.WP(msg,wrt_file)
コード例 #3
0
def calibration_procedure(ns,set_id,step,comp,wrt_file):

    ## el is the # of elements per side of the cube 
    el = 21 
    ## specify the number of local states you are using
    H = 15
    
    M = np.load('M_%s%s_s%s.npy' %(ns,set_id,step))
    r_fft = np.load('r%s_fft_%s%s_s%s.npy' %(comp,ns,set_id,step))
    
    start = time.time()
    
    specinfc = np.zeros((el**3,H),dtype = 'complex64')
    
    ## here we perform the calibration for the scalar FIP
    
    specinfc[0,:] = rr.calib(0,M,r_fft,0,H,el,ns)
    [specinfc[1,:],p] = rr.calib(1,M,r_fft,0,H,el,ns)
    
    ## calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib,M=M,r_fft=r_fft,
                        p=p,H=H,el=el,ns=ns)
    specinfc[2:(el**3),:] = np.asarray(map(calib_red,range(2,el**3)))
     
    
    np.save('specinfc%s_%s%s_s%s' %(comp,ns,set_id,step),specinfc)
    
    end = time.time()
    timeE = np.round((end - start),3)
    msg = 'Calibration, component %s: %s seconds' %(comp, timeE)
    rr.WP(msg,wrt_file)
コード例 #4
0
def calibration_procedure(el, H, ns, set_id, step, comp, typ, wrt_file):

    f = h5py.File("data.hdf5", 'r')
    dset_name = 'M_%s%s_s%s' % (ns, set_id, step)
    M = f.get(dset_name)[...]
    dset_name = '%s%s_fft_fem_%s%s_s%s' % (typ, comp, ns, set_id, step)
    r_fft = f.get(dset_name)[...]
    f.close()

    start = time.time()

    coef = np.zeros((H, el**3), dtype='complex64')

    # here we perform the calibration for the scalar FIP

    coef[:, 0] = rr.calib(0, M, r_fft, 0, H, el, ns)
    [coef[:, 1], p] = rr.calib(1, M, r_fft, 0, H, el, ns)

    # calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib, M=M, r_fft=r_fft, p=p, H=H, el=el, ns=ns)

    coef[:, 2:(el**3)] = np.asarray(map(calib_red,
                                        range(2, el**3))).swapaxes(0, 1)

    f = h5py.File("coef.hdf5", 'a')
    dset_name = 'coef%s_%s%s_s%s' % (comp, ns, set_id, step)
    f.create_dataset(dset_name, data=coef)
    f.close()

    end = time.time()
    timeE = np.round((end - start), 3)
    msg = 'Calibration, component %s: %s seconds' % (comp, timeE)
    rr.WP(msg, wrt_file)
コード例 #5
0
def calibration_procedure(el, H, ns, set_id, step, comp, typ, wrt_file):

    st = time.time()

    # open HDF5 file
    base = tb.open_file("gsh_try_%s%s_s%s.h5" % (ns, set_id, step),
                        mode="r")
    M = base.root.msf.M[...]
    # close the HDF5 file
    base.close()

    # open HDF5 file
    base = tb.open_file("ref_%s%s_s%s.h5" % (ns, set_id, step),
                        mode="r")

    # retrieve data from HDF5 file
    resp = base.get_node('/%s' % typ, 'r%s' % comp)
    r_fft = resp.r_fft[...]
    # close the HDF5 file
    base.close()

    specinfc = np.zeros((H, el**3), dtype='complex64')

    # here we perform the calibration for the scalar FIP

    specinfc[:, 0] = rr.calib(0, M, r_fft, 0, H, el, ns)
    [specinfc[:, 1], p] = rr.calib(1, M, r_fft, 0, H, el, ns)

    # calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib, M=M, r_fft=r_fft,
                        p=p, H=H, el=el, ns=ns)

    specinfc[:, 2:(el**3)] = np.asarray(map(calib_red, range(2, el**3))).swapaxes(0, 1)

    # open HDF5 file
    base = tb.open_file("infl_%s%s_s%s.h5" % (ns, set_id, step), mode="w")
    # create a group one level below root called infl[comp]
    group = base.create_group('/',
                              'infl%s' % comp,
                              'influence function for component %s' % comp)
    base.create_array(group,
                      'infl_coef',
                      specinfc,
                      'array of influence coefficients')
    # close the HDF5 file
    base.close()

    msg = 'Calibration, component %s: %s seconds' % \
          (comp, np.round((time.time() - st), 3))
    rr.WP(msg, wrt_file)
コード例 #6
0
def calibration_procedure(M, y_fft, el, H, ns, wrt_file):

    st = time.time()

    specinfc = np.zeros((el**3, H), dtype='complex64')

    # here we perform the calibration for the scalar FIP

    specinfc[0, :] = rr.calib(0, M, y_fft, 0, H, el, ns)
    [specinfc[1, :], p] = rr.calib(1, M, y_fft, 0, H, el, ns)

    # calib_red is simply calib with some default arguments
    calib_red = partial(rr.calib, M=M, y_fft=y_fft, p=p, H=H, el=el, ns=ns)

    specinfc[2:(el**3), :] = np.asarray(map(calib_red, range(2, el**3)))

    msg = 'Calibration, component 11: %s seconds' % \
          np.round((time.time() - st), 3)
    rr.WP(msg, wrt_file)

    return specinfc.reshape(el, el, el, H)