[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 3 08:45:43 PDT 2017
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/334f8eb71f41/
Changeset: 334f8eb71f41
User: jzuhone
Date: 2017-07-31 16:45:57+00:00
Summary: An attempt to incorporate fixed resolution rays into region expression
Affected #: 1 file
diff -r 995dd2a4b31cc288938fb9dc62faf5e79628dfe8 -r 334f8eb71f41398d9c934a1835ff6349fea0ab3e yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -17,6 +17,7 @@
from yt.funcs import obj_length
from yt.units.yt_array import YTQuantity
from yt.utilities.exceptions import YTDimensionalityError
+from yt.visualization.line_plot import LineBuffer
class RegionExpression(object):
_all_data = None
@@ -155,23 +156,42 @@
def _create_ray(self, ray_slice):
start_point = [self._spec_to_value(v) for v in ray_slice.start]
end_point = [self._spec_to_value(v) for v in ray_slice.stop]
- return self.ds.ray(start_point, end_point)
+ if getattr(ray_slice.step, "imag", 0.0) != 0.0:
+ return LineBuffer(self.ds, start_point, end_point, ray_slice.step)
+ else:
+ return self.ds.ray(start_point, end_point)
def _create_ortho_ray(self, ray_tuple):
axis = None
new_slice = []
coord = []
+ npoints = 0
+ start_point = []
+ end_point = []
for ax, v in enumerate(ray_tuple):
if not isinstance(v, slice):
- coord.append(self._spec_to_value(v))
+ val = self._spec_to_value(v)
+ coord.append(val)
new_slice.append(slice(None, None, None))
+ start_point.append(val)
+ end_point.append(val)
else:
if axis is not None: raise RuntimeError
- axis = ax
- new_slice.append(v)
- if axis == 1: coord = [coord[1], coord[0]]
- source = self._create_region(new_slice)
- ray = self.ds.ortho_ray(axis, coord, data_source=source)
- if getattr(new_slice[axis].step, "imag", 0.0) != 0.0:
- raise NotImplementedError
+ if getattr(v.step, "imag", 0.0) != 0.0:
+ npoints = new_slice[axis].step
+ xi = self._spec_to_value(v.start)
+ xf = self._spec_to_value(v.stop)
+ dx = (xf-xi)/npoints
+ start_point.append(xi+0.5*dx)
+ end_point.append(xf-0.5*dx)
+ else:
+ axis = ax
+ new_slice.append(v)
+ if npoints > 0:
+ ray = LineBuffer(self.ds, start_point, end_point, npoints)
+ else:
+ if axis == 1:
+ coord = [coord[1], coord[0]]
+ source = self._create_region(new_slice)
+ ray = self.ds.ortho_ray(axis, coord, data_source=source)
return ray
\ No newline at end of file
https://bitbucket.org/yt_analysis/yt/commits/cf4ba33b999b/
Changeset: cf4ba33b999b
User: jzuhone
Date: 2017-07-31 20:56:46+00:00
Summary: Get this to the right type
Affected #: 1 file
diff -r 334f8eb71f41398d9c934a1835ff6349fea0ab3e -r cf4ba33b999bfc0f2976060ff372aac8a9edbec8 yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -178,7 +178,7 @@
else:
if axis is not None: raise RuntimeError
if getattr(v.step, "imag", 0.0) != 0.0:
- npoints = new_slice[axis].step
+ npoints = int(v.step.imag)
xi = self._spec_to_value(v.start)
xf = self._spec_to_value(v.stop)
dx = (xf-xi)/npoints
https://bitbucket.org/yt_analysis/yt/commits/513ae0bd37a1/
Changeset: 513ae0bd37a1
User: jzuhone
Date: 2017-07-31 21:01:59+00:00
Summary: Get this into the correct type here
Affected #: 1 file
diff -r cf4ba33b999bfc0f2976060ff372aac8a9edbec8 -r 513ae0bd37a1781712186e4f0a4666f29f8338fe yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -157,7 +157,8 @@
start_point = [self._spec_to_value(v) for v in ray_slice.start]
end_point = [self._spec_to_value(v) for v in ray_slice.stop]
if getattr(ray_slice.step, "imag", 0.0) != 0.0:
- return LineBuffer(self.ds, start_point, end_point, ray_slice.step)
+ return LineBuffer(self.ds, start_point, end_point,
+ int(ray_slice.step.imag))
else:
return self.ds.ray(start_point, end_point)
https://bitbucket.org/yt_analysis/yt/commits/18238d28dc3a/
Changeset: 18238d28dc3a
User: jzuhone
Date: 2017-08-01 13:27:50+00:00
Summary: Adding tests
Affected #: 1 file
diff -r 513ae0bd37a1781712186e4f0a4666f29f8338fe -r 18238d28dc3a7437e81b9f121f8e65ddfe33700e yt/data_objects/tests/test_dataset_access.py
--- a/yt/data_objects/tests/test_dataset_access.py
+++ b/yt/data_objects/tests/test_dataset_access.py
@@ -8,6 +8,8 @@
requires_file
from yt.utilities.answer_testing.framework import \
data_dir_load
+from yt.visualization.line_plot import \
+ LineBuffer
# This will test the "dataset access" method.
@@ -111,6 +113,10 @@
ray6 = ds.ray(start_arr, end_arr)
assert_equal(ray5["density"], ray6["density"])
+ ray7 = ds.r[start:end:500j]
+ ray8 = LineBuffer(ds, [0.1, 0.2, 0.3], [0.5, 0.4, 0.6], 500)
+ assert_equal(ray7["density"], ray8["density"])
+
def test_ortho_ray_from_r():
ds = fake_amr_ds(fields = ["density"])
ray1 = ds.r[:,0.3,0.2]
@@ -128,6 +134,11 @@
ray6 = ds.ortho_ray("x", [0.3, 0.2], data_source=box)
assert_equal(ray5["density"], ray6["density"])
+ # Test fixed-resolution rays
+ ray7 = ds.r[0.25:0.75:100j,0.3,0.2]
+ ray8 = LineBuffer(ds, [0.2525,0.3,0.2], [0.7475,0.3,0.2], 100)
+ assert_equal(ray7["density"], ray8["density"])
+
def test_particle_counts():
ds = fake_random_ds(16, particles=100)
assert ds.particle_type_counts == {'io': 100}
https://bitbucket.org/yt_analysis/yt/commits/0a6764db523a/
Changeset: 0a6764db523a
User: jzuhone
Date: 2017-08-01 21:42:39+00:00
Summary: Add documentation
Affected #: 1 file
diff -r 18238d28dc3a7437e81b9f121f8e65ddfe33700e -r 0a6764db523a57c6f4d50f298ad675f06adc8d93 doc/source/analyzing/objects.rst
--- a/doc/source/analyzing/objects.rst
+++ b/doc/source/analyzing/objects.rst
@@ -235,6 +235,21 @@
end = ((1.0, "Mpc"), (300.0, "kpc"), (0.0, "kpc"))
ray = ds.r[start:end]
+Making Fixed-Resolution Rays
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Rays can also be constructed to have fixed resolution if an imaginary step value
+is provided, similar to the 2 and 3-dimensional cases described above. This
+works for rays directed along an axis:::
+
+ ortho_ray = ds.r[(0.1:0.6:500j,0.3,0.2]
+
+or off-axis rays as well:::
+
+ start = [0.1, 0.2, 0.3] # interpreted in code_length
+ end = [0.4, 0.5, 0.6] # interpreted in code_length
+ ray = ds.r[start:end:100j]
+
Selecting Points
^^^^^^^^^^^^^^^^
https://bitbucket.org/yt_analysis/yt/commits/73d27659e3b2/
Changeset: 73d27659e3b2
User: ngoldbaum
Date: 2017-08-03 15:45:30+00:00
Summary: Merge pull request #1518 from jzuhone/ds_r_lines
Create fixed-resolution rays from region expression
Affected #: 3 files
diff -r ddc31ebe5adffb3921a8e2cef50cf8d8cb0516ed -r 73d27659e3b280ec7f665210eb712704c6f698b9 doc/source/analyzing/objects.rst
--- a/doc/source/analyzing/objects.rst
+++ b/doc/source/analyzing/objects.rst
@@ -235,6 +235,21 @@
end = ((1.0, "Mpc"), (300.0, "kpc"), (0.0, "kpc"))
ray = ds.r[start:end]
+Making Fixed-Resolution Rays
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Rays can also be constructed to have fixed resolution if an imaginary step value
+is provided, similar to the 2 and 3-dimensional cases described above. This
+works for rays directed along an axis:::
+
+ ortho_ray = ds.r[(0.1:0.6:500j,0.3,0.2]
+
+or off-axis rays as well:::
+
+ start = [0.1, 0.2, 0.3] # interpreted in code_length
+ end = [0.4, 0.5, 0.6] # interpreted in code_length
+ ray = ds.r[start:end:100j]
+
Selecting Points
^^^^^^^^^^^^^^^^
diff -r ddc31ebe5adffb3921a8e2cef50cf8d8cb0516ed -r 73d27659e3b280ec7f665210eb712704c6f698b9 yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -17,6 +17,7 @@
from yt.funcs import obj_length
from yt.units.yt_array import YTQuantity
from yt.utilities.exceptions import YTDimensionalityError
+from yt.visualization.line_plot import LineBuffer
class RegionExpression(object):
_all_data = None
@@ -155,23 +156,43 @@
def _create_ray(self, ray_slice):
start_point = [self._spec_to_value(v) for v in ray_slice.start]
end_point = [self._spec_to_value(v) for v in ray_slice.stop]
- return self.ds.ray(start_point, end_point)
+ if getattr(ray_slice.step, "imag", 0.0) != 0.0:
+ return LineBuffer(self.ds, start_point, end_point,
+ int(ray_slice.step.imag))
+ else:
+ return self.ds.ray(start_point, end_point)
def _create_ortho_ray(self, ray_tuple):
axis = None
new_slice = []
coord = []
+ npoints = 0
+ start_point = []
+ end_point = []
for ax, v in enumerate(ray_tuple):
if not isinstance(v, slice):
- coord.append(self._spec_to_value(v))
+ val = self._spec_to_value(v)
+ coord.append(val)
new_slice.append(slice(None, None, None))
+ start_point.append(val)
+ end_point.append(val)
else:
if axis is not None: raise RuntimeError
- axis = ax
- new_slice.append(v)
- if axis == 1: coord = [coord[1], coord[0]]
- source = self._create_region(new_slice)
- ray = self.ds.ortho_ray(axis, coord, data_source=source)
- if getattr(new_slice[axis].step, "imag", 0.0) != 0.0:
- raise NotImplementedError
+ if getattr(v.step, "imag", 0.0) != 0.0:
+ npoints = int(v.step.imag)
+ xi = self._spec_to_value(v.start)
+ xf = self._spec_to_value(v.stop)
+ dx = (xf-xi)/npoints
+ start_point.append(xi+0.5*dx)
+ end_point.append(xf-0.5*dx)
+ else:
+ axis = ax
+ new_slice.append(v)
+ if npoints > 0:
+ ray = LineBuffer(self.ds, start_point, end_point, npoints)
+ else:
+ if axis == 1:
+ coord = [coord[1], coord[0]]
+ source = self._create_region(new_slice)
+ ray = self.ds.ortho_ray(axis, coord, data_source=source)
return ray
\ No newline at end of file
diff -r ddc31ebe5adffb3921a8e2cef50cf8d8cb0516ed -r 73d27659e3b280ec7f665210eb712704c6f698b9 yt/data_objects/tests/test_dataset_access.py
--- a/yt/data_objects/tests/test_dataset_access.py
+++ b/yt/data_objects/tests/test_dataset_access.py
@@ -8,6 +8,8 @@
requires_file
from yt.utilities.answer_testing.framework import \
data_dir_load
+from yt.visualization.line_plot import \
+ LineBuffer
# This will test the "dataset access" method.
@@ -111,6 +113,10 @@
ray6 = ds.ray(start_arr, end_arr)
assert_equal(ray5["density"], ray6["density"])
+ ray7 = ds.r[start:end:500j]
+ ray8 = LineBuffer(ds, [0.1, 0.2, 0.3], [0.5, 0.4, 0.6], 500)
+ assert_equal(ray7["density"], ray8["density"])
+
def test_ortho_ray_from_r():
ds = fake_amr_ds(fields = ["density"])
ray1 = ds.r[:,0.3,0.2]
@@ -128,6 +134,11 @@
ray6 = ds.ortho_ray("x", [0.3, 0.2], data_source=box)
assert_equal(ray5["density"], ray6["density"])
+ # Test fixed-resolution rays
+ ray7 = ds.r[0.25:0.75:100j,0.3,0.2]
+ ray8 = LineBuffer(ds, [0.2525,0.3,0.2], [0.7475,0.3,0.2], 100)
+ assert_equal(ray7["density"], ray8["density"])
+
def test_particle_counts():
ds = fake_random_ds(16, particles=100)
assert ds.particle_type_counts == {'io': 100}
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