Extracting data with yt:
objects, fields, and the clump finder.
Britton Smith

Enzo User Workshop

Hokkaido University, November 20, 2014

GOALS

1. Work with data containers
2. Use derived quantities
3. Make new fields
4. Run the clump finderWhat does grid simulation data actually look like?

(0,1)(0,0)

Data on disk has
no physical meaning.

(1,1)

(1,0)

yt lets you think about
physicalobjects(0,10)Mpc(10,10)Mpc(0,0)Mpc(10,0)Mpc

yt lets you think about
physicalobjects(0,10)Mpc(10,10)Mpc

2(0,0)Mpc

cpM(10,0)Mpc

yt lets you think about
physicalobjects(0,10)Mpc(10,10)Mpc

2(0,0)Mpc

cp
M(10,0)Mpc

and forget what’s underneath.

(0,10)Mpc

yt gives you thedata you want2(0,0)Mpc(10,10)Mpc

cpM(10,0)Mpc

yt gives you thedata you want

2cp
M

and only the data you want.

You can do whatever
you want with it.

2cp
MYou can do whatever
you want with it.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cpM

You can do whatever
you want with it.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cp
M

sp[“density”]

ρ ρ ρρρρρρρρρρρρρρρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρYou can do whatever
you want with it.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cp
M

sp[“temperature”]

T T TTTTTTTTTTTTTTT T T T T T T T T T T T T T T T

Spatial information
is not lost.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cp
M

sp[“x”]x x xxxxxxxxxxxxxx

x x x x x x x x x x x x x x x x

Data containers give fields
as Numpy arrays.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cp
M

sp[“density”] * sp[“temperature”]

p p pppppppppppppp

p p p p p p p p p p p p p p p pSymbolic units andunit conversion.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cp
M

sp[“density”].in_units(“g/cm**3”)ρ ρ ρρρρρρρρρρρρρρρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρSymbolic units andunit conversion.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cpM

sp[“density”].in_units(“Msun/kpc**3”)ρ ρ ρρρρρρρρρρρρρρρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ ρ

DATA CONTAINERS• All Data
• Region• Sphere• Disk• Ray

import yt
ds = yt.load("workshop2014/sample_data/IsolatedGalaxy/galaxy0030/galaxy0030")

DATA CONTAINERS• All Data••••ds.all_data()

DATA CONTAINERS•• Region•••

ds.region(center,left_corner,right_corner)

ords.box(left_corner,right_corner)

DATA CONTAINERS••• Sphere••ds.sphere(center, radius)

DATA CONTAINERS•••• Disk•ds.disk(center, normal_vector,radius, height)Geometry-specific Fields“cylindrical_z”“cylindrical_r””
su
id“raDATA CONTAINERS••••• Rayds.ray(start_point, end_point)Derived quantities turnfields into single values.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))2cp
M

sp[“cell_mass”]

m m mmmmmmmmmmmmmm

m m m m m m m m m m m m m m m m

Derived quantities turnfields into single values.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cpM

sp.quantities.total_quantity(“cell_mass”)

m + m +m +m+ m+m +m +m +m+m+m +m +m++m+m + + + + + + + + + + + + + + ++ =Mmmmm

mmmmmmmmmmmmmDerived quantities turnfields into single values.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2cpM

sp.quantities.total_quantity(“cell_mass”)

M=∑miDerived quantities turnfields into single values.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))

2

sp.quantities.spin_parameter()

1/2∑Li|∑Ei |M= G∑m 5/2
icp
MCHALLENGE 1
1. Create a sphere centered on the center of massof the full dataset.
2. Create a disk centered on the sphere’s center ofmass and aligned with the sphere’s angularmomentum vector.
3. Make “face-on” and “edge-on” density projectionsof the disk.
4. Compare the following quantities for the sphereand the disk: spin parameter, mass-weighted
average temperature.
BONUS: use HiresIsolatedGalaxy/DD0044/DD0044

PROFILES AND PHASE PLOTSDERIVED FIELDS

Creating new fields
is easy.
ds = load(”DD0252/DD0252”)
sp = ds.sphere(center, (2, “Mpc”))
def my_field(field, data):
return k * data[“temperature”] * \data[“number_density”]**(-2./3)

2cpM

ds.add_field(“entropy”, function=my_field,units=“keV*cm**2”)

sp[“entropy”]

e e eeeeeeeeeeeeeee e e e e e e e e e e e e e e e

CHALLENGE 2
1. Use the disk object to compare profiles of density
vs. radius and height.
2. Make a phase plot of the mass-weighted average
metallicity in bins of radial velocity vs. rotational
velocity (“tangential_velocity”) in a disk.
3. Make an interesting new field.
BONUS: use HiresIsolatedGalaxy/DD0044/DD0044

CLUMP FINDING

Finding Clumps

DensityMaxMinFinding Clumps

MinDensityMaxFinding Clumps

Min

DensityMax

Finding Clumps

Min

DensityMax

Finding ClumpsMax

DensityBound?

Finding Clumps

Bound?
NO

DensityMax

Finding ClumpsMax

DensityMin

Finding ClumpsMax

Density

SingleChild

Finding ClumpsMax

DensityBound?

Finding Clumps
Max
Bound?

Density

YES

Finding ClumpsMax

DensityMin

Finding ClumpsMax

DensityBound?

Finding ClumpsMax

DensityBound?
NO

Finding Clumps
Bound?

DensityMax

Finding Clumps
Bound? NO

DensityMax

Finding Clumps
Bound?

DensityMax

Finding Clumps
Bound? YES

DensityMax

Finding Clumps

DensityMax

Finding Clumps

Density

MaxMinFinding Clumps
SingleDensity

MaxChildFinding Clumps
SingleDensity

Max

Child

Finding Clumps
Bound?

DensityMax

Finding Clumps

Density

MaxBound?
YES

Finding Clumps

DensityMax

Clump Finding Recipe
cp /mnt/iscsi5/enzo_workshop/yt-x86_64/src/yt-hg/doc/
source/cookbook/find_clumps.py .

The Cookbook
ls /mnt/iscsi5/enzo_workshop/yt-x86_64/src/yt-hg/doc/
source/cookbook/or
yt-project.org/doc/cookbook/Supported Codes

Simulation Codes/FormatsART Athena
Boxlib Chombo
Enzo Flash
Eagle
GadgetGDF
OWLS
Piernik RAMSES
Tipsy

Halo Finders
FoF
HOP
Rockstar
Other Formats
array datafits