Re: how to keep the time dimension?

From: Mary Haley (haley AT XXXXXX)
Date: Wed Aug 15 2001 - 13:50:42 MDT

  • Next message: Jason Evans: "creating mpegs?"

    > Dear NCL users
    >
    > I try to get the monthly mean by average the daily data. When I use p0 =
    > dim_sum(p(lat|:,lon|:,time|:)), then p0 become two dimension
    > p0(lat,lon). I hope to get three dimensions output p0(lat,lon,time),
    > where dimsize(time)=1, because I need to concatenate all the monthly
    > data into a large file. Has anyone know how to solve my problems? Thanks
    > a lot.
    >
    > Song Feng

    Dear Song Feng,

    You can do this using a combination of the ndtooned/onedtond
    functions, that allow you to convert from multi-dimenioned arrays to
    single-dimensioned arrays, and vice versa. For example:

      dsizes_p = dimsizes(p) ; Dimension sizes of p
      ntime = dsizes_p(0) ; Or whatever dimension represents time.
      nlat = dsizes_p(1) ; " " " " lat
      nlon = dsizes_p(2) ; " " " " lon

      p0 = dim_sum(p(lat|:,lon|:,time|:)) ; p0 is (nlat x nlon)

      p01d = ndtooned(p0) ; convert to 1D
      p0_new = onedtond(p01d,(/nlat,nlon,1/)) ; convert to (nlat x nlon x 1)

    Or, you can create the "p0" array in advance:

      p0 = new((/nlat,nlon,1/),float)

      p0(:,:,0) = dim_sum(p(lat|:,lon|:,time|:))
       

    --Mary



    This archive was generated by hypermail 2b29 : Wed Aug 15 2001 - 13:51:20 MDT