Re: Re: [ncl-talk] Reducing the rank of an arbitrary variable

From: Saji Njarackalazhikam Hameed <saji_at_nyahnyahspammersnyahnyah>
Date: Wed, 5 Dec 2007 23:37:56 +0900

Hi Jan,

Don't know if this will help..I use this to reduce the dimensionality of an array when
the size of the array element is less than 1. It also returns the modified dimension
names array.

function removeRedundantDimsOf(var)
begin
  var_dims=dimsizes(var)
  dim_names=getvardims(var)
  new_indcs=ind(var_dims.gt.1)
  newdims=var_dims(new_indcs)
  new_dimnames=(dim_names(new_indcs))
  ndims=dimsizes(newdims)
  newvar=new(newdims,typeof(var))
  newvar=var
  do i=0,ndims-1
    newvar!i=new_dimnames(i)
  end do
return(newvar)
end

saji

* Jan Ploski <Jan.Ploski_at_offis.de> [2007-12-05 15:38:10 +0100]:

> Dennis Shea <shea_at_ucar.edu> schrieb am 12/05/2007 03:32:35 PM:
>
> >
> > X = V(i,:,:,...,:)
> > printVarSummary(X)
>
> I guess I didn't express myself clearly enough: the actual problem is that
> I do not know the rank of V in advance. I would like to avoid writing code
> like:
>
> rankV = dimsizes(dimsizes(V))
> if (rankV .eq. 1) then
> X = V(i)
> end if
> if (rankV .eq. 2) then
> X = V(i,:)
> end if
> if (rankV .eq. 3) then
> X = V(i,:,:)
> end if
> if (rankV .eq. 4) then
> X = V(i,:,:,:)
> end if
> ...
>
> and so on. Any ideas?
>
> Regards,
> Jan Ploski
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
Saji N. Hameed
APEC Climate Center          				+82 51 668 7470
National Pension Corporation Busan Building 12F         
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705			saji_at_apcc21.net
KOREA
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 05 2007 - 07:37:56 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 05 2007 - 10:17:04 MST