Re: Maximum Covariance Analysis

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 27 2009 - 12:54:43 MST

http://www.ncl.ucar.edu/Document/Functions/Built-in/svdcov.shtml

        function svdcov (
                x [*][*] : numeric,
                y [*][*] : numeric,
                nsvd : integer,
                homlft [*][*] : numeric,
                hetlft [*][*] : numeric,
                homrgt [*][*] : numeric,
                hetrgt [*][*] : numeric
        )

You took
> tempsup = tsm( time|:, lat|:, lon|: ) ; 3d
> uwnd = u( time|:, lat|:, lon|: ) ; 3d

which are 3-dimensional, and then invoked svdcov

> covar = svdcov(tempsup(time|:, tsurf|:),uwnd(time|:, \
> tsurf|:),nsvd,homlft,hetlft,homrgt,hetrgt)

with
tempsup(time|:, tsurf|:) ; 2d
and
uwnd(time|:, tsurf|:) ; 2d

Where did "tsurf" come from?

A transformation from 3d-to-2d does not happen automatically.
The user must do this.

     dimu = dimsizes( u )
     ntim = dimu(0)
     nlat = dimu(1)
     mlon = dimu(2)

     T = onedtond( ndtooned(tempsup), (/ntim,nlat*mlon/)) ; 2D
     U = onedtond( ndtooned( uwnd ), (/ntim,nlat*mlon/)) ; 2D

    covar = svdcov(T,U,nsvd,homlft,hetlft,homrgt,hetrgt)

===
If you are new to NCL I suggest you read the mini-language manual.
Later, if interested in the graphics, the min-graphics manual.

http://www.ncl.ucar.edu/Document/Manuals/

They are pdf. They do have color so if you have a color
printer, I suggest using it.

Good luck

leonardo.silva@cptec.inpe.br wrote:
> Hi all,
>
> I'm a new ncl user and I would like to construct an Atlantic
> Meridional Mode (AMM) Index like done by ERSL
> (http://www.esrl.noaa.gov/psd/data/timeseries/monthly/AMM/). I have to
> apply a Maximum Covariance Analysis to a SST field (left field) and
> the zonal and meridional 10m wind (right field) through a Singular
> Value Decomposition (SVD). I have to extract the first left (SST) and
> right (winds) maps resulting from singular value decomposition of the
> covariance matrix. The AMM time series is calculated via projecting
> SST or the 10m wind field. onto the spatial structure resulting from
> the MCA.
>
> I tried to construct that thing using the scrpt below:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
>
>
> latS = -21.
> latN = 32.
> lonL = -74.
> lonR = 15.
>
> nsvd = 2
> ncolf1 = 1316
> ncolf2 = 1316
>
> homlft = new((/nsvd,ncolf1/),float)
> hetlft = new((/nsvd,ncolf1/),float)
> homrgt = new((/nsvd,ncolf2/),float)
> hetrgt = new((/nsvd,ncolf2/),float)
>
> f1 = addfile ("EH5_OM_20C_2_TSURF_DETRENDRUNMEAN.nc", "w")
> tsm = f1->tsurf
> f1!0 = "time"
> f2 = addfile ("EH5_OM_20C_2_U10M_DETRENDRUNMEAN.nc", "w")
> u = f2->u10
> tempsup = tsm( time|:, lat|:, lon|: )
> uwnd = u( time|:, lat|:, lon|: )
>
> covar = svdcov(tempsup(time|:, tsurf|:),uwnd(time|:,
> tsurf|:),nsvd,homlft,hetlft,homrgt,hetrgt)
>
> asciiwrite("mca.dat", covar(0,:))
>
> and I got it like answer:
>
> ncl 28> covar = svdcov(tempsup(time|:, tsurf|:),uwnd(time|:,
> tsurf|:),nsvd,homlft,hetlft,homrgt,hetrgt)
> fatal:Number of subscripts do not match number of dimensions of
> variable,(2) Subscripts used, (3) Subscripts expected
> fatal:Execute: Error occurred at or near line 28
>
> I have more one question:
>
> How can I put the wind (u+v) components onto a one variable? Have I to
> sum the u and v.nc files?
>
> Regards
>
> Leonardo
>
> _______________________________________________
> 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 Fri Nov 27 12:55:29 2009

This archive was generated by hypermail 2.1.8 : Sun Nov 29 2009 - 20:52:58 MST