<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Matt,<div class=""><br class=""></div><div class="">Thanks for the pointer. </div><div class=""><br class=""></div><div class="">I think the real difficulty here is that in theory the data object used to generate the photons could be literally anything, a sphere, box, disk, or some goofy shape defined by a region cut. </div><div class=""><br class=""></div><div class="">The code in selection_routines.pyx that handles such periodic shifting appears (to me at least) to apply only for rectangular regions for which such an operation is relatively straightforward—but I’d need something that doesn’t necessarily know about “left edge” and “right edge”. You could special-case that for things like rectangular regions and spheres, perhaps, but for anything more general determining a “left edge” becomes a problem. For example, you simply couldn’t just use the minimum value of the coordinate because of course your region could straddle the domain boundary and your minimum coordinate could actually be on the “rightward” side of the object. </div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">John</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 9, 2016, at 1:12 PM, Matthew Turk <<a href="mailto:matthewturk@gmail.com" class="">matthewturk@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi John,<div class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Sep 8, 2016 at 10:22 AM, John ZuHone<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:jzuhone@gmail.com" target="_blank" class="">jzuhone@gmail.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class="">Hi all,<div class=""><br class=""></div><div class="">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. </div><div class=""><br class=""></div><div class="">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. </div><div class=""><br class=""></div><div class="">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. </div><div class=""><br class=""></div><div class="">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? </div></div></blockquote><div class=""><br class=""></div><div class="">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.</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">John Z</div><div class=""><br class=""></div><div class=""><pre style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;" class=""><span style="color: rgb(0, 0, 128); font-weight: bold;" class="">def </span>get_periodic_coords(ds, ctr, x, y, z):<br class="">    coords = ds.arr(np.zeros((<span style="color: rgb(0, 0, 255);" class="">3</span>, x.size)), <span style="color: rgb(0, 128, 128); font-weight: bold;" class="">"kpc"</span>)<br class="">    coords[<span style="color: rgb(0, 0, 255);" class="">0</span>, :] = (x - ctr[<span style="color: rgb(0, 0, 255);" class="">0</span>]).to(<span style="color: rgb(0, 128, 128); font-weight: bold;" class="">"kpc"</span>)<br class="">    coords[<span style="color: rgb(0, 0, 255);" class="">1</span>, :] = (y - ctr[<span style="color: rgb(0, 0, 255);" class="">1</span>]).to(<span style="color: rgb(0, 128, 128); font-weight: bold;" class="">"kpc"</span>)<br class="">    coords[<span style="color: rgb(0, 0, 255);" class="">2</span>, :] = (z - ctr[<span style="color: rgb(0, 0, 255);" class="">2</span>]).to(<span style="color: rgb(0, 128, 128); font-weight: bold;" class="">"kpc"</span>)<br class="">    <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">if </span><span style="color: rgb(0, 0, 128);" class="">sum</span>(ds.periodicity) == <span style="color: rgb(0, 0, 255);" class="">0</span>:<br class="">        <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">return </span>coords<br class="">    dw = <a href="http://ds.domain_width.to/" target="_blank" class="">ds.domain_width.to</a>(<span style="color: rgb(0, 128, 128); font-weight: bold;" class="">"kpc"</span>)<br class="">    <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">for </span>i <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">in </span><span style="color: rgb(0, 0, 128);" class="">range</span>(<span style="color: rgb(0, 0, 255);" class="">3</span>):<br class="">        <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">if </span>ds.periodicity[i]: <br class="">            c = coords[i, :]<br class="">            cdw = c - dw[i]<br class="">            mins = np.argmin([np.abs(c), np.abs(cdw)], <span style="color: rgb(102, 0, 153);" class="">axis</span>=<span style="color: rgb(0, 0, 255);" class="">0</span>)<br class="">            ii = np.where(mins == <span style="color: rgb(0, 0, 255);" class="">1</span>)[<span style="color: rgb(0, 0, 255);" class="">0</span>]<br class="">            coords[i, ii] = coords[i, ii] - dw[i]<br class="">    <span style="color: rgb(0, 0, 128); font-weight: bold;" class="">return </span>coords<br class=""></pre><div class=""><br class=""></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">yt-dev mailing list<br class=""><a href="mailto:yt-dev@lists.spacepope.org" class="">yt-dev@lists.spacepope.org</a><br class=""><a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/<wbr class="">listinfo.cgi/yt-dev-spacepope.<wbr class="">org</a><br class=""><br class=""></blockquote></div><br class=""></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">yt-dev mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:yt-dev@lists.spacepope.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">yt-dev@lists.spacepope.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a></div></blockquote></div><br class=""></div></body></html>