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

Bitbucket commits-noreply at bitbucket.org
Wed May 18 06:37:56 PDT 2011


2 new changesets in yt:

http://bitbucket.org/yt_analysis/yt/changeset/13ca62800e20/
changeset:   r4264:13ca62800e20
branch:      yt
user:        MatthewTurk
date:        2011-05-18 15:29:01
summary:     Better color bounds for the mapper and adding a new misc_utilities.pyx file.
affected #:  4 files (2.5 KB)

--- a/yt/gui/reason/pannable_map.py	Wed May 18 01:41:01 2011 -0400
+++ b/yt/gui/reason/pannable_map.py	Wed May 18 09:29:01 2011 -0400
@@ -27,39 +27,58 @@
 
 from yt.visualization.image_writer import apply_colormap
 from yt.visualization.fixed_resolution import FixedResolutionBuffer
-from yt.utilities.amr_utils import write_png_to_string
+from yt.utilities.amr_utils import write_png_to_string, get_color_bounds
 
 import yt.utilities.bottle as bottle
 
 from yt.funcs import *
 local_dir = os.path.dirname(__file__)
 
-def get_realistic_bounds(field, pdx, width):
-    # We don't want to scale to anything that's as big or bigger than the
-    # possible viewing area.  This should be unique across tiles on this level.
-    min_dx = width / 256
-    ff = na.log10(field[(pdx > min_dx / 64.0) & (pdx < width * 2.0)])
-    return ff.min(), ff.max()
+def exc_writeout(f):
+    import traceback
+    @wraps(f)
+    def func(*args, **kwargs):
+        try:
+            rv = f(*args, **kwargs)
+            return rv
+        except Exception as e:
+            traceback.print_exc(None, open("temp.exc", "w"))
+            raise
+    return func
 
 class PannableMapServer(object):
-    def __init__(self, data):
+    def __init__(self, data, field):
         self.data = data
         self.pf = data.pf
+        self.field = field
         bottle.route("/map/:L/:x/:y.png")(self.map)
         bottle.route("/")(self.index)
         bottle.route("/index.html")(self.index)
         bottle.route("/static/:filename#.+#")(self.static)
+        # This is a double-check, since we do not always mandate this for
+        # slices:
+        self.data[self.field] = self.data[self.field].astype("float64")
 
+    #@exc_writeout
     def map(self, L, x, y):
         dd = 1.0 / (2.0**(int(L)-1))
         relx = int(x) * dd
         rely = int(y) * dd
         DW = (self.pf.domain_left_edge + self.pf.domain_right_edge)/2.0
-        xp = self.pf.domain_left_edge[0] + relx * DW[0]
-        yp = self.pf.domain_left_edge[1] + rely * DW[1]
-        frb = FixedResolutionBuffer(self.data, (xp, xp+dd*DW[0], yp, yp+dd*DW[1]), (256, 256))
-        cmi, cma = get_realistic_bounds(self.data["Density"], self.data["pdx"], dd*DW[0])
-        to_plot = apply_colormap(na.log10(frb["Density"]), color_bounds = (cmi, cma))
+        xl = self.pf.domain_left_edge[0] + relx * DW[0]
+        yl = self.pf.domain_left_edge[1] + rely * DW[1]
+        xr = xl + dd*DW[0]
+        yr = yl + dd*DW[1]
+        frb = FixedResolutionBuffer(self.data, (xl, xr, yl, yr), (256, 256))
+        cmi, cma = get_color_bounds(self.data['px'], self.data['py'],
+                                    self.data['pdx'], self.data['pdy'],
+                                    self.data[self.field],
+                                    xl - dd*DW[0], xr + dd*DW[0], 
+                                    yl - dd*DW[0], yr + dd*DW[0], 
+                                    dd*DW[0] / (64*256))
+        cmi = na.log10(cmi)
+        cma = na.log10(cma)
+        to_plot = apply_colormap(na.log10(frb[self.field]), color_bounds = (cmi, cma))
         rv = write_png_to_string(to_plot)
         return rv
 


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/utilities/_amr_utils/misc_utilities.pyx	Wed May 18 09:29:01 2011 -0400
@@ -0,0 +1,51 @@
+"""
+Simple utilities that don't fit anywhere else
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt.enzotools.org/
+License:
+  Copyright (C) 2011 Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import numpy as np
+cimport numpy as np
+cimport cython
+
+def get_color_bounds(np.ndarray[np.float64_t, ndim=1] px,
+                     np.ndarray[np.float64_t, ndim=1] py,
+                     np.ndarray[np.float64_t, ndim=1] pdx,
+                     np.ndarray[np.float64_t, ndim=1] pdy,
+                     np.ndarray[np.float64_t, ndim=1] value,
+                     np.float64_t leftx, np.float64_t rightx,
+                     np.float64_t lefty, np.float64_t righty,
+                     np.float64_t mindx = -1):
+    cdef int i
+    cdef np.float64_t mi = 1e100, ma = -1e100, v
+    cdef int np = px.shape[0]
+    for i in range(np):
+        v = value[i]
+        if v < mi or v > ma:
+            if px[i] + pdx[i] < leftx: continue
+            if px[i] - pdx[i] > rightx: continue
+            if py[i] + pdy[i] < lefty: continue
+            if py[i] - pdy[i] > righty: continue
+            if pdx[i] < mindx or pdy[i] < mindx: continue
+            if v < mi: mi = v
+            if v > ma: ma = v
+    return (mi, ma)


--- a/yt/utilities/amr_utils.pyx	Wed May 18 01:41:01 2011 -0400
+++ b/yt/utilities/amr_utils.pyx	Wed May 18 09:29:01 2011 -0400
@@ -47,3 +47,4 @@
 include "_amr_utils/QuadTree.pyx"
 include "_amr_utils/Octree.pyx"
 include "_amr_utils/freetype_writer.pyx"
+include "_amr_utils/misc_utilities.pyx"


--- a/yt/utilities/command_line.py	Wed May 18 01:41:01 2011 -0400
+++ b/yt/utilities/command_line.py	Wed May 18 09:29:01 2011 -0400
@@ -497,7 +497,7 @@
         else:
             p = pc.add_slice(opts.field, opts.axis)
         from yt.gui.reason.pannable_map import PannableMapServer
-        mapper = PannableMapServer(p.data)
+        mapper = PannableMapServer(p.data, opts.field)
         import yt.utilities.bottle as bottle
         bottle.debug(True)
         bottle.run(server='rocket')


http://bitbucket.org/yt_analysis/yt/changeset/a5c2741ec080/
changeset:   r4265:a5c2741ec080
branch:      yt
user:        MatthewTurk
date:        2011-05-18 15:37:36
summary:     To use this, we need to figure out a way to get an upper bound that is
universal, based only on the Level.  I'm not sure the right way to do this, but
I have disabled the old way of looking at left/right edges, since they vary
from tile to tile slightly.  Now it just looks at the max_dx, but this doesn't
(in my sims) give a good colorscaling.
affected #:  2 files (273 bytes)

--- a/yt/gui/reason/pannable_map.py	Wed May 18 09:29:01 2011 -0400
+++ b/yt/gui/reason/pannable_map.py	Wed May 18 09:37:36 2011 -0400
@@ -73,9 +73,12 @@
         cmi, cma = get_color_bounds(self.data['px'], self.data['py'],
                                     self.data['pdx'], self.data['pdy'],
                                     self.data[self.field],
-                                    xl - dd*DW[0], xr + dd*DW[0], 
-                                    yl - dd*DW[0], yr + dd*DW[0], 
-                                    dd*DW[0] / (64*256))
+                                    self.pf.domain_left_edge[0],
+                                    self.pf.domain_right_edge[0],
+                                    self.pf.domain_left_edge[1],
+                                    self.pf.domain_right_edge[1],
+                                    dd*DW[0] / (64*256),
+                                    dd*DW[0])
         cmi = na.log10(cmi)
         cma = na.log10(cma)
         to_plot = apply_colormap(na.log10(frb[self.field]), color_bounds = (cmi, cma))


--- a/yt/utilities/_amr_utils/misc_utilities.pyx	Wed May 18 09:29:01 2011 -0400
+++ b/yt/utilities/_amr_utils/misc_utilities.pyx	Wed May 18 09:37:36 2011 -0400
@@ -34,7 +34,7 @@
                      np.ndarray[np.float64_t, ndim=1] value,
                      np.float64_t leftx, np.float64_t rightx,
                      np.float64_t lefty, np.float64_t righty,
-                     np.float64_t mindx = -1):
+                     np.float64_t mindx = -1, np.float64_t maxdx = -1):
     cdef int i
     cdef np.float64_t mi = 1e100, ma = -1e100, v
     cdef int np = px.shape[0]
@@ -46,6 +46,7 @@
             if py[i] + pdy[i] < lefty: continue
             if py[i] - pdy[i] > righty: continue
             if pdx[i] < mindx or pdy[i] < mindx: continue
+            if maxdx > 0 and (pdx[i] > maxdx or pdy[i] > maxdx): continue
             if v < mi: mi = v
             if v > ma: ma = v
     return (mi, ma)

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