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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Feb 23 10:20:19 PST 2013


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/86537e9882bd/
changeset:   86537e9882bd
branch:      yt
user:        chummels
date:        2013-02-22 02:19:25
summary:     Fixing a bug with the volume rendering function draw_grids which overlays grids on top of a VR.  Previously it sampled the entire sim volume for the location of the grid boxes, even if you were rendering a subregion of that overall volume.  The outcome was that you got grids plot on your image which weren't in the rendered volume.  This is now fixed and should just sample the specified subregion.
affected #:  2 files

diff -r 6c92cdaa0dbd1975567f771abe405c2b8e9dd7a2 -r 86537e9882bd5adf4892f1a1d041fa9f2784d5be yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -461,6 +461,7 @@
     def __get_grid_levels(self):
         if self.__grid_levels == None:
             self.__grid_levels = np.array([g.Level for g in self._grids])
+            self.__grid_levels.shape = (self.__grid_levels.size, 1)
         return self.__grid_levels
 
     def __del_grid_levels(self):
@@ -474,7 +475,6 @@
     grid_levels = property(__get_grid_levels, __set_grid_levels,
                              __del_grid_levels)
 
-
     def __get_grid_dimensions(self):
         if self.__grid_dimensions == None:
             self.__grid_dimensions = np.array([g.ActiveDimensions for g in self._grids])

diff -r 6c92cdaa0dbd1975567f771abe405c2b8e9dd7a2 -r 86537e9882bd5adf4892f1a1d041fa9f2784d5be yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -232,16 +232,26 @@
         if self.no_ghost:
             mylog.info('Warning: no_ghost is currently True (default). This may lead to artifacts at grid boundaries.')
         self.tree_type = tree_type
+        if le is None:
+            self.le = self.pf.domain_left_edge
+        else:
+            self.le = np.array(le)
+        if re is None:
+            self.re = self.pf.domain_right_edge
+        else:
+            self.re = np.array(re)
         if volume is None:
             if self.use_kd:
                 volume = AMRKDTree(self.pf, l_max=l_max, fields=self.fields, no_ghost=no_ghost,
-                                   log_fields = log_fields, le=le, re=re)
+                                   log_fields = log_fields, le=self.le, re=self.re)
             else:
                 volume = HomogenizedVolume(fields, pf = self.pf,
                                            log_fields = log_fields)
         else:
             self.use_kd = isinstance(volume, AMRKDTree)
         self.volume = volume        
+        self.center = ((self.re - self.le) / 2.) + self.le
+        self.region = self.pf.h.region(self.center, self.le, self.re)
 
     def _setup_box_properties(self, width, center, unit_vectors):
         self.width = width
@@ -300,8 +310,8 @@
         >>> write_bitmap(im, 'render_with_grids.png')
 
         """
-        corners = self.pf.h.grid_corners
-        levels = self.pf.h.grid_levels[:,0]
+        corners = self.region.grid_corners
+        levels = self.region.grid_levels[:,0]
 
         if max_level is not None:
             subset = levels <= max_level


https://bitbucket.org/yt_analysis/yt/commits/11c2ac9ba1d7/
changeset:   11c2ac9ba1d7
branch:      yt
user:        chummels
date:        2013-02-22 02:20:28
summary:     Merging.
affected #:  1 file

diff -r 86537e9882bd5adf4892f1a1d041fa9f2784d5be -r 11c2ac9ba1d7c21674bcedbd16b3d22bd0bdc72b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -248,6 +248,9 @@
     antialias : boolean
         This can be true or false.  It determines whether or not sub-pixel
         rendering is used during data deposition.
+    window_size : float
+        The size of the window on the longest axis (in units of inches),
+        including the margins but not the colorbar.
 
     """
     _plot_valid = False
@@ -256,7 +259,8 @@
     _vector_info = None
     _frb = None
     def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True, 
-                 periodic=True, origin='center-window', oblique=False, fontsize=15):
+                 periodic=True, origin='center-window', oblique=False, fontsize=15,
+                 window_size=10.0):
         if not hasattr(self, "pf"):
             self.pf = data_source.pf
             ts = self._initialize_dataset(self.pf) 
@@ -268,6 +272,7 @@
         self.oblique = oblique
         self.data_source = data_source
         self.buff_size = buff_size
+        self.window_size = window_size
         self.antialias = antialias
         self.set_window(bounds) # this automatically updates the data and plot
         self.origin = origin
@@ -524,6 +529,33 @@
         self._vector_info = (skip, scale)
 
     @invalidate_data
+    def set_buff_size(self, size):
+        """Sets a new buffer size for the fixed resolution buffer
+
+        parameters
+        ----------
+        size : int or two element sequence of ints
+            The number of data elements in the buffer on the x and y axes.
+            If a scalar is provided,  then the buffer is assumed to be square.
+        """
+        if iterable(size):
+            self.buff_size = size
+        else:
+            self.buff_size = (size, size)
+            
+    @invalidate_plot
+    def set_window_size(self, size):
+        """Sets a new window size for the plot
+
+        parameters
+        ----------
+        size : float
+            The size of the window on the longest axis (in units of inches),
+            including the margins but not the colorbar.
+        """
+        self.window_size = float(size)
+
+    @invalidate_data
     def refresh(self):
         # invalidate_data will take care of everything
         pass
@@ -860,12 +892,11 @@
             
             # This sets the size of the figure, and defaults to making one of the dimensions smaller.
             # This should protect against giant images in the case of a very large aspect ratio.
-            norm_size = 10.0
             cbar_frac = 0.0
             if plot_aspect > 1.0:
-                size = (norm_size*(1.+cbar_frac), norm_size/plot_aspect)
+                size = (self.window_size*(1.+cbar_frac), self.window_size/plot_aspect)
             else:
-                size = (plot_aspect*norm_size*(1.+cbar_frac), norm_size)
+                size = (plot_aspect*self.window_size*(1.+cbar_frac), self.window_size)
 
             # Correct the aspect ratio in case unit_x and unit_y are different
             aspect = self.pf[unit_x]/self.pf[unit_y]
@@ -874,7 +905,7 @@
 
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name, 
                                           self._colormaps[f], extent, aspect, 
-                                          zlim, size)
+                                          zlim, size, self.fontsize)
 
             self.plots[f].cb = self.plots[f].figure.colorbar(
                 self.plots[f].image, cax = self.plots[f].cax)
@@ -1135,7 +1166,7 @@
             axes_unit = units
         if field_parameters is None: field_parameters = {}
         slc = pf.h.slice(axis, center[axis], center=center, fields=fields, **field_parameters)
-        PWViewerMPL.__init__(self, slc, bounds, origin=origin)
+        PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class ProjectionPlot(PWViewerMPL):
@@ -1251,7 +1282,7 @@
         if field_parameters is None: field_parameters = {}
         proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,
                          center=center, **field_parameters)
-        PWViewerMPL.__init__(self,proj,bounds,origin=origin)
+        PWViewerMPL.__init__(self,proj,bounds,origin=origin,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class OffAxisSlicePlot(PWViewerMPL):
@@ -1310,7 +1341,8 @@
         cutting = pf.h.cutting(normal, center, fields=fields, north_vector=north_vector, **field_parameters)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
-        PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,oblique=True)
+        PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,
+                             oblique=True,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class OffAxisProjectionDummyDataSource(object):
@@ -1416,7 +1448,8 @@
                                                        le=le, re=re, north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
-        PWViewerMPL.__init__(self,OffAxisProj,bounds,origin='center-window',periodic=False,oblique=True)
+        PWViewerMPL.__init__(self,OffAxisProj,bounds,origin='center-window',periodic=False,
+                             oblique=True,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 _metadata_template = """
@@ -1591,8 +1624,8 @@
             self._field_transform[field] = linear_transform
 
 class WindowPlotMPL(ImagePlotMPL):
-    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size):
-        fsize, axrect, caxrect = self._get_best_layout(size)
+    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size, fontsize):
+        fsize, axrect, caxrect = self._get_best_layout(size, fontsize)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
                           'There is a good chance the plot will not look very good, '
@@ -1604,17 +1637,18 @@
         self._init_image(data, cbname, cmap, extent, aspect)
         self.image.axes.ticklabel_format(scilimits=(-2,3))
 
-    def _get_best_layout(self, size):
+    def _get_best_layout(self, size, fontsize=15):
         aspect = 1.0*size[0]/size[1]
+        fontscale = fontsize / 15.0
 
         # add room for a colorbar
-        cbar_inches = 0.7
+        cbar_inches = fontscale*0.7
         newsize = [size[0] + cbar_inches, size[1]]
         
         # add buffers for text, and a bit of whitespace on top
-        text_buffx = 1.0/(newsize[0])
-        text_bottomy = 0.7/size[1]
-        text_topy = 0.3/size[1]
+        text_buffx = fontscale * 1.0/(newsize[0])
+        text_bottomy = fontscale * 0.7/size[1]
+        text_topy = fontscale * 0.3/size[1]
 
         # calculate how much room the colorbar takes
         cbar_frac = cbar_inches/newsize[0] 


https://bitbucket.org/yt_analysis/yt/commits/2df269e1e77e/
changeset:   2df269e1e77e
branch:      yt
user:        chummels
date:        2013-02-23 02:45:48
summary:     Simplifying a few things as suggested in PR comments.
affected #:  1 file

diff -r 11c2ac9ba1d7c21674bcedbd16b3d22bd0bdc72b -r 2df269e1e77e619073a823e05ed9cb66db5b54a6 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -232,14 +232,10 @@
         if self.no_ghost:
             mylog.info('Warning: no_ghost is currently True (default). This may lead to artifacts at grid boundaries.')
         self.tree_type = tree_type
-        if le is None:
-            self.le = self.pf.domain_left_edge
-        else:
-            self.le = np.array(le)
-        if re is None:
-            self.re = self.pf.domain_right_edge
-        else:
-            self.re = np.array(re)
+        if le is None: le = self.pf.domain_left_edge
+        self.le = np.array(le)
+        if re is None: re = self.pf.domain_right_edge
+        self.re = np.array(re)
         if volume is None:
             if self.use_kd:
                 volume = AMRKDTree(self.pf, l_max=l_max, fields=self.fields, no_ghost=no_ghost,
@@ -250,7 +246,7 @@
         else:
             self.use_kd = isinstance(volume, AMRKDTree)
         self.volume = volume        
-        self.center = ((self.re - self.le) / 2.) + self.le
+        self.center = (self.re + self.le) / 2.0
         self.region = self.pf.h.region(self.center, self.le, self.re)
 
     def _setup_box_properties(self, width, center, unit_vectors):


https://bitbucket.org/yt_analysis/yt/commits/6ab42020e2d5/
changeset:   6ab42020e2d5
branch:      yt
user:        chummels
date:        2013-02-23 02:53:01
summary:     Fixing problem with grid_levels being non-1d.
affected #:  1 file

diff -r 2df269e1e77e619073a823e05ed9cb66db5b54a6 -r 6ab42020e2d50789325abc761102bdba3324409c yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -424,7 +424,7 @@
         return grids
 
     def select_grid_indices(self, level):
-        return np.where(self.grid_levels == level)
+        return np.where(self.grid_levels[:,0] == level)
 
     def __get_grid_left_edge(self):
         if self.__grid_left_edge == None:


https://bitbucket.org/yt_analysis/yt/commits/d1f5dd01531f/
changeset:   d1f5dd01531f
branch:      yt
user:        samskillman
date:        2013-02-23 19:20:11
summary:     Merged in chummels/yt (pull request #443)

Making VR draw_grids only draw grids on rendered subvolume if specified.
affected #:  2 files
Diff not available.

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