[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Aug 26 07:50:30 PDT 2014


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/91feae9d7a79/
Changeset:   91feae9d7a79
Branch:      yt
User:        mzingale
Date:        2014-08-26 16:14:38
Summary:     add some caveats to the BoxLib frontend docs
Affected #:  1 file

diff -r 2401a32b4fbf9e1ab76d3f3327832e056dcce71f -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -178,6 +178,14 @@
 For Maestro and Castro, you would not need the ``inputs`` file, and you 
 would have a ``job_info`` file in the plotfile directory.
 
+.. rubric:: Caveats
+
+* yt does not read the Maestro base state (although you can have Maestro
+  map it to a full Cartesian state variable before writing the plotfile
+  to get around this).
+* yt does not know about particles in Maestro.
+
+
 .. _loading-enzo-data:
 
 Enzo Data


https://bitbucket.org/yt_analysis/yt/commits/ba24b263607d/
Changeset:   ba24b263607d
Branch:      yt
User:        mzingale
Date:        2014-08-26 16:15:16
Summary:     merge
Affected #:  5 files

diff -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 -r ba24b263607d3dcf750cdc974f99151480325bfa yt/fields/cosmology_fields.py
--- a/yt/fields/cosmology_fields.py
+++ b/yt/fields/cosmology_fields.py
@@ -82,9 +82,9 @@
             raise NeedsParameter("omega_baryon")
         co = data.ds.cosmology
         # critical_density(z) ~ omega_lambda + omega_matter * (1 + z)^3
-        # mean density(z) ~ omega_matter * (1 + z)^3
+        # mean matter density(z) ~ omega_matter * (1 + z)^3
         return data[ftype, "density"] / omega_baryon / co.critical_density(0.0) / \
-          (1.0 + data.ds.hubble_constant)**3
+          (1.0 + data.ds.current_redshift)**3
 
     registry.add_field((ftype, "baryon_overdensity"),
                        function=_baryon_overdensity,
@@ -99,9 +99,9 @@
         co = data.ds.cosmology
         # critical_density(z) ~ omega_lambda + omega_matter * (1 + z)^3
         # mean density(z) ~ omega_matter * (1 + z)^3
-        return data[ftype, "density"] / data.ds.omega_matter / \
+        return data[ftype, "matter_density"] / data.ds.omega_matter / \
           co.critical_density(0.0) / \
-          (1.0 + data.ds.hubble_constant)**3
+          (1.0 + data.ds.current_redshift)**3
 
     registry.add_field((ftype, "matter_overdensity"),
                        function=_matter_overdensity,

diff -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 -r ba24b263607d3dcf750cdc974f99151480325bfa yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py
+++ b/yt/frontends/enzo/fields.py
@@ -219,6 +219,7 @@
             self.add_output_field(
                 ("enzo", te_name),
                 units = "code_velocity**2")
+            self.alias(("gas", "total_energy"), ("enzo", te_name))
             def _tot_minus_kin(field, data):
                 return data[te_name] - 0.5*(
                     data["x-velocity"]**2.0
@@ -226,6 +227,7 @@
                     + data["z-velocity"]**2.0 )
             self.add_field(
                 ("gas", "thermal_energy"),
+                function = _tot_minus_kin,
                 units = "erg/g")
 
     def setup_particle_fields(self, ptype):

diff -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 -r ba24b263607d3dcf750cdc974f99151480325bfa yt/frontends/enzo/io.py
--- a/yt/frontends/enzo/io.py
+++ b/yt/frontends/enzo/io.py
@@ -44,7 +44,10 @@
             if not hasattr(v, "shape") or v.dtype == "O":
                 continue
             elif len(v.dims) == 1:
-                if add_io: fields.append( ("io", str(name)) )
+                if grid.ds.dimensionality == 1:
+                    fields.append( ("enzo", str(name)) )
+                elif add_io:
+                    fields.append( ("io", str(name)) )
             else:
                 fields.append( ("enzo", str(name)) )
         f.close()
@@ -238,12 +241,14 @@
         fields = []
         add_io = "io" in grid.ds.particle_types
         for name, v in self.grids_in_memory[grid.id].items():
-
             # NOTE: This won't work with 1D datasets or references.
             if not hasattr(v, "shape") or v.dtype == "O":
                 continue
             elif v.ndim == 1:
-                if add_io: fields.append( ("io", str(name)) )
+                if grid.ds.dimensionality == 1:
+                    fields.append( ("enzo", str(name)) )
+                elif add_io:
+                    fields.append( ("io", str(name)) )
             else:
                 fields.append( ("enzo", str(name)) )
         return fields

diff -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 -r ba24b263607d3dcf750cdc974f99151480325bfa yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -442,7 +442,7 @@
                         if child_mask[i, j, k] == 1 or this_level == 1:
                             mask[i, j, k] = self.select_cell(pos, dds)
                             total += mask[i, j, k]
-                        pos[2] += dds[1]
+                        pos[2] += dds[2]
                     pos[1] += dds[1]
                 pos[0] += dds[0]
         if total == 0: return None

diff -r 91feae9d7a79cb056c96c8500cc3a933e3a779a5 -r ba24b263607d3dcf750cdc974f99151480325bfa yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -369,32 +369,34 @@
 
 class GridBoundaryCallback(PlotCallback):
     """
-    annotate_grids(alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, 
-                 min_level=None, max_level=None, cmap='B-W LINEAR_r', edgecolors=None,
-                 linewidth=1.0):
+    annotate_grids(alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False,
+                   periodic=True, min_level=None, max_level=None,
+                   cmap='B-W LINEAR_r', edgecolors=None, linewidth=1.0):
 
-    Draws grids on an existing PlotWindow object.
-    Adds grid boundaries to a plot, optionally with alpha-blending. By default, 
-    colors different levels of grids with different colors going from white to
-    black, but you can change to any arbitrary colormap with cmap keyword, to all black
-    grid edges for all levels with cmap=None and edgecolors=None, or to an arbitrary single
-    color for grid edges with edgecolors='YourChosenColor' defined in any of the standard ways
-    (e.g., edgecolors='white', edgecolors='r', edgecolors='#00FFFF', or edgecolor='0.3', where
-    the last is a float in 0-1 scale indicating gray).
-    Note that setting edgecolors overrides cmap if you have both set to non-None values.
-    Cutoff for display is at min_pix wide. draw_ids puts the grid id in the corner of the grid.
-    (Not so great in projections...).  One can set min and maximum level of
-    grids to display, and can change the linewidth of the displayed grids.
+    Draws grids on an existing PlotWindow object.  Adds grid boundaries to a
+    plot, optionally with alpha-blending. By default, colors different levels of
+    grids with different colors going from white to black, but you can change to
+    any arbitrary colormap with cmap keyword, to all black grid edges for all
+    levels with cmap=None and edgecolors=None, or to an arbitrary single color
+    for grid edges with edgecolors='YourChosenColor' defined in any of the
+    standard ways (e.g., edgecolors='white', edgecolors='r',
+    edgecolors='#00FFFF', or edgecolor='0.3', where the last is a float in 0-1
+    scale indicating gray).  Note that setting edgecolors overrides cmap if you
+    have both set to non-None values.  Cutoff for display is at min_pix
+    wide. draw_ids puts the grid id in the corner of the grid.  (Not so great in
+    projections...).  One can set min and maximum level of grids to display, and
+    can change the linewidth of the displayed grids.
     """
     _type_name = "grids"
-    def __init__(self, alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, 
-                 min_level=None, max_level=None, cmap='B-W LINEAR_r', edgecolors=None,
-                 linewidth=1.0):
+
+    def __init__(self, alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False,
+                 periodic=True, min_level=None, max_level=None,
+                 cmap='B-W LINEAR_r', edgecolors=None, linewidth=1.0):
         PlotCallback.__init__(self)
         self.alpha = alpha
         self.min_pix = min_pix
         self.min_pix_ids = min_pix_ids
-        self.draw_ids = draw_ids # put grid numbers in the corner.
+        self.draw_ids = draw_ids  # put grid numbers in the corner.
         self.periodic = periodic
         self.min_level = min_level
         self.max_level = max_level
@@ -437,20 +439,22 @@
             left_edge_y = np.array((GLE[:,py_index]+pyo-y0)*dy) + yy0
             right_edge_x = np.array((GRE[:,px_index]+pxo-x0)*dx) + xx0
             right_edge_y = np.array((GRE[:,py_index]+pyo-y0)*dy) + yy0
-            visible =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
-                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix ) & \
-                       ( levels >= min_level) & \
-                       ( levels <= max_level)
+            xwidth = xpix * (right_edge_x - left_edge_x) / (xx1 - xx0)
+            ywidth = ypix * (right_edge_y - left_edge_y) / (yy1 - yy0)
+            visible = np.logical_and(
+                np.logical_and(xwidth > self.min_pix, ywidth > self.min_pix),
+                np.logical_and(levels >= min_level, levels <= max_level))
 
             # Grids can either be set by edgecolors OR a colormap.
             if self.edgecolors is not None:
-                edgecolors = colorConverter.to_rgba(self.edgecolors, alpha=self.alpha)
+                edgecolors = colorConverter.to_rgba(
+                    self.edgecolors, alpha=self.alpha)
             else:  # use colormap if not explicity overridden by edgecolors
                 if self.cmap is not None:
-                    sample_levels = levels[(levels <= max_level) & (levels >= min_level)]
-                    color_bounds = [0,plot.data.pf.h.max_level]
-                    edgecolors = apply_colormap(sample_levels*1.0, color_bounds=color_bounds,
-                                                cmap_name=self.cmap)[0,:,:]*1.0/255.
+                    color_bounds = [0,plot.data.ds.index.max_level]
+                    edgecolors = apply_colormap(
+                        levels[visible]*1.0, color_bounds=color_bounds,
+                        cmap_name=self.cmap)[0,:,:]*1.0/255.
                     edgecolors[:,3] = self.alpha
                 else:
                     edgecolors = (0.0,0.0,0.0,self.alpha)
@@ -461,13 +465,16 @@
                  (left_edge_y, right_edge_y, right_edge_y, left_edge_y)])
             verts=verts.transpose()[visible,:,:]
             grid_collection = matplotlib.collections.PolyCollection(
-                verts, facecolors="none", edgecolors=edgecolors, linewidth=self.linewidth)
+                verts, facecolors="none", edgecolors=edgecolors,
+                linewidth=self.linewidth)
             plot._axes.hold(True)
             plot._axes.add_collection(grid_collection)
 
             if self.draw_ids:
-                visible_ids =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix_ids ) & \
-                               ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix_ids )
+                visible_ids = np.logical_and(
+                    np.logical_and(xwidth > self.min_pix_ids,
+                                   ywidth > self.min_pix_ids),
+                    np.logical_and(levels >= min_level, levels <= max_level))
                 active_ids = np.unique(plot.data['grid_indices'])
                 for i in np.where(visible_ids)[0]:
                     plot._axes.text(

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list