Re: ndtooned out

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri, 07 Apr 2006 15:48:06 -0600

Hi Scott,

First of all, Saji's suggestion is a very good one. mask is likely the
fastest way to do what you need to do. And while it is recommended you
try to limit your use of do loops in NCL, I don't think you will see a
large performance hit doing a double do loop unless you are dealing with
a rather large data array... Some other users might contradict me on
that...

Anyway, I think I see where the issue is:

if (any(u_asc.eq.0)) then
    u_asc1D = ndtooned (u_asc) ;convert to 1D array
    wvc_asc1D = ndtooned (wvc_asc) ;convert to 1D array

    i0 = ind(u_asc1D.eq.0) ;all indices eq 0
    if (any(wvc_asc1D(i0).eq.0)) then
       iwvc0 = ind(wvc_asc1D(i0).eq.0)

The line above is passing in indices using i0, and thus the entire
wvc_asc1D array is not being analyzed.

For instance, lets say i0 = 0,5,6,9 , and the criteria
wvc_asc1D(i0).eq.0 says that slots 0 and 6 are equal to 0.
ind(wvc_asc1D(i0).eq.0) will result in iwvc0 being = 0,2, which are the
incorrect indices of u_asc1D that you want to set to 0.

I bet there is a way to use ind to accomplish what you want, but I think
using mask is the way to go...
Adam

Scott Capps wrote:
> Greetings,
>
> I am trying to place a FillValue where bad data is residing. The
> wvc_asc array (same size and shape as u_asc) determines where bad data
> is located. For all u_asc indicies with zero wind speeds, check to see
> if wvc_asc is also zero. If it is, place a @_FillValue at that index of
> the u_asc array.
>
> This works just fine but, I want to limit my use of do....loops within NCL:
> u_asc@_FillValue = -999.0
>
> if (any(u_asc.eq.0)) then
>
> ds = dimsizes(u_asc)
>
> do idxlat=0,ds(0)-1
> do idxlon=0,ds(1)-1
> if (u_asc(idxlat,idxlon).eq.0) then
> if (wvc_asc(idxlat,idxlon).eq.0) then
> u_asc(idxlat,idxlon)=-999.0
> end if
> end if
> end do
> end do
> end if
>
>
> Here is a more effecient way that I am trying to accomplish this but, it
> is not producing the same results as the do....loop above:
>
> if (any(u_asc.eq.0)) then
> u_asc1D = ndtooned (u_asc) ;convert to 1D array
> wvc_asc1D = ndtooned (wvc_asc) ;convert to 1D array
>
> i0 = ind(u_asc1D.eq.0) ;all indices eq 0
> if (any(wvc_asc1D(i0).eq.0)) then
> iwvc0 = ind(wvc_asc1D(i0).eq.0)
> u_asc1D(iwvc0) = -999.0
> end if
> u_asc = onedtond(u_asc1D, dimsizes(u_asc));return to the
> original array
> delete (wvc_asc1D)
> delete (u_asc1D)
> delete (i0)
> delete (iwvc0)
> end if
>
> Any suggestions?
>
> Thank you,
>
>
> Scott Capps
> scapps_at_uci.edu
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 07 2006 - 15:48:06 MDT

This archive was generated by hypermail 2.2.0 : Fri Apr 07 2006 - 16:57:49 MDT