Jan,
> newvar = var would work if newdims had fewer elements than
> dimsizes(var)... I thought NCL would complain about mismatched
> dimensionality of the left-hand and right-hand side of the assignment in
> that case?
I thought Dennis explained this very well (please see Dennis mail related to
this thread)
Here is an example.
var=new( (/20,30,1/), "float")
var=1.0
var!0="x"
var!1="y"
var!2="z"
printVarSummary(var)
newvar=removeRedundantDimsOf(var)
printVarSummary(newvar)
%%%%%%%%%%%%%%%
Variable: var
Type: float
Total Size: 2400 bytes
600 values
Number of Dimensions: 3
Dimensions and sizes: [x | 20] x [y | 30] x [z | 1]
Coordinates:
Number Of Attributes: 1
_FillValue : -999
Variable: newvar
Type: float
Total Size: 2400 bytes
600 values
Number of Dimensions: 2
Dimensions and sizes: [x | 20] x [y | 30]
Coordinates:
Number Of Attributes: 1
_FillValue : -999
%%%%%%%%%%%%%%%55
I don't know if it may suit your needs. What it does is the following.
If the size of one the data dimensions is 1, it identifies that
dimension and removes it. For example data(lat,lon,time).. if there
is only one latitude values (dimsizes(lat) = 1), it reduces the
size of the array by removing the "lat" dimension.
saji
* Jan Ploski <Jan.Ploski_at_offis.de> [2007-12-05 16:28:25 +0100]:
> ncl-talk-bounces_at_ucar.edu schrieb am 12/05/2007 03:37:56 PM:
>
> > 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,
>
> Could you please post print(var) and print(newvar) for a little example of
> what the function is supposed to do? I am confused why the assignment
> newvar = var would work if newdims had fewer elements than
> dimsizes(var)... I thought NCL would complain about mismatched
> dimensionality of the left-hand and right-hand side of the assignment in
> that case?
>
> 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-talkReceived on Wed Dec 05 2007 - 18:21:13 MST
This archive was generated by hypermail 2.2.0 : Tue Dec 11 2007 - 14:19:21 MST