Re: '.NOT.' of get1Dindex

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 03 2013 - 10:07:11 MDT

You can easily copy this function and modify it to do what you want.

Look at the file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

You will see the "get1Dindex" code in it:

undef("get1Dindex")
function get1Dindex (cv[*], cvWant[*])
local nWant, indWant, n
begin
  nWant = dimsizes (cvWant)
  indWant = new (nWant, typeof(dimsizes(cv)))

  do n=0,nWant-1
     indWant(n) = ind( cv.eq.cvWant(n) )
  end do

  return (indWant)
end

Copy this code and put it in your own file, say, "get1Dindex_not.ncl", and rename the function:

undef("get1Dindex_not")
function get1Dindex_not (cv[*], cvDontWant[*])
local nDontWant, indWant, ncv, nWantn
begin
  nDontWant = dimsizes (cvDontWant)
  ncv = dimsizes (cv)
  nWant = ncv-nDontWant
  indWant = new (nWant, typeof(dimsizes(cv)))

  nCount = 0
  do n=0,ncv-1
    if(.not.any(cv(n).eq.cvDontWant)) then
     indWant(nCount) = n
     nCount = nCount + 1
    end if
  end do

  return (indWant(0:nCount-1) )
end

On May 30, 2013, at 10:03 PM, Prince K XAVIER wrote:

> Hi all,
>
> Is there a quick way of inverting what get1Dindex does? That is, I need indices of the big array where the values are not equal to the elements in the smaller array. I'm probably after some logic here :)
>
> Thanks in advance,
> Prince
> _______________________________________________
> 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 Mon Jun 3 10:07:24 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 04 2013 - 09:50:17 MDT