Date post: | 02-Jul-2015 |
Category: |
Education |
Upload: | john-zuhone |
View: | 535 times |
Download: | 4 times |
yt: An Analysis and Visualization System
for Astrophysical Simulation Data
John ZuHone NASA/Goddard Space Flight Center, Code 662
What is yt?
astro-ph/1011.3514 astro-ph/1112.4482
yt-project.org
yt is a platform for analysis and visualization of astrophysical* simulations
!
There are many simulation codes, but there’s only one sky.
Fully-Supported Semi-Supported In Progress
Enzo FLASH Nyx
Orion Uniform Data
Chombo Athena
ART Ramses Piernik GDF
Gadget Hydra Cactus
!
data structures, methods,
assumptions, IO formats, units,
variable names, ...
!
yt is designed to address physical, not computational,
entities and questions
Orthogonal Rays Non-orthogonal Rays
Slices Oblique Slices Projections
Spheres Rectangular Prisms Disks/Cylinders Inclined Boxes Clumps Extracted Regions Ellipsoids
1D
2D
3D
Why use Python?
• Object-oriented
• Open source
• Lots of external libraries
• NumPy
• h5py
• Matplotlib
• IPython
• Astropy
• Sherpa/Chips
Python Libraries
Objects
Objects
• Parameter file: a “loaded” data file that contains the simulation parameters and the “hierarchy”
• pf = load(“kh_mhd_hdf5_chk_0100”)
• Hierarchy: grid metadata object that “hangs off” the parameter file: “pf.h”
pf.h.print_stats(): level # grids # cells # cells^3 ---------------------------------------------- 0 1 4096 15 1 8 32768 31 2 64 262144 63 3 512 2097152 127 4 640 2621440 137 5 1728 7077888 191 6 4896 20054016 271 7 15888 65077248 402 ---------------------------------------------- 23737 97226752 !!t = 6.31898207e+16 = 6.31898207e+16 s = 2.00236459e+09 years !Smallest Cell: Width: 4.883e-04 unitary Width: 6.961e-03 mpc Width: 6.961e+00 kpc Width: 6.961e+03 pc Width: 1.436e+09 au Width: 3.090e+11 rsun Width: 1.335e+17 miles Width: 2.148e+22 1 Width: 2.148e+22 cm
Objects
• Astrophysically motivated objects
• Spheres, disks, cylinders
• Slices, projections, rays
• Combinations of these
• These objects can be created from the hierarchy, e.g. “pf.h.slice”, “pf.h.sphere”
Fields and Quantities
Fields
• Some fields come from the simulation dataset itself: density, temperature, velocities, etc.
• yt attempts to treat fields equivalently across codes, converting all to appropriate cgs units
• Fields may also be derived from other fields or some other mathematical quantity
• Fields can be grid-based or particle fields
Fields
def _total_density(field, data) : ! return data["Density"]+data["Dark_Matter_Density"] !add_field("TotalDensity", function=_total_density, take_log=True, units=r"\rm{g}/\rm{cm}^{3}")
Quantities
• Quantities are reductions of field data associated with objects
• yt maintains a registry of commonly used quantities, but derived quantities may also be added
Quantitiesfrom yt.mods import * !pf = load("IsolatedGalaxy/galaxy0030/galaxy0030") # load data !field = "Temperature" # The field to average weight = "CellMassMsun" # The weight for the average !dd = pf.h.all_data() # This is a region describing the entire box, # but note it doesn't read anything in yet! !average_value = dd.quantities["WeightedAverageQuantity"](field, weight) !print "Average %s (weighted by %s) is %0.5e" % (field, weight, average_value)
Quantitiesfrom yt.mods import * !# Load the dataset. pf = load("Enzo_64/DD0029/data0029") !# Create a 1 Mpc radius sphere, centered on the max density. sp = pf.h.sphere("max", (1.0, "mpc")) !# Use the TotalQuantity derived quantity to sum up the # values of the CellMassMsun and ParticleMassMsun fields # within the sphere. baryon_mass, particle_mass = sp.quantities["TotalQuantity"]( ["CellMassMsun", "ParticleMassMsun"]) !print "Total mass in sphere is %0.5e (gas = %0.5e / particles = %0.5e)" % \ (baryon_mass + particle_mass, baryon_mass, particle_mass)
Basic Plotting
Basic Plotting
• yt makes use of Matplotlib
• Basic plot types: slices, projections, profiles
• Plots have many possible annotations
Basic Plotting
from yt.mods import * !pf = load("Enzo_64/RD0005/RedshiftOutput0005") slc = SlicePlot(pf, 0, ["Density","Dark_Matter_Density"],
center="max") slc.save("1")
Basic Plotting
from yt.mods import * !pf = load("Enzo_64/RD0005/RedshiftOutput0005") slc = SlicePlot(pf, 0, ["Density","Dark_Matter_Density"], center="max") slc.save("1") slc.annotate_grids() slc.save("2")
Basic Plotting
from yt.mods import * !pf = load("Enzo_64/RD0005/RedshiftOutput0005") slc = SlicePlot(pf, 0, ["Density","Dark_Matter_Density"], center="max") slc.save("1") slc.annotate_grids() slc.save("2") slc.zoom(4) slc.save("3")
Basic Plottingfrom yt.mods import * !pf = load("Enzo_64/RD0005/RedshiftOutput0005") slc = SlicePlot(pf, 0, ["Density","Dark_Matter_Density"], center="max") slc.save("1") slc.annotate_grids() slc.save("2") slc.zoom(4) slc.save("3") slc.annotate_contour("Density") slc.save("4")
Basic Plotting
from yt.mods import * !pf = load("sloshing_nomag2_hdf5_plt_cnt_0150") !prj = ProjectionPlot(pf, 2, ["Temperature"], weight_field="Density") prj.save("1")
Basic Plotting
from yt.mods import * !pf = load("sloshing_nomag2_hdf5_plt_cnt_0150") !prj = ProjectionPlot(pf, 2, ["Temperature"], weight_field="Density") prj.save("1") prj.zoom(2) prj.save("2")
Basic Plotting
from yt.mods import * !pf = load("sloshing_nomag2_hdf5_plt_cnt_0150") !prj = ProjectionPlot(pf, 2, ["Temperature"], weight_field="Density") prj.save("1") prj.zoom(2) prj.save("2") prj.set_log("Temperature", False) prj.save("3")
Basic Plotting
from yt.mods import * !pf = load("sloshing_nomag2_hdf5_plt_cnt_0150") !prj = ProjectionPlot(pf, 2, ["Temperature"], weight_field="Density") prj.save("1") prj.zoom(2) prj.save("2") prj.set_log("Temperature", False) prj.save("3") prj.annotate_text((0.5,0.5), "This is text") prj.save("4")
x y z
Basic Plotting• Many other annotations:
• Timestamps
• Particle positions
• Vectors
• Other modifications
• Colorbar
• Plot center
• Plot width
Basic Plotting
from yt.mods import * !pf = load("IsolatedGalaxy/galaxy0030/galaxy0030") !slc = SlicePlot(pf, 2, ["Density","Dark_Matter_Density", "Star_Particle_Density"]) !frb = slc.data_source.to_frb((60., "kpc"), 800) !frb.export_fits("isolated_galaxy", units="kpc", gzip_file=True)
Time Series Analysis
# Glob for a list of filenames, then sort them fns = glob.glob("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0") fns.sort() !# Construct the time series object !ts = TimeSeriesData.from_filenames(fns) !times = [] entrs = [] !for pf in ts: t = pf.current_time sphere = pf.h.sphere("c", (100., "kpc")) temp = sphere["Temperature"]/keV dens = sphere["Density"]/(m_p*mue) mgas = sphere["CellMass"] entr = (temp*(dens**mtt)*mgas).sum()/mgas.sum() times.append(t) entrs.append(entr)
Time Series Analysis
Volume Rendering
Sam Skillman
Matthew Turk
Other Things...• GUI
• Parallel Analysis
• Off-Axis Slices/Projections
• Phase/Profile Plotting
• Halo finding/profiling
• Light Cones
• Streamlines
• Absorption Spectra
• Synthetic X-ray Observations (in progress)
How to get more: Information? Examples?
Help?
The Mailing Lists
Users’ List (yt-users): http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org !Developers’ List (yt-dev): http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
Social Media
Google+: yt Project Twitter: @yt_astro
Development
• Mercurial
• Bitbucket
Tom Abel David CollinsBrian Crosby Andrew Cunningham Nathan Goldbaum Cameron Hummels Ji-hoon Kim Steffen Klemer Kacper Kowalik Michael Kuhlen Eve Lee Chris MaloneChris Moody Andrew MyersJeff Oishi
Jean-Claude Passy Thomas Robitaille Anna Rosen Anthony Scopatz Devin Silvia Sam Skillman Stephen Skory Britton Smith Geoffrey So Casey Stark Elizabeth Tasker Matthew Turk Rick Wagner John Wise John ZuHone
Tom Abel David CollinsBrian Crosby Andrew Cunningham Nathan Goldbaum Cameron Hummels Ji-hoon Kim Steffen Klemer Kacper Kowalik Michael Kuhlen Eve Lee Chris MaloneChris Moody Andrew MyersJeff Oishi
Jean-Claude Passy Thomas Robitaille Anna Rosen Anthony Scopatz Devin Silvia Sam Skillman Stephen Skory Britton Smith Geoffrey So Casey Stark Elizabeth Tasker Matthew Turk Rick Wagner John Wise John ZuHone