[Yt-svn] yt: 3 new changesets

hg at spacepope.org hg at spacepope.org
Mon Feb 7 13:17:42 PST 2011


hg Repository: yt
details:   yt/rev/15786bd7102d
changeset: 3721:15786bd7102d
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Feb 07 09:21:00 2011 -0500
description:
Fixing a typo in the docstring

hg Repository: yt
details:   yt/rev/7bb77985de5c
changeset: 3722:7bb77985de5c
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Feb 07 16:17:33 2011 -0500
description:
Adding traceback writer hook, for debugging parallel runs

hg Repository: yt
details:   yt/rev/dcf7c44ef1c3
changeset: 3723:dcf7c44ef1c3
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Feb 07 16:17:38 2011 -0500
description:
Merging

diffstat:

 yt/analysis_modules/halo_mass_function/halo_mass_function.py |   2 +-
 yt/config.py                                                 |   3 ++-
 yt/frontends/enzo/fields.py                                  |  12 ++++++++++++
 yt/funcs.py                                                  |   9 +++++++++
 yt/utilities/parallel_tools/parallel_analysis_interface.py   |   3 +++
 yt/visualization/eps_writer.py                               |   7 +++----
 yt/visualization/volume_rendering/camera.py                  |   2 +-
 7 files changed, 31 insertions(+), 7 deletions(-)

diffs (141 lines):

diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/analysis_modules/halo_mass_function/halo_mass_function.py
--- a/yt/analysis_modules/halo_mass_function/halo_mass_function.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/analysis_modules/halo_mass_function/halo_mass_function.py	Mon Feb 07 16:17:38 2011 -0500
@@ -206,7 +206,7 @@
         bins = na.logspace(self.log_mass_min,
             self.log_mass_max,self.num_sigma_bins)
         avgs = (bins[1:]+bins[:-1])/2.
-        dis, bins = na.histogram(self.haloes,bins,new=True)
+        dis, bins = na.histogram(self.haloes,bins)
         # add right to left
         for i,b in enumerate(dis):
             dis[self.num_sigma_bins-i-3] += dis[self.num_sigma_bins-i-2]
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/config.py
--- a/yt/config.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/config.py	Mon Feb 07 16:17:38 2011 -0500
@@ -43,7 +43,8 @@
     parameterfilestore = 'parameter_files.csv',
     maximumstoredpfs = '500',
     loadfieldplugins = 'True',
-    pluginfilename = 'my_plugins.py'
+    pluginfilename = 'my_plugins.py',
+    parallel_traceback = 'False',
     )
 # Here is the upgrade.  We're actually going to parse the file in its entirety
 # here.  Then, if it has any of the Forbidden Sections, it will be rewritten
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/frontends/enzo/fields.py	Mon Feb 07 16:17:38 2011 -0500
@@ -64,10 +64,15 @@
 def _SpeciesFraction(field, data):
     sp = field.name.split("_")[0] + "_Density"
     return data[sp]/data["Density"]
+def _SpeciesMass(field, data):
+    sp = field.name.split("_")[0] + "_Density"
+    return data[sp] * data["CellVolume"]
 def _SpeciesNumberDensity(field, data):
     species = field.name.split("_")[0]
     sp = field.name.split("_")[0] + "_Density"
     return data[sp]/_speciesMass[species]
+def _convertCellMassMsun(data):
+    return 5.027854e-34 # g^-1
 def _ConvertNumberDensity(data):
     return 1.0/mh
 
@@ -78,6 +83,13 @@
     add_field("Comoving_%s_Density" % species,
              function=_SpeciesComovingDensity,
              validators=ValidateDataField("%s_Density" % species))
+    add_field("%s_Mass" % species, units=r"\rm{g}", 
+              function=_SpeciesMass, 
+              validators=ValidateDataField("%s_Density" % species))
+    add_field("%s_MassMsun" % species, units=r"M_{\odot}", 
+              function=_SpeciesMass, 
+              convert_function=_convertCellMassMsun,
+              validators=ValidateDataField("%s_Density" % species))
     if _speciesMass.has_key(species):
         add_field("%s_NumberDensity" % species,
                   function=_SpeciesNumberDensity,
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/funcs.py
--- a/yt/funcs.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/funcs.py	Mon Feb 07 16:17:38 2011 -0500
@@ -410,6 +410,15 @@
     print "Traceback pasted to http://paste.enzotools.org/show/%s" % (ret)
     print
 
+def traceback_writer_hook(file_suffix = ""):
+    def write_to_file(exc_type, exc, tb):
+        sys.__excepthook__(exc_type, exc, tb)
+        fn = "yt_traceback%s" % file_suffix
+        f = open(fn, "w")
+        traceback.print_exception(exc_type, exc, tb, file=f)
+        print "Wrote traceback to %s" % fn
+    return write_to_file
+
 _ss = "fURbBUUBE0cLXgETJnZgJRMXVhVGUQpQAUBuehQMUhJWRFFRAV1ERAtBXw1dAxMLXT4zXBFfABNN\nC0ZEXw1YUURHCxMXVlFERwxWCQw=\n"
 def _rdbeta(key):
     import itertools, base64
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py	Mon Feb 07 16:17:38 2011 -0500
@@ -68,9 +68,12 @@
         f = logging.Formatter("P%03i %s" % (MPI.COMM_WORLD.rank,
                                             yt.utilities.logger.ufstring))
         yt.utilities.logger.rootLogger.handlers[0].setFormatter(f)
+        if ytcfg.getboolean("yt", "parallel_traceback"):
+            sys.excepthook = traceback_writer_hook("_%03i" % MPI.COMM_WORLD.rank)
     if ytcfg.getint("yt","LogLevel") < 20:
         yt.utilities.logger.ytLogger.warning(
           "Log Level is set low -- this could affect parallel performance!")
+
 else:
     parallel_capable = False
 
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/visualization/eps_writer.py	Mon Feb 07 16:17:38 2011 -0500
@@ -29,6 +29,7 @@
 import pyx
 import numpy as na
 from matplotlib import cm
+from _mpl_imports import FigureCanvasAgg
 
 from yt.utilities.definitions import \
     x_dict, x_names, \
@@ -389,12 +390,12 @@
         _p1.axes[0].set_axis_off()  # remove axes
         _p1.axes[0].set_position([0,0,1,1])  # rescale figure
         _p1.set_facecolor('w')  # set background color
-        figure_canvas = FigureCanvas(_p1)
+        figure_canvas = FigureCanvasAgg(_p1)
         figure_canvas.draw()
         size = _p1.get_size_inches() * _p1.dpi
         image = pyx.bitmap.image(size[0], size[1], "RGB",
                                  figure_canvas.tostring_rgb())
-        figure_canvas.print_png('test.png')
+        #figure_canvas.print_png('test.png')
         self.canvas.insert(pyx.bitmap.bitmap(pos[0], pos[1], image,
                                              width=self.figsize[0],
                                              height=self.figsize[1]))
@@ -547,9 +548,7 @@
             proj = "Proj" in plot._type_name and \
                    plot.data._weight is None
             _zlabel = plot.pf.field_info[plot.axis_names["Z"]].get_label(proj)
-            print _zlabel
             _zlabel = _zlabel.replace("_","\;")
-            print _zlabel
             _zlog = plot.log_field
         else:
             _zlabel = plot._z_label.replace("_","\;")
diff -r a2d94365b2b3 -r dcf7c44ef1c3 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py	Sat Feb 05 17:30:09 2011 -0500
+++ b/yt/visualization/volume_rendering/camera.py	Mon Feb 07 16:17:38 2011 -0500
@@ -267,7 +267,7 @@
         This will recalculate all the necessary vectors and vector planes related
         to a camera with new normal vectors, widths, centers, or north vectors.
 
-        Parameters (All Optional)
+        Parameters
         ----------
         normal_vector: array_like, optional
             The new looking vector.



More information about the yt-svn mailing list