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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Dec 8 19:09:35 PST 2014


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/6b474b188088/
Changeset:   6b474b188088
Branch:      yt
User:        jzuhone
Date:        2014-12-06 18:02:58+00:00
Summary:     Catch code_length before it gets used as a fits unit
Affected #:  1 file

diff -r 134ea7c1c9e8cba1d8845449a000a282ce201a99 -r 6b474b1880885da02e50b16266ca27e38a9d8aa0 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -183,7 +183,7 @@
         same *key*, *value* pair.
         """
         for img in self: img.header[key] = value
-            
+
     def keys(self):
         return [f.name.lower() for f in self]
 
@@ -251,7 +251,7 @@
         self[field].data = new_data.v
         self[field].header["bunit"] = units
         self.field_units[field] = units
-        
+
 axis_wcs = [[1,2],[0,2],[0,1]]
 
 def create_sky_wcs(old_wcs, sky_center, sky_scale,
@@ -341,10 +341,12 @@
         crval = ds.wcs.wcs_pix2world(ctr_pix.reshape(1,self.dimensionality))[0]
         crval = [crval[idx] for idx in axis_wcs[axis]]
     else:
-        # This is some other kind of dataset                                                                                    
+        # This is some other kind of dataset                                                                      
         unit = str(width[0].units)
         if unit == "unitary":
             unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
+        elif unit == "code_length":
+            unit = ds.get_smallest_appropriate_unit(ds.quan(1.0,"code_length"))
         unit = sanitize_fits_unit(unit)
         cunit = [unit]*2
         ctype = ["LINEAR"]*2


https://bitbucket.org/yt_analysis/yt/commits/e27d7550f3ac/
Changeset:   e27d7550f3ac
Branch:      yt
User:        jzuhone
Date:        2014-12-06 18:03:45+00:00
Summary:     Shouldn't need to do this twice
Affected #:  1 file

diff -r 6b474b1880885da02e50b16266ca27e38a9d8aa0 -r e27d7550f3acab88ced7e72c69e1298f2995e3bd yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -157,7 +157,6 @@
         elif method == "sum":
             self.proj_units = self.field_units
 
-        self.data = ds.arr(np.zeros((self.nx,self.ny,self.nv)), self.proj_units)
         storage = {}
         pbar = get_pbar("Generating cube.", self.nv)
         for sto, i in parallel_objects(xrange(self.nv), storage=storage):


https://bitbucket.org/yt_analysis/yt/commits/5d185f3c5b3a/
Changeset:   5d185f3c5b3a
Branch:      yt
User:        jzuhone
Date:        2014-12-08 08:11:45+00:00
Summary:     Rule in favor of the version of get_smallest_appropriate_unit from plot_modifications
Affected #:  4 files

diff -r e27d7550f3acab88ced7e72c69e1298f2995e3bd -r 5d185f3c5b3a1eec2a205437c78bfcb1f2538f59 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -252,13 +252,12 @@
       for i in self.parameters: yield i
 
     def get_smallest_appropriate_unit(self, v):
-        max_nu = 1e30
         good_u = None
         for unit in ['Mpc', 'kpc', 'pc', 'au', 'rsun', 'km', 'cm']:
-            vv = v * self.length_unit.in_units(unit)
-            if vv < max_nu and vv > 1.0:
+            uq = YTQuantity(1.0, unit)
+            if uq < v:
                 good_u = unit
-                max_nu = v * self.length_unit.in_units(unit)
+                break
         if good_u is None : good_u = 'cm'
         return good_u
 

diff -r e27d7550f3acab88ced7e72c69e1298f2995e3bd -r 5d185f3c5b3a1eec2a205437c78bfcb1f2538f59 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -21,8 +21,6 @@
 from yt.utilities.logger import ytLogger as mylog
 from .plot_window import PlotWindow
 from .profile_plotter import PhasePlot
-from .plot_modifications import get_smallest_appropriate_unit
-
 
 class DualEPS(object):
     def __init__(self, figsize=(12,12)):
@@ -286,7 +284,7 @@
             data = plot._frb
             width = plot.width[0]
             if units == None:
-                units = get_smallest_appropriate_unit(width, plot.ds)
+                units = plot.ds.get_smallest_appropriate_unit(width)
             _xrange = (0, width * plot.ds[units])
             _yrange = (0, width * plot.ds[units])
             _xlog = False

diff -r e27d7550f3acab88ced7e72c69e1298f2995e3bd -r 5d185f3c5b3a1eec2a205437c78bfcb1f2538f59 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -557,16 +557,6 @@
         plot._axes.set_xlabel(self.label)
         plot._axes.set_ylabel(self.label)
 
-def get_smallest_appropriate_unit(v, ds):
-    good_u = None
-    for unit in ['Mpc', 'kpc', 'pc', 'au', 'rsun', 'km', 'cm']:
-        uq = YTQuantity(1.0, unit)
-        if uq < v:
-            good_u = unit
-            break
-    if good_u is None : good_u = 'cm'
-    return good_u
-
 class LinePlotCallback(PlotCallback):
     """
     annotate_line(x, y, plot_args = None)

diff -r e27d7550f3acab88ced7e72c69e1298f2995e3bd -r 5d185f3c5b3a1eec2a205437c78bfcb1f2538f59 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -30,8 +30,7 @@
     FixedResolutionBuffer, \
     ObliqueFixedResolutionBuffer, \
     OffAxisProjectionFixedResolutionBuffer
-from .plot_modifications import get_smallest_appropriate_unit, \
-    callback_registry
+from .plot_modifications import callback_registry
 from .plot_container import \
     ImagePlotContainer, \
     log_transform, linear_transform, symlog_transform, \
@@ -691,8 +690,8 @@
             xc, yc = self._setup_origin()
 
             if self._axes_unit_names is None:
-                unit = get_smallest_appropriate_unit(
-                    self.xlim[1] - self.xlim[0], self.ds)
+                unit = self.ds.get_smallest_appropriate_unit(
+                    self.xlim[1] - self.xlim[0])
                 (unit_x, unit_y) = (unit, unit)
             else:
                 (unit_x, unit_y) = self._axes_unit_names
@@ -1647,7 +1646,7 @@
         x_width = self.xlim[1] - self.xlim[0]
         y_width = self.ylim[1] - self.ylim[0]
         if self._axes_unit_names is None:
-            unit = get_smallest_appropriate_unit(x_width, self.ds)
+            unit = self.ds.get_smallest_appropriate_unit(x_width)
             unit = (unit, unit)
         else:
             unit = self._axes_unit_names


https://bitbucket.org/yt_analysis/yt/commits/84059b0061a6/
Changeset:   84059b0061a6
Branch:      yt
User:        jzuhone
Date:        2014-12-08 13:48:55+00:00
Summary:     Make sure we use the unit registry
Affected #:  1 file

diff -r 5d185f3c5b3a1eec2a205437c78bfcb1f2538f59 -r 84059b0061a6371200e94f480ca1f6cfa6dff7b0 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -254,7 +254,7 @@
     def get_smallest_appropriate_unit(self, v):
         good_u = None
         for unit in ['Mpc', 'kpc', 'pc', 'au', 'rsun', 'km', 'cm']:
-            uq = YTQuantity(1.0, unit)
+            uq = self.quan(1.0, unit)
             if uq < v:
                 good_u = unit
                 break


https://bitbucket.org/yt_analysis/yt/commits/c49dbb18e2f0/
Changeset:   c49dbb18e2f0
Branch:      yt
User:        xarthisius
Date:        2014-12-09 03:09:27+00:00
Summary:     Merged in jzuhone/yt-3.x (pull request #1347)

[bugfix] Don't set "code_length" as the length unit in FITSImageBuffer, resolving duplicate get_smallest_appropriate_unit
Affected #:  6 files

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -157,7 +157,6 @@
         elif method == "sum":
             self.proj_units = self.field_units
 
-        self.data = ds.arr(np.zeros((self.nx,self.ny,self.nv)), self.proj_units)
         storage = {}
         pbar = get_pbar("Generating cube.", self.nv)
         for sto, i in parallel_objects(xrange(self.nv), storage=storage):

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -252,13 +252,12 @@
       for i in self.parameters: yield i
 
     def get_smallest_appropriate_unit(self, v):
-        max_nu = 1e30
         good_u = None
         for unit in ['Mpc', 'kpc', 'pc', 'au', 'rsun', 'km', 'cm']:
-            vv = v * self.length_unit.in_units(unit)
-            if vv < max_nu and vv > 1.0:
+            uq = self.quan(1.0, unit)
+            if uq < v:
                 good_u = unit
-                max_nu = v * self.length_unit.in_units(unit)
+                break
         if good_u is None : good_u = 'cm'
         return good_u
 

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -183,7 +183,7 @@
         same *key*, *value* pair.
         """
         for img in self: img.header[key] = value
-            
+
     def keys(self):
         return [f.name.lower() for f in self]
 
@@ -251,7 +251,7 @@
         self[field].data = new_data.v
         self[field].header["bunit"] = units
         self.field_units[field] = units
-        
+
 axis_wcs = [[1,2],[0,2],[0,1]]
 
 def create_sky_wcs(old_wcs, sky_center, sky_scale,
@@ -341,10 +341,12 @@
         crval = ds.wcs.wcs_pix2world(ctr_pix.reshape(1,self.dimensionality))[0]
         crval = [crval[idx] for idx in axis_wcs[axis]]
     else:
-        # This is some other kind of dataset                                                                                    
+        # This is some other kind of dataset                                                                      
         unit = str(width[0].units)
         if unit == "unitary":
             unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
+        elif unit == "code_length":
+            unit = ds.get_smallest_appropriate_unit(ds.quan(1.0,"code_length"))
         unit = sanitize_fits_unit(unit)
         cunit = [unit]*2
         ctype = ["LINEAR"]*2

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -21,8 +21,6 @@
 from yt.utilities.logger import ytLogger as mylog
 from .plot_window import PlotWindow
 from .profile_plotter import PhasePlot
-from .plot_modifications import get_smallest_appropriate_unit
-
 
 class DualEPS(object):
     def __init__(self, figsize=(12,12)):
@@ -286,7 +284,7 @@
             data = plot._frb
             width = plot.width[0]
             if units == None:
-                units = get_smallest_appropriate_unit(width, plot.ds)
+                units = plot.ds.get_smallest_appropriate_unit(width)
             _xrange = (0, width * plot.ds[units])
             _yrange = (0, width * plot.ds[units])
             _xlog = False

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -557,16 +557,6 @@
         plot._axes.set_xlabel(self.label)
         plot._axes.set_ylabel(self.label)
 
-def get_smallest_appropriate_unit(v, ds):
-    good_u = None
-    for unit in ['Mpc', 'kpc', 'pc', 'au', 'rsun', 'km', 'cm']:
-        uq = YTQuantity(1.0, unit)
-        if uq < v:
-            good_u = unit
-            break
-    if good_u is None : good_u = 'cm'
-    return good_u
-
 class LinePlotCallback(PlotCallback):
     """
     annotate_line(x, y, plot_args = None)

diff -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 -r c49dbb18e2f0cbc1357be61e77a1757bf4aa47d2 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -30,8 +30,7 @@
     FixedResolutionBuffer, \
     ObliqueFixedResolutionBuffer, \
     OffAxisProjectionFixedResolutionBuffer
-from .plot_modifications import get_smallest_appropriate_unit, \
-    callback_registry
+from .plot_modifications import callback_registry
 from .plot_container import \
     ImagePlotContainer, \
     log_transform, linear_transform, symlog_transform, \
@@ -691,8 +690,8 @@
             xc, yc = self._setup_origin()
 
             if self._axes_unit_names is None:
-                unit = get_smallest_appropriate_unit(
-                    self.xlim[1] - self.xlim[0], self.ds)
+                unit = self.ds.get_smallest_appropriate_unit(
+                    self.xlim[1] - self.xlim[0])
                 (unit_x, unit_y) = (unit, unit)
             else:
                 (unit_x, unit_y) = self._axes_unit_names
@@ -1647,7 +1646,7 @@
         x_width = self.xlim[1] - self.xlim[0]
         y_width = self.ylim[1] - self.ylim[0]
         if self._axes_unit_names is None:
-            unit = get_smallest_appropriate_unit(x_width, self.ds)
+            unit = self.ds.get_smallest_appropriate_unit(x_width)
             unit = (unit, unit)
         else:
             unit = self._axes_unit_names

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