[SciPy-User] UnivariateSpline returning NaN
nicky van foreest
vanforeest at gmail.com
Sun Aug 19 15:51:02 EDT 2012
Hi,
I also had this problem, but this was due to setting s = 0 in
UnivariateSpline. In my case, setting s = 0.0001 helped remove the
nans. I am not a specialist on splines, but settting s = 0 requires
the splines to go through each and every point. That may be, perhaps,
a too strong requirement.
Nicky
On 19 August 2012 15:44, Vagabond_Aero <vagabondaero at gmail.com> wrote:
> Looking at your data, about 3/4 of the way down you have 2 x values exactly
> the same. Leaving those in, I could recreate your problem, but removing one
> of them made the problem go away.
>
> On Fri, Aug 17, 2012 at 2:34 PM, Kevin Gullikson <kevin.gullikson at gmail.com>
> wrote:
>>
>> Hi all,
>>
>> I am having a weird issue with UnivariateSpline return nan when trying to
>> interpolate some data. I have had this happen before a couple times, but it
>> was always because a nan was in the input arrays. Here, they are all real
>> numbers. Here is some minimal code that recreates my problem:
>>
>> import numpy
>> x,y = numpy.loadtxt("test.out", usecols=(0,1), unpack=True)
>> from scipy.interpolate import UnivariateSpline
>> fcn = UnivariateSpline(x,y,s=0)
>> print fcn(numpy.median(x))
>>
>> (the result of the print is nan)
>>
>>
>> Here is the data that I used:
>>
>> 960.38174 2218580.3 2205540
>> 960.3904 2209433.1 2205465.9
>> 960.39906 2202205.2 2205391.9
>> 960.40773 2209385.9 2205317.8
>> 960.41639 2218550.3 2205243.7
>> 960.42505 2220656.8 2205169.7
>> 960.43372 2220779.4 2205095.6
>> 960.44238 2220771.8 2205021.5
>> 960.45104 2220764.3 2204947.5
>> 960.67545 2220409.5 2203030.8
>> 960.68725 2220387.5 2202930.1
>> 960.69905 2220365.5 2202829.5
>> 960.71085 2220343.4 2202728.8
>> 960.72265 2220321.4 2202628.2
>> 960.73445 2220299.3 2202527.6
>> 960.74625 2220277.3 2202427
>> 960.75805 2220222.8 2202326.4
>> 960.76985 2220200.7 2202225.7
>> 960.78165 2220178.7 2202125.2
>> 960.79345 2220156.6 2202024.6
>> 960.80525 2220134.6 2201924
>> 960.81705 2220080.1 2201823.4
>> 961.16055 2219013.1 2198897.2
>> 961.16699 2218983.4 2198842.3
>> 961.17344 2218953.6 2198787.4
>> 961.17988 2218923.8 2198732.5
>> 961.18788 2218886.9 2198664.3
>> 961.19587 2218882.5 2198596.2
>> 961.20386 2218910.5 2198528.1
>> 961.21186 2218906.1 2198459.9
>> 961.21963 2218837.8 2198393.7
>> 961.2274 2218769.4 2198327.4
>> 961.23517 2218701.1 2198261.2
>> 961.24294 2218697.7 2198194.9
>> 961.25071 2218661.8 2198128.7
>> 961.25695 2218633 2198075.6
>> 961.26317 2218604.3 2198022.5
>> 961.27485 2218550.4 2197922.9
>> 961.28653 2218496.5 2197823.4
>> 961.2982 2218475 2197723.8
>> 961.30988 2218421.1 2197624.3
>> 961.32156 2218367.3 2197524.8
>> 961.75259 2216379.3 2193857.4
>> 961.75259 2225525.5 2193857.4
>> 962.04986 2222983.5 2191338.5
>> 962.05175 2222942.3 2191322.5
>> 962.69908 2217396.7 2185841.9
>> 962.71837 2217210.7 2185678.5
>> 962.73766 2217024.8 2185515.2
>> 962.75695 2214605.6 2185352
>> 962.77624 2180663.5 2185188.7
>> 962.79552 2080767.6 2185025.6
>> 962.81481 2027222.1 2184862.4
>> 962.83411 2080471.4 2184699.3
>> 962.8534 2180022.7 2184536.2
>> 962.87269 2213620.2 2184373.1
>>
>>
>>
>> Thanks,
>>
>> Kevin Gullikson
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
>
>
> --
> Co-discoverer of KBO:
>
> IH-X-694190
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-User
mailing list