Beispiel #1
0
class Suite:
    dsname = "HiresIsolatedGalaxy/DD0044/DD0044"

    def setup(self):
        if yt.__version__.startswith('3'):
            self.ds = yt.load(self.dsname)
            self.ad = self.ds.all_data()
            self.field_name = "density"
        else:
            self.ds = load(self.dsname)
            self.ad = self.ds.h.all_data()
            self.field_name = "Density"
        # Warmup hdd
        self.ad[self.field_name]
        if yt.__version__.startswith('3'):
            mi, ma = self.ad.quantities['Extrema'](self.field_name)
            self.tf = yt.ColorTransferFunction(
                (np.log10(mi) + 1, np.log10(ma)))
        else:
            mi, ma = self.ad.quantities['Extrema'](self.field_name)[0]
            self.tf = ColorTransferFunction((np.log10(mi) + 1, np.log10(ma)))
        self.tf.add_layers(5, w=0.02, colormap="spectral")
        self.c = [0.5, 0.5, 0.5]
        self.L = [0.5, 0.2, 0.7]
        self.W = 1.0
        self.Npixels = 512

    if yt.__version__.startswith('3'):

        def time_load_all_data(self):
            dd = self.ds.all_data()
            dd[self.field_name]
    else:

        def time_load_all_data(self):
            self.ds.h.all_data()
            dd[self.field_name]

    def time_extrema_quantities(self):
        self.ad.quantities['Extrema'](self.field_name)

    if yt.__version__.startswith('3'):

        def time_alldata_projection(self):
            self.ds.proj(self.field_name, 0)
    else:

        def time_alldata_projection(self):
            self.ds.h.proj(0, self.field_name)

    if yt.__version__.startswith('3'):

        def time_slice(self):
            slc = self.ds.slice(0, 0.5)
            slc[self.field_name]
    else:

        def time_slice(self):
            slc = self.ds.h.slice(0, 0.5, self.field_name)
            slc[self.field_name]
def updateTransfer ():
    """
    ------------------------------------------------------------------------
    """
    
    global mi, ma, bins

    from yt.mods import ColorTransferFunction
    transfer = ColorTransferFunction( (mi, ma), bins)
    transfer.map_to_colormap(mi, ma, colormap='spring', scale_func = scale_func)

    camera.setTransfer(tf = transfer)
Beispiel #3
0
def updateTransfer():
    """
    ------------------------------------------------------------------------
    """

    global mi, ma, bins

    from yt.mods import ColorTransferFunction
    transfer = ColorTransferFunction((mi, ma), bins)
    transfer.map_to_colormap(mi, ma, colormap='spring', scale_func=scale_func)

    camera.setTransfer(tf=transfer)
class Suite:
    dsname = "HiresIsolatedGalaxy/DD0044/DD0044"
    def setup(self):
        if yt.__version__.startswith('3'):
            self.ds = yt.load(self.dsname)
            self.ad = self.ds.all_data()
            self.field_name = "density"
        else:
            self.ds = load(self.dsname)
            self.ad = self.ds.h.all_data()
            self.field_name = "Density"
        # Warmup hdd
        self.ad[self.field_name]
        if yt.__version__.startswith('3'):
            mi, ma = self.ad.quantities['Extrema'](self.field_name)
            self.tf = yt.ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
        else:
            mi, ma = self.ad.quantities['Extrema'](self.field_name)[0]
            self.tf = ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
        self.tf.add_layers(5, w=0.02, colormap="spectral")
        self.c = [0.5, 0.5, 0.5]
        self.L = [0.5, 0.2, 0.7]
        self.W = 1.0
        self.Npixels = 512

    if yt.__version__.startswith('3'):
        def time_load_all_data(self):
            dd = self.ds.all_data()
            dd[self.field_name]
    else:
        def time_load_all_data(self):
            self.ds.h.all_data()
            dd[self.field_name]

    def time_extrema_quantities(self):
        self.ad.quantities['Extrema'](self.field_name)

    if yt.__version__.startswith('3'):
        def time_alldata_projection(self):
            self.ds.proj(self.field_name, 0)
    else:
        def time_alldata_projection(self):
           self.ds.h.proj(0, self.field_name)

    if yt.__version__.startswith('3'):
        def time_slice(self):
            slc = self.ds.slice(0, 0.5)
            slc[self.field_name]
    else:
        def time_slice(self):
            slc = self.ds.h.slice(0, 0.5, self.field_name)
            slc[self.field_name]
Beispiel #5
0
 def setup(self):
     if yt.__version__.startswith('3'):
         self.ds = yt.load(self.dsname)
         self.ad = self.ds.all_data()
         self.field_name = "density"
     else:
         self.ds = load(self.dsname)
         self.ad = self.ds.h.all_data()
         self.field_name = "Density"
     # Warmup hdd
     self.ad[self.field_name]
     if yt.__version__.startswith('3'):
         mi, ma = self.ad.quantities['Extrema'](self.field_name)
         self.tf = yt.ColorTransferFunction(
             (np.log10(mi) + 1, np.log10(ma)))
     else:
         mi, ma = self.ad.quantities['Extrema'](self.field_name)[0]
         self.tf = ColorTransferFunction((np.log10(mi) + 1, np.log10(ma)))
     self.tf.add_layers(5, w=0.02, colormap="spectral")
     self.c = [0.5, 0.5, 0.5]
     self.L = [0.5, 0.2, 0.7]
     self.W = 1.0
     self.Npixels = 512
 def setup(self):
     if yt.__version__.startswith('3'):
         self.ds = yt.load(self.dsname)
         self.ad = self.ds.all_data()
         self.field_name = "density"
     else:
         self.ds = load(self.dsname)
         self.ad = self.ds.h.all_data()
         self.field_name = "Density"
     # Warmup hdd
     self.ad[self.field_name]
     if yt.__version__.startswith('3'):
         mi, ma = self.ad.quantities['Extrema'](self.field_name)
         self.tf = yt.ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
     else:
         mi, ma = self.ad.quantities['Extrema'](self.field_name)[0]
         self.tf = ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
     self.tf.add_layers(5, w=0.02, colormap="spectral")
     self.c = [0.5, 0.5, 0.5]
     self.L = [0.5, 0.2, 0.7]
     self.W = 1.0
     self.Npixels = 512
def main():
    """
    ------------------------------------------------------------------------
    """
    

    global bins, ma, mi, tf_interval, global_min, global_max

    ret_args = handleCommandLineArgs()

    datafile = ""

    mi, ma, bins = None, None, None

    for (flag,val) in ret_args:
        if (flag == "data"):
            datafile = val
        elif (flag == "min"):
            mi = float(val)
        elif (flag == "max"):
            ma = float(val)
        elif (flag == "bins"):
            bins = int(val)

    global window, camera, camera2
    initial_size = (1920,1080)

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STEREO)
    glutInitWindowSize(*initial_size)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow("PyCuda GL Interop Example")

    glutDisplayFunc(display)
    glutIdleFunc(idle)
    glutReshapeFunc(resize)
    glutMouseFunc( mouseButton )
    glutMotionFunc( mouseMotion )
    glutKeyboardFunc(keyPressed)
    #glutSpecialFunc(keyPressed)
    init_gl(*initial_size)

    # create texture for blitting to screen
    create_texture(*initial_size)

    import pycuda.gl.autoinit
    import pycuda.gl
    cuda_gl = pycuda.gl

    create_PBO(*initial_size)
    # ----- Load and Set Volume Data -----
    from yt.mods import *
    import numpy as np

    # set to default file if not specified on commandline
    if (len(datafile) == 0):
        datafile = "/home/bogert/log_densities_1024.npy"
        
    data_map = np.load(datafile)
    #data_map *= -1
    
    # ----- Set Transfer Function Parameters -----
    #mi , ma = 0.0, 3.95
    #bins  = 1000

    global_min = np.amin(data_map)
    global_max = np.amax(data_map)

    # set to min/max value of data
    if (mi is None):
        mi = global_min
    if (ma is None):
        ma = global_max

    print "Setting transfer function range to (" + str(mi) + ", " + str(ma) + ")"

    # default to 10000 bins
    if (bins is None):
        bins = 10000

    print "Setting number of bins to " + str(bins)
   
    tf_interval = abs((global_max - global_min))/500

    transfer = ColorTransferFunction( (mi, ma), bins)
    transfer.map_to_colormap(mi, ma, colormap='spring', scale_func = scale_func)

    camera = GLCamera(tf = transfer, width = 1920, height = 1080, grid = data_map)

    glutMainLoop()
Beispiel #8
0
##Modified from Tom Robitaille's script to make a 3D movie, using yt
##(https://gist.github.com/astrofrog/9685403)
import numpy as np
import yt
from yt.mods import ColorTransferFunction, write_bitmap


# Read in the data to yt
pf = yt.load('reproj_b5_c18o_21_noise_weighted.fits', auxiliary_files = ['reproj_b5_11_clean_vlsrm.fits'])


# Instantiate the ColorTransferfunction.
min_c18o, max_c18o = .01, 4.
tf_c18o = ColorTransferFunction((min_c18o, max_c18o))
min_11, max_11 = .03, 2.5
tf_11 = ColorTransferFunction((min_11, max_11))


# Set up the camera parameters: center, looking direction, width, resolution
#c = (pf.domain_right_edge + pf.domain_left_edge) / 2.0 #This results in the camera focusing at the edge of the cube
c = np.array([23., 42., 712.])
L = np.array([0.0, 0.0, -1.0])
W = 120
N = 1024


# Create camera objects
cam_c18o= pf.h.camera(c, L, W, N, tf_c18o,
                       fields=['temperature'], log_fields=[False],
                       no_ghost=True, north_vector = [0., 1., 0.])
cam_11 = pf.h.camera(c, L, W, N, tf_11,
Beispiel #9
0
import matplotlib.pyplot as plt
from yt.mods import write_bitmap, ColorTransferFunction

plt.rcParams['font.family'] = 'Arial'

# Read in model from Hyperion

m = ModelOutput('pla704850_lev7_129.rtout')
grid = m.get_quantities()

# Convert quantities to yt
pf = grid.to_yt()

# Instantiate the ColorTransferfunction.
tmin, tmax = 1.3, 2.3
tf_temp = ColorTransferFunction((tmin, tmax))
dmin, dmax = -20, -16
tf_dens = ColorTransferFunction((dmin, dmax))

# Set up the camera parameters: center, looking direction, width, resolution
c = (pf.domain_right_edge + pf.domain_left_edge) / 2.0

L = np.array([1.0, 1.0, 1.0])
W = 0.7 / pf["unitary"]
N = 512

# Create camera objects

cam_temp = pf.h.camera(c, L, W, N, tf_temp,
                       fields=['temperature'], log_fields=[True],
                       no_ghost=False)
Beispiel #10
0
def main():
    """
    ------------------------------------------------------------------------
    """

    global bins, ma, mi, tf_interval, global_min, global_max

    ret_args = handleCommandLineArgs()

    datafile = ""

    mi, ma, bins = None, None, None

    for (flag, val) in ret_args:
        if (flag == "data"):
            datafile = val
        elif (flag == "min"):
            mi = float(val)
        elif (flag == "max"):
            ma = float(val)
        elif (flag == "bins"):
            bins = int(val)

    global window, camera, camera2
    initial_size = (1920, 1080)

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
                        | GLUT_STEREO)
    glutInitWindowSize(*initial_size)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow("PyCuda GL Interop Example")

    glutDisplayFunc(display)
    glutIdleFunc(idle)
    glutReshapeFunc(resize)
    glutMouseFunc(mouseButton)
    glutMotionFunc(mouseMotion)
    glutKeyboardFunc(keyPressed)
    #glutSpecialFunc(keyPressed)
    init_gl(*initial_size)

    # create texture for blitting to screen
    create_texture(*initial_size)

    import pycuda.gl.autoinit
    import pycuda.gl
    cuda_gl = pycuda.gl

    create_PBO(*initial_size)
    # ----- Load and Set Volume Data -----
    from yt.mods import *
    import numpy as np

    # set to default file if not specified on commandline
    if (len(datafile) == 0):
        datafile = "/home/bogert/log_densities_1024.npy"

    data_map = np.load(datafile)
    #data_map *= -1

    # ----- Set Transfer Function Parameters -----
    #mi , ma = 0.0, 3.95
    #bins  = 1000

    global_min = np.amin(data_map)
    global_max = np.amax(data_map)

    # set to min/max value of data
    if (mi is None):
        mi = global_min
    if (ma is None):
        ma = global_max

    print "Setting transfer function range to (" + str(mi) + ", " + str(
        ma) + ")"

    # default to 10000 bins
    if (bins is None):
        bins = 10000

    print "Setting number of bins to " + str(bins)

    tf_interval = abs((global_max - global_min)) / 500

    transfer = ColorTransferFunction((mi, ma), bins)
    transfer.map_to_colormap(mi, ma, colormap='spring', scale_func=scale_func)

    camera = GLCamera(tf=transfer, width=1920, height=1080, grid=data_map)

    glutMainLoop()
Beispiel #11
0
import matplotlib.pyplot as plt
from yt.mods import write_bitmap, ColorTransferFunction

plt.rcParams['font.family'] = 'Arial'

# Read in model from Hyperion

m = ModelOutput('pla704850_lev7_129.rtout')
grid = m.get_quantities()

# Convert quantities to yt
pf = grid.to_yt()

# Instantiate the ColorTransferfunction.
tmin, tmax = 1.3, 2.3
tf_temp = ColorTransferFunction((tmin, tmax))
dmin, dmax = -20, -16
tf_dens = ColorTransferFunction((dmin, dmax))

# Set up the camera parameters: center, looking direction, width, resolution
c = (pf.domain_right_edge + pf.domain_left_edge) / 2.0

L = np.array([1.0, 1.0, 1.0])
W = 0.7 / pf["unitary"]
N = 512

# Create camera objects

cam_temp = pf.h.camera(c,
                       L,
                       W,