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

Mary Haley haley at ucar.edu
Tue Jan 16 16:37:21 MST 2018


Hi Lin,

I think I found the source of the problem.

Details:

Deep down in the SLATEC code that NCL's lspoly is based on, there's an EPS
variable that's supposed to be an input variable. NCL internally sets this
to 0.0 and passes it to the SLATEC routine.

It turns out that the SLATEC routine is changing this variable, even though
it's supposed to be an input variable only.  This change gets propagated
back to NCL, and then the next time the routine is called (in the case of
where you pass the 2D arrays), EPS is now something slightly different,
which, as you saw, produces different results.

The fix is relatively simple. I'm now making sure that NCL sets EPS to 0.0
every single time it calls the Fortran routine for an nD array.  The
results I get back are now the same for the single lspoly call, versus the
do loop call.

If you want to test this out, I can provide you with a new "ncl" executable
to quickly try. If you let me know how you installed NCL before (and which
file you got, if you downloaded it from the ESG), then I will provide you
with a test "ncl" to try.

--Mary


On Thu, Jan 11, 2018 at 2:15 AM, 林祥 <xianglin72 at icloud.com> wrote:

> Hi, Mary
>
>      Thank you for the reply. The HadCRUT4 data file have been attached
> this time , and you can also downloaded it
> from the web page
> https://www.metoffice.gov.uk/hadobs/hadcrut4/data/current/
> time_series/HadCRUT.4.6.0.0.annual_ns_avg.txt
>
> Lin
>
>
>
>
>
>
>
> 在 2018年1月10日,下午11:25,Mary Haley <haley at ucar.edu> 写道:
>
> ​Lin,
>
> It seems like an issue, but I'm unable to run your script because I don't
> have the
> HadCRUT4_ensemble.median_Ann_Global.txt file?
> ​ Can you include this?
>
> Thanks,
>
> --Mary​
>
> On Tue, Jan 9, 2018 at 9:40 PM, 林祥 via ncl-talk <ncl-talk at ucar.edu>wrote:
>
>> 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
>>
>>
>>
>>
>> _______________________________________________
>> 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/20180116/f104ef0b/attachment.html>


More information about the ncl-talk mailing list