<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">OK, this is embarrassing.<br>
      I had in fact made the kernel only almost symmetric, it was
      slightly offset to one side. <br>
      This caused it. Only a wetware bug.<br>
      Sorry for having wasted your time! <br>
      <br>
      <br>
      On 03/23/2017 03:38 AM, <a class="moz-txt-link-abbreviated" href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a> wrote:<br>
    </div>
    <blockquote
cite="mid:CAMMTP+D-0+bKs86HdK1JmnrkVM+3--DOECMp1+4zSacCNvLMdQ@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Wed, Mar 22, 2017 at 10:06 PM,
            Thøger Emil Rivera-Thorsen <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:thoger.emil@gmail.com" target="_blank">thoger.emil@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div bgcolor="#FFFFFF">
                <p>Dear list;</p>
                <p>I am honestly not certain whether this, or the SciPy
                  list, is the appropriate place to post this; please
                  let me know if I got it wrong.<br>
                </p>
                <p>I am convolving a 1D data set containing a relatively
                  narrow peak, with a relatively narrow Gaussian kernel,
                  in order to emulate the effect of atmospheric seeing
                  on astrophysical observations.</p>
                <p>I have a 1D data array 45 pixels long, and a Gaussian
                  kernel, and run np.convolve(data, kernel, mode='same')
                  on the two arrays, the resulting array's peak is
                  shifted relative to the origin. I have attached a plot
                  to illustrate.</p>
                <p>The original data is shown in blue. When I convolve
                  it with a symmetric kernel (black), I get an offset
                  resulting peak (magenta). If I flip the kernel -- even
                  though it is perfectly symmetric -- the resulting
                  curve is offset in the opposite direction (yellow).
                  However, if I offset the kernel so it is centered
                  exactly one pixel below the central value, the output
                  array gets centered correct (red), even if I flip the
                  (now no longer symmetric) kernel.</p>
                <p>This is using Numpy 1.11.3, python 2.7.13, on
                  Anaconda 4.3.0 64-bit on Ubuntu 16.10 <br>
                </p>
                <p>Using astropy.convolution, reproduces the correct red
                  curve, so I can use that for now, but it seems to me
                  this is either a bug or, if it is indeed the intended
                  behavior, a word of caution would be merited in the
                  docstring.<br>
                </p>
                <p>Cheers, <br>
                </p>
                <p>Emil Rivera-Thorsen</p>
                <p><br>
                </p>
                <p> <img src="cid:part2.9CE30EC0.AEF8668E@gmail.com"
                    alt=""></p>
              </div>
              <br>
              ______________________________<wbr>_________________<br>
              NumPy-Discussion mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
              <a moz-do-not-send="true"
                href="https://mail.scipy.org/mailman/listinfo/numpy-discussion"
                rel="noreferrer" target="_blank">https://mail.scipy.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
        <div class="gmail_extra">Can you provide an example to
          replicate?</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">I haven't seen this behavior, it looks
          centered to me, at least for odd window length.. </div>
        <div class="gmail_extra">AFAIR, I had to try a bit in the past
          for how to set the window and location with even window
          length.</div>
        <div class="gmail_extra">
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">>>> np.__version__</div>
          <div class="gmail_extra">'1.11.2'<br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">>>> x = np.linspace(-1, 1,
            21)<br>
          </div>
        </div>
        <div class="gmail_extra">
          <div class="gmail_extra">>>> w =
            stats.norm.pdf(np.linspace(-3, 3, 5))</div>
          <div class="gmail_extra">>>> np.column_stack((x,
            np.convolve(x, w, mode='same')))[8:13]</div>
          <div class="gmail_extra">array([[ -2.00000000e-01,
             -1.33368234e-01],<br>
          </div>
          <div class="gmail_extra">       [ -1.00000000e-01,
             -6.66841169e-02],</div>
          <div class="gmail_extra">       [  0.00000000e+00,  
            1.51788304e-17],</div>
          <div class="gmail_extra">       [  1.00000000e-01,  
            6.66841169e-02],</div>
          <div class="gmail_extra">       [  2.00000000e-01,  
            1.33368234e-01]])</div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">
            <div class="gmail_extra">>>> x =
              np.abs(np.linspace(-1, 1, 21))</div>
            <div class="gmail_extra">>>> w =
              stats.norm.pdf(np.linspace(-3, 3, 4))<br>
            </div>
            <div class="gmail_extra">>>> np.column_stack((x,
              np.convolve(x, w, mode='same')))[8:13]</div>
            <div class="gmail_extra">array([[ 0.2       ,  0.12320129],<br>
            </div>
            <div class="gmail_extra">       [ 0.1       ,  0.07392077],</div>
            <div class="gmail_extra">       [ 0.        ,  0.02552663],</div>
            <div class="gmail_extra">       [ 0.1       ,  0.02552663],</div>
            <div class="gmail_extra">       [ 0.2       ,  0.07392077]])</div>
            <div class="gmail_extra"><br>
            </div>
            <div class="gmail_extra"><br>
            </div>
            <div class="gmail_extra">>>> w =
              stats.norm.pdf(np.linspace(-3, 3, 5))</div>
            <div class="gmail_extra">>>> np.column_stack((x,
              np.convolve(x, w, mode='same')))[8:13]</div>
            <div class="gmail_extra">array([[ 0.2       ,  0.13336823],<br>
            </div>
            <div class="gmail_extra">       [ 0.1       ,  0.06757049],</div>
            <div class="gmail_extra">       [ 0.        ,  0.02767626],</div>
            <div class="gmail_extra">       [ 0.1       ,  0.06757049],</div>
            <div class="gmail_extra">       [ 0.2       ,  0.13336823]])</div>
            <div class="gmail_extra"><br>
            </div>
            <div class="gmail_extra">Josef</div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="https://mail.scipy.org/mailman/listinfo/numpy-discussion">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>