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

Bitbucket commits-noreply at bitbucket.org
Thu Feb 7 13:27:58 PST 2013


9 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/a5035492b89a/
changeset:   a5035492b89a
branch:      yt
user:        chummels
date:        2013-02-06 22:47:12
summary:     Modifying write_projection function to take dpi and figsize keywords.  This functionality somehow broke in the switch to the plot_window interface.
affected #:  1 file

diff -r 5a379eb6dc53e51731a82be30308812d8676d68c -r a5035492b89a34e5c5888f6fc61f79bc140abd45 yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -335,8 +335,8 @@
     return im
 
 def write_projection(data, filename, colorbar=True, colorbar_label=None, 
-                     title=None, limits=None, take_log=True, var_fig_size=False,
-                     cmap='algae'):
+                     title=None, limits=None, take_log=True, figsize=(8,6),
+                     dpi=100, cmap='algae'):
     r"""Write a projection or volume rendering to disk with a variety of 
     pretty parameters such as limits, title, colorbar, etc.  write_projection
     uses the standard matplotlib interface to create the figure.  N.B. This code
@@ -344,7 +344,8 @@
     framework (i.e. the Camera interface or off_axis_projection).
 
     Accepts an NxM sized array representing the projection itself as well
-    as the filename to which you will save this figure.  
+    as the filename to which you will save this figure.  Note that the final
+    resolution of your image will be a product of dpi/100 * figsize.
 
     Parameters
     ----------
@@ -363,9 +364,10 @@
         of the data array
     take_log : boolean
         plot the log of the data array (and take the log of the limits if set)?
-    var_fig_size : boolean
-        If we want the resolution (and size) of the output image to scale 
-        with the resolution of the image array.  
+    figsize : array_like
+        width, height in inches of final image
+    dpi : int
+        final image resolution in pixels / inch
     cmap : string
         The name of the colormap.
 
@@ -375,7 +377,7 @@
     >>> image = off_axis_projection(pf, c, L, W, N, "Density", no_ghost=False)
     >>> write_projection(image, 'test.png', 
                          colorbar_label="Column Density (cm$^{-2}$)", 
-                         title="Offaxis Projection", limits=(1e-3,1e-5), 
+                         title="Offaxis Projection", limits=(1e-5,1e-3), 
                          take_log=True)
     """
     import matplotlib
@@ -391,7 +393,7 @@
         limits = [None, None]
 
     # Create the figure and paint the data on
-    fig = matplotlib.figure.Figure()
+    fig = matplotlib.figure.Figure(figsize=figsize)
     ax = fig.add_subplot(111)
     fig.tight_layout()
 
@@ -410,16 +412,6 @@
         if colorbar_label:
             cbar.ax.set_ylabel(colorbar_label)
 
-    # If we want the resolution of the image to scale with the resolution
-    # of the image array. we increase the dpi value accordingly
-    
-    if var_fig_size:
-        N = data.shape[0]
-        mag_factor = N/480.
-        dpi = 100*mag_factor
-    else:
-        dpi = None
-
     suffix = get_image_suffix(filename)
 
     if suffix == '':
@@ -436,7 +428,7 @@
         mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
         canvas = FigureCanvasAgg(fig)
 
-    canvas.print_figure(filename)
+    canvas.print_figure(filename, dpi=dpi)
     return filename
 
 


https://bitbucket.org/yt_analysis/yt/commits/cf5fd9d85e25/
changeset:   cf5fd9d85e25
branch:      yt
user:        chummels
date:        2013-02-07 07:06:06
summary:     Making kw convention of write_projection match others in file for cmaps.
affected #:  1 file

diff -r a5035492b89a34e5c5888f6fc61f79bc140abd45 -r cf5fd9d85e25fe645fc66a1a5a793a41b88a15db yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -336,7 +336,7 @@
 
 def write_projection(data, filename, colorbar=True, colorbar_label=None, 
                      title=None, limits=None, take_log=True, figsize=(8,6),
-                     dpi=100, cmap='algae'):
+                     dpi=100, cmap_name='algae'):
     r"""Write a projection or volume rendering to disk with a variety of 
     pretty parameters such as limits, title, colorbar, etc.  write_projection
     uses the standard matplotlib interface to create the figure.  N.B. This code
@@ -368,7 +368,7 @@
         width, height in inches of final image
     dpi : int
         final image resolution in pixels / inch
-    cmap : string
+    cmap_name : string
         The name of the colormap.
 
     Examples
@@ -397,7 +397,7 @@
     ax = fig.add_subplot(111)
     fig.tight_layout()
 
-    cax = ax.imshow(data, vmin=limits[0], vmax=limits[1], norm=norm, cmap=cmap)
+    cax = ax.imshow(data, vmin=limits[0], vmax=limits[1], norm=norm, cmap=cmap_name)
     
     if title:
         ax.set_title(title)


https://bitbucket.org/yt_analysis/yt/commits/c216e386ad4b/
changeset:   c216e386ad4b
branch:      yt
user:        chummels
date:        2013-02-07 09:16:27
summary:     Adding expand_keyword_dictionary function, which is helpful for testing many different keyword combinations in nosetests.
affected #:  1 file

diff -r cf5fd9d85e25fe645fc66a1a5a793a41b88a15db -r c216e386ad4be92bbf84009cac783fe1997a383c yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -163,3 +163,74 @@
                  for field,offset in zip(fields,offsets))
     ug = load_uniform_grid(data, ndims, 1.0, nprocs = nprocs)
     return ug
+
+def expand_keyword_dictionary(keywords):
+    """
+    expand_keyword_dictionary is a means for testing all possible keyword
+    arguments in the nosetests.  Simply pass it a dictionary of all the
+    keyword arguments and all of the values for these arguments that you
+    want to test.
+
+    It will return a list of **kwargs dicts containing combinations of
+    the various kwarg values you passed it.  Note, this does not return
+    every unique combination of keywords, but it does return lists
+    which probe each value of each keyword.  These can then be passed
+    to the appropriate function in nosetests. 
+
+    keywords : dict
+        a dictionary where the keys are the keywords for the function,
+        and the values of each key are the possible values that this key
+        can take in the function
+
+    Returns
+    -------
+    array of dicts
+        An array of **kwargs dictionaries to be individually passed to
+        the appropriate function matching these kwargs.
+
+    Examples
+    --------
+    >>> keywords = {}
+    >>> keywords['dpi'] = (50, 100, 200)
+    >>> keywords['cmap'] = ('algae', 'jet')
+    >>> list_of_kwargs = expand_keyword_dictionary(keywords)
+    >>> print list_of_kwargs
+
+    array([{'cmap': 'algae', 'dpi': 50}, {'cmap': 'jet', 'dpi': 100},
+           {'cmap': 'algae', 'dpi': 200}], dtype=object)
+
+    >>> for kwargs in list_of_kwargs:
+    ...     write_projection(*args, **kwargs)
+    """
+
+    # Determine the maximum number of values any of the keywords has
+    max_num_values = 0
+    import pdb; pdb.set_trace()
+    for val in keywords.values():
+        if isinstance(val, str):
+            max_num_values = max(1.0, max_num_values)
+        else:
+            max_num_values = max(len(val), max_num_values)
+
+    # Construct array of kwargs dicts, each element of the list is a different
+    # **kwargs dict.  each kwargs dict gives a different combination of
+    # the possible values of the kwargs
+
+    # initialize array
+    list_of_kwarg_dicts = np.array([dict() for x in range(max_num_values)])
+
+    # fill in array
+    for i in np.arange(max_num_values):
+        list_of_kwarg_dicts[i] = {}
+        for key in keywords.keys():
+            # if it's a string, use it (there's only one)
+            if isinstance(keywords[key], str):
+                list_of_kwarg_dicts[i][key] = keywords[key]
+            # if there are more options, use the i'th val
+            elif i < len(keywords[key]):
+                list_of_kwarg_dicts[i][key] = keywords[key][i]
+            # if there are not more options, use the 0'th val
+            else:
+                list_of_kwarg_dicts[i][key] = keywords[key][0]
+
+    return list_of_kwarg_dicts


https://bitbucket.org/yt_analysis/yt/commits/d2cf51a0dadb/
changeset:   d2cf51a0dadb
branch:      yt
user:        chummels
date:        2013-02-07 09:18:52
summary:     Renaming function to not be too verbose.
affected #:  1 file

diff -r c216e386ad4be92bbf84009cac783fe1997a383c -r d2cf51a0dadbf8e57df02525d218060e87f6be1a yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -164,9 +164,9 @@
     ug = load_uniform_grid(data, ndims, 1.0, nprocs = nprocs)
     return ug
 
-def expand_keyword_dictionary(keywords):
+def expand_keywords(keywords):
     """
-    expand_keyword_dictionary is a means for testing all possible keyword
+    expand_keywords is a means for testing all possible keyword
     arguments in the nosetests.  Simply pass it a dictionary of all the
     keyword arguments and all of the values for these arguments that you
     want to test.
@@ -193,7 +193,7 @@
     >>> keywords = {}
     >>> keywords['dpi'] = (50, 100, 200)
     >>> keywords['cmap'] = ('algae', 'jet')
-    >>> list_of_kwargs = expand_keyword_dictionary(keywords)
+    >>> list_of_kwargs = expand_keywords(keywords)
     >>> print list_of_kwargs
 
     array([{'cmap': 'algae', 'dpi': 50}, {'cmap': 'jet', 'dpi': 100},


https://bitbucket.org/yt_analysis/yt/commits/77845626cc08/
changeset:   77845626cc08
branch:      yt
user:        chummels
date:        2013-02-07 10:14:42
summary:     Removing a pdb call.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/4c01520f3f22/
changeset:   4c01520f3f22
branch:      yt
user:        chummels
date:        2013-02-07 10:18:23
summary:     Adding nose test for off_axis_projection and write_projection
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/063a28de6a3e/
changeset:   063a28de6a3e
branch:      yt
user:        chummels
date:        2013-02-07 18:26:01
summary:     Fixing some bugs with the off_axis_projection test.  Works now.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/654b2e1847f5/
changeset:   654b2e1847f5
branch:      yt
user:        chummels
date:        2013-02-07 21:02:49
summary:     Adding full keyword to expand_keywords, which allows for testing EVERY combination of keywords available.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/2f54217d37d8/
changeset:   2f54217d37d8
branch:      yt
user:        MatthewTurk
date:        2013-02-07 22:27:52
summary:     Merged in chummels/yt (pull request #417)

Fixes write_projection, adds helper function for unit testing, closes issue #434
affected #:  3 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