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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jan 5 13:10:10 PST 2015


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/2176cac8117c/
Changeset:   2176cac8117c
Branch:      yt
User:        jzuhone
Date:        2015-01-05 17:40:38+00:00
Summary:     Cleaning up the PPVCube interface so that it's clearer how to set the dimensions of the cube.
Affected #:  1 file

diff -r 714ee06c641e182cd87b7d9118c634fc25577a8c -r 2176cac8117c6db10946d0b60a88ca76eaf68d5d 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
@@ -50,8 +50,8 @@
              "wavelength":("angstrom","WAVELENG","lambda")}
 
 class PPVCube(object):
-    def __init__(self, ds, normal, field, center="c", width=(1.0,"unitary"),
-                 dims=(100,100), velocity_bounds=None, thermal_broad=False,
+    def __init__(self, ds, normal, field, velocity_bounds, center="c", 
+                 width=(1.0,"unitary"), dims=100, thermal_broad=False,
                  atomic_weight=56., method="integrate", no_shifting=False,
                  north_vector=None):
         r""" Initialize a PPVCube object.
@@ -66,6 +66,9 @@
             principal axes of the domain ("x", "y", or "z").
         field : string
             The field to project.
+        velocity_bounds : tuple
+            A 4-tuple of (vmin, vmax, nbins, units) for the velocity bounds to
+            integrate over. 
         center : A sequence of floats, a string, or a tuple.
             The coordinate of the center of the image. If set to 'c', 'center' or
             left blank, the plot is centered on the middle of the domain. If set to
@@ -80,14 +83,10 @@
             The width of the projection. A float will assume the width is in code units.
             A (value, unit) tuple or YTQuantity allows for the units of the width to be
             specified. Implies width = height, e.g. the aspect ratio of the PPVCube's 
-            spatial dimensions is 1. 
-        dims : tuple, optional
-            A 2-tuple of dimensions (nx,nv) for the cube. Implies nx = ny, e.g. the aspect
-            ratio of the PPVCube's spatial dimensions is 1. 
-        velocity_bounds : tuple, optional
-            A 3-tuple of (vmin, vmax, units) for the velocity bounds to
-            integrate over. If None, the largest velocity of the
-            dataset will be used, e.g. velocity_bounds = (-v.max(), v.max())
+            spatial dimensions is 1.
+        dims : integer, optional
+            The spatial resolution of the cube. Implies nx = ny, e.g. the 
+            aspect ratio of the PPVCube's spatial dimensions is 1.
         atomic_weight : float, optional
             Set this value to the atomic weight of the particle that is emitting the line
             if *thermal_broad* is True. Defaults to 56 (Fe).
@@ -107,8 +106,7 @@
         --------
         >>> i = 60*np.pi/180.
         >>> L = [0.0,np.sin(i),np.cos(i)]
-        >>> cube = PPVCube(ds, L, "density", width=(10.,"kpc"),
-        ...                velocity_bounds=(-5.,4.,"km/s"))
+        >>> cube = PPVCube(ds, L, "density", (-5.,4.,100,"km/s"), width=(10.,"kpc"))
         """
 
         self.ds = ds
@@ -123,9 +121,9 @@
 
         self.center = ds.coordinates.sanitize_center(center, normal)[0]
 
-        self.nx = dims[0]
-        self.ny = dims[0]
-        self.nv = dims[1]
+        self.nx = dims
+        self.ny = dims
+        self.nv = velocity_bounds[2]
 
         if method not in ["integrate","sum"]:
             raise RuntimeError("Only the 'integrate' and 'sum' projection +"
@@ -137,14 +135,10 @@
 
         self.field_units = ds._get_field_info(fd).units
 
-        if velocity_bounds is None:
-            vmin, vmax = dd.quantities.extrema("velocity_magnitude")
-            self.v_bnd = -vmax, vmax
-        else:
-            self.v_bnd = (ds.quan(velocity_bounds[0], velocity_bounds[2]),
-                          ds.quan(velocity_bounds[1], velocity_bounds[2]))
+        self.vbins = ds.arr(np.linspace(velocity_bounds[0],
+                                        velocity_bounds[1],
+                                        velocity_bounds[2]+1), velocity_bounds[3])
 
-        self.vbins = np.linspace(self.v_bnd[0], self.v_bnd[1], num=self.nv+1)
         self._vbins = self.vbins.copy()
         self.vmid = 0.5*(self.vbins[1:]+self.vbins[:-1])
         self.vmid_cgs = self.vmid.in_cgs().v


https://bitbucket.org/yt_analysis/yt/commits/2dd18b77fe85/
Changeset:   2dd18b77fe85
Branch:      yt
User:        jzuhone
Date:        2015-01-05 17:51:23+00:00
Summary:     Updating notebook to match new method signature
Affected #:  1 file

diff -r 2176cac8117c6db10946d0b60a88ca76eaf68d5d -r 2dd18b77fe85deb63b8aac853c2a8d6a71137401 doc/source/analyzing/analysis_modules/PPVCube.ipynb
--- a/doc/source/analyzing/analysis_modules/PPVCube.ipynb
+++ b/doc/source/analyzing/analysis_modules/PPVCube.ipynb
@@ -1,7 +1,7 @@
 {
  "metadata": {
   "name": "",
-  "signature": "sha256:794e861818b8a105bc91b537e8359801c8d28d5a13a32787fb386b0578109a66"
+  "signature": "sha256:67e4297cbc32716b2481c71659305687cb5bdadad648a0acf6b48960267bb069"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -189,14 +189,14 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "Next, we need to specify a field that will serve as the \"intensity\" of the emission that we see. For simplicity, we'll simply choose the gas density as this field, though it could be any field (including derived fields) in principle. We also need to specify the dimensions of the data cube, and optionally we may choose the bounds in line-of-sight velocity that the data will be binned into. Otherwise, the bounds will simply be set to the negative and positive of the largest speed in the dataset."
+      "Next, we need to specify a field that will serve as the \"intensity\" of the emission that we see. For simplicity, we'll simply choose the gas density as this field, though it could be any field (including derived fields) in principle. We also need to choose the bounds in line-of-sight velocity that the data will be binned into, which is a 4-tuple in the shape of `(vmin, vmax, nbins, units)`, which specifies a linear range of `nbins` velocity bins from `vmin` to `vmax` in units of `units`. We may also optionally specify the dimensions of the data cube with the `dims` argument."
      ]
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "cube = PPVCube(ds, L, \"density\", dims=(200,50), velocity_bounds=(-150.,150.,\"km/s\"), method=\"sum\")"
+      "cube = PPVCube(ds, L, \"density\", (-150.,150.,50,\"km/s\"), dims=200, method=\"sum\")"
      ],
      "language": "python",
      "metadata": {},
@@ -336,7 +336,7 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "cube2 = PPVCube(ds, L, \"density\", dims=(200,50), velocity_bounds=(-150,150,\"km/s\"), thermal_broad=True, \n",
+      "cube2 = PPVCube(ds, L, \"density\", (-150.,150.,50,\"km/s\"), dims=200, thermal_broad=True, \n",
       "                atomic_weight=12.0, method=\"sum\")\n",
       "cube2.write_fits(\"cube2.fits\", clobber=True, length_unit=\"kpc\")"
      ],


https://bitbucket.org/yt_analysis/yt/commits/0fb4a3521239/
Changeset:   0fb4a3521239
Branch:      yt
User:        jzuhone
Date:        2015-01-05 17:54:42+00:00
Summary:     Updating test to match new signature
Affected #:  1 file

diff -r 2dd18b77fe85deb63b8aac853c2a8d6a71137401 -r 0fb4a3521239a0f0bba010cc34dd1dddf160dd84 yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -38,9 +38,8 @@
 
     ds = load_uniform_grid(data, dims)
 
-    cube = PPVCube(ds, "z", "density", dims=(8,1024),
-                   velocity_bounds=(-300., 300., "km/s"),
-                   thermal_broad=True)
+    cube = PPVCube(ds, "z", "density", (-300., 300., 1024, "km/s"),
+                   dims=8, thermal_broad=True)
 
     dv = cube.dv
     v_th = np.sqrt(2.*kboltz*T_0/(56.*mh) + 2.*sigma_v**2).in_units("km/s")


https://bitbucket.org/yt_analysis/yt/commits/a0ffb93abdd0/
Changeset:   a0ffb93abdd0
Branch:      yt
User:        ngoldbaum
Date:        2015-01-05 21:10:01+00:00
Summary:     Merged in jzuhone/yt-3.x (pull request #1390)

Clearing up an ambiguity in PPVCube's constructor
Affected #:  3 files

diff -r 15f858d36882d76af4fcac124f25e291f316e65a -r a0ffb93abdd0a09b675cfa6a5ce582bd1763c39f doc/source/analyzing/analysis_modules/PPVCube.ipynb
--- a/doc/source/analyzing/analysis_modules/PPVCube.ipynb
+++ b/doc/source/analyzing/analysis_modules/PPVCube.ipynb
@@ -1,7 +1,7 @@
 {
  "metadata": {
   "name": "",
-  "signature": "sha256:794e861818b8a105bc91b537e8359801c8d28d5a13a32787fb386b0578109a66"
+  "signature": "sha256:67e4297cbc32716b2481c71659305687cb5bdadad648a0acf6b48960267bb069"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -189,14 +189,14 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "Next, we need to specify a field that will serve as the \"intensity\" of the emission that we see. For simplicity, we'll simply choose the gas density as this field, though it could be any field (including derived fields) in principle. We also need to specify the dimensions of the data cube, and optionally we may choose the bounds in line-of-sight velocity that the data will be binned into. Otherwise, the bounds will simply be set to the negative and positive of the largest speed in the dataset."
+      "Next, we need to specify a field that will serve as the \"intensity\" of the emission that we see. For simplicity, we'll simply choose the gas density as this field, though it could be any field (including derived fields) in principle. We also need to choose the bounds in line-of-sight velocity that the data will be binned into, which is a 4-tuple in the shape of `(vmin, vmax, nbins, units)`, which specifies a linear range of `nbins` velocity bins from `vmin` to `vmax` in units of `units`. We may also optionally specify the dimensions of the data cube with the `dims` argument."
      ]
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "cube = PPVCube(ds, L, \"density\", dims=(200,50), velocity_bounds=(-150.,150.,\"km/s\"), method=\"sum\")"
+      "cube = PPVCube(ds, L, \"density\", (-150.,150.,50,\"km/s\"), dims=200, method=\"sum\")"
      ],
      "language": "python",
      "metadata": {},
@@ -336,7 +336,7 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "cube2 = PPVCube(ds, L, \"density\", dims=(200,50), velocity_bounds=(-150,150,\"km/s\"), thermal_broad=True, \n",
+      "cube2 = PPVCube(ds, L, \"density\", (-150.,150.,50,\"km/s\"), dims=200, thermal_broad=True, \n",
       "                atomic_weight=12.0, method=\"sum\")\n",
       "cube2.write_fits(\"cube2.fits\", clobber=True, length_unit=\"kpc\")"
      ],

diff -r 15f858d36882d76af4fcac124f25e291f316e65a -r a0ffb93abdd0a09b675cfa6a5ce582bd1763c39f 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
@@ -50,8 +50,8 @@
              "wavelength":("angstrom","WAVELENG","lambda")}
 
 class PPVCube(object):
-    def __init__(self, ds, normal, field, center="c", width=(1.0,"unitary"),
-                 dims=(100,100), velocity_bounds=None, thermal_broad=False,
+    def __init__(self, ds, normal, field, velocity_bounds, center="c", 
+                 width=(1.0,"unitary"), dims=100, thermal_broad=False,
                  atomic_weight=56., method="integrate", no_shifting=False,
                  north_vector=None):
         r""" Initialize a PPVCube object.
@@ -66,6 +66,9 @@
             principal axes of the domain ("x", "y", or "z").
         field : string
             The field to project.
+        velocity_bounds : tuple
+            A 4-tuple of (vmin, vmax, nbins, units) for the velocity bounds to
+            integrate over. 
         center : A sequence of floats, a string, or a tuple.
             The coordinate of the center of the image. If set to 'c', 'center' or
             left blank, the plot is centered on the middle of the domain. If set to
@@ -80,14 +83,10 @@
             The width of the projection. A float will assume the width is in code units.
             A (value, unit) tuple or YTQuantity allows for the units of the width to be
             specified. Implies width = height, e.g. the aspect ratio of the PPVCube's 
-            spatial dimensions is 1. 
-        dims : tuple, optional
-            A 2-tuple of dimensions (nx,nv) for the cube. Implies nx = ny, e.g. the aspect
-            ratio of the PPVCube's spatial dimensions is 1. 
-        velocity_bounds : tuple, optional
-            A 3-tuple of (vmin, vmax, units) for the velocity bounds to
-            integrate over. If None, the largest velocity of the
-            dataset will be used, e.g. velocity_bounds = (-v.max(), v.max())
+            spatial dimensions is 1.
+        dims : integer, optional
+            The spatial resolution of the cube. Implies nx = ny, e.g. the 
+            aspect ratio of the PPVCube's spatial dimensions is 1.
         atomic_weight : float, optional
             Set this value to the atomic weight of the particle that is emitting the line
             if *thermal_broad* is True. Defaults to 56 (Fe).
@@ -107,8 +106,7 @@
         --------
         >>> i = 60*np.pi/180.
         >>> L = [0.0,np.sin(i),np.cos(i)]
-        >>> cube = PPVCube(ds, L, "density", width=(10.,"kpc"),
-        ...                velocity_bounds=(-5.,4.,"km/s"))
+        >>> cube = PPVCube(ds, L, "density", (-5.,4.,100,"km/s"), width=(10.,"kpc"))
         """
 
         self.ds = ds
@@ -123,9 +121,9 @@
 
         self.center = ds.coordinates.sanitize_center(center, normal)[0]
 
-        self.nx = dims[0]
-        self.ny = dims[0]
-        self.nv = dims[1]
+        self.nx = dims
+        self.ny = dims
+        self.nv = velocity_bounds[2]
 
         if method not in ["integrate","sum"]:
             raise RuntimeError("Only the 'integrate' and 'sum' projection +"
@@ -137,14 +135,10 @@
 
         self.field_units = ds._get_field_info(fd).units
 
-        if velocity_bounds is None:
-            vmin, vmax = dd.quantities.extrema("velocity_magnitude")
-            self.v_bnd = -vmax, vmax
-        else:
-            self.v_bnd = (ds.quan(velocity_bounds[0], velocity_bounds[2]),
-                          ds.quan(velocity_bounds[1], velocity_bounds[2]))
+        self.vbins = ds.arr(np.linspace(velocity_bounds[0],
+                                        velocity_bounds[1],
+                                        velocity_bounds[2]+1), velocity_bounds[3])
 
-        self.vbins = np.linspace(self.v_bnd[0], self.v_bnd[1], num=self.nv+1)
         self._vbins = self.vbins.copy()
         self.vmid = 0.5*(self.vbins[1:]+self.vbins[:-1])
         self.vmid_cgs = self.vmid.in_cgs().v

diff -r 15f858d36882d76af4fcac124f25e291f316e65a -r a0ffb93abdd0a09b675cfa6a5ce582bd1763c39f yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -38,9 +38,8 @@
 
     ds = load_uniform_grid(data, dims)
 
-    cube = PPVCube(ds, "z", "density", dims=(8,1024),
-                   velocity_bounds=(-300., 300., "km/s"),
-                   thermal_broad=True)
+    cube = PPVCube(ds, "z", "density", (-300., 300., 1024, "km/s"),
+                   dims=8, thermal_broad=True)
 
     dv = cube.dv
     v_th = np.sqrt(2.*kboltz*T_0/(56.*mh) + 2.*sigma_v**2).in_units("km/s")

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