[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Mon Oct 25 12:31:19 PDT 2010


hg Repository: yt
details:   yt/rev/557f48483cd7
changeset: 3459:557f48483cd7
user:      John Wise <jwise at astro.princeton.edu>
date:
Mon Oct 25 15:27:53 2010 -0400
description:
Adding rho_crit_now import for Overdensity.

hg Repository: yt
details:   yt/rev/14ed6f4a1583
changeset: 3460:14ed6f4a1583
user:      John Wise <jwise at astro.princeton.edu>
date:
Mon Oct 25 15:29:43 2010 -0400
description:
User can define sizes of axis boxes and images now, instead of using
figsize as the size, which is set during instantiation.

diffstat:

 yt/frontends/enzo/fields.py    |   2 +-
 yt/visualization/eps_writer.py |  29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 8 deletions(-)

diffs (105 lines):

diff -r 080643ec3066 -r 14ed6f4a1583 yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py	Thu Oct 21 15:24:29 2010 -0700
+++ b/yt/frontends/enzo/fields.py	Mon Oct 25 15:29:43 2010 -0400
@@ -34,7 +34,7 @@
     ValidateGridType
 import yt.data_objects.universal_fields
 from yt.utilities.physical_constants import \
-    mh
+    mh, rho_crit_now
 import yt.utilities.amr_utils as amr_utils
 
 class EnzoFieldContainer(CodeFieldInfoContainer):
diff -r 080643ec3066 -r 14ed6f4a1583 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py	Thu Oct 21 15:24:29 2010 -0700
+++ b/yt/visualization/eps_writer.py	Mon Oct 25 15:29:43 2010 -0400
@@ -63,7 +63,7 @@
 
     def axis_box(self, xrange=(0,1), yrange=(0,1), xlabel="", ylabel="",
                  xlog=False, ylog=False, tickcolor=None, bare_axes=False,
-                 pos=(0,0), xaxis_side=0, yaxis_side=0):
+                 pos=(0,0), xaxis_side=0, yaxis_side=0, size=None):
         r"""Draws an axis box in the figure.
 
         Parameters
@@ -93,6 +93,8 @@
         yaxis_side : integer
             Set to 0 for the y-axis annotations to be on the bottom.  Set
             to 1 to print them on the top.
+        size : tuple of floats
+            Size of axis box in units of figsize
 
         Examples
         --------
@@ -110,6 +112,11 @@
             c2 = pyx.graph.axis.painter.regular\
                  (tickattrs=[tickcolor], labelattrs=None)
 
+        if size is None:
+            psize = self.figsize
+        else:
+            psize = (size[0]*self.figsize[0], size[1]*self.figsize[1])
+
         xticklabels = True
         yticklabels = True
         if xaxis_side == 0:
@@ -220,16 +227,16 @@
                 xaxis2 = pyx.graph.axis.lin(min=xrange[0], max=xrange[1],
                                             title=xrightlabel, parter=None)
 
-        blank_data = pyx.graph.data.points([(-1,-1),(-0.99,-0.99)], x=1,y=2)
+        blank_data = pyx.graph.data.points([(-10,-10),(-9.99,-9.99)], x=1,y=2)
         if self.canvas is None:
             self.canvas = pyx.graph.graphxy \
-                          (width=self.figsize[0], height=self.figsize[1],
+                          (width=psize[0], height=psize[1],
                            x=xaxis, y=yaxis, x2=xaxis2, y2=yaxis2,
                            xpos=pos[0], ypos=pos[1])
             self.canvas.plot(blank_data)
         else:
             plot = pyx.graph.graphxy \
-                   (width=self.figsize[0], height=self.figsize[1],
+                   (width=psize[0], height=psize[1],
                     x=xaxis, y=yaxis, x2=xaxis2, y2=yaxis2,
                     xpos=pos[0], ypos=pos[1])
             plot.plot(blank_data)
@@ -301,7 +308,7 @@
 
 #=============================================================================
 
-    def insert_image(self, filename, pos=(0,0)):
+    def insert_image(self, filename, pos=(0,0), size=None):
         r"""Inserts a JPEG file in the figure.
 
         Parameters
@@ -310,6 +317,8 @@
             Name of the JPEG file
         pos : tuple of floats
             Position of the origin of the image in centimeters
+        size : tuple of flots
+            Size of image in units of figsize
 
         Examples
         --------
@@ -318,13 +327,19 @@
         >>> d.insert_image("image.jpg")
         >>> d.save_fig()
         """
+        if size != None:
+            width = size[0]*self.figsize[0]
+            height = size[1]*self.figsize[1]
+        else:
+            width = self.figsize[0]
+            height = self.figsize[1]
         image = pyx.bitmap.jpegimage(filename)
         if self.canvas is None:
             self.canvas = pyx.canvas.canvas()
         self.canvas.insert(pyx.bitmap.bitmap(pos[0], pos[1], image,
                                              compressmode=None,
-                                             width=self.figsize[0],
-                                             height=self.figsize[1]))
+                                             width=width,
+                                             height=height))
 
 #=============================================================================
 



More information about the yt-svn mailing list