> if i didn't know the variable name dimention  but i want to reorder the variable dimention
> i try the codes :
> begin
> f = addfile(filepath,"r")
> var = f->varname
> dims = getvardims(var)
> var_reorder = dim_rmvmean_Wrap(dims(1)|:,dim(2)|:,dim(0)|:)
> end
>
> it has syntax error about  the line " var_reorder = dim_rmvmean_Wrap(dims(1)|:,dim(2)|:,dim(0)|:) "
> how can i reorder the dimention without knowing the name dimention ?
You are using the correct function to retrieve the dimension
names of a variable.
  http://www.ncl.ucar.edu/Document/Functions/Built-in/getvardims.shtml
However, there are two problems with what you have done:
[1]  These are probably just errors for this example:
     var_reorder = dim_rmvmean_Wrap(var(dims(1)|:,dim(2)|:,dim(0)|:))
                                    ^^^           ^^^      ^^^      ^
     The 'dim' should be 'dims'.
[2] This is much more subtle.  It involves using a
     "variable string reference". This is accomplished by
     enclosing a string  with dollar sign ("$") syntax.
     http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#FileStringRef
    The example for getvardims will be improved to include this example.
    var_reorder = dim_rmvmean_Wrap(var($dims(1)$|:,$dims(2)$|:,$dims(0)$|:))
    ------------
    Note you could make this so it could work on 3- or 4-dimensional arrays
   var  = f->varname
   dims = getvardims(var)
   rank = dimsizes(dims)
   if (rank.eq.3) then
       var_reorder = dim_rmvmean_Wrap($dims(1)$|:,$dims(2)$|:,$dims(0)$|:)
   end if
   if (rank.eq.4) then
       var_reorder = dim_rmvmean_Wrap($dims(1)$|:,$dims(2)$|:,$dims(3)$|:,$dims(0)$|:)
   end if
-----------
D
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Mon Jun 20 2005 - 10:07:29 MDT