Re: ndtooned out

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 10 Apr 2006 07:04:46 -0600 (MDT)

As Saji suggests the "mask" function is the best way to
accomplish what you want: setting values that satisfy
specific conditions to the _FillValue.

The ndtooned, onedtond, ind approach is a general appraoch.

On Fri, 7 Apr 2006, Saji Njarackalazhikam Hameed wrote:

> Scott,
>
> There is a function called mask. I think you would be able to do this
> sort of thing efficiently with mask.
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/mask.shtml
>
> something like
> u_asc=mask(u_asc,wvc_asc.eq.0 .and. u_asc.eq.0, False)
>
> may work...
>
> saji
> ---
>
> * Scott Capps <scapps_at_uci.edu> [2006-04-07 14:08:19 -0700]:
>
>> 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
>
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 10 2006 - 07:04:46 MDT

This archive was generated by hypermail 2.2.0 : Mon Apr 10 2006 - 15:41:13 MDT