Exemplo n.º 1
0
hc = HaloCatalog(data_ds=ds, halos_ds=halos_ds)
hc.load()
halos = hc.halo_list

fieldname = 'gas'
fieldvalue = fields[fieldname]
index = 0
halo = halos[index]

# PROJECTION PLOT
com = [halo.quantities['particle_position_x'], halo.quantities['particle_position_y'], halo.quantities['particle_position_z']]
sp = ds.sphere(com, (30, 'kpc'))
amv = sp.quantities.angular_momentum_vector()
amv = amv / np.sqrt((amv**2).sum())
center = sp.quantities.center_of_mass()
res = 1024
width = [0.01, 0.01, 0.01]
image = yt.off_axis_projection(ds, center, amv, width, res, fieldvalue)
yt.write_image(np.log10(image), '%s_%d_%s_offaxis_projection.png' % (ds, index, fieldname))

# PROFILE PLOT
com = [halo.quantities['particle_position_x'], halo.quantities['particle_position_y'], halo.quantities['particle_position_z']]
sp = ds.sphere(com, (30, 'kpc'))
profiles = yt.create_profile(sp, 'radius', fields.values())
for fieldname, field in fields.iteritems():
    plt.loglog(profiles.x, profiles[field], label=fieldname)
plt.xlim([profiles.x.min(), profiles.x.max()])
plt.xlabel('Radius $[kpc]$')
plt.ylabel('$\\rho [M_{\odot} kpc^{-3}]$')
plt.legend(loc='best')
plt.savefig('%s_%d_profile.png' % (ds, index))
Exemplo n.º 2
0
import matplotlib.pyplot as plt
import yt.visualization._mpl_imports as mpl
from io import BytesIO
import yt
import time
import numpy as np

imname = 'Image6'

ds = yt.load("~/data/IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.ProjectionPlot(ds, "x", "density")
p.save("hi.png")
plot = p.plots["density"]
fig = plot.figure
f = BytesIO()
vv = yt.write_image(np.log10(p.frb["density"][:,:-1].d),f)
pixels = (vv/255.).ravel()

ncols = vv.shape[1]
nrows = vv.shape[0]
image = bpy.data.images.new(imname, width=ncols, height=nrows)
image.pixels = pixels

# activate the image in the uv editor
for area in bpy.context.screen.areas:
    if area.type == 'IMAGE_EDITOR':
        area.spaces.active.image = image
Exemplo n.º 3
0
# objects, you could set it the way you would a cutting plane -- but for this
# dataset, we'll just choose an off-axis value at random.  This gets normalized
# automatically.
L = [1.0, 0.0, 0.0]

# Our "width" is the width of the image plane as well as the depth.
# The first element is the left to right width, the second is the
# top-bottom width, and the last element is the back-to-front width
# (all in code units)
W = [0.04, 0.04, 0.4]

# The number of pixels along one side of the image.
# The final image will have Npixel^2 pixels.
Npixels = 512

# Create the off axis projection.
# Setting no_ghost to False speeds up the process, but makes a
# slightly lower quality image.
image = yt.off_axis_projection(ds,
                               c,
                               L,
                               W,
                               Npixels, ("gas", "density"),
                               no_ghost=False)

# Write out the final image and give it a name
# relating to what our dataset is called.
# We save the log of the values so that the colors do not span
# many orders of magnitude.  Try it without and see what happens.
yt.write_image(np.log10(image), f"{ds}_offaxis_projection.png")
Exemplo n.º 4
0
# Choose a center for the render.
c = [0.5, 0.5, 0.5]

# Our image plane will be normal to some vector.  For things like collapsing
# objects, you could set it the way you would a cutting plane -- but for this
# dataset, we'll just choose an off-axis value at random.  This gets normalized
# automatically.
L = [1.0, 0.0, 0.0]

# Our "width" is the width of the image plane as well as the depth.
# The first element is the left to right width, the second is the
# top-bottom width, and the last element is the back-to-front width
# (all in code units)
W = [0.04, 0.04, 0.4]

# The number of pixels along one side of the image.
# The final image will have Npixel^2 pixels.
Npixels = 512

# Create the off axis projection.
# Setting no_ghost to False speeds up the process, but makes a
# slightly lower quality image.
image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)

# Write out the final image and give it a name
# relating to what our dataset is called.
# We save the log of the values so that the colors do not span
# many orders of magnitude.  Try it without and see what happens.
yt.write_image(np.log10(image), "%s_offaxis_projection.png" % ds)
Exemplo n.º 5
0
"""
Make simple off-axis plot using data
      
"""
from GL import *
from cycler import cycler
import queb3
from queb3 import powerlaw_fit as plfit
import davetools as dt
import h5py
from matplotlib.pyplot import cm
import yt

reload(queb3)

simdir = "half_half"
frame = 30
plotdir = "/Users/Kye/512reruns/512rerunplots/offaxisplots"

ds = yt.load("/Users/Kye/512reruns/frbs/half_half/DD%04d/data%04d" %
             (frame, frame))
L = [1, 1, 0]  # vector normal to cutting plane
north_vector = [-1, 1, 0]
W = [0.02, 0.02, 0.02]
c = [0.5, 0.5, 0.5]
N = 512
image = yt.off_axis_projection(ds, c, L, W, N, "density")
yt.write_image(
    np.log10(image),
    "%s/%s/%04d_offaxis_density_projection.png" % (plotdir, simdir, frame))
Exemplo n.º 6
0
halo = halos[index]

# PROJECTION PLOT
com = [
    halo.quantities['particle_position_x'],
    halo.quantities['particle_position_y'],
    halo.quantities['particle_position_z']
]
sp = ds.sphere(com, (30, 'kpc'))
amv = sp.quantities.angular_momentum_vector()
amv = amv / np.sqrt((amv**2).sum())
center = sp.quantities.center_of_mass()
res = 1024
width = [0.01, 0.01, 0.01]
image = yt.off_axis_projection(ds, center, amv, width, res, fieldvalue)
yt.write_image(np.log10(image),
               '%s_%d_%s_offaxis_projection.png' % (ds, index, fieldname))

# PROFILE PLOT
com = [
    halo.quantities['particle_position_x'],
    halo.quantities['particle_position_y'],
    halo.quantities['particle_position_z']
]
sp = ds.sphere(com, (30, 'kpc'))
profiles = yt.create_profile(sp, 'radius', fields.values())
for fieldname, field in fields.iteritems():
    plt.loglog(profiles.x, profiles[field], label=fieldname)
plt.xlim([profiles.x.min(), profiles.x.max()])
plt.xlabel('Radius $[kpc]$')
plt.ylabel('$\\rho [M_{\odot} kpc^{-3}]$')
plt.legend(loc='best')
# Choose a center for the render.
c = [0.5, 0.5, 0.5]

# Our image plane will be normal to some vector.  For things like collapsing
# objects, you could set it the way you would a cutting plane -- but for this
# dataset, we'll just choose an off-axis value at random.  This gets normalized
# automatically.
L = [0.5, 0.4, 0.7]

# Our "width" is the width of the image plane as well as the depth.
# The first element is the left to right width, the second is the
# top-bottom width, and the last element is the back-to-front width
# (all in code units)
W = [0.04,0.04,0.4]

# The number of pixels along one side of the image.
# The final image will have Npixel^2 pixels.
Npixels = 512

# Create the off axis projection.
# Setting no_ghost to False speeds up the process, but makes a
# slighly lower quality image.
image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)

# Write out the final image and give it a name
# relating to what our dataset is called.
# We save the log of the values so that the colors do not span
# many orders of magnitude.  Try it without and see what happens.
yt.write_image(np.log10(image), "%s_offaxis_projection.png" % ds)