Esempio n. 1
0
def GenKolmogorov(N,
                  seed=0):

    grid=pybnlib.doubleArray( N*N)

    pybnlib.KolmogorovPlatform(N,
                               grid,
                               seed)
    return CopyToNA(grid,N)
Esempio 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) )
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 8
0
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)
Esempio 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
Esempio n. 10
0

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)