[ncl-talk] NCL spline question
Dennis Shea
shea at ucar.edu
Wed Dec 23 16:54:23 MST 2015
Try:
http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurv.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/ftcurvs.shtml
Experiment with the tension.
Merry Christmas
D
On Wed, Dec 23, 2015 at 4:15 PM, Jonathan Vigh <jvigh at ucar.edu> wrote:
> 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.
> http://www.mathworks.com/help/matlab/ref/pchip.html?s_tid=gn_loc_drop
>
> 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:
>> 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:
>> http://www.ncarg.ucar.edu/ngmath/fitgrid/plot4.html
>>
>> 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:
>> http://topofusion.com/spline.php (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
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
More information about the ncl-talk
mailing list