<div dir="ltr">Hi John,<div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 8, 2016 at 10:22 AM, John ZuHone <span dir="ltr"><<a href="mailto:jzuhone@gmail.com" target="_blank">jzuhone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div>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><br></div><div>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><br></div><div>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><br></div><div>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><br></div><div>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> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Best,</div><div><br></div><div>John Z</div><div><br></div><div><pre style="background-color:rgb(255,255,255);font-family:Menlo;font-size:9pt"><span style="color:#000080;font-weight:bold">def </span>get_periodic_coords(ds, ctr, x, y, z):<br>    coords = ds.arr(np.zeros((<span style="color:#0000ff">3</span>, x.size)), <span style="color:#008080;font-weight:bold">"kpc"</span>)<br>    coords[<span style="color:#0000ff">0</span>, :] = (x - ctr[<span style="color:#0000ff">0</span>]).to(<span style="color:#008080;font-weight:bold">"kpc"</span>)<br>    coords[<span style="color:#0000ff">1</span>, :] = (y - ctr[<span style="color:#0000ff">1</span>]).to(<span style="color:#008080;font-weight:bold">"kpc"</span>)<br>    coords[<span style="color:#0000ff">2</span>, :] = (z - ctr[<span style="color:#0000ff">2</span>]).to(<span style="color:#008080;font-weight:bold">"kpc"</span>)<br>    <span style="color:#000080;font-weight:bold">if </span><span style="color:#000080">sum</span>(ds.periodicity) == <span style="color:#0000ff">0</span>:<br>        <span style="color:#000080;font-weight:bold">return </span>coords<br>    dw = <a href="http://ds.domain_width.to" target="_blank">ds.domain_width.to</a>(<span style="color:#008080;font-weight:bold">"kpc"</span>)<br>    <span style="color:#000080;font-weight:bold">for </span>i <span style="color:#000080;font-weight:bold">in </span><span style="color:#000080">range</span>(<span style="color:#0000ff">3</span>):<br>        <span style="color:#000080;font-weight:bold">if </span>ds.periodicity[i]: <br>            c = coords[i, :]<br>            cdw = c - dw[i]<br>            mins = np.argmin([np.abs(c), np.abs(cdw)], <span style="color:#660099">axis</span>=<span style="color:#0000ff">0</span>)<br>            ii = np.where(mins == <span style="color:#0000ff">1</span>)[<span style="color:#0000ff">0</span>]<br>            coords[i, ii] = coords[i, ii] - dw[i]<br>    <span style="color:#000080;font-weight:bold">return </span>coords<br></pre><div><br></div></div></div><br>______________________________<wbr>_________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-dev-spacepope.<wbr>org</a><br>
<br></blockquote></div><br></div></div>