Beispiel #1
0
def part_mass_halo(ds,dim,cen,wid,simtype,curr_sim,curr_halo):
    """
    usage: part_mass_halo(ds,wid,cen,simtype,curr_sim,curr_halo,field)\
           ds: dataset\
           wid: width of halo\
           cen: center of halo (x,y,z) in code units\
           simtype: simulation type (used for file formating)"
    """
    print datetime.now().strftime('%H:%M:%S'),'Making Particle mass Projection plots of halo #%d along %s axis'%(curr_halo,dim)
    weightfield = 'particle_mass'

    if dim == 'x': 
        output = yt.ParticlePlot(ds, 'particle_position_y', 'particle_position_z', weightfield, width=wid,center=cen)
    elif dim == 'y': 
        output = yt.ParticlePlot(ds, 'particle_position_z', 'particle_position_x', weightfield, width=wid,center=cen)
    elif dim == 'z': 
        output = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y', weightfield, width=wid,center=cen)
    else:
        raise ValueError("Function part_mass_halo received an unknown dimension '%s'. Use 'x','y','z'. This is case sensitive"%(dim))

    #Format pictures with nice units and color map.
    output.annotate_timestamp(corner='upper_left', time=False,redshift=True, draw_inset_box=False)
    #output.annotate_scale(corner='upper_right')
    output.set_axes_unit('Mpccm/h')
    output.set_unit(weightfield, 'Msun')
    #output.set_cmap('particle_mass','RdBu_r')

    #Save with filename corresponding to dimension
    output.save('%s_%s_%d_%s_%s.png'%(simtype,curr_sim,curr_halo,weightfield,dim))

    return output
Beispiel #2
0
def part_mass_whole(ds,dim,simtype,curr_src):
    print datetime.now().strftime('%H:%M:%S'),'Making Particle Projection plots of whole sim along %s axis'%dim
    field = 'particle_mass'

    #Make plot
    if dim == 'x':
        output = yt.ParticlePlot(ds, 'particle_position_y', 'particle_position_z', field)
    elif dim == 'y':
        output = yt.ParticlePlot(ds, 'particle_position_z', 'particle_position_x', field)
    elif dim == 'z':
        output = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y',field)
    else:
        raise ValueError("Function part_mass_whole received an unknown dimension '%s'. Use 'x','y','z'. This is case sensitive"%(dim))
    #Save object to disk
    #output.frb.save_as_dataset('yt_%s_%s_part_%s_%s'%(simtype,curr_src,field,dim))

    #Format color bar and axis units.
    #output.set_zlim(('all','particle_mass'), all_particle_mass_extrema[0],all_particle_mass_extrema[1])
    output.annotate_timestamp(corner='upper_left', time=False,redshift=True, draw_inset_box=False)
    output.annotate_scale(corner='upper_right')
    output.set_axes_unit('Mpccm/h')
    output.set_unit(field, 'Msun')

    #Save figure to disk
    output.save('%s_%s_part_%s_%s.png'%(simtype,curr_src,field,dim))
 
    
    #Return the plot object for future use.
    return output
Beispiel #3
0
def yt_inline_ParticlePlot():
    ds = yt.frontends.libyt.libytDataset()

    ## ParticleProjectionPlot
    #==========================
    # par = yt.ParticleProjectionPlot(ds, "z")

    ## ParticlePlot
    #==========================
    par = yt.ParticlePlot(ds, "particle_position_x", "particle_position_y", "Level", center = 'c')
    if yt.is_root():
        par.save()
Beispiel #4
0
def yt_inline():
    # Get data
    ds = yt.frontends.libyt.libytDataset()

    # Do ProjectionPlot to field Cloud0.
    sz = yt.ProjectionPlot(ds, 'z', ('gamer', 'Cloud0'), center='c')

    # Do ParticlePlot
    par = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y', 'particle_mass', center='c')

    if yt.is_root():
        sz.save()
        par.save()
Beispiel #5
0
def rvirprojections(ds, center, rvir, sp, out_dir, VELA_a, Id):
    fig = plt.figure()

    grid = AxesGrid(fig, (0.075, 0.075, 15, 5),
                    nrows_ncols=(2, 3),
                    axes_pad=0.05,
                    label_mode="L",
                    share_all=True,
                    cbar_location="right",
                    cbar_mode="single",
                    cbar_size="3%",
                    cbar_pad="0%")

    a = yt.ParticlePlot(ds, ('stars', 'particle_position_x'), ('stars', 'particle_position_y'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)
    b = yt.ParticlePlot(ds, ('stars', 'particle_position_y'), ('stars', 'particle_position_z'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)
    c = yt.ParticlePlot(ds, ('stars', 'particle_position_z'), ('stars', 'particle_position_x'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)

    d = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_x'), ('darkmatter', 'particle_position_y'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)
    e = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_y'), ('darkmatter', 'particle_position_z'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)
    f = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_z'), ('darkmatter', 'particle_position_x'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*4, "kpc"), data_source=sp)

    a.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})
    b.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})
    c.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})
    d.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})
    e.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})
    f.annotate_marker(center, 'x', plot_args={'s': 100, 'color': 'red'})

    index = 0
    for letter in [a, b, c]:
        plot = letter.plots[('stars', 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index].axes
        plot.cax = grid.cbar_axes[0]
        letter._setup_plots()
        index = index + 1

    for letter in [d, e, f]:
        plot = letter.plots[('darkmatter', 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index].axes
        plot.cax = grid.cbar_axes[0]
        letter._setup_plots()
        index = index + 1

    plt.savefig('%s/%sid%s.png' % (out_dir, VELA_a, Id), bbox_inches='tight')
    plt.close()
Beispiel #6
0
def yt_inline_ParticlePlot():
    # YT Particle Plot does not support parallelism for now
    # So we run mpirun -np 1
    ds = yt.frontends.libyt.libytDataset()

    ## ParticleProjectionPlot
    #==========================
    # par = yt.ParticleProjectionPlot(ds, "z")

    ## ParticlePlot
    #==========================
    par = yt.ParticlePlot(ds,
                          "particle_position_x",
                          "particle_position_y",
                          "Level",
                          center='c')

    par.save()
Beispiel #7
0
idx_end = args.idx_end
didx = args.didx
prefix = args.prefix

colormap = 'arbre'
dpi = 150
field = 'particle_mass'

yt.enable_parallelism()

ts = yt.load([
    prefix + '/Data_%06d' % idx for idx in range(idx_start, idx_end + 1, didx)
])
p = []
for idx in range(idx_start, idx_end + 1, 1):
    ds = yt.load('Data_%06d' % idx)
    p = yt.ParticlePlot(ds,
                        'particle_position_x',
                        'particle_position_y',
                        'particle_mass',
                        center='c')
    field = 'particle_mass'
    p.set_background_color(field)
    p.set_unit('particle_mass', 'code_mass')
    p.set_axes_unit('code_length')
    p.annotate_timestamp(time_unit='code_time',
                         corner='upper_right',
                         text_args={'color': 'k'})
    p.save(mpl_kwargs={"dpi": dpi})
    p.save()
import yt
from yt.units import kpc
#fname =  'Run0/snapshot_000'

unit_base = {
    'UnitLength_in_cm': 3.08568e+21,
    'UnitMass_in_g': 1.989e+43,
    'UnitVelocity_in_cm_per_s': 100000
}

bbox_lim = 0.5e5  #kpc

bbox = [[0, bbox_lim], [0, bbox_lim], [0, bbox_lim]]

path = 'Outputs1/snapshots/'
for filename in os.listdir(path):
    file = os.path.join(path, filename)
    ds = yt.load(file, unit_base=unit_base)
    if ds is not None:

        ad = ds.all_data()
        p = yt.ParticlePlot(ds,
                            'particle_position_x',
                            'particle_position_y',
                            'particle_mass',
                            width=(0.5e5, 0.5e5))
        p.set_unit('particle_mass', 'Msun')

        p.annotate_title('Zoomed-in Particle Plot')
        p.save()
Beispiel #9
0
            
            sp_proj = ds.sphere(center, (float(proper_rvir.in_units('kpc')), 'kpc'))
            
            fig = plt.figure()

            grid = AxesGrid(fig, (0.075,0.075,15,5),
            nrows_ncols = (2, 3),
            axes_pad = 0.05,
            label_mode = "L",
            share_all = True,
            cbar_location="right",
            cbar_mode="single",
            cbar_size="3%",
            cbar_pad="0%")

            a = yt.ParticlePlot(ds, ('stars', 'particle_position_x'), ('stars', 'particle_position_y'),\
                                  ('stars', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)
            b = yt.ParticlePlot(ds, ('stars', 'particle_position_y'), ('stars', 'particle_position_z'),\
                                  ('stars', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)
            c = yt.ParticlePlot(ds, ('stars', 'particle_position_z'), ('stars', 'particle_position_x'),\
                                  ('stars', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)

            d = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_x'), ('darkmatter', 'particle_position_y'),\
                                  ('darkmatter', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)
            e = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_y'), ('darkmatter', 'particle_position_z'),\
                                  ('darkmatter', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)
            f = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_z'), ('darkmatter', 'particle_position_x'),\
                                  ('darkmatter', 'particle_mass'), center=center, width=(float(proper_rvir.in_units('kpc'))*2, "kpc"), data_source=sp_proj)

            a.annotate_marker(center, 'x', plot_args={'s':100, 'color':'red'})
            b.annotate_marker(center, 'x', plot_args={'s':100, 'color':'red'})
            c.annotate_marker(center, 'x', plot_args={'s':100, 'color':'red'})
Beispiel #10
0
import yt

# load the dataset
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# create our plot
p = yt.ParticlePlot(ds, ("all", "particle_position_x"),
                    ("all", "particle_position_y"),
                    color="b")

# zoom in a little bit
p.set_width(500, "kpc")

# save result
p.save()
Beispiel #11
0
import yt

# load the dataset
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# create our plot
p = yt.ParticlePlot(
    ds,
    ("all", "particle_position_x"),
    ("all", "particle_velocity_z"),
    [("all", "particle_mass")],
)

# pick some appropriate units
p.set_unit(("all", "particle_position_x"), "Mpc")
p.set_unit(("all", "particle_velocity_z"), "km/s")
p.set_unit(("all", "particle_mass"), "Msun")

# save result
p.save()
Beispiel #12
0
tsMax = 500
nTot = tsMax - tsMin + 1


def getTimeStepString(n):
    if n < 10: return '00' + str(n)
    elif n < 100: return '0' + str(n)
    else: return str(n)


for ts in range(tsMin, tsMax + 1):
    snapName = inDir + 'snapshot_' + getTimeStepString(ts) + '.hdf5'
    ds = yt.load(snapName)
    print(ds.field_list)
    quantity = 'density'
    #p = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y', quantity, width=(1.0, 1.0))
    p = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y',
                        quantity)
    p.set_xlabel('x')
    p.set_ylabel('y')
    p.zoom(1.8)
    p.set_cmap(quantity, 'viridis')
    #p.set_zlim(quantity, 1.e-22, 1.e-20)
    #save result
    thisOutDir = outDirBase + quantity + '/'
    if not os.path.exists(thisOutDir): os.makedirs(thisOutDir)
    plotName = quantity + '_' + str(ts) + '.png'
    p.save(name=thisOutDir + plotName)

#
Beispiel #13
0
import yt

# load the dataset
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# create our plot
p = yt.ParticlePlot(
    ds,
    ("all", "particle_position_x"),
    ("all", "particle_position_y"),
    ("all", "particle_mass"),
    width=(0.5, 0.5),
)

# pick some appropriate units
p.set_axes_unit("kpc")
p.set_unit(("all", "particle_mass"), "Msun")

# save result
p.save()
Beispiel #14
0
import yt

# load the dataset
ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')

# create our plot
p = yt.ParticlePlot(ds, 'particle_position_x', 'particle_velocity_z', ['particle_mass'])

# pick some appropriate units
p.set_unit('particle_position_x', 'Mpc')
p.set_unit('particle_velocity_z', 'km/s')
p.set_unit('particle_mass', 'Msun')

# save result
p.save()
Beispiel #15
0
  # px.set_cmap(field , cmap='Haze')
  px.set_unit(field, 'km/s')
  px.set_background_color('{}'.format(field))
  plot = px.plots['{}'.format(field)]
  plot.figure = fig
  plot.axes = grid[i].axes
  plot.cax = grid.cbar_axes[i]
  px.set_background_color(field)
  px._setup_plots()
# plt.savefig("results/plot{}200kpc.pdf".format(field), bbox_inches="tight")
plt.show()


# %% phase diagram
for i in range(len(models)):
  plot = yt.ParticlePlot(ds[i], ('PartType0', "Density"), ('PartType0', "temperature"),   ('PartType0', "Masses"))
  plot.set_unit(('PartType0', "Density"), 'g/cm/cm/cm')
  plot.set_unit(('PartType0', "Masses"), 'Msun')
  plot.set_log(('PartType0', "Density"), True)
  plot.set_log(('PartType0', "temperature"), True)
  plot.set_xlim(1e-32, 1e-21)
  plot.set_ylim(5e1, 1e8)
  plot.set_zlim(('PartType0', "Masses"),1e4, 1e7)
  # plot.hide_colorbar()
  plot.show()


# %% phase diagram
# ---------------------
fig = plt.figure()
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
Beispiel #16
0
prefix = args.prefix

colormap = 'arbre'
dpi = 150
field = 'particle_mass'

yt.enable_parallelism()

ts = yt.load([
    prefix + '/Data_%06d' % idx for idx in range(idx_start, idx_end + 1, didx)
])

for ds in ts.piter():

    par = yt.ParticlePlot(ds,
                          'particle_position_x',
                          'particle_position_y',
                          field,
                          center='c')

    par.set_background_color(field)
    #  par.set_zlim( field, 1.0e9, 1.0e12 )
    par.set_cmap(field, colormap)
    par.set_font({'size': 16})
    par.set_axes_unit('code_length')
    par.set_unit(field, 'code_mass')
    par.annotate_timestamp(time_unit='code_time',
                           corner='upper_right',
                           text_args={'color': 'k'})
    par.save(mpl_kwargs={"dpi": dpi})
Beispiel #17
0
#slc = yt.SlicePlot(ds, 'z', [('gas', 'density')], width = (my_width, 'kpc'))
#slc.set_cmap(field="density", cmap= my_cmap)
#slc.save('/Users/francisco/DATA/Pegasus/'+run+'/plots/GasDensitySlice_z_snapshot_' + str(isnap).zfill(3) +'.png')

"************ CREATE AND SAVE A PARTICLE PLOT ***************"

# create our plot
#p = yt.ParticleProjectionPlot(ds,2,[('PartType1','Masses')], width = (5,5), center = halocenter, data_source = sp)
#p.set_cmap(field="particle_mass", cmap= my_cmap)
#p.set_unit('particle_mass', 'Msun')
#save result
#p.save('/Users/francisco/DATA/Pegasus/run_2/plots/particle_plot_snapshot_' + str(isnap).zfill(3) +'.png')

#####...Test Particle Plot
p0 = yt.ParticlePlot(ds, ('PartType0', 'particle_position_x'),
                     ('PartType0', 'particle_position_y'),
                     ('PartType0', 'density'))
#p0.set_zlim('density', 5*10**-6, 10**-3 )
p0.save('/data8/data/mercadf1/output/Pegasus/' + run +
        '/Plots/Gas_ParticlePlot_x_snapshot_' + str(isnap).zfill(3) + '.png')

#p1 = yt.ParticlePlot(ds, ('PartType1','particle_position_x'), ('PartType1','particle_position_y'),('PartType1', 'particle_mass'))
#p1.set_zlim('particle_mass', 5*10**-6, 10**-3 )
#p1.save('/data8/data/mercadf1/output/Pegasus/'+run+'/Plots/DM_ParticlePlot_x_snapshot_' + str(isnap).zfill(3) +'.png')

#p2 = yt.ParticlePlot(ds, ('PartType4','particle_position_x'), ('PartType4','particle_position_y'),('PartType4', 'particle_mass'))
#p2.set_zlim('particle_mass', 5*10**-6, 10**-3 )
#p2.save('/data8/data/mercadf1/output/Pegasus/'+run+'/Plots/Stars_ParticlePlot_x_snapshot_' + str(isnap).zfill(3) +'.png')

#p1 = yt.ParticlePlot(ds,[('ParticleType4','particle_position_x'),('ParticleType4','particle_position_y')],('ParticleType4','particle_mass'), width = (my_width, 'kpc'))
#p1.set_cmap(field="particle_mass", cmap= my_cmap)
Beispiel #18
0
def rvirprojectionsallhalos(ds, center, rvir, sp, tomer_center, tomer_rvir,
                            halo_data, domain_width, input_dir, VELA_a):
    fig = plt.figure()

    grid = AxesGrid(fig, (0.075, 0.075, 15, 5),
                    nrows_ncols=(2, 3),
                    axes_pad=0.5,
                    label_mode="L",
                    share_all=True,
                    cbar_location="right",
                    cbar_mode="single",
                    cbar_size="3%",
                    cbar_pad="0%")

    #create the 3 different x-y-z projection plots to add to the grid, one for stars and two for darkmatter
    a = yt.ParticlePlot(ds, ('stars', 'particle_position_x'), ('stars', 'particle_position_y'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    a.set_unit(('stars', 'particle_mass'), 'Msun')
    b = yt.ParticlePlot(ds, ('stars', 'particle_position_y'), ('stars', 'particle_position_z'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    b.set_unit(('stars', 'particle_mass'), 'Msun')
    c = yt.ParticlePlot(ds, ('stars', 'particle_position_z'), ('stars', 'particle_position_x'),\
                          ('stars', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    c.set_unit(('stars', 'particle_mass'), 'Msun')

    d = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_x'), ('darkmatter', 'particle_position_y'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    d.set_unit(('darkmatter', 'particle_mass'), 'Msun')
    e = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_y'), ('darkmatter', 'particle_position_z'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    e.set_unit(('darkmatter', 'particle_mass'), 'Msun')
    f = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_z'), ('darkmatter', 'particle_position_x'),\
                          ('darkmatter', 'particle_mass'), center=center, width=(rvir*3, "kpc"), data_source=sp)
    f.set_unit(('darkmatter', 'particle_mass'), 'Msun')

    #add the x marker for the largest halo from the rockstar catalog
    a.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})
    b.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})
    c.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})
    d.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})
    e.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})
    f.annotate_marker(center, 'o', plot_args={'s': 100, 'color': 'red'})

    #add the x marker for the tomer catalog
    a.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })
    b.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })
    c.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })
    d.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })
    e.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })
    f.annotate_marker(tomer_center,
                      'x',
                      plot_args={
                          's': 200,
                          'color': 'black'
                      })

    #add the circle for the tomer catalog for the 3rd row

    a.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})
    b.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})
    c.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})
    d.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})
    e.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})
    f.annotate_sphere(center,
                      radius=(rvir, 'kpc'),
                      circle_args={'color': 'red'})

    a.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})
    b.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})
    c.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})

    d.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})
    e.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})
    f.annotate_sphere(tomer_center,
                      radius=(tomer_rvir, 'kpc'),
                      circle_args={'color': 'black'})

    #add the title for each column
    a.annotate_title('Stellar Mass X-Y Projection')
    b.annotate_title('Stellar Mass Y-Z Projection')
    c.annotate_title('Stellar Mass Z-X Projection')

    d.annotate_title('Darkmatter Mass X-Y Projection')
    e.annotate_title('Darkmatter Mass Y-Z Projection')
    f.annotate_title('Darkmatter Mass Z-X Projection')
    #add annotations for redshift and scale
    a.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    a.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})
    b.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    b.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})
    c.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    c.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})
    d.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    d.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})
    e.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    e.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})
    f.annotate_timestamp(corner='lower_left',
                         redshift=True,
                         time=False,
                         draw_inset_box=False,
                         text_args={'color': 'black'})
    f.annotate_scale(corner='lower_right',
                     unit='kpc',
                     size_bar_args={'color': 'b'})

    #add the annotations for what the dot and x is, and the color circles
    count = 0
    while count < 6:
        current_halo = halo_data[count]
        x = float(current_halo[17]) / domain_width
        y = float(current_halo[18]) / domain_width
        z = float(current_halo[19]) / domain_width
        rvir_smaller_halos = float(
            current_halo[11]) * (float(VELA_a) / 1000) / .7
        center = [x, y, z]

        #a.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})
        #b.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})
        #c.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})

        #d.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})
        #e.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})
        #f.annotate_sphere(center, radius=(rvir_smaller_halos, 'kpc'), circle_args={'color':'red'})

        count = count + 1
    index = 0
    for letter in [a, b, c]:
        plot = letter.plots[('stars', 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index].axes
        plot.cax = grid.cbar_axes[0]
        letter._setup_plots()
        index = index + 1

    for letter in [d, e, f]:
        plot = letter.plots[('darkmatter', 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index].axes
        plot.cax = grid.cbar_axes[0]
        letter._setup_plots()
        index = index + 1

    plt.savefig('%s/%s.png' % (input_dir, VELA_a), bbox_inches='tight')
    plt.close()
Beispiel #19
0
import yt

# load the dataset
ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')

# create our plot
p = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y', color='b')

# zoom in a little bit
p.set_width(500, 'kpc')

#save result
p.save()
Beispiel #20
0
def plotting_xyz_projection(ds, zoom, center, rvir, tomer_center, tomer_rvir,
                            VELA_a, input_dir):
    #setup the figure grid to put the images onto
    fig = plt.figure()

    grid = AxesGrid(fig, (0.075, 0.075, 15, 5),
                    nrows_ncols=(6, 3),
                    axes_pad=0.05,
                    label_mode="L",
                    share_all=True,
                    cbar_location="right",
                    cbar_mode="single",
                    cbar_size="3%",
                    cbar_pad="0%")

    ad = ds.all_data()
    par_type = 'darkmatter'
    masses = yt.np.unique(ad[(par_type, 'particle_mass')])
    for index in range(len(masses)):
        global filter_name, index1
        index1 = index
        filter_name = par_type + str(index)

        def mass_filter(pfilter, data):
            filter = data[(pfilter.filtered_type,
                           'particle_mass')] == masses[index]
            return filter

        yt.add_particle_filter(filter_name,
                               function=mass_filter,
                               filtered_type=par_type,
                               requires=['particle_mass'])
        ds.add_particle_filter(filter_name)

        global a, b, c
        a = yt.ParticlePlot(ds, (filter_name, 'particle_position_x'), (filter_name, 'particle_position_y'),\
                        (filter_name,'particle_mass'))
        a.set_unit((filter_name, 'particle_mass'), 'Msun')
        a.set_figure_size(5)
        a.zoom(zoom)

        b = yt.ParticlePlot(ds, (filter_name, 'particle_position_y'), (filter_name, 'particle_position_z'),\
                        (filter_name,'particle_mass'))
        b.set_unit((filter_name, 'particle_mass'), 'Msun')
        b.set_figure_size(5)
        b.zoom(zoom)

        c = yt.ParticlePlot(ds, (filter_name, 'particle_position_z'), (filter_name, 'particle_position_x'),\
                            (filter_name,'particle_mass'))
        c.set_unit((filter_name, 'particle_mass'), 'Msun')
        c.set_figure_size(5)
        c.zoom(zoom)

        a.annotate_sphere(tomer_center,
                          radius=(tomer_rvir, 'kpc'),
                          circle_args={'color': 'red'})
        a.annotate_sphere(center,
                          radius=(rvir, 'kpc'),
                          circle_args={'color': 'black'})
        b.annotate_sphere(tomer_center,
                          radius=(tomer_rvir, 'kpc'),
                          circle_args={'color': 'red'})
        b.annotate_sphere(center,
                          radius=(rvir, 'kpc'),
                          circle_args={'color': 'black'})
        c.annotate_sphere(tomer_center,
                          radius=(tomer_rvir, 'kpc'),
                          circle_args={'color': 'red'})
        c.annotate_sphere(center,
                          radius=(rvir, 'kpc'),
                          circle_args={'color': 'black'})

        plot = a.plots[(filter_name, 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index * 3].axes
        plot.cax = grid.cbar_axes[0]
        a._setup_plots()

        plot = b.plots[(filter_name, 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index * 3 + 1].axes
        plot.cax = grid.cbar_axes[0]
        b._setup_plots()

        plot = c.plots[(filter_name, 'particle_mass')]
        plot.figure = fig
        plot.axes = grid[index * 3 + 2].axes
        plot.cax = grid.cbar_axes[0]
        c._setup_plots()

    plt.savefig('%s/%sdarkmattercomparison.png' % (input_dir, VELA_a),
                bbox_inches='tight')
    plt.close()
Beispiel #21
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
# -----------------------------------------------------------------------------
#
# This program creates test plots for the initial condition generator provided
# for the Keplerian Ring example.
#
###############################################################################
"""


if __name__ == "__main__":
    import yt

    data = yt.load("initial_conditions.hdf5")

    plot = yt.ParticlePlot(
        data,
        "particle_position_x",
        "particle_position_y",
        "density"
    )

    plot.save("test.png")


Beispiel #22
0
                        cbar_location="right",
                        cbar_mode="each",
                        cbar_size="3%",
                        cbar_pad="0%")

        zoom = 10

        x0 = float(
            consistent.halo_data_sorted[index][0][17]) * scale / domain_width
        y0 = float(
            consistent.halo_data_sorted[index][0][18]) * scale / domain_width
        z0 = float(
            consistent.halo_data_sorted[index][0][19]) * scale / domain_width
        center = [x0, y0, z0]

        a = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_x'), ('darkmatter0', 'particle_position_y'),\
                              ('darkmatter0', 'particle_mass'), center=center)
        a.set_unit(('darkmatter0', 'particle_mass'), 'Msun')
        a.zoom(zoom)
        b = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_y'), ('darkmatter0', 'particle_position_z'),\
                              ('darkmatter0', 'particle_mass'), center=center)
        b.set_unit(('darkmatter0', 'particle_mass'), 'Msun')
        b.zoom(zoom)
        c = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_z'), ('darkmatter0', 'particle_position_x'),\
                              ('darkmatter0', 'particle_mass'), center=center)
        c.set_unit(('darkmatter0', 'particle_mass'), 'Msun')
        c.zoom(zoom)

        for halos in consistent.halo_data_sorted[index]:
            x = float(halos[17]) * scale / domain_width
            y = float(halos[18]) * scale / domain_width
            z = float(halos[19]) * scale / domain_width
import yt

#fname = '/home/elismar/Documentos/Fisica/IC/Gadget3/simulation_galmer-like_test2/snapshot_0010'
fname = '/home/elismar/Documentos/Fisica/IC/simulations_ICs/codes/snapshot10'

unit_base = {
    'UnitLength_in_cm': 3.08568e+21,
    'UnitMass_in_g': 1.989e+43,
    'UnitVelocity_in_cm_per_s': 100000
}

bbox_lim = 2000  #kpc

bbox = [[-bbox_lim, bbox_lim], [-bbox_lim, bbox_lim], [-bbox_lim, bbox_lim]]

ds = yt.load(fname, unit_base=unit_base, bounding_box=bbox)

p = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y',
                    'particle_mass')

p.set_font({'family': 'sans-serif', 'style': 'italic', 'size': 30})

p.annotate_title('0.5 Gyr')

p.set_unit('particle_mass', 'Msun')
p.zoom(20)
p.save('galmer_10.png')
                 #now plot the graph
                 
                 fig = plt.figure()
 
                 grid = AxesGrid(fig, (0.075,0.075,10,5),
                 nrows_ncols = (3, 2),
                 axes_pad = 1.0,
                 label_mode = "L",
                 share_all = False,
                 cbar_location="right",
                 cbar_mode="each",
                 cbar_size="3%",
                 cbar_pad="0%")
 
                 #create the 3 different x-y-z projection plots to add to the grid, one for stars and two for darkmatter
                 a = yt.ParticlePlot(ds, ('stars', 'particle_position_x'), ('stars', 'particle_position_y'),\
                                       ('stars', 'particle_mass'), center=center, width=(graph_size, "kpc"), data_source=sp)
                 a.set_unit(('stars','particle_mass'), 'Msun')
                 b = yt.ParticlePlot(ds, ('stars', 'particle_position_y'), ('stars', 'particle_position_z'),\
                                       ('stars', 'particle_mass'), center=center, width=(graph_size, "kpc"), data_source=sp)
                 b.set_unit(('stars','particle_mass'), 'Msun')
                 c = yt.ParticlePlot(ds, ('stars', 'particle_position_z'), ('stars', 'particle_position_x'),\
                                       ('stars', 'particle_mass'), center=center, width=(graph_size, "kpc"), data_source=sp)
                 c.set_unit(('stars','particle_mass'), 'Msun')
         
         
                 g = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_x'), ('darkmatter', 'particle_position_y'),\
                                       ('darkmatter', 'particle_mass'), center=center, width=(graph_size, "kpc"), data_source=sp)
                 g.set_unit(('darkmatter','particle_mass'), 'Msun')
                 h = yt.ParticlePlot(ds, ('darkmatter', 'particle_position_y'), ('darkmatter', 'particle_position_z'),\
                                       ('darkmatter', 'particle_mass'), center=center, width=(graph_size, "kpc"), data_source=sp)
                 h.set_unit(('darkmatter','particle_mass'), 'Msun')
Beispiel #25
0
    sz_dens.save(mpl_kwargs={"dpi": dpi})

    #  temperature
    field = 'temperature'
    sz_temp = yt.SlicePlot(ds, 'z', field, center=center_mode)

    sz_temp.set_zlim(field, 2.0e7, 1.5e8)
    sz_temp.set_cmap(field, colormap_temp)
    sz_temp.annotate_timestamp(time_unit='Myr', corner='upper_right')

    sz_temp.save(mpl_kwargs={"dpi": dpi})

    #  CDM particles
    field = 'particle_mass'
    cdm_mass = yt.ParticlePlot(ds,
                               'particle_position_x',
                               'particle_position_y',
                               field,
                               center=center_mode,
                               depth=(8.0 * Mpc))

    cdm_mass.set_background_color(field)
    cdm_mass.set_zlim(field, 1.0e9, 1.0e12)
    cdm_mass.set_unit(field, 'Msun')
    cdm_mass.set_cmap(field, colormap_cdm)
    cdm_mass.set_colorbar_label(field, 'Dark matter mass [$M_{\odot}$]')
    cdm_mass.annotate_timestamp(time_unit='Myr', corner='upper_right')

    cdm_mass.save(mpl_kwargs={"dpi": dpi})
Beispiel #26
0
import yt

# load the dataset
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# create our plot
p = yt.ParticlePlot(ds,
                    "particle_position_x",
                    "particle_position_y",
                    color="b")

# zoom in a little bit
p.set_width(500, "kpc")

# save result
p.save()