Re: Re: [ncl-talk] How to convert 3-d array into a 2-d array withoutmissing beforeusing SVD function?

From: leo.aries.g <leo.aries.g_at_nyahnyahspammersnyahnyah>
Date: Mon, 6 Oct 2008 01:34:31 +0800

Thank you for the reply, but my question is

[1] The two array share the same time span, but with different grids. ie.
     x(time,lat1,lon1) and y(time,lat2,lon2)



[2] As to your untested example,

     assume x and y have the same time span and grids, x(time,lat,lon) and y(time,lat,lon),
     A certain grid should be excluded even if there is only one missing for the whole time span.
     for example, x(0,0,0) = x@_FillValue, and all the values of the first grid should be excluded.
     ie, x(1:time-1,0,0) should also be removed. But I think the script in the example fail to do this.

    
Thanks


- Lin


2008-10-05



leo.aries.g



发件人: Dennis Shea
发送时间: 2008-10-05 22:30:03
收件人: leo.aries.g
抄送: ncl-talk
主题: Re: [ncl-talk] How to convert 3-d array into a 2-d array withoutmissing beforeusing SVD function?
Hello,

[1]
The following will *not* work:

       numbers(i,j) = num(x(:,i,j).ne.x@_FillValue)

The *only* way to test of missing values is:

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

[2]

The following illustrates how to remove missing values from 1D arrays:

   http://www.ncl.ucar.edu/FAQ/#array_funcs_003

This is far more efficient ... no loops.

[3]
Untested and assuming that all time steps are present.

        x(time,lat,lon) , y(time,lat,lon)

        x1D = ndtooned( x(lat|:,lon|:,time|:) ) ; (nlat*nlon*ntim)
        y1D = ndtooned( y(lat|:,lon|:,time|:) )

        ii = ind( .not.ismissing(x1D) .and. .not.ismissing(y1D))
        nii = dimsizes(ii)

        ngrd = nii/ntim

        xsvd = onedtond( x1D(ii), (/ngrd,ntim/) )
        ysvd = onedtond( y1D(ii), (/ngrd,ntim/) )




leo.aries.g wrote:
>
> Hi, all
>
> I want to do a SVD analysis between sea ice (time,lat,lon) and
> slp(time,lat,lon).
> The SVD function of NCL do not allow the missing value, but the sea ice
> grid datas often
> contain some missing values. So My question is how to change the
> 3-dimension array of sea
> ice with some _FillValue points into a 2-dimension(required by the SVD
> function) array without
> _FillValue points.
>
> I write some script to solve it, but it is a little fussy.
> Anyone could show me a easy way?
> possiblely, without using loops. Thanks!
>
> Here below is my script:
>
> +2 begin
> +3
> +6 fi = addfile("/dgpfs/fs1/linxiang/Seaice/HadISST_ice.nc","r")
> +7 x = fi- >ice(1308:1655,{-50.5:},:) ; Jan
> 1979 to Dec 2007, 348 months in total
> +8
> +9 lat = x&lat
> +10 lon = x&lon
> +11 printVarSummary(x)
> +12
> +13 numbers = new((/dimsizes(x&lat),dimsizes(x&lon)/),"integer")
> +14 do i = 0,dimsizes(x&lat)-1
> +15 do j = 0,dimsizes(x&lon)-1
> +16 numbers(i,j) = num(x(:,i,j).ne.x@_FillValue)
> +17 end do
> +18 end do
> +19
> +20 nx = num(numbers.eq.348)
> +21
> +22 y = new((/nx,348/),"float")
> +23 ylat = new((/nx/),"float")
> +24 ylon = new((/nx/),"float")
> +25
> +26 n = 0
> +27 do i = 0,dimsizes(x&lat)-1
> +28 do j = 0,dimsizes(x&lon)-1
> +29 if(all(.not.ismissing(x(:,i,j)))) then
> +30 y(n,:) = x(:,i,j)
> +31 ylat(n) = lat(i)
> +32 ylon(n) = lon(j)
> +33 n = n+1
> +34 end if
> +35 end do
> +36 end do
> end
>
> Regards
>
> Lin
>
> 2008-10-04
> leo.aries.g
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Oct 05 2008 - 11:34:31 MDT

This archive was generated by hypermail 2.2.0 : Tue Oct 07 2008 - 09:09:48 MDT