<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Dennis and NCL-Talk.<br>
      <br>
      I tried out Dennis's suggestion. The results are attached as two
      plots and summarized below. <br>
      <ul>
        <li>Fitting the best track points parametrically using ftkurv
          resulted in average error of about half a degree (~30 n mi) at
          the validation points due to the time drift issue. <br>
        </li>
        <li>Fitting the best track lat/lon separately to time using a 1D
          cubic spline using ftcurv gave an error of zero at all of the
          validation points. So this is definitely superior to the
          results from ftkurv. I found that using a tension of between 5
          and 10 gave something that had good fidelity to the best track
          while keeping wiggles to a minimum. <br>
        </li>
      </ul>
      <p>For my immediate problem, it looks like the separate 1D cubic
        spline fits will suffice. In the longer term, I'll be interested
        to see if we can develop a piecewise parametric spline routine
        that is optimized for fitting trajectories in 2- or even 3-
        space. Maybe something like Matlab's 'pchip' function or the
        more complex method described here:
        <a class="moz-txt-link-freetext" href="http://topofusion.com/spline.php">http://topofusion.com/spline.php</a><br>
      </p>
      <p>Merry Christmas,<br>
        Jonathan <br>
      </p>
      <br>
      <br>
      <br>
      On 12/23/2015 05:11 PM, Dennis Shea wrote:<br>
    </div>
    <blockquote
cite="mid:CAOF1d_4nrXNXgTPQ-VWzU7DuMTZW0vto2cnPA6CKc-wuDx+3Pw@mail.gmail.com"
      type="cite">
      <pre wrap="">I would try separately. D

On Wed, Dec 23, 2015 at 5:07 PM, Jonathan Vigh <a class="moz-txt-link-rfc2396E" href="mailto:jvigh@ucar.edu">&lt;jvigh@ucar.edu&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi Dennis,
   Do you mean use ftcurv separately for lat and for lon as functions of
time? Would fitting each separately interfere the 2d nature of this problem?
Jonathan



On 12/23/2015 04:54 PM, Dennis Shea wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">
Try:

<a class="moz-txt-link-freetext" href="http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurv.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurv.shtml</a>
<a class="moz-txt-link-freetext" href="http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurvs.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurvs.shtml</a>

Experiment with the tension.


Merry Christmas
D

On Wed, Dec 23, 2015 at 4:15 PM, Jonathan Vigh <a class="moz-txt-link-rfc2396E" href="mailto:jvigh@ucar.edu">&lt;jvigh@ucar.edu&gt;</a> wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">
As an update to my question, a colleague informed me that Matlab has a
function called pchip: Piecewise Cubic Hermite Interpolating Polynomial
(PCHIP). It is the same as a regular cubic spline but it does not permit
overshoot/undershoot, which can occur with regular cubic splines.
<a class="moz-txt-link-freetext" href="http://www.mathworks.com/help/matlab/ref/pchip.html?s_tid=gn_loc_drop">http://www.mathworks.com/help/matlab/ref/pchip.html?s_tid=gn_loc_drop</a>

I think something like this would be sufficient for my problem.

Do any of NCL's functions offer this type of spline?

Thanks,
     Jonathan



On 12/23/2015 04:01 PM, Jonathan Vigh wrote:
</pre>
            <blockquote type="cite">
              <pre wrap="">
Greetings NCL-Talk,

I'm trying to generate an interpolatory spline* for a lat/lon tropical
cyclone trajectory from a set of lat/lon points at semi-regular time
intervals. The input points are regularly spaced (for the most part)
6-hourly Best Track points, however there are occasional irregular
time points in between, such as the exact time of landfall. The
desired output is a semi-regular grid of hourly points, but with the
same few irregular time points as the for the input times.

(*An interpolatory spline is one in which the interpolated spline
passes through the points that are being interpolated from, as opposed
to an approximating spline which does not have to pass through the
points.)

It was suggested that NCL's ftkurv function (from the FitGrid library)
might do what I'd like, since this does an interpolation for
parametric curves. If I understand my problem correctly, lat and lon
can be thought of as parameters of time.

The example plot for ftkurv looks promising:
<a class="moz-txt-link-freetext" href="http://www.ncarg.ucar.edu/ngmath/fitgrid/plot4.html">http://www.ncarg.ucar.edu/ngmath/fitgrid/plot4.html</a>

ftkurv (
                 xi [*] : numeric,
                 yi [*] : numeric,
                 t  [*] : numeric,
                 xo [*] : float,    ; or double
                 yo [*] : float     ; or double
         )

In the example given for this function, the parameter array passed in
for 't' is a regularly-spaced normalized parameter array that ranges
from 0 to 1. I don't understand where this function gets any
information about the input time values however. I built a test case
for a real hurricane track and validated the interpolated spline
points at the input points. I get zero "error" at the end points of
the track, with maximum error in the middle. The error increases and
decreases smoothly, suggesting an offset issue (probably related to
time drift).

- Does anybody know if this function allow for irregular parameter
values for 't'?
- Is there a way to use ftkurv in a way that makes it aware of the
times of the input lat/lon?

I've created a fairly detailed stand-alone test code, which is
attached. Feel free to run to see the error characteristics of the
ftkurv spline.

Ultimately, I'd like to be able to do piecewise cubic spline
interpolation along the lines of what is done for gps tracks:
<a class="moz-txt-link-freetext" href="http://topofusion.com/spline.php">http://topofusion.com/spline.php</a> (piecewise interpolation, matching
derivatives to ensure continuity of slope, Bessel interpolation used
to compute the first derivative by fitting a 3-point parabola for each
point). If someone has already implemented something like this in NCL,
that would of course be awesome. But I can make do with something more
basic provided it can handle the irregular input/output times.

If anyone has experience with this type of spline problem, or has
suggestions on other NCL routines to try, I'd appreciate any input you
can provide.

Jonathan
</pre>
            </blockquote>
            <pre wrap="">
_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
          </blockquote>
        </blockquote>
        <pre wrap="">

</pre>
      </blockquote>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
  </body>
</html>