示例#1
0
  --rskip=<A>, -r <A>                     The radius of the core to skip
  --Lx=<Lx>                               The spatial extent in the x-direction
  --Ly=<Ly>                               The spatial extent in the y-direction
  -h --help                               Show this screen.
"""

import pylab as pl
import pimchelp
from docopt import docopt
import loadgmt, kevent
import itertools

#cmap = loadgmt.getcmap('dca','alarm.p1.0.1')
#cmap = loadgmt.getcmap('cb/div','Spectral_11')
#cmap = loadgmt.getcmap('cb/div','RdGy_11')
cmap = loadgmt.getcmap('gist', 'earth')
cmap = loadgmt.getcmap('ncl', 'precip3_16lev')

#cmap = loadgmt.getcmap('ncl','temp_diff_18lev')


# ===================================================================
def main():

    # Read in the command line arguments
    args = docopt(__doc__)
    fileName = args['<input-file>']

    rskip = args['--rskip'] and float(args['--rskip'])

    # Open up the matrix file, and determine the size of the matrix
示例#2
0
def main():

    np.random.seed(111)
    scene = []
    povName = "area_law.pov"

    pov_file = File(povName,"colors.inc","textures.inc")
    # pov_file.writeln("default { finish { ambient 0 }}\n")
    cam = Camera(location=(-0,-0,-20),look_at=(0,0,0))
    # bg = Background(color="rgb <1,1,1>",transmit=1.0)

    scene.append(cam)
    # scene.append(bg)

    light = LightSource((-10,-10,-500), color="rgb 1 shadowless")
    scene.append(light)
    light = LightSource((0,0,0), color="rgb 1")
    scene.append(light)
    #light = LightSource( (0,25,0), color="White")

    cmap = loadgmt.getcmap('cb/div','RdBu_04',reverse=True)
    colors=cmap(np.linspace(0,1,4))

    blue = hex_to_rgb('4173b3')
    # blue = tuple(colors[0,:3])
    red = tuple(colors[-1,:3])
    white = (1.0,1.0,1.0)

    # col_blue = Texture(Finish(phong=1.0),Pigment(color=white))
    col_white = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color=blue))
    col_blue = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color=blue))
    col_red = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color=red))

    R = 6.0
    L = 20 
    rad = 0.15
    dR = 0.8
    delta = 0.4
    max_r = 0.99*np.sqrt(3.0)*0.5*L

    spheres = []
    r_blobs = []
    for i in range(L+1):
        for j in range(L+1):
            for k in range(L+1):
                x = -0.5*L + 1.0*i + delta*(-1.0 + 2.0*np.random.random())
                y = -0.5*L + 1.0*j + delta*(-1.0 + 2.0*np.random.random())
                z = -0.5*L + 1.0*k + delta*(-1.0 + 2.0*np.random.random())
                
                v = np.array([x,y,z])
                r = np.sqrt(x*x + y*y + z*z)

                # make sure we don't overlap the boundary 
                while R-rad < r < R:
                    v -= 10E-3*v
                    r = np.linalg.norm(v)
                while R < r < R+rad:
                    v += 10E-3*v
                    r = np.linalg.norm(v)

                if r >= R and r < max_r:
                    scene.append(Sphere(list(v),rad,col_white))
                elif r < R:
                    scene.append(Sphere(list(v),rad,col_blue))
                r_blobs.append(list(v))

    sweeps = ""
    for v1 in r_blobs:
        r1 = np.linalg.norm(v1)
        for v2 in r_blobs:
            r2 = np.linalg.norm(v2)
            if (R-dR <= r1 <= R) and (R <= r2 <= R+dR):
                sep = np.array(v2)-np.array(v1)
                rsep = np.linalg.norm(sep)
                if rsep < 2*dR:
                    sweeps += sweep(v1,v2,10,0.8*rad)

    # add a spatial bipartition sphere
    bond_color = hex_to_rgb('#6bff2b')
    # s = Sphere([0,0,0],R,Texture(Pigment(color=blue,transmit=0.70)))
    s = Sphere([0,0,0],R,Texture("Green_Glass"))
    scene.append(s)

    for s in scene:
        s.write(pov_file)

    pov_file.writeln(sweeps)
    pov_file.close()

    low_res = ["-p"]
    width = 6000
    height = int(3*width/4.0)
    high_res = ["-p","+H%d"%height,"+W%d"%width,"+Q11","+UA"]

    # render the povray files
    # subprocess.call(["povray"] + low_res+ [povName])
    subprocess.call(["povray"] + high_res + [povName])
  --Lx=<Lx>                               The spatial extent in the x-direction
  --Ly=<Ly>                               The spatial extent in the y-direction
  -h --help                               Show this screen.
"""


import pylab as pl
import pimchelp
from docopt import docopt
import loadgmt,kevent
import itertools

#cmap = loadgmt.getcmap('dca','alarm.p1.0.1')
#cmap = loadgmt.getcmap('cb/div','Spectral_11')
#cmap = loadgmt.getcmap('cb/div','RdGy_11')
cmap = loadgmt.getcmap('gist','earth')
cmap = loadgmt.getcmap('ncl','precip3_16lev')
#cmap = loadgmt.getcmap('ncl','temp_diff_18lev')

# ===================================================================
def main():

    # Read in the command line arguments
    args = docopt(__doc__)
    fileName = args['<input-file>']

    rskip = args['--rskip'] and float(args['--rskip'])

    # Open up the matrix file, and determine the size of the matrix
    data = pl.loadtxt(fileName,ndmin=2)
    N = int(pl.sqrt(data.shape[0]))
def main():

    np.random.seed(112)
    scene = []
    povName = "reduction.pov"

    L = 10

    pov_file = File(povName,"colors.inc","textures.inc")
    cam = Camera(location=(3.0*L,-0.5*L,-45),look_at=(0,-1.0*L,0))
    bg = Background(color="rgbt <1,1,1,1>")

    scene.append(cam)
    scene.append(bg)

    light = LightSource((-10,-10,-500), color="rgb 1 shadowless")
    scene.append(light)
    # light = LightSource((0,0,0), color="rgb 1")
    # scene.append(light)
    #light = LightSource( (0,25,0), color="White")

    cmap = loadgmt.getcmap('cb/div','RdBu_04',reverse=True)
    colors=cmap(np.linspace(0,1,4))

    blue = hex_to_rgb('4173b3')
    white = (1.0,1.0,1.0)
    red = hex_to_rgb('971746')

    # col_blue = Texture(Finish(phong=1.0),Pigment(color=white))
    #col_blue = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color=blue))
    col_blue = Texture(Finish(ambient=0.2, diffuse=0.6, phong=0.75,phong_size=25),Pigment(color=blue))
    col_white = Texture(Finish(ambient=0.2, diffuse=0.6, phong=0.75,phong_size=25),Pigment(color='White'))
    col_red = Texture(Finish(ambient=0.2, diffuse=0.6, phong=0.75,phong_size=25),Pigment(color=red))
    # col_white = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color='White'))
    # col_red = Texture(Finish('reflection { .6, metallic}',ambient=0.2,diffuse=0.4,specular=0.75,roughness=.001),Pigment(color=red))
    col_gray = Texture(Pigment(color='Gray'))

    rad = 0.15
    δ = 0.4
    max_r = 0.99*np.sqrt(3.0)*0.5*L
    R = 0.05

    L *= 1.1

    v1 = Vector(-L/2,-L/2,L/2)
    v2 = Vector(L/2,-L/2,L/2)
    tube = [Cylinder(v1,v2,R,col_gray)]

    v1 = Vector(-L/2,L/2,L/2)
    v2 = Vector(L/2,L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(L/2,-L/2,L/2)
    v2 = Vector(L/2,L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,-L/2,L/2)
    v2 = Vector(-L/2,L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,-L/2,-L/2)
    v2 = Vector(L/2,-L/2,-L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,L/2,-L/2)
    v2 = Vector(L/2,L/2,-L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(L/2,-L/2,-L/2)
    v2 = Vector(L/2,L/2,-L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,-L/2,-L/2)
    v2 = Vector(-L/2,L/2,-L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(L/2,L/2,-L/2)
    v2 = Vector(L/2,L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,-L/2,-L/2)
    v2 = Vector(-L/2,-L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,L/2,-L/2)
    v2 = Vector(-L/2,L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(L/2,-L/2,-L/2)
    v2 = Vector(L/2,-L/2,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    # 2D
    y = -1.25*10
    v1 = Vector(-L/2,y,L/2)
    v2 = Vector(L/2,y,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,y,-L/2)
    v2 = Vector(L/2,y,-L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(L/2,y,-L/2)
    v2 = Vector(L/2,y,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    v1 = Vector(-L/2,y,-L/2)
    v2 = Vector(-L/2,y,L/2)
    tube.append(Cylinder(v1,v2,R,col_gray))

    box = Union(*tube)
    scene.append(box)

    L /= 1.1

    # 3 dimensions
    spheres = []
    r_blobs = []
    for i in np.arange(L+1):
        for j in np.arange(L+1):
            for k in np.arange(L+1):
                x = -0.5*L + 1.0*i + δ*(-1.0 + 2.0*np.random.random())
                y = -0.5*L + 1.0*j + δ*(-1.0 + 2.0*np.random.random())
                z = -0.5*L + 1.0*k + δ*(-1.0 + 2.0*np.random.random())
                
                v = np.array([x,y,z])
                r = np.sqrt(x*x + y*y + z*z)

                if r < max_r:
                    scene.append(Sphere(list(v),rad,col_blue))
                    r_blobs.append(list(v))

    sweeps = ""
    # for v1 in r_blobs:
    #     r1 = np.linalg.norm(v1)
    #     for v2 in r_blobs:
    #         r2 = np.linalg.norm(v2)
    #         sep = np.array(v2)-np.array(v1)
    #         rsep = np.linalg.norm(sep)
    #         if rsep < 2:
    #             sweeps += sweep(v1,v2,10,0.8*rad)

    # 2 dimensions
    spheres = []
    r_blobs = []
    for i in np.arange(L+1):
        for k in np.arange(L+1):
            x = -0.5*L + 1.0*i + δ*(-1.0 + 2.0*np.random.random())
            y = -1.25*L
            z = -0.5*L + 1.0*k + δ*(-1.0 + 2.0*np.random.random())
                
            v = np.array([x,y,z])
            r = np.sqrt(x*x + y*y + z*z)

            scene.append(Sphere(list(v),rad,col_white))
            r_blobs.append(list(v))

    # for v1 in r_blobs:
    #     r1 = np.linalg.norm(v1)
    #     for v2 in r_blobs:
    #         r2 = np.linalg.norm(v2)
    #         sep = np.array(v2)-np.array(v1)
    #         rsep = np.linalg.norm(sep)
    #         if rsep < 2:
    #             sweeps += sweep(v1,v2,10,0.8*rad)

    # 1 dimensions
    spheres = []
    r_blobs = []
    for i in np.arange(L+1):
        x = -0.5*L + 1.0*i + δ*(-1.0 + 2.0*np.random.random())
        y = -2.0*L
        z = 0.0 #-0.5*L + 1.0*i + δ*(-1.0 + 2.0*np.random.random())
                
        v = np.array([x,y,z])
        r = np.sqrt(x*x + y*y + z*z)

        scene.append(Sphere(list(v),rad,col_red))
        r_blobs.append(list(v))


    for s in scene:
        s.write(pov_file)

    pov_file.writeln(sweeps)


    pov_file.close()

    low_res = ["-p"]
    width = 5000
    height = int(3*width/4.0)
    high_res = ["-p","+H%d"%height,"+W%d"%width,"+Q11","+UA"]

    # render the povray files
    # subprocess.call(["povray"] + low_res+ [povName])
    subprocess.call(["povray"] + high_res + [povName])
# Author:       Max Graves
#               Adrian Del Maestro
# Date:         8-NOV-2012
# ===================================================================

import pylab as pl
import argparse
import pimchelp
from docopt import docopt
import loadgmt,kevent
import itertools

#cmap = loadgmt.getcmap('dca','alarm.p1.0.1')
#cmap = loadgmt.getcmap('cb/div','Spectral_11')
#cmap = loadgmt.getcmap('cb/div','RdGy_11')
cmap = loadgmt.getcmap('gist','earth')
cmap = loadgmt.getcmap('ncl','precip3_16lev')
cmap = loadgmt.getcmap('ncl','temp_diff_18lev')

# ===================================================================
def main():

    # Read in the command line arguments
    args = docopt(__doc__)
    fileName = args['<input-file>']
    estName = args['--estimator']

    # Open up the tensor file, and determine the number of grid boxes in each
    # dimension and the column headers
    with open(fileName,'r') as inFile:
        N = int(inFile.readline().split()[1])