# [ncl-talk] Problem with the function "lspoly" : difference between the result

Tue Jan 9 20:40:12 MST 2018

```Hi, all

I just use the function “lspoly” to do polynomial fitting for some series, and met something strange .
Here below is a part of my scripts

…….
;  ***********************************
tstep = ispan(-maxlag,maxlag,1)                   ; define x axis

;  polynomial interpolation
c       = lspoly(tstep,ccrtot,1,3)

do k = 0,nd-1
print(k + "  " + xid(k) )
cc  = lspoly(tstep,ccrtot(k,:),1,3)
print(c(k,0)  +  "  " + cc(0))
end do
;   ***********************************

Here below is a part of the corresponding output.
We  can see that for most of the series, the result is consistent between c(k,0) and cc(0),
however, for the other series , for example, the series with the id of “CA002202200” or “CA002204100”,
there are difference between c(k,0) and cc(0).

I am a little puzzled, why there are difference for the results of these series
when I change the procedure of calling function. And Which way should I choose
to got the correct polynomial fitting for all the series. (I also attached the
whole scripts and data files, Please check it.)

(0)	0  CA002100700
(0)	0.239934  0.239934
(0)	1  CA002100880
(0)	0.380426  0.380426
(0)	2  CA002202200
(0)	0.380426  0.415303
(0)	3  CA002202400
(0)	0.328062  0.328062
(0)	4  CA002202800
(0)	0.233068  0.233068
(0)	5  CA002204100
(0)	0.233068  0.341998
(0)	6  CA002300500
(0)	0.233068  0.500022
(0)	7  CA002300902
(0)	0.233068  0.50636
(0)	8  CA002301000
(0)	0.477951  0.477951
(0)	9  CA002400600
(0)	0.477951  0.482882
(0)	10  CA002401200
(0)	0.619622  0.619622
(0)	11  CA002403500
(0)	0.557136  0.557136
(0)	12  CAW00711410
(0)	0.448455  0.448455
(0)	13  CAW00719110
(0)	0.550481  0.550481
(0)	14  FI000000304
(0)	0.511676  0.511676
(0)	15  FI000002401
(0)	0.511676  0.525073
(0)	16  FI000007501
(0)	0.511676  0.609115
(0)	17  FIW00028050
(0)	0.511676  0.539957
(0)	18  FIW00028070
(0)	0.55604  0.55604
(0)	19  FIW00028230
(0)	0.571857  0.571857
(0)	20  FIW00028440
(0)	0.571857  0.660955
(0)	21  FIW00028450
(0)	0.614022  0.614022
(0)	22  FIW00028640
(0)	0.561348  0.561348
(0)	23  FIW00028690
(0)	0.566393  0.566393
(0)	24  FIW00028740
(0)	0.553346  0.553346
(0)	25  FIW00028750
(0)	0.507437  0.507437
(0)	26  FIW00028970
(0)	0.464211  0.464211
(0)	27  FIW00029100
(0)	0.530141  0.530141
(0)	28  FIW00029110
(0)	0.452507  0.452507
(0)	29  FIW00029130
(0)	0.452507  0.585739
(0)	30  FIW00029150
(0)	0.452507  0.481584
(0)	31  FIW00029170
(0)	0.488413  0.488413
(0)	32  FIW00029240
(0)	0.487094  0.487094
(0)	33  FIW00029290
(0)	0.523639  0.523639
(0)	34  FIW00029420
(0)	0.531159  0.531159
(0)	35  FIW00029440
(0)	0.471023  0.471023
(0)	36  FIW00029450
(0)	0.495872  0.495872
(0)	37  FIW00029470
(0)	0.327738  0.327738
(0)	38  FIW00029520
(0)	0.489859  0.489859
(0)	39  FIW00029580
(0)	0.467005  0.467005
(0)	40  FIW00029650
(0)	0.467005  0.493549
(0)	41  FIW00029660
(0)	0.467005  0.542049
(0)	42  FIW00029700
(0)	0.494033  0.494033
(0)	43  FIW00029720
(0)	0.407923  0.407923
(0)	44  FIW00029760
(0)	0.502163  0.502163
(0)	45  FOW00060110
(0)	0.502163  0.553852
(0)	46  GL000004360
(0)	0.672092  0.672092
(0)	47  GLW00042200
(0)	0.511462  0.511462
(0)	48  GLW00042600
(0)	0.373208  0.373208
(0)	49  GLW00042720
(0)	0.50284  0.50284
(0)	50  IC000004030
(0)	0.713142  0.713142
(0)	51  IC000004048
(0)	0.671089  0.671089
(0)	52  IC000004097
(0)	0.581897  0.581897
(0)	53  ICW00040050
(0)	0.603685  0.603685
(0)	54  NO000001026
(0)	0.602763  0.602763
(0)	55  NO000050540
(0)	0.513178  0.513178
(0)	56  NO000080700
(0)	0.513178  0.620591
(0)	57  NO000099710
(0)	0.612189  0.612189
(0)	58  NOE00105467
(0)	0.612189  0.645705
(0)	59  NOE00105477
(0)	0.693077  0.693077
(0)	60  NOE00105494
(0)	0.635884  0.635884
(0)	61  NOE00109394
(0)	0.562202  0.562202
(0)	62  NOE00109450
(0)	0.445114  0.445114
(0)	63  NOE00109459
(0)	0.445114  0.592654
(0)	64  NOE00109476
(0)	0.535851  0.535851
(0)	65  NOE00109485
(0)	0.535851  0.595297
(0)	66  NOE00109514
(0)	0.527777  0.527777
(0)	67  NOE00109604
(0)	0.527777  0.541985
(0)	68  NOE00109701
(0)	0.579877  0.579877

Thanks

Lin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lag_corr.ncl
Type: application/octet-stream
Size: 6103 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0002.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0005.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: station-northpole.txt
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0001.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0006.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t60N_AnnAvg_1951-2016.nc
Type: application/octet-stream
Size: 1134088 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0003.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180110/863cfa4c/attachment-0007.html>
```