Ejemplo n.º 1
0
    # Compute the average of the given species
    if (qoi=='ave'):
        ave=np.average(sol[-tail:,1:],axis=0)
        ncol=ave.shape[0]
        npc=ncol/3
        np.savetxt("pccf.dat",ave[npc*(spid-1):npc*spid])
    elif (qoi=='tf'):
        sp_tf=np.array(sol[-1,1:])
        ncol=sp_tf.shape[0]
        npc=ncol/3
        np.savetxt("pccf.dat",sp_tf[npc*(spid-1):npc*spid])

    # Find (in a very unpleasant way) the stochastic dimension
    for dim in range(1,7):
        npcc=get_npc(dim,ord)
        if (npc==npcc):
            break
    
    pcerv=uqtkbin+"/pce_rv"
    os.system(pcerv+" -w'PC' -f'pccf.dat' -x" + pctype + " -d1 -n" + str(nsam) +" -p"+str(dim)+" -o"+str(ord))
    spls=np.genfromtxt("rvar.dat")
    #xlin=np.linspace(spls.min(),spls.max(),npts) ;
    xlin=np.linspace(lims[0],lims[1],npts) ;
    kernlin=stats.kde.gaussian_kde(spls);
    pdflin1=kernlin(xlin);

    plt.plot(xlin,pdflin1,linewidth=2,label=method)

ax.set_xlim(lims)
if qoi == 'ave':
Ejemplo n.º 2
0
f_handle = file("pcfile", "a")
npy.savetxt(f_handle, stdmat, fmt="%.12e", delimiter=" ", newline="\n")
f_handle.close()
print "Mean of model parameters:"
print nomdim
print "Std.dev. of model parameters:"
print stdmat

#-check number of PC terms
inord=1
pccf = npy.genfromtxt('pcfile')
if len(pccf.shape) == 1:
    pccf=npy.array(npy.transpose([pccf]))
indim_par = pccf.shape[1]
npc = pccf.shape[0]
npcc = get_npc(dim,inord)
if npc != npcc:
    print "forUQ_BB(): The number of input PC coefficients does not match to the given dimension and order -> Abort !\n"
    quit()

print "-----------------------------------------------------------------------------------------------------"
print "  ____                    _                 "
print " |  _ \ _   _ _ __  _ __ (_)_ __   __ _   _ "
print " | |_) | | | | '_ \| '_ \| | '_ \ / _` | (_)"
print " |  _ <| |_| | | | | | | | | | | | (_| |  _ "
print " |_| \_\\\__,_|_| |_|_| |_|_|_| |_|\__, | (_)"
print "                                  |___/     "
print "-----------------------------------------------------------------------------------------------------"
#--------------------------------------------------------------------------------------------------
# Construct a PCE expansion of model output as a function of input chaos germ
#--------------------------------------------------------------------------------------------------
Ejemplo n.º 3
0
    # Compute the average of the given species
    if (qoi=='ave'):
        ave=np.average(sol[-tail:,1:],axis=0)
        ncol=ave.shape[0]
        npc=ncol/3
        np.savetxt("pccf.dat",ave[npc*(spid-1):npc*spid])
    elif (qoi=='tf'):
        sp_tf=np.array(sol[-1,1:])
        ncol=sp_tf.shape[0]
        npc=ncol/3
        np.savetxt("pccf.dat",sp_tf[npc*(spid-1):npc*spid])

    # Find (in a very unpleasant way) the stochastic dimension
    for dim in range(1,7):
        npcc=get_npc(dim,ord)
        if (npc==npcc):
            break
    
        
    pcerv=uqtkbin+"/pce_rv"
    os.system(pcerv+" -w'PC' -f'pccf.dat' -x" + pctype + " -d1 -n" + str(nsam) +" -p"+str(dim)+" -q"+str(ord))

    spls=np.genfromtxt("rvar.dat")

    xlin=np.linspace(spls.min(),spls.max(),100) ;
    kernlin=stats.kde.gaussian_kde(spls);
    pdflin1=kernlin(xlin);

    plt.plot(xlin,pdflin1,linewidth=2,label=method)