How to use the gr.setcolormap function in gr

To help you get started, we’ve selected a few gr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sciapp / gr / examples / slices.py View on Github external
data = np.fromfile("mri.raw", np.uint16)
data = data.reshape((64, 64, 93))
data[data > 2000] = 2000
data[:, :, :] = data / 2000.0 * np.iinfo(np.uint16).max

gr.setviewport(0, 1, 0, 1)
gr3.init()
gr3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
mesh = gr3.createisosurfacemesh(data, isolevel=40000)

gr.setcolormap(1)
for z in np.linspace(0, 1, 300):
    draw(mesh, x=0.9, z=z)
for y in np.linspace(1, 0.5, 300):
    draw(mesh, x=0.9, y=y, z=1)
gr.setcolormap(19)
for x in np.linspace(0.9, 0, 300):
    draw(mesh, x=x, y=0.5, z=1)
for x in np.linspace(0, 0.9, 300):
    draw(mesh, x=x, z=1)

gr3.terminate()
github sciapp / python-gr / examples / mandel_gpu.py View on Github external
griddim = (32, 16)

f = 0.5
for i in range(200):
    start = timer()
    d_image = cuda.to_device(image)
    mandel_kernel[griddim, blockdim](x-f, x+f, y-f, y+f, d_image, 400) 
    d_image.to_host()
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)
    ca = 1000.0 + image.ravel()

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(13)
    gr.cellarray(0, 1, 0, 1, 500, 500, ca)
    gr.updatews()

    f *= 0.9
github sciapp / gr / examples / mandel_vec.py View on Github external
x = -0.9223327810370947027656057193752719757635
y = 0.3102598350874576432708737495917724836010

f = 0.5
for i in range(200):
    start = timer()
    pixels = create_fractal(x-f, x+f, y-f, y+f, 500, 500, 400)
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)
    ca = 1000.0 + pixels.ravel()

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(13)
    gr.cellarray(0, 1, 0, 1, 500, 500, ca)
    gr.updatews()

    f *= 0.9
github sciapp / python-gr / examples / mandel_gr3.py View on Github external
os.environ['PYOPENCL_CTX'] = os.environ.get('PYOPENCL_CTX', '0')

x = -0.9223327810370947027656057193752719757635
y = 0.3102598350874576432708737495917724836010

f = 0.5
for i in range(200):
    start = timer()
    pixels = create_fractal(x-f, x+f, y-f, y+f, 500, 500, 400)
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(113)
    z = np.resize(pixels, (500, 500))
    gr.setwindow(0, 500, 0, 500)
    gr.setspace(0, 600, 30, 80)
    gr3.surface(range(500), range(500), z, 3)
    gr.updatews()

    f *= 0.9
github sciapp / gr / examples / pygrwidgetpyside_ex.py View on Github external
def draw(self):
        if not self._draw_graphics:
            return

        x = range(0, 128)
        y = range(0, 128)
        z = readfile(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "kws.dat"), separator='$')
        zrange = max(z) - min(z)
        h = [min(z) + i * 0.025 * zrange for i in range(0, 40)]

        gr.setviewport(0.075, 0.95, 0.075, 0.95)
        gr.setwindow(1, 128, 1, 128)
        gr.setspace(min(z), max(z), 0, 90)
        gr.setcharheight(0.018)
        gr.setcolormap(-3)
        gr.surface(x, y, z, 5)
        gr.contour(x, y, h, z, -1)
        gr.axes(5, 5, 1, 1, 2, 2, 0.0075)
github sciapp / gr / examples / mandel_gr3.py View on Github external
environ['PYOPENCL_CTX'] = '0'

x = -0.9223327810370947027656057193752719757635
y = 0.3102598350874576432708737495917724836010

f = 0.5
for i in range(200):
    start = timer()
    pixels = create_fractal(x-f, x+f, y-f, y+f, 500, 500, 400)
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(113)
    z = np.resize(pixels, (500, 500))
    gr.setwindow(0, 500, 0, 500)
    gr.setspace(0, 600, 30, 80)
    gr3.surface(range(500), range(500), z, 3)
    gr.updatews()

    f *= 0.9
github sciapp / python-gr / examples / trianglesurface.py View on Github external
# Set up example data
radii = np.linspace(0, 1, 20)
angles = np.linspace(0, np.pi * 2, 30)
points = np.zeros((len(angles), len(radii), 3))
points[:, :, 0] = np.cos(angles).reshape(len(angles), 1) * radii.reshape(1, len(radii))
points[:, :, 1] = np.sin(angles).reshape(len(angles), 1) * radii.reshape(1, len(radii))
points[:, :, 2] = -radii.reshape(1, len(radii))
points.shape = (len(angles) * len(radii), 3)
points[:, :] = points[:, :] * 0.5 + 0.5

# Perform 2D delaunay triangulation
triangles = Delaunay(points[:, :2]).simplices.copy()
points = points[triangles]

# Set up GR state
gr.setcolormap(1)
gr.clearws()
gr.setspace(points[:, 2].min(), points[:, 2].max(), 0, 0)

# Draw using GR3
gr3.drawtrianglesurface(points)
gr.updatews()
github sciapp / gr / examples / mandel.py View on Github external
x = -0.9223327810370947027656057193752719757635
y = 0.3102598350874576432708737495917724836010

f = 0.5
for i in range(200):
    start = timer()
    image = zeros((500, 500), dtype=uint8)
    pixels = create_fractal(x-f, x+f, y-f, y+f, image, 400)
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)
    ca = 1000.0 + pixels.ravel()

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(13)
    gr.cellarray(0, 1, 0, 1, 500, 500, ca)
    gr.updatews()

    f *= 0.9
github sciapp / python-gr / examples / mandel_ocl.py View on Github external
x = -0.9223327810370947027656057193752719757635
y = 0.3102598350874576432708737495917724836010

f = 0.5
for i in range(200):
    start = timer()
    pixels = create_fractal(x-f, x+f, y-f, y+f, 500, 500, 400)
    dt = timer() - start

    print("Mandelbrot created in %f s" % dt)
    ca = 1000.0 + pixels.ravel()

    gr.clearws()
    gr.setviewport(0, 1, 0, 1)
    gr.setcolormap(13)
    gr.cellarray(0, 1, 0, 1, 500, 500, ca)
    gr.updatews()

    f *= 0.9
github sciapp / gr / examples / pygrwidgetqt5_ex.py View on Github external
def draw(self):
        if not self._draw_graphics:
            return

        x = range(0, 128)
        y = range(0, 128)
        z = readfile(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "kws.dat"), separator='$')
        zrange = max(z) - min(z)
        h = [min(z) + i * 0.025 * zrange for i in range(0, 40)]

        gr.setviewport(0.075, 0.95, 0.075, 0.95)
        gr.setwindow(1, 128, 1, 128)
        gr.setspace(min(z), max(z), 0, 90)
        gr.setcharheight(0.018)
        gr.setcolormap(-3)
        gr.surface(x, y, z, 5)
        gr.contour(x, y, h, z, -1)
        gr.axes(5, 5, 1, 1, 2, 2, 0.0075)