[Yt-svn] yt: 2 new changesets
hg at spacepope.org
hg at spacepope.org
Sun Apr 25 09:43:19 PDT 2010
hg Repository: yt
details: yt/rev/6a8f0d88b9d9
changeset: 1599:6a8f0d88b9d9
user: Matthew Turk <matthewturk at gmail.com>
date:
Sun Apr 25 09:42:51 2010 -0700
description:
Adding a new, sort-of-working particle deposition routine to drop particles
down on an image.
hg Repository: yt
details: yt/rev/ce128bc6fd1f
changeset: 1600:ce128bc6fd1f
user: Matthew Turk <matthewturk at gmail.com>
date:
Sun Apr 25 09:43:14 2010 -0700
description:
Merging with John's changes
diffstat:
yt/_amr_utils/png_writer.pyx | 24 ++++++++++++++++++++++++
yt/extensions/image_writer.py | 12 ++++++++++++
yt/raven/Callbacks.py | 5 +++--
3 files changed, 39 insertions(+), 2 deletions(-)
diffs (79 lines):
diff -r 7e320eb41392 -r ce128bc6fd1f yt/_amr_utils/png_writer.pyx
--- a/yt/_amr_utils/png_writer.pyx Fri Apr 23 19:09:01 2010 -0700
+++ b/yt/_amr_utils/png_writer.pyx Sun Apr 25 09:43:14 2010 -0700
@@ -145,3 +145,27 @@
fclose(fileobj)
png_destroy_write_struct(&png_ptr, &info_ptr)
+
+def add_points_to_image(
+ np.ndarray[np.uint8_t, ndim=3] buffer,
+ np.ndarray[np.float64_t, ndim=1] px,
+ np.ndarray[np.float64_t, ndim=1] py,
+ np.float64_t pv):
+ cdef int i, j, k, pi
+ cdef int np = px.shape[0]
+ cdef int xs = buffer.shape[0]
+ cdef int ys = buffer.shape[1]
+ cdef int v
+ v = iclip(<int>(pv * 255), 0, 255)
+ print "VALUE CONTRIBUTION", v
+ for pi in range(np):
+ j = <int> (xs * px[pi])
+ i = <int> (ys * py[pi])
+ for k in range(3):
+ buffer[i, j, k] = 0
+ return
+ for i in range(xs):
+ for j in range(ys):
+ for k in range(3):
+ v = buffer[i, j, k]
+ buffer[i, j, k] = iclip(v, 0, 255)
diff -r 7e320eb41392 -r ce128bc6fd1f yt/extensions/image_writer.py
--- a/yt/extensions/image_writer.py Fri Apr 23 19:09:01 2010 -0700
+++ b/yt/extensions/image_writer.py Sun Apr 25 09:43:14 2010 -0700
@@ -63,3 +63,15 @@
f.write(",\n")
f.write(" )\n\n")
f.close()
+
+def splat_points(image, points_x, points_y,
+ contribution = None, transposed = False):
+ if contribution is None:
+ contribution = 100.0
+ val = contribution * 1.0/points_x.size
+ if transposed:
+ points_y = 1.0 - points_y
+ points_x = 1.0 - points_x
+ im = image.copy()
+ au.add_points_to_image(im, points_x, points_y, val)
+ return im
diff -r 7e320eb41392 -r ce128bc6fd1f yt/raven/Callbacks.py
--- a/yt/raven/Callbacks.py Fri Apr 23 19:09:01 2010 -0700
+++ b/yt/raven/Callbacks.py Sun Apr 25 09:43:14 2010 -0700
@@ -767,7 +767,7 @@
_type_name = "particles"
region = None
_descriptor = None
- def __init__(self, width, p_size=1.0, col='k', stride=1.0, ptype=None, stars_only=False, dm_only=False):
+ def __init__(self, width, p_size=1.0, col='k', marker='o', stride=1.0, ptype=None, stars_only=False, dm_only=False):
"""
Adds particle positions, based on a thick slab along *axis* with a
*width* along the line of sight. *p_size* controls the number of
@@ -778,6 +778,7 @@
self.width = width
self.p_size = p_size
self.color = col
+ self.marker = marker
self.stride = stride
self.ptype = ptype
self.stars_only = stars_only
@@ -808,7 +809,7 @@
px, py = self.convert_to_pixels(plot,
[reg[field_x][gg][::self.stride],
reg[field_y][gg][::self.stride]])
- plot._axes.scatter(px, py, edgecolors='None',
+ plot._axes.scatter(px, py, edgecolors='None', marker=self.marker,
s=self.p_size, c=self.color)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
More information about the yt-svn
mailing list