[yt-svn] commit/yt: jzuhone: Merged in mzingale/yt-new (pull request #1229)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Oct 22 07:43:24 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/4ac89a837391/
Changeset: 4ac89a837391
Branch: yt
User: jzuhone
Date: 2014-10-22 14:43:15+00:00
Summary: Merged in mzingale/yt-new (pull request #1229)
this change addresses issue #914 -- the orientation of draw_domain()
Affected #: 2 files
diff -r 1fb34fd879d0f912e531eb69253b82df9b28ffc8 -r 4ac89a8373911095eab03cbd009ca1bbf10c940e yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -217,7 +217,8 @@
np.ndarray[np.int64_t, ndim=1] ys,
np.ndarray[np.float64_t, ndim=2] colors,
int points_per_color=1,
- int thick=1):
+ int thick=1,
+ int flip=0):
cdef int nx = image.shape[0]
cdef int ny = image.shape[1]
@@ -256,18 +257,23 @@
if x0 >= thick and x0 < nx-thick and y0 >= thick and y0 < ny-thick:
for xi in range(x0-thick/2, x0+(1+thick)/2):
for yi in range(y0-thick/2, y0+(1+thick)/2):
+ if flip:
+ yi0 = ny - yi
+ else:
+ yi0 = yi
+
if has_alpha:
- image[xi, yi, 3] = outa = alpha[3] + image[xi, yi, 3]*(1-alpha[3])
+ image[xi, yi0, 3] = outa = alpha[3] + image[xi, yi0, 3]*(1-alpha[3])
if outa != 0.0:
outa = 1.0/outa
for i in range(3):
- image[xi, yi, i] = \
- ((1.-alpha[3])*image[xi, yi, i]*image[xi, yi, 3]
+ image[xi, yi0, i] = \
+ ((1.-alpha[3])*image[xi, yi0, i]*image[xi, yi0, 3]
+ alpha[3]*alpha[i])*outa
else:
for i in range(3):
- image[xi, yi, i] = \
- (1.-alpha[i])*image[xi,yi,i] + alpha[i]
+ image[xi, yi0, i] = \
+ (1.-alpha[i])*image[xi,yi0,i] + alpha[i]
if (x0 == x1 and y0 == y1):
break
diff -r 1fb34fd879d0f912e531eb69253b82df9b28ffc8 -r 4ac89a8373911095eab03cbd009ca1bbf10c940e yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -316,8 +316,11 @@
nim = im.rescale(inline=False)
enhance_rgba(nim)
nim.add_background_color('black', inline=True)
-
- lines(nim, px, py, colors, 24)
+
+ # we flipped it in snapshot to get the orientation correct, so
+ # flip the lines
+ lines(nim, px, py, colors, 24, flip=1)
+
return nim
def draw_coordinate_vectors(self, im, length=0.05, thickness=1):
@@ -370,11 +373,13 @@
np.array([0.0, 1.0, 0.0, alpha]),
np.array([0.0, 0.0, 1.0, alpha])]
+ # we flipped it in snapshot to get the orientation correct, so
+ # flip the lines
for vec, color in zip(coord_vectors, colors):
dx = int(np.dot(vec, self.orienter.unit_vectors[0]))
dy = int(np.dot(vec, self.orienter.unit_vectors[1]))
lines(im, np.array([px0, px0+dx]), np.array([py0, py0+dy]),
- np.array([color, color]), 1, thickness)
+ np.array([color, color]), 1, thickness, flip=1)
def draw_line(self, im, x0, x1, color=None):
r"""Draws a line on an existing volume rendering.
@@ -415,7 +420,10 @@
py1 = int(self.resolution[0]*(dx1/self.width[0]))
px0 = int(self.resolution[1]*(dy0/self.width[1]))
px1 = int(self.resolution[1]*(dy1/self.width[1]))
- lines(im, np.array([px0,px1]), np.array([py0,py1]), color=np.array([color,color]))
+
+ # we flipped it in snapshot to get the orientation correct, so
+ # flip the lines
+ lines(im, np.array([px0,px1]), np.array([py0,py1]), color=np.array([color,color]),flip=1)
def draw_domain(self,im,alpha=0.3):
r"""Draws domain edges on an existing volume rendering.
@@ -497,7 +505,9 @@
px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
- lines(im, px, py, color.reshape(1,4), 24)
+ # we flipped it in snapshot to get the orientation correct, so
+ # flip the lines
+ lines(im, px, py, color.reshape(1,4), 24, flip=1)
def look_at(self, new_center, north_vector = None):
r"""Change the view direction based on a new focal point.
@@ -748,7 +758,7 @@
image, sampler),
info=self.get_information())
- # flip it up/down to handle how the png orientation is donetest.png
+ # flip it up/down to handle how the png orientation is done
image = image[:,::-1,:]
self.save_image(image, fn=fn, clip_ratio=clip_ratio,
transparent=transparent)
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