[yt-svn] commit/yt: xarthisius: Merged in ngoldbaum/yt (pull request #2564)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Mar 30 06:38:00 PDT 2017
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/3fee41c2ea35/
Changeset: 3fee41c2ea35
Branch: yt
User: xarthisius
Date: 2017-03-30 13:37:52+00:00
Summary: Merged in ngoldbaum/yt (pull request #2564)
Allow negative data in ParticleProfile. Closes #1340
Approved-by: Andrew Myers <atmyers2 at gmail.com>
Approved-by: Suoqing Ji <jisuoqing at gmail.com>
Approved-by: Kacper Kowalik <xarthisius.kk at gmail.com>
Affected #: 5 files
diff -r dc14ea0fd19f7bff66c111f5d274b14a5d869188 -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -42,7 +42,7 @@
local_owls_001:
- yt/frontends/owls/tests/test_outputs.py
- local_pw_012:
+ local_pw_013:
- yt/visualization/tests/test_plotwindow.py:test_attributes
- yt/visualization/tests/test_plotwindow.py:test_attributes_wt
- yt/visualization/tests/test_profile_plots.py:test_phase_plot_attributes
diff -r dc14ea0fd19f7bff66c111f5d274b14a5d869188 -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 yt/data_objects/profiles.py
--- a/yt/data_objects/profiles.py
+++ b/yt/data_objects/profiles.py
@@ -708,7 +708,7 @@
self.GridDimensions,
cell_size)
- locs = storage.values[:, :, fi] > 0.0
+ locs = storage.values[:, :, fi] != 0.0
storage.used[locs] = True
if self.weight_field is not None:
diff -r dc14ea0fd19f7bff66c111f5d274b14a5d869188 -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 yt/data_objects/tests/test_profiles.py
--- a/yt/data_objects/tests/test_profiles.py
+++ b/yt/data_objects/tests/test_profiles.py
@@ -1,3 +1,4 @@
+import yt
import numpy as np
from yt.data_objects.profiles import \
@@ -195,3 +196,28 @@
assert_raises(
YTIllDefinedProfile, PhasePlot, ad, 'particle_radius', 'particle_mass',
'particle_ones')
+
+def test_particle_profile_negative_field():
+ # see Issue #1340
+ n_particles = int(1e4)
+
+ ppx, ppy, ppz = np.random.normal(size=[3, n_particles])
+ pvx, pvy, pvz = - np.ones((3, n_particles))
+
+ data = {'particle_position_x': ppx,
+ 'particle_position_y': ppy,
+ 'particle_position_z': ppz,
+ 'particle_velocity_x': pvx,
+ 'particle_velocity_y': pvy,
+ 'particle_velocity_z': pvz}
+
+ bbox = 1.1*np.array([[min(ppx), max(ppx)], [min(ppy), max(ppy)], [min(ppz), max(ppz)]])
+ ds = yt.load_particles(data, bbox=bbox)
+ ad = ds.all_data()
+
+ profile = yt.create_profile(
+ ad,
+ ["particle_position_x", "particle_position_y"],
+ "particle_velocity_x",
+ weight_field=None)
+ assert profile['particle_velocity_x'].min() < 0
diff -r dc14ea0fd19f7bff66c111f5d274b14a5d869188 -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 yt/utilities/lib/image_utilities.pyx
--- a/yt/utilities/lib/image_utilities.pyx
+++ b/yt/utilities/lib/image_utilities.pyx
@@ -17,6 +17,7 @@
def add_points_to_greyscale_image(
np.ndarray[np.float64_t, ndim=2] buffer,
+ np.ndarray[np.int_t, ndim=2] buffer_mask,
np.ndarray[np.float64_t, ndim=1] px,
np.ndarray[np.float64_t, ndim=1] py,
np.ndarray[np.float64_t, ndim=1] pv):
@@ -28,6 +29,7 @@
j = <int> (xs * px[pi])
i = <int> (ys * py[pi])
buffer[i, j] += pv[pi]
+ buffer_mask[i, j] = 1
return
def add_points_to_image(
diff -r dc14ea0fd19f7bff66c111f5d274b14a5d869188 -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -648,24 +648,31 @@
# splat particles
buff = np.zeros(self.buff_size)
+ buff_mask = np.zeros(self.buff_size).astype('int')
add_points_to_greyscale_image(buff,
+ buff_mask,
px[mask],
py[mask],
splat_vals)
+ # remove values in no-particle region
+ buff[buff_mask==0] = np.nan
ia = ImageArray(buff, input_units=data.units,
info=self._get_info(item))
# divide by the weight_field, if needed
if weight_field is not None:
weight_buff = np.zeros(self.buff_size)
+ weight_buff_mask = np.zeros(self.buff_size).astype('int')
add_points_to_greyscale_image(weight_buff,
+ weight_buff_mask,
px[mask],
py[mask],
weight_data[mask])
weight_array = ImageArray(weight_buff,
input_units=weight_data.units,
info=self._get_info(item))
-
+ # remove values in no-particle region
+ weight_buff[weight_buff_mask==0] = np.nan
locs = np.where(weight_array > 0)
ia[locs] /= weight_array[locs]
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