[Yt-svn] yt-commit r1313 - branches/yt-1.5/examples

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue May 19 21:05:27 PDT 2009


Author: mturk
Date: Tue May 19 21:05:25 2009
New Revision: 1313
URL: http://yt.spacepope.org/changeset/1313

Log:
Many, many minor updates to the cookbook & examples to bring up to speed with
new YT usage patterns.



Modified:
   branches/yt-1.5/examples/cookbook_hop_mass_sum.py
   branches/yt-1.5/examples/cookbook_linked_plot_save.py
   branches/yt-1.5/examples/cookbook_make_timeseries.py
   branches/yt-1.5/examples/cookbook_make_zoomin.py
   branches/yt-1.5/examples/cookbook_making_1d_profiles.py
   branches/yt-1.5/examples/cookbook_making_2d_profiles.py
   branches/yt-1.5/examples/cookbook_mass_sum.py
   branches/yt-1.5/examples/cookbook_multiple_fields_multiple_widths_plot.py
   branches/yt-1.5/examples/cookbook_multiple_fields_single_width_plot.py
   branches/yt-1.5/examples/cookbook_multiple_widths_plot.py
   branches/yt-1.5/examples/cookbook_simple_projection.py
   branches/yt-1.5/examples/cookbook_single_width_plot.py
   branches/yt-1.5/examples/cookbook_timeseries_avg_temp.py
   branches/yt-1.5/examples/cookbook_timeseries_max_dens.py

Modified: branches/yt-1.5/examples/cookbook_hop_mass_sum.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_hop_mass_sum.py	(original)
+++ branches/yt-1.5/examples/cookbook_hop_mass_sum.py	Tue May 19 21:05:25 2009
@@ -1,17 +1,12 @@
 from yt.mods import *
 
-pf = get_pf() # last argument on the command line gets turned into an EnzoStaticOutput
+pf = load("my_data") # load "my_data"
 
-hop_results = HaloFinder(pf, threshold=80.0)
+hop_results = HaloFinder(pf)
 
-def get_mass_results(hop_group):
+for hop_group in hop_results:
     sphere = hop_group.get_sphere()
-    baryon_mass = sphere["CellMassMsun"].sum()
-    dm = sphere["creation_time"] < 0
-    dm_mass = sphere["ParticleMassMsun"][dm].sum()
-    star_mass = sphere["ParticleMassMsun"][~dm].sum()
-    return "Total mass in HOP group %s is %0.5e (gas = %0.5e / dm = %0.5e / star = %0.5e)" % \
-           (hop_group.id, baryon_mass + dm_mass + star_mass, baryon_mass, dm_mass, star_mass)
-
-s = [get_mass_results(g) for g in hop_results]
-print "\n".join(s)
+    baryon_mass, particle_mass = sphere.quantities["TotalQuantity"](
+            ["CellMassMsun", "ParticleMassMsun"], lazy_reader=True)
+    print "Total mass in HOP group %s is %0.5e (gas = %0.5e / particles = %0.5e)" % \
+            (hop_group.id, baryon_mass + particle_mass, baryon_mass, particle_mass)

Modified: branches/yt-1.5/examples/cookbook_linked_plot_save.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_linked_plot_save.py	(original)
+++ branches/yt-1.5/examples/cookbook_linked_plot_save.py	Tue May 19 21:05:25 2009
@@ -1,7 +1,7 @@
 from yt.mods import *
-pf = get_pf()
+pf = load("my_data") # Open "my_data"
 
-pc = raven.PlotCollection(pf)
+pc = PlotCollection(pf)
 
 fn = "%(bn)s_%(width)010i_%(unit)s" # template for image file names
 

Modified: branches/yt-1.5/examples/cookbook_make_timeseries.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_make_timeseries.py	(original)
+++ branches/yt-1.5/examples/cookbook_make_timeseries.py	Tue May 19 21:05:25 2009
@@ -12,9 +12,9 @@
 
 for i in range(min_output_number, max_output_number+1, skip):
     basename = basename_template % (i,i)
-    pf = lagos.EnzoStaticOutput(basename)
-    pc = raven.PlotCollection(pf, center=[0.5,0.5,0.5])
-    pc.add_projection("Density",0)
+    pf = load(basename)
+    pc = PlotCollection(pf, center=[0.5,0.5,0.5])
+    pc.add_projection("Density", 0)
     pc.set_zlim(rho_min, rho_max)
     # Override the name
     pc.save(frame_template % (i), override=True)

Modified: branches/yt-1.5/examples/cookbook_make_zoomin.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_make_zoomin.py	(original)
+++ branches/yt-1.5/examples/cookbook_make_zoomin.py	Tue May 19 21:05:25 2009
@@ -10,7 +10,7 @@
 
 for i in range(3):
     pl = pc.add_slice("Density",i)
-    pl.add_callback(raven.UnitBoundaryCallback('pc'))
+    pl.modify["units"]()
 
 for i,v in enumerate(na.logspace(0,
              na.log10(pf.h.get_smallest_dx()*min_dx), n_frames)):

Modified: branches/yt-1.5/examples/cookbook_making_1d_profiles.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_making_1d_profiles.py	(original)
+++ branches/yt-1.5/examples/cookbook_making_1d_profiles.py	Tue May 19 21:05:25 2009
@@ -1,6 +1,6 @@
 from yt.mods import *
 
-pf = get_pf() # Last argument on command line turned into an output file
+pf = load("my_data") # Open "my_data"
 
 v,c = pf.h.find_max("Density")
 
@@ -14,7 +14,7 @@
 r_max = sphere["Radius"].max()
 x_bins_1d = 64
 
-prof1d = lagos.BinnedProfile1D(sphere, x_bins_1d, "Radius", r_min, r_max, lazy_reader=True)
+prof1d = BinnedProfile1D(sphere, x_bins_1d, "Radius", r_min, r_max, lazy_reader=True)
 prof1d.add_fields("CellMassMsun", accumulation=True, weight=None)
 prof1d.add_fields("NumberDensity")
 prof1d.add_fields("Temperature")

Modified: branches/yt-1.5/examples/cookbook_making_2d_profiles.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_making_2d_profiles.py	(original)
+++ branches/yt-1.5/examples/cookbook_making_2d_profiles.py	Tue May 19 21:05:25 2009
@@ -1,6 +1,6 @@
 from yt.mods import *
 
-pf = get_pf() # Last argument on command line turned into an output file
+pf = load("my_data") # Open "my_data"
 
 v,c = pf.h.find_max("Density")
 
@@ -16,10 +16,10 @@
 T_max = sphere["Temperature"].max()
 
 
-prof2d = lagos.BinnedProfile2D(sphere,
-                         x_bins, "NumberDensity", n_min, n_max, True,
-                         y_bins, "Temperature", T_min, T_max, True,
-                         lazy_reader=True)
+prof2d = BinnedProfile2D(sphere,
+                   x_bins, "NumberDensity", n_min, n_max, True,
+                   y_bins, "Temperature", T_min, T_max, True,
+                   lazy_reader=True)
 
 prof2d.add_fields("x-velocity")
 prof2d.add_fields("CellMassMsun", weight=None)

Modified: branches/yt-1.5/examples/cookbook_mass_sum.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_mass_sum.py	(original)
+++ branches/yt-1.5/examples/cookbook_mass_sum.py	Tue May 19 21:05:25 2009
@@ -1,13 +1,11 @@
 from yt.mods import *
 
-pf = get_pf() # last argument on the command line gets turned into an EnzoStaticOutput
+pf = load("my_data") # load this data file
 
-sp = pf.h.sphere([0.5,0.5,0.5], 1.0) # Everything, no pre-loading of fields
+sp = pf.h.all_data()
 baryon_mass = sp["CellMassMsun"].sum()
-dm = sphere["creation_time"] < 0
-dm_mass = sphere["ParticleMassMsun"][dm].sum()
-star_mass = sphere["ParticleMassMsun"][~dm].sum()
+particle_mass = sphere["ParticleMassMsun"].sum()
 
-print "Total mass in grids in %s is %0.5e (gas = %0.5e / dm = %0.5e / star = %0.5e)" % \
-            (pf, baryon_mass + dm_mass + star_mass, baryon_mass, dm_mass, star_mass)
+print "Total mass in grids in %s is %0.5e (gas = %0.5e / particles = %0.5e)" % \
+            (pf, baryon_mass + particle_mass, baryon_mass, particle_mass)
 

Modified: branches/yt-1.5/examples/cookbook_multiple_fields_multiple_widths_plot.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_multiple_fields_multiple_widths_plot.py	(original)
+++ branches/yt-1.5/examples/cookbook_multiple_fields_multiple_widths_plot.py	Tue May 19 21:05:25 2009
@@ -1,12 +1,12 @@
 from yt.mods import *
-pf = get_pf()
+pf = load("my_data") # Open "my_data"
 
 fields = ["Density", "Temperature", "x-velocity"]
 widths = [1000.0, 100.0, 10.0, 1.0]
 units = ['mpc','kpc','pc','au']
 my_pairs = [ (w,u) for u in units for w in widths ]
 
-pc = raven.PlotCollection(pf)
+pc = PlotCollection(pf)
 pc.add_slice(fields[0],0)
 pc.add_slice(fields[0],1)
 pc.add_slice(fields[0],2)

Modified: branches/yt-1.5/examples/cookbook_multiple_fields_single_width_plot.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_multiple_fields_single_width_plot.py	(original)
+++ branches/yt-1.5/examples/cookbook_multiple_fields_single_width_plot.py	Tue May 19 21:05:25 2009
@@ -1,8 +1,8 @@
 from yt.mods import *
-pf = get_pf()
+pf = load("my_data") # Open "my_data"
 
 fields = ["Density", "Temperature", "x-velocity"]
-pc = raven.PlotCollection(pf)
+pc = PlotCollection(pf)
 pc.add_slice(fields[0],0)
 pc.add_slice(fields[0],1)
 pc.add_slice(fields[0],2)

Modified: branches/yt-1.5/examples/cookbook_multiple_widths_plot.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_multiple_widths_plot.py	(original)
+++ branches/yt-1.5/examples/cookbook_multiple_widths_plot.py	Tue May 19 21:05:25 2009
@@ -1,11 +1,11 @@
 from yt.mods import *
-pf = get_pf()
+pf = load("my_data") # Open "my_data"
 
 widths = [1000.0, 100.0, 10.0, 1.0]
 units = ['mpc','kpc','pc','au']
 my_pairs = [ (w,u) for u in units for w in widths ]
 
-pc = raven.PlotCollection(pf)
+pc = PlotCollection(pf)
 pc.add_slice("Density",0)
 pc.add_slice("Density",1)
 pc.add_slice("Density",2)

Modified: branches/yt-1.5/examples/cookbook_simple_projection.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_simple_projection.py	(original)
+++ branches/yt-1.5/examples/cookbook_simple_projection.py	Tue May 19 21:05:25 2009
@@ -1,11 +1,10 @@
-
 from yt.mods import *
 
-#Substitute your parameter file location.
-file_name = "/scratch/cbabbage/enzorun/DD0001/data0001"
-pf = lagos.EnzoStaticOutput(file_name)
-pc = raven.PlotCollection(pf)
+pf = load("my_data") # Open "my_data"
+
+pc = PlotCollection(pf)
 pc.add_slice("Density", 0)
 pc.add_slice("Density", 1)
 pc.add_slice("Density", 2)
+
 print pc.save("enzorun")

Modified: branches/yt-1.5/examples/cookbook_single_width_plot.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_single_width_plot.py	(original)
+++ branches/yt-1.5/examples/cookbook_single_width_plot.py	Tue May 19 21:05:25 2009
@@ -1,7 +1,7 @@
 from yt.mods import *
-pf = get_pf()
+pf = load("my_data") # Open "my_data"
 
-pc = raven.PlotCollection(pf)
+pc = PlotCollection(pf)
 pc.add_slice("Density",0)
 pc.add_slice("Density",1)
 pc.add_slice("Density",2)

Modified: branches/yt-1.5/examples/cookbook_timeseries_avg_temp.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_timeseries_avg_temp.py	(original)
+++ branches/yt-1.5/examples/cookbook_timeseries_avg_temp.py	Tue May 19 21:05:25 2009
@@ -3,7 +3,7 @@
 avg_T = []
 times = []
 for i in range(30):
-    pf = lagos.EnzoStaticOutput("my_output%04i" % (i))
+    pf = load("my_output%04i" % (i))
     v, c = pf.h.find_max("Density")
     sp = pf.h.sphere(c, 10.0/pf['kpc'])
     avg_T.append(sp.quantities["WeightedAverageQuantity"]\

Modified: branches/yt-1.5/examples/cookbook_timeseries_max_dens.py
==============================================================================
--- branches/yt-1.5/examples/cookbook_timeseries_max_dens.py	(original)
+++ branches/yt-1.5/examples/cookbook_timeseries_max_dens.py	Tue May 19 21:05:25 2009
@@ -4,7 +4,7 @@
 max_pos = []
 times = []
 for i in range(30):
-    pf = lagos.EnzoStaticOutput("my_output%04i" % (i))
+    pf = load("my_output%04i" % (i))
     v, c = pf.h.find_max("Density")
     max_rho.append(v)
     max_pos.append(c)



More information about the yt-svn mailing list