[ncl-talk] NCL spline question
Jonathan Vigh
jvigh at ucar.edu
Thu Dec 24 14:57:11 MST 2015
Hi Dennis and NCL-Talk.
I tried out Dennis's suggestion. The results are attached as two plots
and summarized below.
* 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.
* 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.
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:
http://topofusion.com/spline.php
Merry Christmas,
Jonathan
On 12/23/2015 05:11 PM, Dennis Shea wrote:
> I would try separately. D
>
> On Wed, Dec 23, 2015 at 5:07 PM, Jonathan Vigh <jvigh at ucar.edu> wrote:
>> 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:
>>> 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
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151224/6a89c77e/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: track_spline_using_ftcurv_separately_on_each_dimension.png
Type: image/png
Size: 79204 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151224/6a89c77e/attachment.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: track_spline_using_ftkurv_to_parametrically_fit_both_dimensions.png
Type: image/png
Size: 79031 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151224/6a89c77e/attachment-0001.png
More information about the ncl-talk
mailing list