# Re: Warning! LAPACK routine returned eigenvalue <= 0

From: Gus Correa <gus_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 10 2013 - 14:59:38 MDT

Hi Erika

The cos(rad * 90.) is a very small *negative* number
(-4.37114e-08, not zero), because of the limited precision
of floating point computer representation (see below).
(The cosine is probably approximated by a truncated power series.)
Hence, the result is the square root of a negative number,
which is a NaN.

It is close to 0 (to three decimal places),
and the "abs" probably won't harm the results for the other latitudes,
which all have positive cosines anyway.

If you need it to be exactly 0 for lat=+/-90,
then you can force the result to be zero
when the latitude index is 0 or 72 (poles),
using an "if" or "where" in your code.

I hope this helps,
Gus Correa

[gus@monk sst]\$ ncl
University Corporation for Atmospheric Research
NCAR Command Language Version 6.1.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
ncl 1> x=90.
ncl 4> z=sqrt(y)
ncl 5> w=sqrt(abs(y))
ncl 6> print("z="+z+" w="+w)
(0) z=nan w=0.000209073

On 06/10/2013 03:35 PM, Erika Folova wrote:
> Hallo,
>
> Here some information:
>
> ncl 43> print("X: min="+min(u)+" max="+max(u))
> (0)X: min=-82.4277 max=156.545
>
> then, you are correct that
> utrend&lat( 0) = 90.
> .
> .
> .
> utrend&lat(72) = -90.
>
> So what should I do, do I have to reverse the pole points?
>
> Thank you
>
>
>
>
> On Tue, Jun 11, 2013 at 4:22 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> print( utrend&lat )
>
> Looks like the pole points are wrong. Maybe ..
>
> utrend&lat( 0) = 90.
> utrend&lat(72) = -90.
>
>
> clat = utrend&lat
> clat = sqrt( cos(rad*clat) )
>
> Also, if X is the original (unweighted) array
>
> print("X: min="+min(X)+" max="+max)X))
>
> If there are NaNs, the user must eliminate.
>
>
>
> On 6/10/13 1:13 PM, Erika Folova wrote:
>
> I think the problem is in these lines:
>
> clat = utrend&lat
> clat = sqrt( cos(rad*clat) )
>
>
> Variable: clat
> Type: float
> Total Size: 292 bytes
> 73 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat | 73]
> Coordinates:
> Number Of Attributes: 2
> long_name : latitude
> units : degrees_north
> *(0) -nan*
>
> (1) 0.2088527
> (2) 0.2952216
> (3) 0.3612842
> (4) 0.4167112
> (5) 0.4652308
> (6) 0.5087426
> (7) 0.5483665
> (8) 0.5848249
> (9) 0.6186141
> (10) 0.6500909
> (11) 0.6795208
> (12) 0.7071068
> (13) 0.7330072
> (14) 0.7573483
> (15) 0.7802317
> (16) 0.8017403
> (17) 0.8219429
> (18) 0.8408964
> (19) 0.8586485
> (20) 0.8752397
> (21) 0.8907039 <tel:%2821%29%200.8907039>
> (22) 0.9050702
> (23) 0.9183635
> (24) 0.9306049 <tel:%2824%29%200.9306049>
> (25) 0.9418126 <tel:%2825%29%200.9418126>
> (26) 0.952002
> (27) 0.9611865 <tel:%2827%29%200.9611865>
> (28) 0.9693775
> (29) 0.9765844
> (30) 0.9828153
> (31) 0.9880769 <tel:%2831%29%200.9880769>
> (32) 0.9923748 <tel:%2832%29%200.9923748>
> (33) 0.9957132 <tel:%2833%29%200.9957132>
> (34) 0.9980956 <tel:%2834%29%200.9980956>
> (35) 0.999524
> (36) 1
> (37) 0.999524
> (38) 0.9980956 <tel:%2838%29%200.9980956>
> (39) 0.9957132
> (40) 0.9923748
> (41) 0.9880769 <tel:%2841%29%200.9880769>
> (42) 0.9828153
> (43) 0.9765844 <tel:%2843%29%200.9765844>
> (44) 0.9693775 <tel:%2844%29%200.9693775>
> (45) 0.9611865 <tel:%2845%29%200.9611865>
> (46) 0.952002
> (47) 0.9418126 <tel:%2847%29%200.9418126>
> (48) 0.9306049 <tel:%2848%29%200.9306049>
> (49) 0.9183635
> (50) 0.9050702 <tel:%2850%29%200.9050702>
> (51) 0.8907039 <tel:%2851%29%200.8907039>
> (52) 0.8752397 <tel:%2852%29%200.8752397>
> (53) 0.8586485 <tel:%2853%29%200.8586485>
> (54) 0.8408964 <tel:%2854%29%200.8408964>
> (55) 0.8219429
> (56) 0.8017403
> (57) 0.7802317 <tel:%2857%29%200.7802317>
> (58) 0.7573483 <tel:%2858%29%200.7573483>
> (59) 0.7330072
> (60) 0.7071068 <tel:%2860%29%200.7071068>
> (61) 0.6795208 <tel:%2861%29%200.6795208>
> (62) 0.6500909 <tel:%2862%29%200.6500909>
> (63) 0.6186141 <tel:%2863%29%200.6186141>
> (64) 0.5848249
> (65) 0.5483665 <tel:%2865%29%200.5483665>
> (66) 0.5087426 <tel:%2866%29%200.5087426>
> (67) 0.4652308
> (68) 0.4167112
> (69) 0.3612842
> (70) 0.2952216 <tel:%2870%29%200.2952216>
> (71) 0.2088527 <tel:%2871%29%200.2088527>
> *(72) -nan*
>
>
>
> Variable: utrend
> Type: float
> Total Size: 510630912 bytes
> 127657728 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 528] x [level | 23] x [lat | 73] x
> [lon | 144]
> Coordinates:
> time: [508416..893376]
> level: [1..1000]
> lat: [90..-90]
> lon: [ 0..357.5]
>
>
> But I dont know why I got "NaN".
>
> Thank you,
>
>
>
>
>
>
>
>
>
>
> On Tue, Jun 11, 2013 at 3:56 AM, Erika Folova
> <e.folova@gmail.com <mailto:e.folova@gmail.com>> wrote:
>
> Hallo everyone,
>
> would you please to help me, I got some errors when I tried
> to calculate
> eof
> for variable (*level, lat*, time):
>
>
> Warning! LAPACK routine returned eigenvalue <= 0.
> Setting it to zero...
> warning:ContourPlotInitialize: no valid values in scalar field;
> ContourPlot not possible:[errno=1101]
> warning:LlSetValues: invalid range for Y Axis log mode;
> setting trYLog off
>
>
> Part of my codes:
> [SNIP]
>
> wx = xw (level|:,lat|:,lon|:,time|:)
> delete(xw)
> x= wx (:,:,{0},:)
> printVarSummary(x)
>
>
> eof = eofunc_Wrap(x, neof, optEOF)
> eof = -1*eof
> eof_ts = eofunc_ts_Wrap (x, eof, optETS)
>
> printVarSummary( eof ) ;
> examine EOF
> variables
> printVarSummary( eof_ts )
>
> eof_ts = dim_standardize_n( eof_ts, 0, 1) ; normalize
>
> eof_regres = eof ; regress
> do ne=0,neof-1
> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
> x(level|:,lat|:,time|:)) /)
> end do
>
> ----
>
> plot = gsn_csm_pres_hgt(wks, eof_regres(0,:,:), res )
> ; place holder
>
> end
>
>
> ==============================
>
> Variable: x
> Type: float
> Total Size: 3546048 bytes
> 886512 values
> Number of Dimensions: 3
> Dimensions and sizes: [level | 23] x [lat | 73] x [time | 528]
> Coordinates:
> level: [1..1000]
> lat: [90..-90]
> time: [508416..893376]
> Number Of Attributes: 7
> lon : 0
> missing_value : -32767
> long_name : Wgt: U velocity
> units : m s**-1
> missing_value_original : -32767
> _FillValue : -32767
> _FillValue_original : -32767
> Warning! LAPACK routine returned eigenvalue <= 0.
> Setting it to zero...
>
> Variable: eof
> Type: float
> Total Size: 6716 bytes
> 1679 values
> Number of Dimensions: 3
> Dimensions and sizes: [evn | 1] x [level | 23] x [lat | 73]
> Coordinates:
> evn: [1..1]
> level: [1..1000]
> lat: [90..-90]
> Number Of Attributes: 7
> eval_transpose : 0
> eval : 0
> pcvar : -nan
> matrix : covariance
> method : transpose
> _FillValue : -32767
> long_name : EOF: Wgt: U velocity
>
> Variable: eof_ts
> Type: float
> Total Size: 2112 bytes
> 528 values
> Number of Dimensions: 2
> Dimensions and sizes: [evn | 1] x [time | 528]
> Coordinates:
> evn: [1..1]
> time: [508416..893376]
> Number Of Attributes: 4
> ts_mean : -nan
> matrix : covariance
> _FillValue : -32767
> long_name : EOF: Amplitude: Wgt: U velocity
> *ncl 77> print(max(eof_regres))*
> *(0) 9.96921e+36*
> *ncl 78> print(max(eof)) *
> *(0) -nan*
> *ncl 79> print(max(eof_ts))*
> *(0) -nan*
> *ncl 80> print(min(eof)) *
> *(0) -nan*
>
>
>
> Erika,
>
>
>
>
>
>
>
> _________________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/__mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 10 14:59:49 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:57 MDT