On Sep 9, 2016, at 1:12 PM, Matthew Turk <matthewturk@gmail.com> wrote:Hi John,_______________________________________________On Thu, Sep 8, 2016 at 10:22 AM, John ZuHone <jzuhone@gmail.com> wrote:Hi all,I’m working on some updates to my yt-based pyXSIM package and I’m stuck and I thought I would email this list for some guidance.I’m thinking of a situation where we have a data object (sphere, box, whatever) and it straddles a periodic boundary. I want to convert the coordinates such that the coordinates are translated with respect to some arbitrary origin (say, the center of a sphere but in theory it could be anywhere), but are also continuous, i.e, they do not wrap at the boundary.I’ve looked at the functions get_radius and get_periodic_rvec in yt/fields/field_functions.py, and based on that I have come up with the code below, but it doesn’t quite work for any arbitrary value of the “ctr” argument (the origin). I think it’s because the functions I mentioned only need to calculate absolute value differences in order to compute a radius.The x, y, and z arguments to the function below are the input coordinate arrays. Could anyone who is more familiar with this sort of thing point out what I should be doing?I think that Doug implemented something in the region selector that does exactly this; it computes whether or not something needs a coordinate shift, and then if so, it applies that. If you look through selection_routines.pyx for anything with "shift" in the name, it should be there. If that doesn't do what you're looking for, we can try to figure something else out.Best,John Zdef get_periodic_coords(ds, ctr, x, y, z):
coords = ds.arr(np.zeros((3, x.size)), "kpc")
coords[0, :] = (x - ctr[0]).to("kpc")
coords[1, :] = (y - ctr[1]).to("kpc")
coords[2, :] = (z - ctr[2]).to("kpc")
if sum(ds.periodicity) == 0:
return coords
dw = ds.domain_width.to("kpc")
for i in range(3):
if ds.periodicity[i]:
c = coords[i, :]
cdw = c - dw[i]
mins = np.argmin([np.abs(c), np.abs(cdw)], axis=0)
ii = np.where(mins == 1)[0]
coords[i, ii] = coords[i, ii] - dw[i]
return coords
_______________________________________________
yt-dev mailing list
yt-dev@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope. org
yt-dev mailing list
yt-dev@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org