[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Jan 6 10:06:38 PST 2014
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/fda9638d4694/
Changeset: fda9638d4694
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-21 22:14:25
Summary: Adding a fake_amr_pf function based on IsolatedGalaxy.
Affected #: 1 file
diff -r 38fff02747cadf3674047f662f325756143dd225 -r fda9638d4694459616e5822ab44fa14f1bacb817 yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -159,6 +159,20 @@
ug = load_uniform_grid(data, ndims, 1.0, nprocs = nprocs)
return ug
+def fake_amr_pf(fields = ("Density",)):
+ from yt.frontends.stream.api import load_amr_grids
+ data = []
+ for gspec in _amr_grid_hierarchy:
+ level, left_edge, right_edge, dims = gspec
+ gdata = dict(level = level,
+ left_edge = left_edge,
+ right_edge = right_edge,
+ dimensions = dims)
+ for f in fields:
+ gdata[f] = np.random.random(dims)
+ data.append(gdata)
+ return load_amr_grids(data, [32, 32, 32], 1.0)
+
def expand_keywords(keywords, full=False):
"""
expand_keywords is a means for testing all possible keyword
@@ -289,3 +303,207 @@
else:
return ffalse
+# This is an export of the 40 grids in IsolatedGalaxy that are of level 4 or
+# lower. It's just designed to give a sample AMR hierarchy to deal with.
+_amr_grid_hierarchy = [
+ [ 0,
+ [0.0,0.0,0.0],
+ [1.0,1.0,1.0],
+ [32,32,32],
+ ],
+ [ 1,
+ [0.25,0.21875,0.25],
+ [0.5,0.5,0.5],
+ [16,18,16],
+ ],
+ [ 1,
+ [0.5,0.21875,0.25],
+ [0.75,0.5,0.5],
+ [16,18,16],
+ ],
+ [ 1,
+ [0.21875,0.5,0.25],
+ [0.5,0.75,0.5],
+ [18,16,16],
+ ],
+ [ 1,
+ [0.5,0.5,0.25],
+ [0.75,0.75,0.5],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.25,0.25,0.5],
+ [0.5,0.5,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.5,0.25,0.5],
+ [0.75,0.5,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.25,0.5,0.5],
+ [0.5,0.75,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.5,0.5,0.5],
+ [0.75,0.75,0.75],
+ [16,16,16],
+ ],
+ [ 2,
+ [0.5,0.5,0.5],
+ [0.71875,0.71875,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.5,0.5],
+ [0.6640625,0.65625,0.6796875],
+ [42,40,46],
+ ],
+ [ 4,
+ [0.5,0.5,0.5],
+ [0.59765625,0.6015625,0.6015625],
+ [50,52,52],
+ ],
+ [ 2,
+ [0.28125,0.5,0.5],
+ [0.5,0.734375,0.71875],
+ [28,30,28],
+ ],
+ [ 3,
+ [0.3359375,0.5,0.5],
+ [0.5,0.671875,0.6640625],
+ [42,44,42],
+ ],
+ [ 4,
+ [0.40625,0.5,0.5],
+ [0.5,0.59765625,0.59765625],
+ [48,50,50],
+ ],
+ [ 2,
+ [0.5,0.28125,0.5],
+ [0.71875,0.5,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.3359375,0.5],
+ [0.671875,0.5,0.6640625],
+ [44,42,42],
+ ],
+ [ 4,
+ [0.5,0.40625,0.5],
+ [0.6015625,0.5,0.59765625],
+ [52,48,50],
+ ],
+ [ 2,
+ [0.28125,0.28125,0.5],
+ [0.5,0.5,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.3359375,0.3359375,0.5],
+ [0.5,0.5,0.671875],
+ [42,42,44],
+ ],
+ [ 4,
+ [0.46484375,0.37890625,0.50390625],
+ [0.4765625,0.390625,0.515625],
+ [6,6,6],
+ ],
+ [ 4,
+ [0.40625,0.40625,0.5],
+ [0.5,0.5,0.59765625],
+ [48,48,50],
+ ],
+ [ 2,
+ [0.5,0.5,0.28125],
+ [0.71875,0.71875,0.5],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.5,0.3359375],
+ [0.6796875,0.6953125,0.5],
+ [46,50,42],
+ ],
+ [ 4,
+ [0.5,0.5,0.40234375],
+ [0.59375,0.6015625,0.5],
+ [48,52,50],
+ ],
+ [ 2,
+ [0.265625,0.5,0.28125],
+ [0.5,0.71875,0.5],
+ [30,28,28],
+ ],
+ [ 3,
+ [0.3359375,0.5,0.328125],
+ [0.5,0.65625,0.5],
+ [42,40,44],
+ ],
+ [ 4,
+ [0.40234375,0.5,0.40625],
+ [0.5,0.60546875,0.5],
+ [50,54,48],
+ ],
+ [ 2,
+ [0.5,0.265625,0.28125],
+ [0.71875,0.5,0.5],
+ [28,30,28],
+ ],
+ [ 3,
+ [0.5,0.3203125,0.328125],
+ [0.6640625,0.5,0.5],
+ [42,46,44],
+ ],
+ [ 4,
+ [0.5,0.3984375,0.40625],
+ [0.546875,0.5,0.5],
+ [24,52,48],
+ ],
+ [ 4,
+ [0.546875,0.41796875,0.4453125],
+ [0.5625,0.4375,0.5],
+ [8,10,28],
+ ],
+ [ 4,
+ [0.546875,0.453125,0.41796875],
+ [0.5546875,0.48046875,0.4375],
+ [4,14,10],
+ ],
+ [ 4,
+ [0.546875,0.4375,0.4375],
+ [0.609375,0.5,0.5],
+ [32,32,32],
+ ],
+ [ 4,
+ [0.546875,0.4921875,0.41796875],
+ [0.56640625,0.5,0.4375],
+ [10,4,10],
+ ],
+ [ 4,
+ [0.546875,0.48046875,0.41796875],
+ [0.5703125,0.4921875,0.4375],
+ [12,6,10],
+ ],
+ [ 4,
+ [0.55859375,0.46875,0.43359375],
+ [0.5703125,0.48046875,0.4375],
+ [6,6,2],
+ ],
+ [ 2,
+ [0.265625,0.28125,0.28125],
+ [0.5,0.5,0.5],
+ [30,28,28],
+ ],
+ [ 3,
+ [0.328125,0.3359375,0.328125],
+ [0.5,0.5,0.5],
+ [44,42,44],
+ ],
+ [ 4,
+ [0.4140625,0.40625,0.40625],
+ [0.5,0.5,0.5],
+ [44,48,48],
+ ],
+]
https://bitbucket.org/yt_analysis/yt/commits/199c8452d803/
Changeset: 199c8452d803
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-21 22:28:39
Summary: Adding first set of callback tests for velocity.
Affected #: 1 file
diff -r fda9638d4694459616e5822ab44fa14f1bacb817 -r 199c8452d803bfa0afec24ad00936137a7f3f2c0 yt/visualization/tests/test_callbacks.py
--- /dev/null
+++ b/yt/visualization/tests/test_callbacks.py
@@ -0,0 +1,74 @@
+"""
+Tests for callbacks
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+import os, tempfile, shutil
+from yt.testing import \
+ fake_amr_pf
+from test_plotwindow import assert_fname
+from yt.visualization.api import \
+ SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+import contextlib
+
+# These are a very simple set of tests that verify that each callback is or is
+# not working. They only check that it functions without an error; they do not
+# check that it is providing correct results.
+
+# These are the callbacks still to test:
+#
+# X velocity
+# magnetic_field
+# quiver
+# contour
+# grids
+# streamlines
+# axis_label
+# units
+# line
+# image_line
+# cquiver
+# clumps
+# arrow
+# point
+# marker
+# sphere
+# hop_circles
+# hop_particles
+# coord_axes
+# text
+# particles
+# title
+# flash_ray_data
+# timestamp
+# material_boundary
+
+ at contextlib.contextmanager
+def _cleanup_fname():
+ tmpdir = tempfile.mkdtemp()
+ yield tmpdir
+ shutil.rmtree(tmpdir)
+
+def test_velocity_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields =
+ ("Density", "x-velocity", "y-velocity", "z-velocity"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
https://bitbucket.org/yt_analysis/yt/commits/fb7f8c192ec4/
Changeset: fb7f8c192ec4
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-22 00:47:24
Summary: Adding tests for magnetic_field, quiver, and contour
Affected #: 1 file
diff -r 199c8452d803bfa0afec24ad00936137a7f3f2c0 -r fb7f8c192ec4a18b9b25124496808076566b7edf yt/visualization/tests/test_callbacks.py
--- a/yt/visualization/tests/test_callbacks.py
+++ b/yt/visualization/tests/test_callbacks.py
@@ -27,9 +27,9 @@
# These are the callbacks still to test:
#
# X velocity
-# magnetic_field
-# quiver
-# contour
+# X magnetic_field
+# X quiver
+# X contour
# grids
# streamlines
# axis_label
@@ -72,3 +72,77 @@
p = SlicePlot(pf, ax, "Density")
p.annotate_velocity()
yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_velocity(factor=8, scale=0.5, scale_units="inches",
+ normalize = True)
+ p.save()
+
+def test_magnetic_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Bx", "By", "Bz"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_magnetic_field(factor=8, scale=0.5,
+ scale_units="inches", normalize = True)
+ p.save()
+
+def test_quiver_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Vx", "Vy"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_quiver("Vx", "Vy", factor=8, scale=0.5,
+ scale_units="inches", normalize = True,
+ bv_x = 0.5, bv_y = 0.5)
+ p.save()
+
+def test_contour_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Temperature"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_contour("Temperature", ncont=10, factor=8,
+ take_log=False, clim=(0.4, 0.6),
+ plot_args={'lw':2.0}, label=True,
+ label_args={'text-size':'x-large'})
+ p.save()
+
+ p = SlicePlot(pf, "x", "Density")
+ s2 = pf.h.slice(0.2, 0)
+ p.annotate_contour("Temperature", ncont=10, factor=8,
+ take_log=False, clim=(0.4, 0.6),
+ plot_args={'lw':2.0}, label=True,
+ label_args={'text-size':'x-large'},
+ data_source=s2)
+ p.save()
https://bitbucket.org/yt_analysis/yt/commits/675f0502e5bd/
Changeset: 675f0502e5bd
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-22 00:53:27
Summary: Adding currently failing grid callback test.
Affected #: 1 file
diff -r fb7f8c192ec4a18b9b25124496808076566b7edf -r 675f0502e5bdbaacfb049e410320ee015cadf18e yt/visualization/tests/test_callbacks.py
--- a/yt/visualization/tests/test_callbacks.py
+++ b/yt/visualization/tests/test_callbacks.py
@@ -139,10 +139,31 @@
p.save()
p = SlicePlot(pf, "x", "Density")
- s2 = pf.h.slice(0.2, 0)
+ s2 = pf.h.slice(0, 0.2)
p.annotate_contour("Temperature", ncont=10, factor=8,
take_log=False, clim=(0.4, 0.6),
plot_args={'lw':2.0}, label=True,
label_args={'text-size':'x-large'},
data_source=s2)
p.save()
+
+def test_grids_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf()
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
+ draw_ids=True, periodic=False, min_level=2,
+ max_level=3, cmap="gist_stern")
+ p.save()
+
https://bitbucket.org/yt_analysis/yt/commits/afd87380e8f1/
Changeset: afd87380e8f1
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-22 01:03:31
Summary: Fixing grid callback.
Affected #: 2 files
diff -r 675f0502e5bdbaacfb049e410320ee015cadf18e -r afd87380e8f1431d0567cacd096df9bac27be30f yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -234,6 +234,10 @@
self.get_data(field)
@property
+ def blocks(self):
+ return self.data_source.blocks
+
+ @property
def _mrep(self):
return MinimalProjectionData(self)
@@ -263,6 +267,7 @@
return convs
def get_data(self, fields = None):
+ fields = fields or []
fields = self._determine_fields(ensure_list(fields))
# We need a new tree for every single set of fields we add
if len(fields) == 0: return
diff -r 675f0502e5bdbaacfb049e410320ee015cadf18e -r afd87380e8f1431d0567cacd096df9bac27be30f yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -366,30 +366,29 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- xi = x_dict[plot.data.axis]
- yi = y_dict[plot.data.axis]
(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]
- dom = plot.data.pf.domain_right_edge - plot.data.pf.domain_left_edge
+ DW = plot.data.pf.domain_width
if self.periodic:
pxs, pys = np.mgrid[-1:1:3j,-1:1:3j]
else:
pxs, pys = np.mgrid[0:0:1j,0:0:1j]
- GLE = plot.data.grid_left_edge
- GRE = plot.data.grid_right_edge
- levels = plot.data.grid_levels[:,0]
- min_level = self.min_level
- max_level = self.max_level
- if max_level is None:
- max_level = plot.data.pf.h.max_level
- if min_level is None:
- min_level = 0
+ GLE, GRE, levels = [], [], []
+ for block, mask in plot.data.blocks:
+ GLE.append(block.LeftEdge)
+ GRE.append(block.RightEdge)
+ levels.append(block.Level)
+ GLE = np.array(GLE)
+ GRE = np.array(GRE)
+ levels = np.array(levels)
+ min_level = self.min_level or 0
+ max_level = self.max_level or levels.max()
for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
- pxo = px_off * dom[px_index]
- pyo = py_off * dom[py_index]
+ pxo = px_off * DW[px_index]
+ pyo = py_off * DW[py_index]
left_edge_x = (GLE[:,px_index]+pxo-x0)*dx + xx0
left_edge_y = (GLE[:,py_index]+pyo-y0)*dy + yy0
right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
https://bitbucket.org/yt_analysis/yt/commits/009bbf295f0a/
Changeset: 009bbf295f0a
Branch: yt-3.0
User: MatthewTurk
Date: 2014-01-06 19:06:31
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #681)
Adding tests for callbacks and updating grid callback
Affected #: 4 files
diff -r bc9faeefee77acc1e0a042b20da35b3bf26b4d82 -r 009bbf295f0a1dcb3a48ecd51c848294fd815992 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -234,6 +234,10 @@
self.get_data(field)
@property
+ def blocks(self):
+ return self.data_source.blocks
+
+ @property
def _mrep(self):
return MinimalProjectionData(self)
@@ -263,6 +267,7 @@
return convs
def get_data(self, fields = None):
+ fields = fields or []
fields = self._determine_fields(ensure_list(fields))
# We need a new tree for every single set of fields we add
if len(fields) == 0: return
diff -r bc9faeefee77acc1e0a042b20da35b3bf26b4d82 -r 009bbf295f0a1dcb3a48ecd51c848294fd815992 yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -166,6 +166,20 @@
ug = load_uniform_grid(data, ndims, 1.0, nprocs = nprocs)
return ug
+def fake_amr_pf(fields = ("Density",)):
+ from yt.frontends.stream.api import load_amr_grids
+ data = []
+ for gspec in _amr_grid_hierarchy:
+ level, left_edge, right_edge, dims = gspec
+ gdata = dict(level = level,
+ left_edge = left_edge,
+ right_edge = right_edge,
+ dimensions = dims)
+ for f in fields:
+ gdata[f] = np.random.random(dims)
+ data.append(gdata)
+ return load_amr_grids(data, [32, 32, 32], 1.0)
+
def expand_keywords(keywords, full=False):
"""
expand_keywords is a means for testing all possible keyword
@@ -296,3 +310,207 @@
else:
return ffalse
+# This is an export of the 40 grids in IsolatedGalaxy that are of level 4 or
+# lower. It's just designed to give a sample AMR hierarchy to deal with.
+_amr_grid_hierarchy = [
+ [ 0,
+ [0.0,0.0,0.0],
+ [1.0,1.0,1.0],
+ [32,32,32],
+ ],
+ [ 1,
+ [0.25,0.21875,0.25],
+ [0.5,0.5,0.5],
+ [16,18,16],
+ ],
+ [ 1,
+ [0.5,0.21875,0.25],
+ [0.75,0.5,0.5],
+ [16,18,16],
+ ],
+ [ 1,
+ [0.21875,0.5,0.25],
+ [0.5,0.75,0.5],
+ [18,16,16],
+ ],
+ [ 1,
+ [0.5,0.5,0.25],
+ [0.75,0.75,0.5],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.25,0.25,0.5],
+ [0.5,0.5,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.5,0.25,0.5],
+ [0.75,0.5,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.25,0.5,0.5],
+ [0.5,0.75,0.75],
+ [16,16,16],
+ ],
+ [ 1,
+ [0.5,0.5,0.5],
+ [0.75,0.75,0.75],
+ [16,16,16],
+ ],
+ [ 2,
+ [0.5,0.5,0.5],
+ [0.71875,0.71875,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.5,0.5],
+ [0.6640625,0.65625,0.6796875],
+ [42,40,46],
+ ],
+ [ 4,
+ [0.5,0.5,0.5],
+ [0.59765625,0.6015625,0.6015625],
+ [50,52,52],
+ ],
+ [ 2,
+ [0.28125,0.5,0.5],
+ [0.5,0.734375,0.71875],
+ [28,30,28],
+ ],
+ [ 3,
+ [0.3359375,0.5,0.5],
+ [0.5,0.671875,0.6640625],
+ [42,44,42],
+ ],
+ [ 4,
+ [0.40625,0.5,0.5],
+ [0.5,0.59765625,0.59765625],
+ [48,50,50],
+ ],
+ [ 2,
+ [0.5,0.28125,0.5],
+ [0.71875,0.5,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.3359375,0.5],
+ [0.671875,0.5,0.6640625],
+ [44,42,42],
+ ],
+ [ 4,
+ [0.5,0.40625,0.5],
+ [0.6015625,0.5,0.59765625],
+ [52,48,50],
+ ],
+ [ 2,
+ [0.28125,0.28125,0.5],
+ [0.5,0.5,0.71875],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.3359375,0.3359375,0.5],
+ [0.5,0.5,0.671875],
+ [42,42,44],
+ ],
+ [ 4,
+ [0.46484375,0.37890625,0.50390625],
+ [0.4765625,0.390625,0.515625],
+ [6,6,6],
+ ],
+ [ 4,
+ [0.40625,0.40625,0.5],
+ [0.5,0.5,0.59765625],
+ [48,48,50],
+ ],
+ [ 2,
+ [0.5,0.5,0.28125],
+ [0.71875,0.71875,0.5],
+ [28,28,28],
+ ],
+ [ 3,
+ [0.5,0.5,0.3359375],
+ [0.6796875,0.6953125,0.5],
+ [46,50,42],
+ ],
+ [ 4,
+ [0.5,0.5,0.40234375],
+ [0.59375,0.6015625,0.5],
+ [48,52,50],
+ ],
+ [ 2,
+ [0.265625,0.5,0.28125],
+ [0.5,0.71875,0.5],
+ [30,28,28],
+ ],
+ [ 3,
+ [0.3359375,0.5,0.328125],
+ [0.5,0.65625,0.5],
+ [42,40,44],
+ ],
+ [ 4,
+ [0.40234375,0.5,0.40625],
+ [0.5,0.60546875,0.5],
+ [50,54,48],
+ ],
+ [ 2,
+ [0.5,0.265625,0.28125],
+ [0.71875,0.5,0.5],
+ [28,30,28],
+ ],
+ [ 3,
+ [0.5,0.3203125,0.328125],
+ [0.6640625,0.5,0.5],
+ [42,46,44],
+ ],
+ [ 4,
+ [0.5,0.3984375,0.40625],
+ [0.546875,0.5,0.5],
+ [24,52,48],
+ ],
+ [ 4,
+ [0.546875,0.41796875,0.4453125],
+ [0.5625,0.4375,0.5],
+ [8,10,28],
+ ],
+ [ 4,
+ [0.546875,0.453125,0.41796875],
+ [0.5546875,0.48046875,0.4375],
+ [4,14,10],
+ ],
+ [ 4,
+ [0.546875,0.4375,0.4375],
+ [0.609375,0.5,0.5],
+ [32,32,32],
+ ],
+ [ 4,
+ [0.546875,0.4921875,0.41796875],
+ [0.56640625,0.5,0.4375],
+ [10,4,10],
+ ],
+ [ 4,
+ [0.546875,0.48046875,0.41796875],
+ [0.5703125,0.4921875,0.4375],
+ [12,6,10],
+ ],
+ [ 4,
+ [0.55859375,0.46875,0.43359375],
+ [0.5703125,0.48046875,0.4375],
+ [6,6,2],
+ ],
+ [ 2,
+ [0.265625,0.28125,0.28125],
+ [0.5,0.5,0.5],
+ [30,28,28],
+ ],
+ [ 3,
+ [0.328125,0.3359375,0.328125],
+ [0.5,0.5,0.5],
+ [44,42,44],
+ ],
+ [ 4,
+ [0.4140625,0.40625,0.40625],
+ [0.5,0.5,0.5],
+ [44,48,48],
+ ],
+]
diff -r bc9faeefee77acc1e0a042b20da35b3bf26b4d82 -r 009bbf295f0a1dcb3a48ecd51c848294fd815992 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -366,30 +366,29 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- xi = x_dict[plot.data.axis]
- yi = y_dict[plot.data.axis]
(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]
- dom = plot.data.pf.domain_right_edge - plot.data.pf.domain_left_edge
+ DW = plot.data.pf.domain_width
if self.periodic:
pxs, pys = np.mgrid[-1:1:3j,-1:1:3j]
else:
pxs, pys = np.mgrid[0:0:1j,0:0:1j]
- GLE = plot.data.grid_left_edge
- GRE = plot.data.grid_right_edge
- levels = plot.data.grid_levels[:,0]
- min_level = self.min_level
- max_level = self.max_level
- if max_level is None:
- max_level = plot.data.pf.h.max_level
- if min_level is None:
- min_level = 0
+ GLE, GRE, levels = [], [], []
+ for block, mask in plot.data.blocks:
+ GLE.append(block.LeftEdge)
+ GRE.append(block.RightEdge)
+ levels.append(block.Level)
+ GLE = np.array(GLE)
+ GRE = np.array(GRE)
+ levels = np.array(levels)
+ min_level = self.min_level or 0
+ max_level = self.max_level or levels.max()
for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
- pxo = px_off * dom[px_index]
- pyo = py_off * dom[py_index]
+ pxo = px_off * DW[px_index]
+ pyo = py_off * DW[py_index]
left_edge_x = (GLE[:,px_index]+pxo-x0)*dx + xx0
left_edge_y = (GLE[:,py_index]+pyo-y0)*dy + yy0
right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
diff -r bc9faeefee77acc1e0a042b20da35b3bf26b4d82 -r 009bbf295f0a1dcb3a48ecd51c848294fd815992 yt/visualization/tests/test_callbacks.py
--- /dev/null
+++ b/yt/visualization/tests/test_callbacks.py
@@ -0,0 +1,169 @@
+"""
+Tests for callbacks
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+import os, tempfile, shutil
+from yt.testing import \
+ fake_amr_pf
+from test_plotwindow import assert_fname
+from yt.visualization.api import \
+ SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+import contextlib
+
+# These are a very simple set of tests that verify that each callback is or is
+# not working. They only check that it functions without an error; they do not
+# check that it is providing correct results.
+
+# These are the callbacks still to test:
+#
+# X velocity
+# X magnetic_field
+# X quiver
+# X contour
+# grids
+# streamlines
+# axis_label
+# units
+# line
+# image_line
+# cquiver
+# clumps
+# arrow
+# point
+# marker
+# sphere
+# hop_circles
+# hop_particles
+# coord_axes
+# text
+# particles
+# title
+# flash_ray_data
+# timestamp
+# material_boundary
+
+ at contextlib.contextmanager
+def _cleanup_fname():
+ tmpdir = tempfile.mkdtemp()
+ yield tmpdir
+ shutil.rmtree(tmpdir)
+
+def test_velocity_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields =
+ ("Density", "x-velocity", "y-velocity", "z-velocity"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_velocity()
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_velocity(factor=8, scale=0.5, scale_units="inches",
+ normalize = True)
+ p.save()
+
+def test_magnetic_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Bx", "By", "Bz"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_magnetic_field()
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_magnetic_field(factor=8, scale=0.5,
+ scale_units="inches", normalize = True)
+ p.save()
+
+def test_quiver_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Vx", "Vy"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_quiver("Vx", "Vy")
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_quiver("Vx", "Vy", factor=8, scale=0.5,
+ scale_units="inches", normalize = True,
+ bv_x = 0.5, bv_y = 0.5)
+ p.save()
+
+def test_contour_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf(fields = ("Density", "Temperature"))
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_contour("Temperature")
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_contour("Temperature", ncont=10, factor=8,
+ take_log=False, clim=(0.4, 0.6),
+ plot_args={'lw':2.0}, label=True,
+ label_args={'text-size':'x-large'})
+ p.save()
+
+ p = SlicePlot(pf, "x", "Density")
+ s2 = pf.h.slice(0, 0.2)
+ p.annotate_contour("Temperature", ncont=10, factor=8,
+ take_log=False, clim=(0.4, 0.6),
+ plot_args={'lw':2.0}, label=True,
+ label_args={'text-size':'x-large'},
+ data_source=s2)
+ p.save()
+
+def test_grids_callback():
+ with _cleanup_fname() as prefix:
+ pf = fake_amr_pf()
+ for ax in 'xyz':
+ p = ProjectionPlot(pf, ax, "Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ p = ProjectionPlot(pf, ax, "Density", weight_field="Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ p = SlicePlot(pf, ax, "Density")
+ p.annotate_grids()
+ yield assert_fname, p.save(prefix)[0]
+ # Now we'll check a few additional minor things
+ p = SlicePlot(pf, "x", "Density")
+ p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
+ draw_ids=True, periodic=False, min_level=2,
+ max_level=3, cmap="gist_stern")
+ p.save()
+
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