# SVD analysis Display problem

From: Siraj ul Islam <sirajkhan78_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 07 2011 - 14:18:08 MST

Hi All,

I am very new to NCL and working hard to learn all about NCL. I started some
basic analysis by using codes available on Internet. I made some changes in
the code for SVD analysis and I think have made every thing fine. I just
need some help to display right and left singular vectors in NCL using this
code. I do not now how to plot output (spatial patterns and time series).
Can someone further edit this script to plot patterns. I did some thing for
plotting but I received an error.

here is the script
-----------------------------------

begin
nsvd = 3

ppr = f1->prec(:,{-5:45},{55:110}) ; (time,lat,lon)
pr = dim_rmvmean_n(ppr,0)

stt = f2->ssto(:,{-60:60},{-180:180}) ; (time,lat,lon)
st = dim_rmvmean_n(stt,0)

dimtsm = dimsizes(pr)
ntim = dimtsm(0)
nlat = dimtsm(1)
mlon = dimtsm(2)

dimu10 = dimsizes(st)
ntim1 = dimu10(0)
nlat1 = dimu10(1)
mlon1 = dimu10(2)

printVarSummary(pr)
printVarSummary(st)

if (ntim.ne.ntim1) then
print("time dimensions must be the same: ntim="+ntim+" ,
ntim1="+ntim1)
exit
end if

P = onedtond( ndtooned(pr), (/ntim ,nlat *mlon /))
S = onedtond( ndtooned(st) , (/ntim1,nlat1*mlon1/))
P!0 = "time"
P!1 = "space"
S!0 = "time"
S!1 = "space"

PP = P(space|:,time|:)
SS = S(space|:,time|:)

; covar = svdcov(PP,SS,nsvd,homlft,hetlft,homrgt,hetrgt)
; print(covar)

svLeft = new((/nsvd,nlat *mlon /),float)
svRight = new((/nsvd,nlat1*mlon1/),float)

svdec = svdstd_sv(PP,SS,nsvd,svLeft,svRight)
print (svdec)

Le = svLeft
Le!0 = "time"
Le!1 = "space"
Left = Le(space|:,time|:)

Ri = svRight
Ri!0 = "time"
Ri!1 = "space"
Right = Ri(space|:,time|:)

transsvLeft = transpose(Left)
transsst = transpose(P)
xL = onedtond(ndtooned(transsvLeft),(/2,nlat,mlon/))

transsvRight = transpose(Right)
transV = transpose(S)
xR = onedtond(ndtooned(transsvRight),(/2,nlat1,mlon1/))

expcoeficientsL = transsvLeft#transsst
expcoeficientsR = transsvRight#transV

printVarSummary(transsvLeft)
printVarSummary(xL)
printVarSummary(transsvRight)
printVarSummary(xR)
printVarSummary(expcoeficientsR)
printVarSummary(expcoeficientsL)

end

------------------------------
here is the output
------------------------------
SVD: Warning all Y values in column are missing or are constant

Variable: svdec
Type: float
Total Size: 8 bytes
2 values
Number of Dimensions: 1
Dimensions and sizes: [2]
Coordinates:
Number Of Attributes: 1
sv : <ARRAY of 380 elements>
(0) 29.16271
(1) 14.85151

Variable: transsvLeft
Type: float
Total Size: 3040 bytes
760 values
Number of Dimensions: 2
Dimensions and sizes: [time | 2] x [space | 380]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Variable: xL
Type: float
Total Size: 3040 bytes
760 values
Number of Dimensions: 3
Dimensions and sizes: [2] x [19] x [20]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Variable: transsvRight
Type: float
Total Size: 87840 bytes
21960 values
Number of Dimensions: 2
Dimensions and sizes: [time | 2] x [space | 10980]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Variable: xR
Type: float
Total Size: 87840 bytes
21960 values
Number of Dimensions: 3
Dimensions and sizes: [2] x [61] x [180]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Variable: expcoeficientsR
Type: float
Total Size: 160 bytes
40 values
Number of Dimensions: 2
Dimensions and sizes: [2] x [20]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Variable: expcoeficientsL
Type: float
Total Size: 160 bytes
40 values
Number of Dimensions: 2
Dimensions and sizes: [2] x [20]
Coordinates:
Number Of Attributes: 1
_FillValue : -999

Cheers
Siraj

```--
Siraj Ul Islam
PhD student / Research Assistant
Environmental Science and Engineering,
University of Northern British Columbia,