[yt-svn] commit/yt: 8 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Apr 27 11:20:53 PDT 2014
8 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/0036acf481a0/
Changeset: 0036acf481a0
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:04:21
Summary: First pass at removing x_dict and y_dict everywhere.
Affected #: 19 files
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -41,7 +41,6 @@
march_cubes_grid, march_cubes_grid_flux
from yt.utilities.data_point_utilities import CombineGrids,\
DataCubeRefine, DataCubeReplace, FillRegion, FillBuffer
-from yt.utilities.definitions import axis_names, x_dict, y_dict
from yt.utilities.minimal_representation import \
MinimalProjectionData
from yt.utilities.parallel_tools.parallel_analysis_interface import \
@@ -252,8 +251,8 @@
self._mrep.upload()
def _get_tree(self, nvals):
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
xd = self.pf.domain_dimensions[xax]
yd = self.pf.domain_dimensions[yax]
bounds = (self.pf.domain_left_edge[xax],
@@ -292,18 +291,20 @@
else:
raise NotImplementedError
# TODO: Add the combine operation
- ox = self.pf.domain_left_edge[x_dict[self.axis]]
- oy = self.pf.domain_left_edge[y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ ox = self.pf.domain_left_edge[xax]
+ oy = self.pf.domain_left_edge[yax]
px, py, pdx, pdy, nvals, nwvals = tree.get_all(False, merge_style)
nvals = self.comm.mpi_allreduce(nvals, op=op)
nwvals = self.comm.mpi_allreduce(nwvals, op=op)
- np.multiply(px, self.pf.domain_width[x_dict[self.axis]], px)
+ np.multiply(px, self.pf.domain_width[xax], px)
np.add(px, ox, px)
- np.multiply(pdx, self.pf.domain_width[x_dict[self.axis]], pdx)
+ np.multiply(pdx, self.pf.domain_width[xax], pdx)
- np.multiply(py, self.pf.domain_width[y_dict[self.axis]], py)
+ np.multiply(py, self.pf.domain_width[yax], py)
np.add(py, oy, py)
- np.multiply(pdy, self.pf.domain_width[y_dict[self.axis]], pdy)
+ np.multiply(pdy, self.pf.domain_width[yax], pdy)
if self.weight_field is not None:
np.divide(nvals, nwvals[:,None], nvals)
# We now convert to half-widths and center-points
@@ -348,8 +349,10 @@
def _initialize_chunk(self, chunk, tree):
icoords = chunk.icoords
- i1 = icoords[:,x_dict[self.axis]]
- i2 = icoords[:,y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ i1 = icoords[:,xax]
+ i2 = icoords[:,yax]
ilevel = chunk.ires * self.pf.ires_factor
tree.initialize_chunk(i1, i2, ilevel)
@@ -370,8 +373,10 @@
else:
w = np.ones(chunk.ires.size, dtype="float64")
icoords = chunk.icoords
- i1 = icoords[:,x_dict[self.axis]]
- i2 = icoords[:,y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ i1 = icoords[:,xax]
+ i2 = icoords[:,yax]
ilevel = chunk.ires * self.pf.ires_factor
tree.add_chunk_to_tree(i1, i2, ilevel, v, w)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -28,7 +28,6 @@
from yt.data_objects.particle_io import particle_handler_registry
from yt.utilities.lib.marching_cubes import \
march_cubes_grid, march_cubes_grid_flux
-from yt.utilities.definitions import x_dict, y_dict
from yt.utilities.parallel_tools.parallel_analysis_interface import \
ParallelAnalysisInterface
from yt.utilities.parameter_file_storage import \
@@ -821,8 +820,8 @@
if not iterable(resolution):
resolution = (resolution, resolution)
from yt.visualization.fixed_resolution import FixedResolutionBuffer
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
bounds = (center[xax] - width*0.5, center[xax] + width*0.5,
center[yax] - height*0.5, center[yax] + height*0.5)
frb = FixedResolutionBuffer(self, bounds, resolution,
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -20,13 +20,11 @@
import numpy as np
from yt.funcs import *
-from yt.utilities.definitions import x_dict, y_dict
from yt.data_objects.data_containers import \
YTFieldData, \
YTDataContainer, \
YTSelectionContainer
-from yt.utilities.definitions import x_dict, y_dict
from yt.fields.field_exceptions import \
NeedsGridType, \
NeedsOriginalGrid, \
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -25,8 +25,6 @@
YTSelectionContainer1D, YTSelectionContainer2D, YTSelectionContainer3D
from yt.data_objects.derived_quantities import \
DerivedQuantityCollection
-from yt.utilities.definitions import \
- x_dict, y_dict, axis_names
from yt.utilities.exceptions import YTSphereTooSmall
from yt.utilities.linear_interpolators import TrilinearFieldInterpolator
from yt.utilities.minimal_representation import \
@@ -73,12 +71,15 @@
def __init__(self, axis, coords, pf=None, field_parameters=None):
super(YTOrthoRayBase, self).__init__(pf, field_parameters)
self.axis = axis
- self.px_ax = x_dict[self.axis]
- self.py_ax = y_dict[self.axis]
- self.px_dx = 'd%s'%(axis_names[self.px_ax])
- self.py_dx = 'd%s'%(axis_names[self.py_ax])
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ self.px_ax = xax
+ self.py_ax = yax
+ # Even though we may not be using x,y,z we use them here.
+ self.px_dx = 'd%s'%('xyz'[self.px_ax])
+ self.py_dx = 'd%s'%('xyz'[self.py_ax])
self.px, self.py = coords
- self.sort_by = axis_names[self.axis]
+ self.sort_by = 'xyz'[self.axis]
@property
def coords(self):
@@ -191,16 +192,18 @@
self.coord = coord
def _generate_container_field(self, field):
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
if self._current_chunk is None:
self.index._identify_base_chunk(self)
if field == "px":
- return self._current_chunk.fcoords[:,x_dict[self.axis]]
+ return self._current_chunk.fcoords[:,xax]
elif field == "py":
- return self._current_chunk.fcoords[:,y_dict[self.axis]]
+ return self._current_chunk.fcoords[:,yax]
elif field == "pdx":
- return self._current_chunk.fwidth[:,x_dict[self.axis]] * 0.5
+ return self._current_chunk.fwidth[:,xax] * 0.5
elif field == "pdy":
- return self._current_chunk.fwidth[:,y_dict[self.axis]] * 0.5
+ return self._current_chunk.fwidth[:,yax] * 0.5
else:
raise KeyError(field)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/tests/test_chunking.py
--- a/yt/data_objects/tests/test_chunking.py
+++ b/yt/data_objects/tests/test_chunking.py
@@ -3,7 +3,7 @@
def _get_dobjs(c):
dobjs = [("sphere", ("center", (1.0, "unitary"))),
("sphere", ("center", (0.1, "unitary"))),
- ("ortho_ray", (0, (c[x_dict[0]], c[y_dict[0]]))),
+ ("ortho_ray", (0, (c[1], c[2]))),
("slice", (0, c[0])),
#("disk", ("center", [0.1, 0.3, 0.6],
# (0.2, 'unitary'), (0.1, 'unitary'))),
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/tests/test_projection.py
--- a/yt/data_objects/tests/test_projection.py
+++ b/yt/data_objects/tests/test_projection.py
@@ -29,8 +29,8 @@
uc = [np.unique(c) for c in coords]
# Some simple projection tests with single grids
for ax, an in enumerate("xyz"):
- xax = x_dict[ax]
- yax = y_dict[ax]
+ xax = pf.coordinates.x_axis[ax]
+ yax = pf.coordinates.y_axis[ax]
for wf in ["density", None]:
fns = []
proj = pf.proj(["ones", "density"], ax, weight_field = wf)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/data_objects/tests/test_slice.py
--- a/yt/data_objects/tests/test_slice.py
+++ b/yt/data_objects/tests/test_slice.py
@@ -17,8 +17,6 @@
from nose.tools import raises
from yt.testing import \
fake_random_pf, assert_equal, assert_array_equal, YTArray
-from yt.utilities.definitions import \
- x_dict, y_dict
from yt.utilities.exceptions import \
YTNoDataInObjectError
from yt.units.unit_object import Unit
@@ -50,8 +48,8 @@
slc_pos = 0.5
# Some simple slice tests with single grids
for ax, an in enumerate("xyz"):
- xax = x_dict[ax]
- yax = y_dict[ax]
+ xax = pf.coordinates.x_axis[ax]
+ yax = pf.coordinates.y_axis[ax]
for wf in ["density", None]:
fns = []
slc = pf.slice(ax, slc_pos)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -24,7 +24,7 @@
from yt.utilities.exceptions import *
from yt.utilities.logger import ytLogger as mylog
-from yt.utilities.definitions import inv_axis_names, axis_names, x_dict, y_dict
+from yt.utilities.definitions import inv_axis_names, axis_names
import yt.extern.progressbar as pb
import yt.utilities.rpdb as rpdb
from yt.units.yt_array import YTArray, YTQuantity
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/geometry/object_finding_mixin.py
--- a/yt/geometry/object_finding_mixin.py
+++ b/yt/geometry/object_finding_mixin.py
@@ -37,10 +37,12 @@
# So if gRE > coord, we get a mask, if not, we get a zero
# if gLE > coord, we get a zero, if not, mask
# Thus, if the coordinate is between the two edges, we win!
- np.choose(np.greater(self.grid_right_edge[:,x_dict[axis]],coord[0]),(0,mask),mask)
- np.choose(np.greater(self.grid_left_edge[:,x_dict[axis]],coord[0]),(mask,0),mask)
- np.choose(np.greater(self.grid_right_edge[:,y_dict[axis]],coord[1]),(0,mask),mask)
- np.choose(np.greater(self.grid_left_edge[:,y_dict[axis]],coord[1]),(mask,0),mask)
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
+ np.choose(np.greater(self.grid_right_edge[:,xax],coord[0]),(0,mask),mask)
+ np.choose(np.greater(self.grid_left_edge[:,xax],coord[0]),(mask,0),mask)
+ np.choose(np.greater(self.grid_right_edge[:,yax],coord[1]),(0,mask),mask)
+ np.choose(np.greater(self.grid_left_edge[:,yax],coord[1]),(mask,0),mask)
ind = np.where(mask == 1)
return self.grids[ind], ind
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/gui/reason/widget_store.py
--- a/yt/gui/reason/widget_store.py
+++ b/yt/gui/reason/widget_store.py
@@ -64,7 +64,8 @@
axis = inv_axis_names[axis.lower()]
coord = center[axis]
sl = pf.slice(axis, coord, center = center)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
pw = PWViewerExtJS(sl, (DLE[xax], DRE[xax], DLE[yax], DRE[yax]),
setup = False, plot_type='SlicePlot')
@@ -84,7 +85,8 @@
if weight == "None": weight = None
axis = inv_axis_names[axis.lower()]
proj = pf.proj(field, axis, weight_field=weight)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
pw = PWViewerExtJS(proj, (DLE[xax], DRE[xax], DLE[yax], DRE[yax]),
setup = False, plot_type='ProjectionPlot')
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/utilities/answer_testing/output_tests.py
--- a/yt/utilities/answer_testing/output_tests.py
+++ b/yt/utilities/answer_testing/output_tests.py
@@ -177,8 +177,8 @@
This is a helper function that returns a 2D array of the specified
source, in the specified field, at the specified spatial extent.
"""
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
if edges is None:
edges = (self.pf.domain_left_edge[xax],
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/utilities/definitions.py
--- a/yt/utilities/definitions.py
+++ b/yt/utilities/definitions.py
@@ -26,12 +26,6 @@
inv_axis_names = {'x':0,'y':1,'z':2,
'X':0,'Y':1,'Z':2}
-vm_axis_names = {0:'x', 1:'y', 2:'z', 3:'dx', 4:'dy'}
-
-# The appropriate axes for which way we are slicing
-x_dict = [1,0,0]
-y_dict = [2,2,1]
-
x_names = ['y','x','x']
y_names = ['z','z','y']
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -27,8 +27,6 @@
ensure_list, iterable, traceback_writer_hook
from yt.config import ytcfg
-from yt.utilities.definitions import \
- x_dict, y_dict
import yt.utilities.logger
from yt.utilities.lib.QuadTree import \
QuadTree, merge_quadtrees
@@ -1080,7 +1078,8 @@
return False, self.index.grid_collection(self.center,
self.index.grids)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
cc = MPI.Compute_dims(self.comm.size, 2)
mi = self.comm.rank
cx, cy = np.unravel_index(mi, cc)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -17,7 +17,7 @@
from ._mpl_imports import \
FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \
- get_image_suffix, mylog, x_dict, y_dict
+ get_image_suffix, mylog
import numpy as np
class CallbackWrapper(object):
@@ -30,8 +30,8 @@
self.image = self._axes.images[0]
if frb.axis < 3:
DD = frb.pf.domain_width
- xax = x_dict[frb.axis]
- yax = y_dict[frb.axis]
+ xax = frb.pf.coordinates.x_axis[frb.axis]
+ yax = frb.pf.coordinates.y_axis[frb.axis]
self._period = (DD[xax], DD[yax])
self.pf = frb.pf
self.xlim = viewer.xlim
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -19,8 +19,8 @@
from yt.utilities.logger import ytLogger as mylog
from yt.utilities.definitions import \
- x_dict, x_names, \
- y_dict, y_names, \
+ x_names, \
+ y_names, \
axis_names, \
axis_labels
from .plot_window import PlotWindow
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -15,8 +15,6 @@
from yt.funcs import *
from yt.utilities.definitions import \
- x_dict, \
- y_dict, \
axis_names
from .volume_rendering.api import off_axis_projection
from yt.data_objects.image_array import ImageArray
@@ -104,8 +102,8 @@
DRE = self.pf.domain_right_edge
DD = float(self.periodic)*(DRE - DLE)
axis = self.data_source.axis
- xax = x_dict[axis]
- yax = y_dict[axis]
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
self._period = (DD[xax], DD[yax])
self._edges = ( (DLE[xax], DRE[xax]), (DLE[yax], DRE[yax]) )
@@ -334,8 +332,8 @@
@property
def limits(self):
rv = dict(x = None, y = None, z = None)
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
xn = axis_names[xax]
yn = axis_names[yax]
rv[xn] = (self.bounds[0], self.bounds[1])
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/image_panner/vm_panner.py
--- a/yt/visualization/image_panner/vm_panner.py
+++ b/yt/visualization/image_panner/vm_panner.py
@@ -19,8 +19,6 @@
FixedResolutionBuffer, ObliqueFixedResolutionBuffer
from yt.data_objects.data_containers import \
data_object_registry
-from yt.utilities.definitions import \
- x_dict, y_dict
from yt.funcs import *
class VariableMeshPanner(object):
@@ -62,7 +60,8 @@
if not hasattr(self, 'pf'): self.pf = self.source.pf
DLE, DRE = self.pf.domain_left_edge, self.pf.domain_right_edge
ax = self.source.axis
- xax, yax = x_dict[ax], y_dict[ax]
+ xax = self.pf.coordinates.x_axis[ax]
+ yax = self.pf.coordinates.y_axis[ax]
xbounds = DLE[xax], DRE[xax]
ybounds = DLE[yax], DRE[yax]
return (xbounds, ybounds)
@@ -183,8 +182,10 @@
if len(center) == 2:
centerx, centery = center
elif len(center) == 3:
- centerx = center[x_dict[self.source.axis]]
- centery = center[y_dict[self.source.axis]]
+ xax = self.pf.coordinates.x_axis[self.source.axis]
+ yax = self.pf.coordinates.y_axis[self.source.axis]
+ centerx = center[xax]
+ centery = center[yax]
else:
raise RuntimeError
Wx, Wy = self.width
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -19,8 +19,8 @@
from yt.funcs import *
from _mpl_imports import *
from yt.utilities.definitions import \
- x_dict, x_names, \
- y_dict, y_names, \
+ x_names, \
+ y_names, \
axis_names, \
axis_labels
from yt.utilities.physical_constants import \
@@ -120,8 +120,11 @@
bv = plot.data.get_field_parameter("bulk_velocity")
if bv is not None:
- bv_x = bv[x_dict[plot.data.axis]]
- bv_y = bv[y_dict[plot.data.axis]]
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ bv_x = bv[xi]
+ bv_y = bv[yi]
else: bv_x = bv_y = YTQuantity(0, 'cm/s')
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
@@ -194,8 +197,10 @@
# periodicity
ax = plot.data.axis
pf = plot.data.pf
- period_x = pf.domain_width[x_dict[ax]]
- period_y = pf.domain_width[y_dict[ax]]
+ (xi, yi) = (pf.coordinates.x_axis[ax],
+ pf.coordinates.y_axis[ax])
+ period_x = pf.domain_width[xi]
+ period_y = pf.domain_width[yi]
periodic = int(any(pf.periodicity))
fv_x = plot.data[self.field_x]
if self.bv_x != 0.0:
@@ -384,8 +389,9 @@
yy0, yy1 = plot._axes.get_ylim()
(dx, dy) = self.pixel_scale(plot)
(xpix, ypix) = plot.image._A.shape
- px_index = x_dict[plot.data.axis]
- py_index = y_dict[plot.data.axis]
+ ax = plot.data.axis
+ px_index = plot.data.pf.coordinates.x_axis[ax]
+ py_index = plot.data.pf.coordinates.y_axis[ax]
DW = plot.data.pf.domain_width
if self.periodic:
pxs, pys = np.mgrid[-1:1:3j,-1:1:3j]
@@ -650,8 +656,9 @@
plot._axes.hold(True)
- px_index = x_dict[plot.data.axis]
- py_index = y_dict[plot.data.axis]
+ ax = plot.data.axis
+ px_index = plot.data.pf.coordinates.x_axis[ax]
+ py_index = plot.data.pf.coordinates.y_axis[ax]
xf = axis_names[px_index]
yf = axis_names[py_index]
@@ -701,8 +708,10 @@
def __call__(self, plot):
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
if isinstance(self.code_size[1], basestring):
code_size = plot.data.pf.quan(*self.code_size).value
@@ -732,8 +741,10 @@
def __call__(self, plot):
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
width,height = plot.image._A.shape
x,y = self.convert_to_plot(plot, pos)
@@ -758,8 +769,10 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
elif len(self.pos) == 2:
pos = self.pos
x,y = self.convert_to_plot(plot, pos)
@@ -802,7 +815,9 @@
if plot.data.axis == 4:
(xi, yi) = (0, 1)
else:
- (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
(center_x,center_y) = self.convert_to_plot(plot,(self.center[xi], self.center[yi]))
@@ -853,7 +868,9 @@
radius = halo.maximum_radius() * self.pixel_scale(plot)[0]
center = halo.center_of_mass()
- (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
(center_x,center_y) = self.convert_to_plot(plot,(center[xi], center[yi]))
color = np.ones(3) * (0.4 * (num - halo.id)/ num) + 0.6
@@ -940,8 +957,10 @@
kwargs = self.text_args.copy()
if self.data_coords and len(plot.image._A.shape) == 2:
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
x,y = self.convert_to_plot(plot, pos)
else:
@@ -992,8 +1011,11 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
reg = self._get_region((x0,x1), (y0,y1), plot.data.axis, data)
- field_x = "particle_position_%s" % axis_names[x_dict[data.axis]]
- field_y = "particle_position_%s" % axis_names[y_dict[data.axis]]
+ ax = data.axis
+ xax = plot.data.pf.coordinates.x_axis[ax]
+ yax = plot.data.pf.coordinates.y_axis[ax]
+ field_x = "particle_position_%s" % axis_names[xax]
+ field_y = "particle_position_%s" % axis_names[yax]
gg = ( ( reg[field_x] >= x0 ) & ( reg[field_x] <= x1 )
& ( reg[field_y] >= y0 ) & ( reg[field_y] <= y1 ) )
if self.ptype is not None:
@@ -1021,8 +1043,9 @@
def _get_region(self, xlim, ylim, axis, data):
LE, RE = [None]*3, [None]*3
- xax = x_dict[axis]
- yax = y_dict[axis]
+ pf = data.pf
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
zax = axis
LE[xax], RE[xax] = xlim
LE[yax], RE[yax] = ylim
@@ -1240,7 +1263,9 @@
def __call__(self, plot):
plot._axes.hold(True)
- xax, yax = x_dict[plot.data.axis], y_dict[plot.data.axis]
+ ax = data.axis
+ xax = plot.data.pf.coordinates.x_axis[ax]
+ yax = plot.data.pf.coordinates.y_axis[ax]
l_cy = triangle_plane_intersect(plot.data.axis, plot.data.coord, self.vertices)[:,:,(xax, yax)]
lc = matplotlib.collections.LineCollection(l_cy, **self.plot_args)
plot._axes.add_collection(lc)
diff -r 8c3d54b7ef018f70667fa928f34208cd13f5dbf7 -r 0036acf481a08fe355d20a453ec691eb30c7756b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -43,7 +43,6 @@
from yt.utilities.png_writer import \
write_png_to_string
from yt.utilities.definitions import \
- x_dict, y_dict, \
axis_names, axis_labels, \
formatted_length_unit_names
from yt.utilities.math_utils import \
@@ -108,7 +107,9 @@
if width is None:
# Default to code units
if not iterable(axis):
- w = pf.domain_width[[x_dict[axis], y_dict[axis]]]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
+ w = pf.domain_width[[xax, yax]]
else:
# axis is actually the normal vector
# for an off-axis data object.
@@ -179,10 +180,12 @@
center = pf.arr([0.0, 0.0, 0.0], "code_length")
else:
raise NotImplementedError
- bounds = (center[x_dict[axis]]-width[0] / 2,
- center[x_dict[axis]]+width[0] / 2,
- center[y_dict[axis]]-width[1] / 2,
- center[y_dict[axis]]+width[1] / 2)
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
+ bounds = (center[xax]-width[0] / 2,
+ center[xax]+width[0] / 2,
+ center[yax]-width[1] / 2,
+ center[yax]+width[1] / 2)
return (bounds, center)
def get_oblique_window_parameters(normal, center, width, pf, depth=None):
@@ -642,10 +645,12 @@
xllim, xrlim = self.xlim
yllim, yrlim = self.ylim
elif origin[2] == 'domain':
- xllim = self.pf.domain_left_edge[x_dict[axis_index]]
- xrlim = self.pf.domain_right_edge[x_dict[axis_index]]
- yllim = self.pf.domain_left_edge[y_dict[axis_index]]
- yrlim = self.pf.domain_right_edge[y_dict[axis_index]]
+ xax = pf.coordinates.x_axis[axis_index]
+ yax = pf.coordinates.y_axis[axis_index]
+ xllim = self.pf.domain_left_edge[xax]
+ xrlim = self.pf.domain_right_edge[xax]
+ yllim = self.pf.domain_left_edge[yax]
+ yrlim = self.pf.domain_right_edge[yax]
elif origin[2] == 'native':
return (self.pf.quan(0.0, 'code_length'),
self.pf.quan(0.0, 'code_length'))
@@ -1416,8 +1421,10 @@
self._frb.bounds, (nx,ny))
axis = self._frb.data_source.axis
- fx = "%s-velocity" % (axis_names[x_dict[axis]])
- fy = "%s-velocity" % (axis_names[y_dict[axis]])
+ xax = self._frb.data_source.pf.coordinates.x_axis[axis]
+ yax = self._frb.data_source.pf.coordinates.y_axis[axis]
+ fx = "velocity_%s" % (axis_names[xax])
+ fy = "velocity_%x" % (axis_names[yax])
px = new_frb[fx][::-1,:]
py = new_frb[fy][::-1,:]
x = np.mgrid[0:vi-1:ny*1j]
@@ -1501,12 +1508,14 @@
unit = self._axes_unit_names
units = self.get_field_units(field, strip_mathml)
center = getattr(self._frb.data_source, "center", None)
+ xax = self.pf.coordinates.x_axis[self._frb.axis]
+ yax = self.pf.coordinates.y_axis[self._frb.axis]
if center is None or self._frb.axis == 4:
xc, yc, zc = -999, -999, -999
else:
- center[x_dict[self._frb.axis]] = 0.5 * (
+ center[xax] = 0.5 * (
self.xlim[0] + self.xlim[1])
- center[y_dict[self._frb.axis]] = 0.5 * (
+ center[yax] = 0.5 * (
self.ylim[0] + self.ylim[1])
xc, yc, zc = center
if return_string:
https://bitbucket.org/yt_analysis/yt/commits/c62a66a864f6/
Changeset: c62a66a864f6
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:23:35
Summary: Removing uses of axis_names and inv_axis_names.
Affected #: 10 files
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -22,7 +22,6 @@
from yt.fields.local_fields import add_field, derived_field
from yt.data_objects.image_array import ImageArray
from yt.funcs import fix_axis, mylog, iterable, get_pbar
-from yt.utilities.definitions import inv_axis_names
from yt.visualization.volume_rendering.camera import off_axis_projection
from yt.utilities.parallel_tools.parallel_analysis_interface import \
communication_system, parallel_root_only
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -24,7 +24,6 @@
from yt.utilities.exceptions import *
from yt.utilities.logger import ytLogger as mylog
-from yt.utilities.definitions import inv_axis_names, axis_names
import yt.extern.progressbar as pb
import yt.utilities.rpdb as rpdb
from yt.units.yt_array import YTArray, YTQuantity
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/gui/reason/extdirect_repl.py
--- a/yt/gui/reason/extdirect_repl.py
+++ b/yt/gui/reason/extdirect_repl.py
@@ -39,7 +39,6 @@
from yt.funcs import *
from yt.utilities.logger import ytLogger, ufstring
-from yt.utilities.definitions import inv_axis_names
from yt.visualization.image_writer import apply_colormap
from yt.visualization.api import Streamlines
from .widget_store import WidgetStore
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/gui/reason/widget_store.py
--- a/yt/gui/reason/widget_store.py
+++ b/yt/gui/reason/widget_store.py
@@ -61,7 +61,7 @@
center = pf.h.find_max('Density')[1]
else:
center = np.array(center)
- axis = inv_axis_names[axis.lower()]
+ axis = pf.coordinates.axis_id[axis.lower()]
coord = center[axis]
sl = pf.slice(axis, coord, center = center)
xax = pf.coordinates.x_axis[axis]
@@ -83,7 +83,7 @@
def create_proj(self, pf, axis, field, weight):
if weight == "None": weight = None
- axis = inv_axis_names[axis.lower()]
+ axis = pf.coordinates.axis_id[axis.lower()]
proj = pf.proj(field, axis, weight_field=weight)
xax = pf.coordinates.x_axis[axis]
yax = pf.coordinates.y_axis[axis]
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/utilities/definitions.py
--- a/yt/utilities/definitions.py
+++ b/yt/utilities/definitions.py
@@ -22,10 +22,6 @@
MAXLEVEL=48
axis_labels = [('y','z'),('x','z'),('x','y')]
-axis_names = {0: 'x', 1: 'y', 2: 'z', 4:''}
-inv_axis_names = {'x':0,'y':1,'z':2,
- 'X':0,'Y':1,'Z':2}
-
x_names = ['y','x','x']
y_names = ['z','z','y']
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -18,11 +18,6 @@
from _mpl_imports import FigureCanvasAgg
from yt.utilities.logger import ytLogger as mylog
-from yt.utilities.definitions import \
- x_names, \
- y_names, \
- axis_names, \
- axis_labels
from .plot_window import PlotWindow
from .profile_plotter import PhasePlot
from .plot_modifications import get_smallest_appropriate_unit
@@ -294,6 +289,7 @@
_yrange = (0, width * plot.pf[units])
_xlog = False
_ylog = False
+ axis_names = plot.pf.coordinates.axis_name
if bare_axes:
_xlabel = ""
_ylabel = ""
@@ -303,14 +299,16 @@
_xlabel = xlabel
else:
if data.axis != 4:
- _xlabel = '%s (%s)' % (x_names[data.axis], units)
+ xax = plot.pf.coordinates.x_axis[data.axis]
+ _xlabel = '%s (%s)' % (axis_names[xax], units)
else:
_xlabel = 'Image x (%s)' % (units)
if ylabel != None:
_ylabel = ylabel
else:
if data.axis != 4:
- _ylabel = '%s (%s)' % (y_names[data.axis], units)
+ yax = plot.pf.coordinatesyx_axis[data.axis]
+ _ylabel = '%s (%s)' % (axis_names[yax], units)
else:
_ylabel = 'Image y (%s)' % (units)
if tickcolor == None:
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -14,8 +14,6 @@
#-----------------------------------------------------------------------------
from yt.funcs import *
-from yt.utilities.definitions import \
- axis_names
from .volume_rendering.api import off_axis_projection
from yt.data_objects.image_array import ImageArray
from yt.utilities.lib.misc_utilities import \
@@ -334,8 +332,8 @@
rv = dict(x = None, y = None, z = None)
xax = self.pf.coordinates.x_axis[self.axis]
yax = self.pf.coordinates.y_axis[self.axis]
- xn = axis_names[xax]
- yn = axis_names[yax]
+ xn = self.pf.coordinates.axis_name[xax]
+ yn = self.pf.coordinates.axis_name[yax]
rv[xn] = (self.bounds[0], self.bounds[1])
rv[yn] = (self.bounds[2], self.bounds[3])
return rv
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -16,7 +16,6 @@
from yt.funcs import \
defaultdict, get_image_suffix, \
get_ipython_api_version
-from yt.utilities.definitions import axis_names
from yt.utilities.exceptions import \
YTNotInsideNotebook
from ._mpl_imports import FigureCanvasAgg
@@ -418,7 +417,7 @@
for k, v in self.plots.iteritems():
names.append(v.save(name, mpl_kwargs))
return names
- axis = axis_names[self.data_source.axis]
+ axis = self.pf.coordinates.axis_names[self.data_source.axis]
weight = None
type = self._plot_type
if type in ['Projection', 'OffAxisProjection']:
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -18,11 +18,6 @@
from yt.funcs import *
from _mpl_imports import *
-from yt.utilities.definitions import \
- x_names, \
- y_names, \
- axis_names, \
- axis_labels
from yt.utilities.physical_constants import \
sec_per_Gyr, sec_per_Myr, \
sec_per_kyr, sec_per_year, \
@@ -115,14 +110,15 @@
"cutting_plane_velocity_y",
self.factor)
else:
- xv = "velocity_%s" % (x_names[plot.data.axis])
- yv = "velocity_%s" % (y_names[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ axis_names = plot.data.pf.coordinates.axis_name
+ xv = "velocity_%s" % (axis_names[xi])
+ yv = "velocity_%s" % (axis_names[yi])
bv = plot.data.get_field_parameter("bulk_velocity")
if bv is not None:
- ax = plot.data.axis
- (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
- plot.data.pf.coordinates.y_axis[ax])
bv_x = bv[xi]
bv_y = bv[yi]
else: bv_x = bv_y = YTQuantity(0, 'cm/s')
@@ -159,8 +155,11 @@
"cutting_plane_by",
self.factor)
else:
- xv = "magnetic_field_%s" % (x_names[plot.data.axis])
- yv = "magnetic_field_%s" % (y_names[plot.data.axis])
+ xax = plot.data.pf.coordinates.x_axis[plot.data.axis]
+ yax = plot.data.pf.coordinates.y_axis[plot.data.axis]
+ axis_names = plot.data.pf.coordinates.axis_name
+ xv = "magnetic_field_%s" % (axis_names[xax])
+ yv = "magnetic_field_%s" % (axis_names[yax])
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale, scale_units=self.scale_units, normalize=self.normalize)
return qcb(plot)
@@ -660,8 +659,8 @@
px_index = plot.data.pf.coordinates.x_axis[ax]
py_index = plot.data.pf.coordinates.y_axis[ax]
- xf = axis_names[px_index]
- yf = axis_names[py_index]
+ xf = plot.data.pf.coordinates.axis_name[px_index]
+ yf = plot.data.pf.coordinates.axis_name[py_index]
dxf = "d%s" % xf
dyf = "d%s" % yf
@@ -909,7 +908,10 @@
def __call__(self,plot):
(dx,dy) = self.pixel_scale(plot)
- (xi, yi) = (x_names[plot.data.axis], y_names[plot.data.axis])
+ xax = plot.data.pf.coordinates.x_axis[plot.data.axis]
+ yax = plot.data.pf.coordinates.y_axis[plot.data.axis]
+ axis_names = plot.data.pf.coordinates.axis_name
+ (xi, yi) = (axis_names[xax], axis_names[yax])
# now we loop over the haloes
for halo in self.hop_output[:self.max_number]:
@@ -1014,6 +1016,7 @@
ax = data.axis
xax = plot.data.pf.coordinates.x_axis[ax]
yax = plot.data.pf.coordinates.y_axis[ax]
+ axis_names = plot.data.pf.coordinates.axis_name
field_x = "particle_position_%s" % axis_names[xax]
field_y = "particle_position_%s" % axis_names[yax]
gg = ( ( reg[field_x] >= x0 ) & ( reg[field_x] <= x1 )
diff -r 0036acf481a08fe355d20a453ec691eb30c7756b -r c62a66a864f6c867fd2090938f8d06ee7864e806 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -43,7 +43,6 @@
from yt.utilities.png_writer import \
write_png_to_string
from yt.utilities.definitions import \
- axis_names, axis_labels, \
formatted_length_unit_names
from yt.utilities.math_utils import \
ortho_find
@@ -781,7 +780,8 @@
labels = [r'$\rm{Image\/x'+axes_unit_labels[0]+'}$',
r'$\rm{Image\/y'+axes_unit_labels[1]+'}$']
else:
- labels = [r'$\rm{'+axis_labels[axis_index][i]+
+ axis_names = self.pf.coordinates.axis_name
+ labels = [r'$\rm{'+axis_names[axis_index][i]+
axes_unit_labels[i] + r'}$' for i in (0,1)]
self.plots[f].axes.set_xlabel(labels[0],fontproperties=fp)
@@ -1423,6 +1423,7 @@
axis = self._frb.data_source.axis
xax = self._frb.data_source.pf.coordinates.x_axis[axis]
yax = self._frb.data_source.pf.coordinates.y_axis[axis]
+ axis_names = self._frb.data_source.pf.coordinates.axis_name
fx = "velocity_%s" % (axis_names[xax])
fy = "velocity_%x" % (axis_names[yax])
px = new_frb[fx][::-1,:]
https://bitbucket.org/yt_analysis/yt/commits/043233ffc50f/
Changeset: 043233ffc50f
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:28:19
Summary: Adding a parameter file to the fix_axis call.
Affected #: 4 files
diff -r c62a66a864f6c867fd2090938f8d06ee7864e806 -r 043233ffc50f5304951267ef5f9d51d30ff1ce5e yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -133,7 +133,7 @@
--------
>>> szprj.on_axis("y", center="max", width=(1.0, "Mpc"), source=my_sphere)
"""
- axis = fix_axis(axis)
+ axis = fix_axis(axis, self.pf)
if center == "c":
ctr = self.pf.domain_center
diff -r c62a66a864f6c867fd2090938f8d06ee7864e806 -r 043233ffc50f5304951267ef5f9d51d30ff1ce5e yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -725,9 +725,10 @@
_spatial = False
def __init__(self, axis, pf, field_parameters):
ParallelAnalysisInterface.__init__(self)
- self.axis = fix_axis(axis)
super(YTSelectionContainer2D, self).__init__(
pf, field_parameters)
+ # We need the pf, which will exist by now, for fix_axis.
+ self.axis = fix_axis(axis, self.pf)
self.set_field_parameter("axis", axis)
def _convert_field_name(self, field):
diff -r c62a66a864f6c867fd2090938f8d06ee7864e806 -r 043233ffc50f5304951267ef5f9d51d30ff1ce5e yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -636,8 +636,8 @@
return os.environ.get("OMP_NUM_THREADS", 0)
return nt
-def fix_axis(axis):
- return inv_axis_names.get(axis, axis)
+def fix_axis(axis, pf):
+ return pf.coordinates.axis_id.get(axis, axis)
def get_image_suffix(name):
suffix = os.path.splitext(name)[1]
diff -r c62a66a864f6c867fd2090938f8d06ee7864e806 -r 043233ffc50f5304951267ef5f9d51d30ff1ce5e yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -963,7 +963,7 @@
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
- axis = fix_axis(axis)
+ axis = fix_axis(axis, pf)
(bounds, center) = get_window_parameters(axis, center, width, pf)
if field_parameters is None: field_parameters = {}
slc = pf.slice(axis, center[axis],
@@ -1089,7 +1089,7 @@
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
- axis = fix_axis(axis)
+ axis = fix_axis(axis, pf)
(bounds, center) = get_window_parameters(axis, center, width, pf)
if field_parameters is None: field_parameters = {}
proj = pf.proj(fields, axis, weight_field=weight_field,
https://bitbucket.org/yt_analysis/yt/commits/6d02ccf74f1b/
Changeset: 6d02ccf74f1b
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:29:13
Summary: Removing axis_labels, x_names, y_names.
Affected #: 1 file
diff -r 043233ffc50f5304951267ef5f9d51d30ff1ce5e -r 6d02ccf74f1bb5f24a55db84491d1fb6c87709c7 yt/utilities/definitions.py
--- a/yt/utilities/definitions.py
+++ b/yt/utilities/definitions.py
@@ -21,10 +21,6 @@
# The number of levels we expect to have at most
MAXLEVEL=48
-axis_labels = [('y','z'),('x','z'),('x','y')]
-x_names = ['y','x','x']
-y_names = ['z','z','y']
-
# How many of each thing are in an Mpc
mpc_conversion = {'Mpc' : mpc_per_mpc,
'mpc' : mpc_per_mpc,
@@ -46,5 +42,3 @@
'Myr' : sec_per_Myr,
'years' : sec_per_year,
'days' : sec_per_day}
-
-axis_labels = [('y','z'),('x','z'),('x','y')]
https://bitbucket.org/yt_analysis/yt/commits/7e6d0b4f1222/
Changeset: 7e6d0b4f1222
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:40:59
Summary: Fixing an error in plot window with axis_names.
Affected #: 1 file
diff -r 6d02ccf74f1bb5f24a55db84491d1fb6c87709c7 -r 7e6d0b4f1222ce5462365cea6d2dba9edf512613 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -781,8 +781,10 @@
r'$\rm{Image\/y'+axes_unit_labels[1]+'}$']
else:
axis_names = self.pf.coordinates.axis_name
- labels = [r'$\rm{'+axis_names[axis_index][i]+
- axes_unit_labels[i] + r'}$' for i in (0,1)]
+ xax = self.pf.coordinates.x_axis[axis_index]
+ yax = self.pf.coordinates.y_axis[axis_index]
+ labels = [r'$\rm{'+axis_names[xax]+axes_unit_labels[0] + r'}$',
+ r'$\rm{'+axis_names[yax]+axes_unit_labels[1] + r'}$']
self.plots[f].axes.set_xlabel(labels[0],fontproperties=fp)
self.plots[f].axes.set_ylabel(labels[1],fontproperties=fp)
https://bitbucket.org/yt_analysis/yt/commits/d51382185ae8/
Changeset: d51382185ae8
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:51:17
Summary: Fixing reference to axis_names instead of axis_name.
Affected #: 1 file
diff -r 7e6d0b4f1222ce5462365cea6d2dba9edf512613 -r d51382185ae8031fe7e7ed9424bbc2d1463619cc yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -417,7 +417,7 @@
for k, v in self.plots.iteritems():
names.append(v.save(name, mpl_kwargs))
return names
- axis = self.pf.coordinates.axis_names[self.data_source.axis]
+ axis = self.pf.coordinates.axis_name[self.data_source.axis]
weight = None
type = self._plot_type
if type in ['Projection', 'OffAxisProjection']:
https://bitbucket.org/yt_analysis/yt/commits/92ae2f6814fc/
Changeset: 92ae2f6814fc
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-15 17:55:48
Summary: Add a default axis name of '' for axis 4.
Affected #: 1 file
diff -r d51382185ae8031fe7e7ed9424bbc2d1463619cc -r 92ae2f6814fc2340fded3f331bccc58bba9d0f2f yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -417,7 +417,8 @@
for k, v in self.plots.iteritems():
names.append(v.save(name, mpl_kwargs))
return names
- axis = self.pf.coordinates.axis_name[self.data_source.axis]
+ axis = self.pf.coordinates.axis_name.get(
+ self.data_source.axis, '')
weight = None
type = self._plot_type
if type in ['Projection', 'OffAxisProjection']:
https://bitbucket.org/yt_analysis/yt/commits/3cb702b86a17/
Changeset: 3cb702b86a17
Branch: yt-3.0
User: jzuhone
Date: 2014-04-27 20:20:44
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #821)
Abstract out all axis information
Affected #: 22 files
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -22,7 +22,6 @@
from yt.fields.local_fields import add_field, derived_field
from yt.data_objects.image_array import ImageArray
from yt.funcs import fix_axis, mylog, iterable, get_pbar
-from yt.utilities.definitions import inv_axis_names
from yt.visualization.volume_rendering.camera import off_axis_projection
from yt.utilities.parallel_tools.parallel_analysis_interface import \
communication_system, parallel_root_only
@@ -134,7 +133,7 @@
--------
>>> szprj.on_axis("y", center="max", width=(1.0, "Mpc"), source=my_sphere)
"""
- axis = fix_axis(axis)
+ axis = fix_axis(axis, self.pf)
if center == "c":
ctr = self.pf.domain_center
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -41,7 +41,6 @@
march_cubes_grid, march_cubes_grid_flux
from yt.utilities.data_point_utilities import CombineGrids,\
DataCubeRefine, DataCubeReplace, FillRegion, FillBuffer
-from yt.utilities.definitions import axis_names, x_dict, y_dict
from yt.utilities.minimal_representation import \
MinimalProjectionData
from yt.utilities.parallel_tools.parallel_analysis_interface import \
@@ -252,8 +251,8 @@
self._mrep.upload()
def _get_tree(self, nvals):
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
xd = self.pf.domain_dimensions[xax]
yd = self.pf.domain_dimensions[yax]
bounds = (self.pf.domain_left_edge[xax],
@@ -292,18 +291,20 @@
else:
raise NotImplementedError
# TODO: Add the combine operation
- ox = self.pf.domain_left_edge[x_dict[self.axis]]
- oy = self.pf.domain_left_edge[y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ ox = self.pf.domain_left_edge[xax]
+ oy = self.pf.domain_left_edge[yax]
px, py, pdx, pdy, nvals, nwvals = tree.get_all(False, merge_style)
nvals = self.comm.mpi_allreduce(nvals, op=op)
nwvals = self.comm.mpi_allreduce(nwvals, op=op)
- np.multiply(px, self.pf.domain_width[x_dict[self.axis]], px)
+ np.multiply(px, self.pf.domain_width[xax], px)
np.add(px, ox, px)
- np.multiply(pdx, self.pf.domain_width[x_dict[self.axis]], pdx)
+ np.multiply(pdx, self.pf.domain_width[xax], pdx)
- np.multiply(py, self.pf.domain_width[y_dict[self.axis]], py)
+ np.multiply(py, self.pf.domain_width[yax], py)
np.add(py, oy, py)
- np.multiply(pdy, self.pf.domain_width[y_dict[self.axis]], pdy)
+ np.multiply(pdy, self.pf.domain_width[yax], pdy)
if self.weight_field is not None:
np.divide(nvals, nwvals[:,None], nvals)
# We now convert to half-widths and center-points
@@ -348,8 +349,10 @@
def _initialize_chunk(self, chunk, tree):
icoords = chunk.icoords
- i1 = icoords[:,x_dict[self.axis]]
- i2 = icoords[:,y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ i1 = icoords[:,xax]
+ i2 = icoords[:,yax]
ilevel = chunk.ires * self.pf.ires_factor
tree.initialize_chunk(i1, i2, ilevel)
@@ -370,8 +373,10 @@
else:
w = np.ones(chunk.ires.size, dtype="float64")
icoords = chunk.icoords
- i1 = icoords[:,x_dict[self.axis]]
- i2 = icoords[:,y_dict[self.axis]]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ i1 = icoords[:,xax]
+ i2 = icoords[:,yax]
ilevel = chunk.ires * self.pf.ires_factor
tree.add_chunk_to_tree(i1, i2, ilevel, v, w)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -28,7 +28,6 @@
from yt.data_objects.particle_io import particle_handler_registry
from yt.utilities.lib.marching_cubes import \
march_cubes_grid, march_cubes_grid_flux
-from yt.utilities.definitions import x_dict, y_dict
from yt.utilities.parallel_tools.parallel_analysis_interface import \
ParallelAnalysisInterface
from yt.utilities.parameter_file_storage import \
@@ -726,9 +725,10 @@
_spatial = False
def __init__(self, axis, pf, field_parameters):
ParallelAnalysisInterface.__init__(self)
- self.axis = fix_axis(axis)
super(YTSelectionContainer2D, self).__init__(
pf, field_parameters)
+ # We need the pf, which will exist by now, for fix_axis.
+ self.axis = fix_axis(axis, self.pf)
self.set_field_parameter("axis", axis)
def _convert_field_name(self, field):
@@ -821,8 +821,8 @@
if not iterable(resolution):
resolution = (resolution, resolution)
from yt.visualization.fixed_resolution import FixedResolutionBuffer
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
bounds = (center[xax] - width*0.5, center[xax] + width*0.5,
center[yax] - height*0.5, center[yax] + height*0.5)
frb = FixedResolutionBuffer(self, bounds, resolution,
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -20,13 +20,11 @@
import numpy as np
from yt.funcs import *
-from yt.utilities.definitions import x_dict, y_dict
from yt.data_objects.data_containers import \
YTFieldData, \
YTDataContainer, \
YTSelectionContainer
-from yt.utilities.definitions import x_dict, y_dict
from yt.fields.field_exceptions import \
NeedsGridType, \
NeedsOriginalGrid, \
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -25,8 +25,6 @@
YTSelectionContainer1D, YTSelectionContainer2D, YTSelectionContainer3D
from yt.data_objects.derived_quantities import \
DerivedQuantityCollection
-from yt.utilities.definitions import \
- x_dict, y_dict, axis_names
from yt.utilities.exceptions import YTSphereTooSmall
from yt.utilities.linear_interpolators import TrilinearFieldInterpolator
from yt.utilities.minimal_representation import \
@@ -73,12 +71,15 @@
def __init__(self, axis, coords, pf=None, field_parameters=None):
super(YTOrthoRayBase, self).__init__(pf, field_parameters)
self.axis = axis
- self.px_ax = x_dict[self.axis]
- self.py_ax = y_dict[self.axis]
- self.px_dx = 'd%s'%(axis_names[self.px_ax])
- self.py_dx = 'd%s'%(axis_names[self.py_ax])
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ self.px_ax = xax
+ self.py_ax = yax
+ # Even though we may not be using x,y,z we use them here.
+ self.px_dx = 'd%s'%('xyz'[self.px_ax])
+ self.py_dx = 'd%s'%('xyz'[self.py_ax])
self.px, self.py = coords
- self.sort_by = axis_names[self.axis]
+ self.sort_by = 'xyz'[self.axis]
@property
def coords(self):
@@ -191,16 +192,18 @@
self.coord = coord
def _generate_container_field(self, field):
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
if self._current_chunk is None:
self.index._identify_base_chunk(self)
if field == "px":
- return self._current_chunk.fcoords[:,x_dict[self.axis]]
+ return self._current_chunk.fcoords[:,xax]
elif field == "py":
- return self._current_chunk.fcoords[:,y_dict[self.axis]]
+ return self._current_chunk.fcoords[:,yax]
elif field == "pdx":
- return self._current_chunk.fwidth[:,x_dict[self.axis]] * 0.5
+ return self._current_chunk.fwidth[:,xax] * 0.5
elif field == "pdy":
- return self._current_chunk.fwidth[:,y_dict[self.axis]] * 0.5
+ return self._current_chunk.fwidth[:,yax] * 0.5
else:
raise KeyError(field)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/tests/test_chunking.py
--- a/yt/data_objects/tests/test_chunking.py
+++ b/yt/data_objects/tests/test_chunking.py
@@ -3,7 +3,7 @@
def _get_dobjs(c):
dobjs = [("sphere", ("center", (1.0, "unitary"))),
("sphere", ("center", (0.1, "unitary"))),
- ("ortho_ray", (0, (c[x_dict[0]], c[y_dict[0]]))),
+ ("ortho_ray", (0, (c[1], c[2]))),
("slice", (0, c[0])),
#("disk", ("center", [0.1, 0.3, 0.6],
# (0.2, 'unitary'), (0.1, 'unitary'))),
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/tests/test_projection.py
--- a/yt/data_objects/tests/test_projection.py
+++ b/yt/data_objects/tests/test_projection.py
@@ -29,8 +29,8 @@
uc = [np.unique(c) for c in coords]
# Some simple projection tests with single grids
for ax, an in enumerate("xyz"):
- xax = x_dict[ax]
- yax = y_dict[ax]
+ xax = pf.coordinates.x_axis[ax]
+ yax = pf.coordinates.y_axis[ax]
for wf in ["density", None]:
fns = []
proj = pf.proj(["ones", "density"], ax, weight_field = wf)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/data_objects/tests/test_slice.py
--- a/yt/data_objects/tests/test_slice.py
+++ b/yt/data_objects/tests/test_slice.py
@@ -17,8 +17,6 @@
from nose.tools import raises
from yt.testing import \
fake_random_pf, assert_equal, assert_array_equal, YTArray
-from yt.utilities.definitions import \
- x_dict, y_dict
from yt.utilities.exceptions import \
YTNoDataInObjectError
from yt.units.unit_object import Unit
@@ -50,8 +48,8 @@
slc_pos = 0.5
# Some simple slice tests with single grids
for ax, an in enumerate("xyz"):
- xax = x_dict[ax]
- yax = y_dict[ax]
+ xax = pf.coordinates.x_axis[ax]
+ yax = pf.coordinates.y_axis[ax]
for wf in ["density", None]:
fns = []
slc = pf.slice(ax, slc_pos)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -24,7 +24,6 @@
from yt.utilities.exceptions import *
from yt.utilities.logger import ytLogger as mylog
-from yt.utilities.definitions import inv_axis_names, axis_names, x_dict, y_dict
import yt.extern.progressbar as pb
import yt.utilities.rpdb as rpdb
from yt.units.yt_array import YTArray, YTQuantity
@@ -637,8 +636,8 @@
return os.environ.get("OMP_NUM_THREADS", 0)
return nt
-def fix_axis(axis):
- return inv_axis_names.get(axis, axis)
+def fix_axis(axis, pf):
+ return pf.coordinates.axis_id.get(axis, axis)
def get_image_suffix(name):
suffix = os.path.splitext(name)[1]
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/geometry/object_finding_mixin.py
--- a/yt/geometry/object_finding_mixin.py
+++ b/yt/geometry/object_finding_mixin.py
@@ -38,10 +38,12 @@
# So if gRE > coord, we get a mask, if not, we get a zero
# if gLE > coord, we get a zero, if not, mask
# Thus, if the coordinate is between the two edges, we win!
- np.choose(np.greater(self.grid_right_edge[:,x_dict[axis]],coord[0]),(0,mask),mask)
- np.choose(np.greater(self.grid_left_edge[:,x_dict[axis]],coord[0]),(mask,0),mask)
- np.choose(np.greater(self.grid_right_edge[:,y_dict[axis]],coord[1]),(0,mask),mask)
- np.choose(np.greater(self.grid_left_edge[:,y_dict[axis]],coord[1]),(mask,0),mask)
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
+ np.choose(np.greater(self.grid_right_edge[:,xax],coord[0]),(0,mask),mask)
+ np.choose(np.greater(self.grid_left_edge[:,xax],coord[0]),(mask,0),mask)
+ np.choose(np.greater(self.grid_right_edge[:,yax],coord[1]),(0,mask),mask)
+ np.choose(np.greater(self.grid_left_edge[:,yax],coord[1]),(mask,0),mask)
ind = np.where(mask == 1)
return self.grids[ind], ind
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/gui/reason/extdirect_repl.py
--- a/yt/gui/reason/extdirect_repl.py
+++ b/yt/gui/reason/extdirect_repl.py
@@ -39,7 +39,6 @@
from yt.funcs import *
from yt.utilities.logger import ytLogger, ufstring
-from yt.utilities.definitions import inv_axis_names
from yt.visualization.image_writer import apply_colormap
from yt.visualization.api import Streamlines
from .widget_store import WidgetStore
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/gui/reason/widget_store.py
--- a/yt/gui/reason/widget_store.py
+++ b/yt/gui/reason/widget_store.py
@@ -61,10 +61,11 @@
center = pf.h.find_max('Density')[1]
else:
center = np.array(center)
- axis = inv_axis_names[axis.lower()]
+ axis = pf.coordinates.axis_id[axis.lower()]
coord = center[axis]
sl = pf.slice(axis, coord, center = center)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
pw = PWViewerExtJS(sl, (DLE[xax], DRE[xax], DLE[yax], DRE[yax]),
setup = False, plot_type='SlicePlot')
@@ -82,9 +83,10 @@
def create_proj(self, pf, axis, field, weight):
if weight == "None": weight = None
- axis = inv_axis_names[axis.lower()]
+ axis = pf.coordinates.axis_id[axis.lower()]
proj = pf.proj(field, axis, weight_field=weight)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
pw = PWViewerExtJS(proj, (DLE[xax], DRE[xax], DLE[yax], DRE[yax]),
setup = False, plot_type='ProjectionPlot')
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/utilities/answer_testing/output_tests.py
--- a/yt/utilities/answer_testing/output_tests.py
+++ b/yt/utilities/answer_testing/output_tests.py
@@ -177,8 +177,8 @@
This is a helper function that returns a 2D array of the specified
source, in the specified field, at the specified spatial extent.
"""
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
if edges is None:
edges = (self.pf.domain_left_edge[xax],
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/utilities/definitions.py
--- a/yt/utilities/definitions.py
+++ b/yt/utilities/definitions.py
@@ -21,20 +21,6 @@
# The number of levels we expect to have at most
MAXLEVEL=48
-axis_labels = [('y','z'),('x','z'),('x','y')]
-axis_names = {0: 'x', 1: 'y', 2: 'z', 4:''}
-inv_axis_names = {'x':0,'y':1,'z':2,
- 'X':0,'Y':1,'Z':2}
-
-vm_axis_names = {0:'x', 1:'y', 2:'z', 3:'dx', 4:'dy'}
-
-# The appropriate axes for which way we are slicing
-x_dict = [1,0,0]
-y_dict = [2,2,1]
-
-x_names = ['y','x','x']
-y_names = ['z','z','y']
-
# How many of each thing are in an Mpc
mpc_conversion = {'Mpc' : mpc_per_mpc,
'mpc' : mpc_per_mpc,
@@ -56,5 +42,3 @@
'Myr' : sec_per_Myr,
'years' : sec_per_year,
'days' : sec_per_day}
-
-axis_labels = [('y','z'),('x','z'),('x','y')]
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -27,8 +27,6 @@
ensure_list, iterable, traceback_writer_hook
from yt.config import ytcfg
-from yt.utilities.definitions import \
- x_dict, y_dict
import yt.utilities.logger
from yt.utilities.lib.QuadTree import \
QuadTree, merge_quadtrees
@@ -1066,7 +1064,8 @@
return False, self.index.grid_collection(self.center,
self.index.grids)
- xax, yax = x_dict[axis], y_dict[axis]
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
cc = MPI.Compute_dims(self.comm.size, 2)
mi = self.comm.rank
cx, cy = np.unravel_index(mi, cc)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -17,7 +17,7 @@
from ._mpl_imports import \
FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \
- get_image_suffix, mylog, x_dict, y_dict
+ get_image_suffix, mylog
import numpy as np
class CallbackWrapper(object):
@@ -30,8 +30,8 @@
self.image = self._axes.images[0]
if frb.axis < 3:
DD = frb.pf.domain_width
- xax = x_dict[frb.axis]
- yax = y_dict[frb.axis]
+ xax = frb.pf.coordinates.x_axis[frb.axis]
+ yax = frb.pf.coordinates.y_axis[frb.axis]
self._period = (DD[xax], DD[yax])
self.pf = frb.pf
self.xlim = viewer.xlim
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -19,11 +19,6 @@
from _mpl_imports import FigureCanvasAgg
from yt.utilities.logger import ytLogger as mylog
-from yt.utilities.definitions import \
- x_dict, x_names, \
- y_dict, y_names, \
- axis_names, \
- axis_labels
from .plot_window import PlotWindow
from .profile_plotter import PhasePlot
from .plot_modifications import get_smallest_appropriate_unit
@@ -296,6 +291,7 @@
_yrange = (0, width * plot.pf[units])
_xlog = False
_ylog = False
+ axis_names = plot.pf.coordinates.axis_name
if bare_axes:
_xlabel = ""
_ylabel = ""
@@ -305,14 +301,16 @@
_xlabel = xlabel
else:
if data.axis != 4:
- _xlabel = '%s (%s)' % (x_names[data.axis], units)
+ xax = plot.pf.coordinates.x_axis[data.axis]
+ _xlabel = '%s (%s)' % (axis_names[xax], units)
else:
_xlabel = 'Image x (%s)' % (units)
if ylabel != None:
_ylabel = ylabel
else:
if data.axis != 4:
- _ylabel = '%s (%s)' % (y_names[data.axis], units)
+ yax = plot.pf.coordinatesyx_axis[data.axis]
+ _ylabel = '%s (%s)' % (axis_names[yax], units)
else:
_ylabel = 'Image y (%s)' % (units)
if tickcolor == None:
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -14,10 +14,6 @@
#-----------------------------------------------------------------------------
from yt.funcs import *
-from yt.utilities.definitions import \
- x_dict, \
- y_dict, \
- axis_names
from .volume_rendering.api import off_axis_projection
from yt.data_objects.image_array import ImageArray
from yt.utilities.lib.misc_utilities import \
@@ -104,8 +100,8 @@
DRE = self.pf.domain_right_edge
DD = float(self.periodic)*(DRE - DLE)
axis = self.data_source.axis
- xax = x_dict[axis]
- yax = y_dict[axis]
+ xax = self.pf.coordinates.x_axis[axis]
+ yax = self.pf.coordinates.y_axis[axis]
self._period = (DD[xax], DD[yax])
self._edges = ( (DLE[xax], DRE[xax]), (DLE[yax], DRE[yax]) )
@@ -334,10 +330,10 @@
@property
def limits(self):
rv = dict(x = None, y = None, z = None)
- xax = x_dict[self.axis]
- yax = y_dict[self.axis]
- xn = axis_names[xax]
- yn = axis_names[yax]
+ xax = self.pf.coordinates.x_axis[self.axis]
+ yax = self.pf.coordinates.y_axis[self.axis]
+ xn = self.pf.coordinates.axis_name[xax]
+ yn = self.pf.coordinates.axis_name[yax]
rv[xn] = (self.bounds[0], self.bounds[1])
rv[yn] = (self.bounds[2], self.bounds[3])
return rv
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/image_panner/vm_panner.py
--- a/yt/visualization/image_panner/vm_panner.py
+++ b/yt/visualization/image_panner/vm_panner.py
@@ -19,8 +19,6 @@
FixedResolutionBuffer, ObliqueFixedResolutionBuffer
from yt.data_objects.data_containers import \
data_object_registry
-from yt.utilities.definitions import \
- x_dict, y_dict
from yt.funcs import *
class VariableMeshPanner(object):
@@ -62,7 +60,8 @@
if not hasattr(self, 'pf'): self.pf = self.source.pf
DLE, DRE = self.pf.domain_left_edge, self.pf.domain_right_edge
ax = self.source.axis
- xax, yax = x_dict[ax], y_dict[ax]
+ xax = self.pf.coordinates.x_axis[ax]
+ yax = self.pf.coordinates.y_axis[ax]
xbounds = DLE[xax], DRE[xax]
ybounds = DLE[yax], DRE[yax]
return (xbounds, ybounds)
@@ -183,8 +182,10 @@
if len(center) == 2:
centerx, centery = center
elif len(center) == 3:
- centerx = center[x_dict[self.source.axis]]
- centery = center[y_dict[self.source.axis]]
+ xax = self.pf.coordinates.x_axis[self.source.axis]
+ yax = self.pf.coordinates.y_axis[self.source.axis]
+ centerx = center[xax]
+ centery = center[yax]
else:
raise RuntimeError
Wx, Wy = self.width
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -17,7 +17,6 @@
from yt.funcs import \
defaultdict, get_image_suffix, \
get_ipython_api_version
-from yt.utilities.definitions import axis_names
from yt.utilities.exceptions import \
YTNotInsideNotebook
from ._mpl_imports import FigureCanvasAgg
@@ -424,7 +423,8 @@
for k, v in self.plots.iteritems():
names.append(v.save(name, mpl_kwargs))
return names
- axis = axis_names[self.data_source.axis]
+ axis = self.pf.coordinates.axis_name.get(
+ self.data_source.axis, '')
weight = None
type = self._plot_type
if type in ['Projection', 'OffAxisProjection']:
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -18,11 +18,6 @@
from yt.funcs import *
from _mpl_imports import *
-from yt.utilities.definitions import \
- x_dict, x_names, \
- y_dict, y_names, \
- axis_names, \
- axis_labels
from yt.utilities.physical_constants import \
sec_per_Gyr, sec_per_Myr, \
sec_per_kyr, sec_per_year, \
@@ -115,13 +110,17 @@
"cutting_plane_velocity_y",
self.factor)
else:
- xv = "velocity_%s" % (x_names[plot.data.axis])
- yv = "velocity_%s" % (y_names[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ axis_names = plot.data.pf.coordinates.axis_name
+ xv = "velocity_%s" % (axis_names[xi])
+ yv = "velocity_%s" % (axis_names[yi])
bv = plot.data.get_field_parameter("bulk_velocity")
if bv is not None:
- bv_x = bv[x_dict[plot.data.axis]]
- bv_y = bv[y_dict[plot.data.axis]]
+ bv_x = bv[xi]
+ bv_y = bv[yi]
else: bv_x = bv_y = YTQuantity(0, 'cm/s')
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
@@ -156,8 +155,11 @@
"cutting_plane_by",
self.factor)
else:
- xv = "magnetic_field_%s" % (x_names[plot.data.axis])
- yv = "magnetic_field_%s" % (y_names[plot.data.axis])
+ xax = plot.data.pf.coordinates.x_axis[plot.data.axis]
+ yax = plot.data.pf.coordinates.y_axis[plot.data.axis]
+ axis_names = plot.data.pf.coordinates.axis_name
+ xv = "magnetic_field_%s" % (axis_names[xax])
+ yv = "magnetic_field_%s" % (axis_names[yax])
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale, scale_units=self.scale_units, normalize=self.normalize)
return qcb(plot)
@@ -194,8 +196,10 @@
# periodicity
ax = plot.data.axis
pf = plot.data.pf
- period_x = pf.domain_width[x_dict[ax]]
- period_y = pf.domain_width[y_dict[ax]]
+ (xi, yi) = (pf.coordinates.x_axis[ax],
+ pf.coordinates.y_axis[ax])
+ period_x = pf.domain_width[xi]
+ period_y = pf.domain_width[yi]
periodic = int(any(pf.periodicity))
fv_x = plot.data[self.field_x]
if self.bv_x != 0.0:
@@ -384,8 +388,9 @@
yy0, yy1 = plot._axes.get_ylim()
(dx, dy) = self.pixel_scale(plot)
(xpix, ypix) = plot.image._A.shape
- px_index = x_dict[plot.data.axis]
- py_index = y_dict[plot.data.axis]
+ ax = plot.data.axis
+ px_index = plot.data.pf.coordinates.x_axis[ax]
+ py_index = plot.data.pf.coordinates.y_axis[ax]
DW = plot.data.pf.domain_width
if self.periodic:
pxs, pys = np.mgrid[-1:1:3j,-1:1:3j]
@@ -650,11 +655,12 @@
plot._axes.hold(True)
- px_index = x_dict[plot.data.axis]
- py_index = y_dict[plot.data.axis]
+ ax = plot.data.axis
+ px_index = plot.data.pf.coordinates.x_axis[ax]
+ py_index = plot.data.pf.coordinates.y_axis[ax]
- xf = axis_names[px_index]
- yf = axis_names[py_index]
+ xf = plot.data.pf.coordinates.axis_name[px_index]
+ yf = plot.data.pf.coordinates.axis_name[py_index]
dxf = "d%s" % xf
dyf = "d%s" % yf
@@ -701,8 +707,10 @@
def __call__(self, plot):
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
if isinstance(self.code_size[1], basestring):
code_size = plot.data.pf.quan(*self.code_size).value
@@ -732,8 +740,10 @@
def __call__(self, plot):
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
width,height = plot.image._A.shape
x,y = self.convert_to_plot(plot, pos)
@@ -758,8 +768,10 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
elif len(self.pos) == 2:
pos = self.pos
x,y = self.convert_to_plot(plot, pos)
@@ -802,7 +814,9 @@
if plot.data.axis == 4:
(xi, yi) = (0, 1)
else:
- (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
(center_x,center_y) = self.convert_to_plot(plot,(self.center[xi], self.center[yi]))
@@ -853,7 +867,9 @@
radius = halo.maximum_radius() * self.pixel_scale(plot)[0]
center = halo.center_of_mass()
- (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
(center_x,center_y) = self.convert_to_plot(plot,(center[xi], center[yi]))
color = np.ones(3) * (0.4 * (num - halo.id)/ num) + 0.6
@@ -892,7 +908,10 @@
def __call__(self,plot):
(dx,dy) = self.pixel_scale(plot)
- (xi, yi) = (x_names[plot.data.axis], y_names[plot.data.axis])
+ xax = plot.data.pf.coordinates.x_axis[plot.data.axis]
+ yax = plot.data.pf.coordinates.y_axis[plot.data.axis]
+ axis_names = plot.data.pf.coordinates.axis_name
+ (xi, yi) = (axis_names[xax], axis_names[yax])
# now we loop over the haloes
for halo in self.hop_output[:self.max_number]:
@@ -940,8 +959,10 @@
kwargs = self.text_args.copy()
if self.data_coords and len(plot.image._A.shape) == 2:
if len(self.pos) == 3:
- pos = (self.pos[x_dict[plot.data.axis]],
- self.pos[y_dict[plot.data.axis]])
+ ax = plot.data.axis
+ (xi, yi) = (plot.data.pf.coordinates.x_axis[ax],
+ plot.data.pf.coordinates.y_axis[ax])
+ pos = self.pos[xi], self.pos[yi]
else: pos = self.pos
x,y = self.convert_to_plot(plot, pos)
else:
@@ -992,8 +1013,12 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
reg = self._get_region((x0,x1), (y0,y1), plot.data.axis, data)
- field_x = "particle_position_%s" % axis_names[x_dict[data.axis]]
- field_y = "particle_position_%s" % axis_names[y_dict[data.axis]]
+ ax = data.axis
+ xax = plot.data.pf.coordinates.x_axis[ax]
+ yax = plot.data.pf.coordinates.y_axis[ax]
+ axis_names = plot.data.pf.coordinates.axis_name
+ field_x = "particle_position_%s" % axis_names[xax]
+ field_y = "particle_position_%s" % axis_names[yax]
gg = ( ( reg[field_x] >= x0 ) & ( reg[field_x] <= x1 )
& ( reg[field_y] >= y0 ) & ( reg[field_y] <= y1 ) )
if self.ptype is not None:
@@ -1021,8 +1046,9 @@
def _get_region(self, xlim, ylim, axis, data):
LE, RE = [None]*3, [None]*3
- xax = x_dict[axis]
- yax = y_dict[axis]
+ pf = data.pf
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
zax = axis
LE[xax], RE[xax] = xlim
LE[yax], RE[yax] = ylim
@@ -1240,7 +1266,9 @@
def __call__(self, plot):
plot._axes.hold(True)
- xax, yax = x_dict[plot.data.axis], y_dict[plot.data.axis]
+ ax = data.axis
+ xax = plot.data.pf.coordinates.x_axis[ax]
+ yax = plot.data.pf.coordinates.y_axis[ax]
l_cy = triangle_plane_intersect(plot.data.axis, plot.data.coord, self.vertices)[:,:,(xax, yax)]
lc = matplotlib.collections.LineCollection(l_cy, **self.plot_args)
plot._axes.add_collection(lc)
diff -r a52509219135faa377fcbefdff695c70a0d3de7f -r 3cb702b86a173b0c5165ee771e674bde9e850a82 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -43,8 +43,6 @@
from yt.utilities.png_writer import \
write_png_to_string
from yt.utilities.definitions import \
- x_dict, y_dict, \
- axis_names, axis_labels, \
formatted_length_unit_names
from yt.utilities.math_utils import \
ortho_find
@@ -108,7 +106,9 @@
if width is None:
# Default to code units
if not iterable(axis):
- w = pf.domain_width[[x_dict[axis], y_dict[axis]]]
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
+ w = pf.domain_width[[xax, yax]]
else:
# axis is actually the normal vector
# for an off-axis data object.
@@ -189,10 +189,12 @@
center[2] = 0.0
else:
raise NotImplementedError
- bounds = (center[x_dict[axis]]-width[0] / 2,
- center[x_dict[axis]]+width[0] / 2,
- center[y_dict[axis]]-width[1] / 2,
- center[y_dict[axis]]+width[1] / 2)
+ xax = pf.coordinates.x_axis[axis]
+ yax = pf.coordinates.y_axis[axis]
+ bounds = (center[xax]-width[0] / 2,
+ center[xax]+width[0] / 2,
+ center[yax]-width[1] / 2,
+ center[yax]+width[1] / 2)
return (bounds, center)
def get_oblique_window_parameters(normal, center, width, pf, depth=None):
@@ -672,10 +674,12 @@
xllim, xrlim = self.xlim
yllim, yrlim = self.ylim
elif origin[2] == 'domain':
- xllim = self.pf.domain_left_edge[x_dict[axis_index]]
- xrlim = self.pf.domain_right_edge[x_dict[axis_index]]
- yllim = self.pf.domain_left_edge[y_dict[axis_index]]
- yrlim = self.pf.domain_right_edge[y_dict[axis_index]]
+ xax = pf.coordinates.x_axis[axis_index]
+ yax = pf.coordinates.y_axis[axis_index]
+ xllim = self.pf.domain_left_edge[xax]
+ xrlim = self.pf.domain_right_edge[xax]
+ yllim = self.pf.domain_left_edge[yax]
+ yrlim = self.pf.domain_right_edge[yax]
elif origin[2] == 'native':
return (self.pf.quan(0.0, 'code_length'),
self.pf.quan(0.0, 'code_length'))
@@ -806,8 +810,11 @@
labels = [r'$\rm{Image\/x'+axes_unit_labels[0]+'}$',
r'$\rm{Image\/y'+axes_unit_labels[1]+'}$']
else:
- labels = [r'$\rm{'+axis_labels[axis_index][i]+
- axes_unit_labels[i] + r'}$' for i in (0,1)]
+ axis_names = self.pf.coordinates.axis_name
+ xax = self.pf.coordinates.x_axis[axis_index]
+ yax = self.pf.coordinates.y_axis[axis_index]
+ labels = [r'$\rm{'+axis_names[xax]+axes_unit_labels[0] + r'}$',
+ r'$\rm{'+axis_names[yax]+axes_unit_labels[1] + r'}$']
self.plots[f].axes.set_xlabel(labels[0],fontproperties=fp)
self.plots[f].axes.set_ylabel(labels[1],fontproperties=fp)
@@ -988,7 +995,7 @@
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
- axis = fix_axis(axis)
+ axis = fix_axis(axis, pf)
(bounds, center) = get_window_parameters(axis, center, width, pf)
if field_parameters is None: field_parameters = {}
slc = pf.slice(axis, center[axis],
@@ -1114,7 +1121,7 @@
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
- axis = fix_axis(axis)
+ axis = fix_axis(axis, pf)
(bounds, center) = get_window_parameters(axis, center, width, pf)
if field_parameters is None: field_parameters = {}
proj = pf.proj(fields, axis, weight_field=weight_field,
@@ -1444,8 +1451,11 @@
self._frb.bounds, (nx,ny))
axis = self._frb.data_source.axis
- fx = "%s-velocity" % (axis_names[x_dict[axis]])
- fy = "%s-velocity" % (axis_names[y_dict[axis]])
+ xax = self._frb.data_source.pf.coordinates.x_axis[axis]
+ yax = self._frb.data_source.pf.coordinates.y_axis[axis]
+ axis_names = self._frb.data_source.pf.coordinates.axis_name
+ fx = "velocity_%s" % (axis_names[xax])
+ fy = "velocity_%x" % (axis_names[yax])
px = new_frb[fx][::-1,:]
py = new_frb[fy][::-1,:]
x = np.mgrid[0:vi-1:ny*1j]
@@ -1529,12 +1539,14 @@
unit = self._axes_unit_names
units = self.get_field_units(field, strip_mathml)
center = getattr(self._frb.data_source, "center", None)
+ xax = self.pf.coordinates.x_axis[self._frb.axis]
+ yax = self.pf.coordinates.y_axis[self._frb.axis]
if center is None or self._frb.axis == 4:
xc, yc, zc = -999, -999, -999
else:
- center[x_dict[self._frb.axis]] = 0.5 * (
+ center[xax] = 0.5 * (
self.xlim[0] + self.xlim[1])
- center[y_dict[self._frb.axis]] = 0.5 * (
+ center[yax] = 0.5 * (
self.ylim[0] + self.ylim[1])
xc, yc, zc = center
if return_string:
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