[yt-svn] commit/yt: MatthewTurk: Merged in chummels/yt (pull request #1224)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Sep 29 11:19:48 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/90dad9d0c93b/
Changeset: 90dad9d0c93b
Branch: yt
User: MatthewTurk
Date: 2014-09-29 18:19:34+00:00
Summary: Merged in chummels/yt (pull request #1224)
[APICHANGE] [BUGFIX] Changing ProjectionPlot's "proj_style" attribute to be "style" attribute
Affected #: 9 files
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 doc/source/analyzing/analysis_modules/PPVCube.ipynb
--- a/doc/source/analyzing/analysis_modules/PPVCube.ipynb
+++ b/doc/source/analyzing/analysis_modules/PPVCube.ipynb
@@ -291,7 +291,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "prj = yt.ProjectionPlot(ds, \"z\", [\"density\"], proj_style=\"sum\")\n",
+ "prj = yt.ProjectionPlot(ds, \"z\", [\"density\"], method=\"sum\")\n",
"prj.set_log(\"density\", True)\n",
"prj.set_zlim(\"density\", 1.0e-3, 0.2)\n",
"prj.show()"
@@ -304,4 +304,4 @@
"metadata": {}
}
]
-}
\ No newline at end of file
+}
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 doc/source/analyzing/objects.rst
--- a/doc/source/analyzing/objects.rst
+++ b/doc/source/analyzing/objects.rst
@@ -225,12 +225,12 @@
**Projection**
| Class :class:`~yt.data_objects.construction_data_containers.YTQuadTreeProjBase`
- | Usage: ``proj(field, axis, weight_field=None, center=None, ds=None, data_source=None, style="integrate", field_parameters=None)``
+ | Usage: ``proj(field, axis, weight_field=None, center=None, ds=None, data_source=None, method="integrate", field_parameters=None)``
| A 2D projection of a 3D volume along one of the axis directions.
By default, this is a line integral through the entire simulation volume
(although it can be a subset of that volume specified by a data object
with the ``data_source`` keyword). Alternatively, one can specify
- a weight_field and different ``style`` values to change the nature
+ a weight_field and different ``method`` values to change the nature
of the projection outcome. See :ref:`projection-types` for more information.
**Streamline**
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 doc/source/cookbook/fits_radio_cubes.ipynb
--- a/doc/source/cookbook/fits_radio_cubes.ipynb
+++ b/doc/source/cookbook/fits_radio_cubes.ipynb
@@ -183,14 +183,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "We can also make a projection of all the emission along the line of sight. Since we're not doing an integration along a path length, we needed to specify `proj_style = \"sum\"`:"
+ "We can also make a projection of all the emission along the line of sight. Since we're not doing an integration along a path length, we needed to specify `method = \"sum\"`:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
- "prj = yt.ProjectionPlot(ds, \"z\", [\"intensity\"], proj_style=\"sum\", origin=\"native\")\n",
+ "prj = yt.ProjectionPlot(ds, \"z\", [\"intensity\"], method=\"sum\", origin=\"native\")\n",
"prj.show()"
],
"language": "python",
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 doc/source/cookbook/fits_xray_images.ipynb
--- a/doc/source/cookbook/fits_xray_images.ipynb
+++ b/doc/source/cookbook/fits_xray_images.ipynb
@@ -264,7 +264,7 @@
" [\"flux\",\"projected_temperature\",\"pseudo_pressure\",\"pseudo_entropy\"], \n",
" origin=\"native\", field_parameters={\"exposure_time\":exposure_time},\n",
" data_source=circle_reg,\n",
- " proj_style=\"sum\")\n",
+ " method=\"sum\")\n",
"prj.set_log(\"flux\",True)\n",
"prj.set_log(\"pseudo_pressure\",False)\n",
"prj.set_log(\"pseudo_entropy\",False)\n",
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -239,13 +239,13 @@
Types of Projections
""""""""""""""""""""
-There are several different styles of projections that can be made either
+There are several different methods of projections that can be made either
when creating a projection with ds.proj() or when making a ProjectionPlot.
-In either construction method, set the ``style`` keyword to be one of the
+In either construction method, set the ``method`` keyword to be one of the
following:
``integrate`` (unweighted)
- This is the default projection style. It simply integrates the
+ This is the default projection method. It simply integrates the
requested field :math:`f(x)` along a line of sight :math:`\hat{n}` ,
given by the axis parameter (e.g. :math:`\hat{i},\hat{j},` or
:math:`\hat{k}`). The units of the projected field
@@ -258,7 +258,7 @@
g(X) = {\int\ {f(x)\hat{n}\cdot{dx}}}
``integrate`` (weighted)
- When using the ``integrate`` style, a ``weight_field`` argument may also
+ When using the ``integrate`` method, a ``weight_field`` argument may also
be specified, which will produce a weighted projection. :math:`w(x)`
is the field used as a weight. One common example would
be to weight the "temperature" field by the "density" field. In this case,
@@ -269,15 +269,15 @@
g(X) = \frac{\int\ {f(x)w(x)\hat{n}\cdot{dx}}}{\int\ {w(x)\hat{n}\cdot{dx}}}
``mip``
- This style picks out the maximum value of a field along the line of
+ This method picks out the maximum value of a field along the line of
sight given by the axis parameter.
``sum``
- This style is the same as ``integrate``, except that it does not
+ This method is the same as ``integrate``, except that it does not
multiply by a path length when performing the integration, and is just a
straight summation of the field along the given axis. The units of the
projected field will be the same as those of the unprojected field. This
- style is typically only useful for datasets such as 3D FITS cubes where
+ method is typically only useful for datasets such as 3D FITS cubes where
the third axis of the dataset is something like velocity or frequency.
.. _off-axis-projections:
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -186,11 +186,14 @@
data_source : `yt.data_objects.api.AMRData`, optional
If specified, this will be the data source used for selecting
regions to project.
- style : string, optional
- The style of projection to be performed.
+ method : string, optional
+ The method of projection to be performed.
"integrate" : integration along the axis
"mip" : maximum intensity projection
"sum" : same as "integrate", except that we don't multiply by the path length
+ style : string, optional
+ The same as the method keyword. Deprecated as of version 3.0.2.
+ Please use method keyword instead.
field_parameters : dict of items
Values to be passed as field parameters that can be
accessed by generated fields.
@@ -208,20 +211,26 @@
_container_fields = ('px', 'py', 'pdx', 'pdy', 'weight_field')
def __init__(self, field, axis, weight_field = None,
center = None, ds = None, data_source = None,
- style = "integrate", field_parameters = None):
+ style = None, method = "integrate",
+ field_parameters = None):
YTSelectionContainer2D.__init__(self, axis, ds, field_parameters)
- if style == "sum":
- self.proj_style = "integrate"
+ # Style is deprecated, but if it is set, then it trumps method
+ # keyword. TODO: Remove this keyword and this check at some point in
+ # the future.
+ if style is not None:
+ method = style
+ if method == "sum":
+ self.method = "integrate"
self._sum_only = True
else:
- self.proj_style = style
+ self.method = method
self._sum_only = False
- if style == "mip":
+ if self.method == "mip":
self.func = np.max
- elif style == "integrate" or style == "sum":
+ elif self.method == "integrate":
self.func = np.sum # for the future
else:
- raise NotImplementedError(style)
+ raise NotImplementedError(self.method)
self._set_center(center)
if data_source is None: data_source = self.ds.all_data()
for k, v in data_source.field_parameters.items():
@@ -260,7 +269,7 @@
self.ds.domain_left_edge[xax],
self.ds.domain_right_edge[yax])
return QuadTree(np.array([xd,yd], dtype='int64'), nvals,
- bounds, style = self.proj_style)
+ bounds, method = self.method)
def get_data(self, fields = None):
fields = fields or []
@@ -282,10 +291,10 @@
get_memory_usage()/1024.)
self._handle_chunk(chunk, fields, tree)
# Note that this will briefly double RAM usage
- if self.proj_style == "mip":
+ if self.method == "mip":
merge_style = -1
op = "max"
- elif self.proj_style == "integrate":
+ elif self.method == "integrate":
merge_style = 1
op = "sum"
else:
@@ -324,7 +333,10 @@
finfo = self.ds._get_field_info(*field)
mylog.debug("Setting field %s", field)
units = finfo.units
- if self.weight_field is None and not self._sum_only:
+ # add length units to "projected units" if non-weighted
+ # integral projection
+ if self.weight_field is None and not self._sum_only and \
+ self.method == 'integrate':
# See _handle_chunk where we mandate cm
if units == '':
input_units = "cm"
@@ -336,7 +348,9 @@
self[field] = YTArray(field_data[fi].ravel(),
input_units=input_units,
registry=self.ds.unit_registry)
- if self.weight_field is None and not self._sum_only:
+ # convert units if non-weighted integral projection
+ if self.weight_field is None and not self._sum_only and \
+ self.method == 'integrate':
u_obj = Unit(units, registry=self.ds.unit_registry)
if ((u_obj.is_code_unit or self.ds.no_cgs_equiv_length) and
not u_obj.is_dimensionless) and input_units != units:
@@ -355,7 +369,7 @@
tree.initialize_chunk(i1, i2, ilevel)
def _handle_chunk(self, chunk, fields, tree):
- if self.proj_style == "mip" or self._sum_only:
+ if self.method == "mip" or self._sum_only:
dl = 1.0
else:
# This gets explicitly converted to cm
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 yt/utilities/lib/QuadTree.pyx
--- a/yt/utilities/lib/QuadTree.pyx
+++ b/yt/utilities/lib/QuadTree.pyx
@@ -113,10 +113,10 @@
cdef np.int64_t last_dims[2]
def __cinit__(self, np.ndarray[np.int64_t, ndim=1] top_grid_dims,
- int nvals, bounds, style = "integrate"):
- if style == "integrate":
+ int nvals, bounds, method = "integrate"):
+ if method == "integrate":
self.combine = QTN_add_value
- elif style == "mip":
+ elif method == "mip":
self.combine = QTN_max_value
else:
raise NotImplementedError
@@ -212,10 +212,10 @@
def frombuffer(self, np.ndarray[np.int32_t, ndim=1] refined,
np.ndarray[np.float64_t, ndim=2] values,
np.ndarray[np.float64_t, ndim=1] wval,
- style):
- if style == "mip" or style == -1:
+ method):
+ if method == "mip" or method == -1:
self.merged = -1
- elif style == "integrate" or style == 1:
+ elif method == "integrate" or method == 1:
self.merged = 1
cdef int curpos = 0
cdef QuadTreeNode *root
@@ -348,11 +348,11 @@
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
- def get_all(self, int count_only = 0, int style = 1):
+ def get_all(self, int count_only = 0, int method = 1):
cdef int i, j, vi
cdef int total = 0
vals = []
- self.merged = style
+ self.merged = method
for i in range(self.top_grid_dims[0]):
for j in range(self.top_grid_dims[1]):
total += self.count(self.root_nodes[i][j])
@@ -540,14 +540,14 @@
else:
raise RuntimeError
-def merge_quadtrees(QuadTree qt1, QuadTree qt2, style = 1):
+def merge_quadtrees(QuadTree qt1, QuadTree qt2, method = 1):
cdef int i, j
qt1.num_cells = 0
cdef QTN_combine *func
- if style == 1:
+ if method == 1:
qt1.merged = 1
func = QTN_add_value
- elif style == -1:
+ elif method == -1:
qt1.merged = -1
func = QTN_max_value
else:
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1109,6 +1109,27 @@
The maximum level to project to.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
+ method : string
+ The method of projection. Valid methods are:
+
+ "integrate" with no weight_field specified : integrate the requested
+ field along the line of sight.
+
+ "integrate" with a weight_field specified : weight the requested
+ field by the weighting field and integrate along the line of sight.
+
+ "mip" : pick out the maximum value of the field in the line of sight.
+
+ "sum" : This method is the same as integrate, except that it does not
+ multiply by a path length when performing the integration, and is
+ just a straight summation of the field along the given axis.
+ proj_style : string
+ The method of projection--same as method keyword. Deprecated as of
+ version 3.0.2. Please use method instead.
+ window_size : float
+ The size of the window in inches. Set to 8 by default.
+ aspect : float
+ The aspect ratio of the plot. Set to None for 1.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived
fields.
@@ -1130,20 +1151,25 @@
def __init__(self, ds, axis, fields, center='c', width=None, axes_unit=None,
weight_field=None, max_level=None, origin='center-window',
fontsize=18, field_parameters=None, data_source=None,
- proj_style = "integrate", window_size=8.0, aspect=None):
+ method = "integrate", proj_style = None, window_size=8.0,
+ aspect=None):
ts = self._initialize_dataset(ds)
self.ts = ts
ds = self.ds = ts[0]
axis = fix_axis(axis, ds)
+ # proj_style is deprecated, but if someone specifies then it trumps
+ # method.
+ if proj_style is not None:
+ method = proj_style
# If a non-weighted integral projection, assure field-label reflects that
- if weight_field is None and proj_style == "integrate":
+ if weight_field is None and method == "integrate":
self.projected = True
(bounds, center, display_center) = \
get_window_parameters(axis, center, width, ds)
if field_parameters is None: field_parameters = {}
proj = ds.proj(fields, axis, weight_field=weight_field,
center=center, data_source=data_source,
- field_parameters = field_parameters, style = proj_style)
+ field_parameters = field_parameters, method = method)
PWViewerMPL.__init__(self, proj, bounds, fields=fields, origin=origin,
fontsize=fontsize, window_size=window_size,
aspect=aspect)
@@ -1236,7 +1262,7 @@
class OffAxisProjectionDummyDataSource(object):
_type_name = 'proj'
- proj_style = 'integrate'
+ method = 'integrate'
_key_fields = []
def __init__(self, center, ds, normal_vector, width, fields,
interpolated, resolution = (800,800), weight=None,
@@ -1348,7 +1374,7 @@
weight=weight_field, volume=volume, no_ghost=no_ghost,
le=le, re=re, north_vector=north_vector)
# If a non-weighted, integral projection, assure field-label reflects that
- if weight_field is None and OffAxisProj.proj_style == "integrate":
+ if weight_field is None and OffAxisProj.method == "integrate":
self.projected = True
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
@@ -1542,7 +1568,7 @@
if source._type_name in ("slice", "cutting"):
units = finfo.get_units()
elif source._type_name == "proj":
- if source.weight_field is not None or source.proj_style in ("mip", "sum"):
+ if source.weight_field is not None or source.method in ("mip", "sum"):
units = finfo.get_units()
else:
units = finfo.get_projected_units()
diff -r 64c466c241dccbffa835bfe3c8ee042996a03273 -r 90dad9d0c93ba29a7ce3ed072c09a391d758fdf1 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -146,6 +146,12 @@
('gas', 'density'),
)
+PROJECTION_METHODS = (
+ 'integrate',
+ 'sum',
+ 'mip'
+)
+
@requires_ds(M7)
def test_attributes():
"""Test plot member functions that aren't callbacks"""
@@ -240,6 +246,7 @@
projections_c = []
projections_wf = []
projections_w = {}
+ projections_m = []
for dim in range(3):
projections.append(ProjectionPlot(test_ds, dim, "density"))
projections_ds.append(ProjectionPlot(test_ds, dim, "density",
@@ -253,6 +260,9 @@
for wf in WEIGHT_FIELDS:
projections_wf.append(ProjectionPlot(test_ds, dim, "density",
weight_field=wf))
+ for m in PROJECTION_METHODS:
+ projections_m.append(ProjectionPlot(test_ds, dim, "density",
+ method=m))
cls.slices = [SlicePlot(test_ds, dim, "density") for dim in range(3)]
cls.projections = projections
@@ -260,6 +270,7 @@
cls.projections_c = projections_c
cls.projections_wf = projections_wf
cls.projections_w = projections_w
+ cls.projections_m = projections_m
cls.offaxis_slice = OffAxisSlicePlot(test_ds, normal, "density")
cls.offaxis_proj = OffAxisProjectionPlot(test_ds, normal, "density")
@@ -296,6 +307,10 @@
def test_projection_plot_wf(self, dim):
self.projections_wf[dim].save()
+ @parameterized.expand([(i, ) for i in range(len(PROJECTION_METHODS))])
+ def test_projection_plot_m(self, dim):
+ self.projections_m[dim].save()
+
@parameterized.expand(
param.explicit((fname, ))
for fname in TEST_FLNMS)
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