예제 #1
0
파일: kolmogorov.py 프로젝트: bnikolic/oof
def GenKolmogorov(N,
                  seed=0):

    grid=pybnlib.doubleArray( N*N)

    pybnlib.KolmogorovPlatform(N,
                               grid,
                               seed)
    return CopyToNA(grid,N)
예제 #2
0
def GenerateKolmogorov3D( Nx,Ny,Nz,
                          seed=None,
                          opt=pybnlib.KInitialEFB):

    grid=pybnlib.doubleArray( Nx*Ny*Nz)
    rfn=pybnlib.NormDistZM(1.0)
    if seed != None:
        rfn.reseed(seed)
    pybnlib.Kolmogorov3D( grid, Nx,Ny,Nz, rfn, opt)
    return ( grid,
             ( Nx,Ny,Nz) )
예제 #3
0
def DrawCorners(N=3,ver="V1"):
    cube= pybnlib.doubleArray( N**3)
    for i in range(N**3):
        cube[i]=0
    if ver == "V1":
        pybnlib.KolmogorovCorners3D( cube, N, rfn)
    elif ver == "V2":
        pybnlib.KolmogorovCorners3DV2( cube, N, rfn)
    else:
        raise "Unkown version"
    
    return cube
예제 #4
0
def SimpleGridMagTest():
    N=3

    a=pybnlib.doubleArray( N*N*N)
    for x,y,z in [ (0,0,0),
                   (N-1,0,0),
                   (0,N-1,0),
                   (0,0,N-1),
                   (N-1,N-1,0),
                   (N-1,0,N-1),
                   (0,N-1,N-1),
                   (N-1,N-1,N-1)]:

        a[x+ y*N + z*N*N]=1

    b=pybnlib.doubleArray( 5*3*3)

    pybnlib.KMagnifyGrid( a, N,
                          b,
                          5,3,3)

    return b
예제 #5
0
def GenK(N,usenumpy=False):
    grid=pybnlib.doubleArray( N*N*N)
    rfn=pybnlib.NormDistZM(1.0)
    pybnlib.Kolmogorov3D( grid, N, rfn)
    if usenumpy:
        res=numpy.zeros( (N,N,N), numpy.float64)
    else:
        res=numarray.zeros( (N,N,N), numarray.Float64)
        
    for k in range(N):
        for j in range(N):
            for i in range(N):
                res[i,j,k] = grid[ k*N*N+j*N+i]
    return res
예제 #6
0
def ZFlatten(g,x):

    Nx, Ny, Nz = g[1]

    ext=pybnlib.Extnent3D()
    ext.i=Nx
    ext.j=Ny
    ext.k=Nz

    res=pybnlib.doubleArray( Nx*Ny)
    pybnlib.ZFlatten( g[0],
                      ext,
                      0,
                      x,
                      res)
    return res
예제 #7
0
def RandomCubeSFN(cube,
                  s_p,
                  acumlen):

    "Compute the structure function"

    acum= pybnlib.doubleArray( acumlen)
    ns=   pybnlib.size_tArray( acumlen)
    
    pybnlib.RandomSFN( cube[0], cube[1][0], cube[1][1], cube[1][2], s_p, acum, ns, acumlen)

    r=[]
    for i in range(acumlen):
        r.append( (10**(float(i)/acumlen * math.log10(2*cube[1][0] )) ,
                   acum[i], ns[i] ))

    return numarray.array( r)
예제 #8
0
파일: kolmogorov.py 프로젝트: bnikolic/oof
def GenKolmogorovV2(N,
                    seed=None,
                    sfn=pybnlib.KolPowerLawFn(pybnlib.KolPowerLawFn.D3Thick)):

    grid=pybnlib.doubleArray( N*N)

    rfn=pybnlib.NormDistZM(1.0)
    if seed != None:
        rfn.reseed(seed)
    else:
        rfn.reseed(pybnlib.TimeSeed())

    pybnlib.KolmogorovPlatform(N,
                               grid,
                               sfn,
                               rfn)

    return CopyToNA(grid,N)
예제 #9
0
def GenKV2_raw(Nx,Ny,Nz):

    grid=pybnlib.doubleArray( Nx*Ny*Nz)
    rfn=pybnlib.NormDistZM(1.0)
    pybnlib.Kolmogorov3D( grid, Nx,Ny,Nz, rfn)
    return grid
예제 #10
0
파일: testbnlib.py 프로젝트: bnikolic/oof

import pybnlib

dd = range(1,10)

da= pybnlib.doubleArray( len(dd))

for i, val in enumerate(dd): da[i]=val

il=pybnlib.InterpolatorLog(da, da, len(dd) , pybnlib.InterpolatorLog.akima, pybnlib.InterpolatorLog.linear )

il2=pybnlib.InterpolatorGSL(da, da, len(dd) , pybnlib.InterpolatorLog.akima)