reading 3 hourly data

From: Debasish PaiMazumder <debasish_at_nyahnyahspammersnyahnyah>
Date: Thu, 27 Aug 2009 16:59:46 -0400

Hello,

I have 480 months 3 hourly precipitation data. I am trying to add all
the files to create PREc (Year, month, lat, lon) using example
crcm_2.ncl from http://www.ncl.ucar.edu/Applications/cccma.shtml

I am including my script below

  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

  begin

  diri = "/rech/debasish/PREC/aev/" ; input directory
  fili = systemfunc("cd "+diri+" ; ls aev_p1pcp_*.nc"); inpit
file name(s)
  nfil = dimsizes(fili)
  print(fili)
  varName = "pcp"
  netCDF = True
;*******************************************
; Loop over files
;*******************************************
  do nf=0,nfil-1
     f = addfile (diri+fili(nf), "r")
     x3 = f->$varName$ ; (time,yc, xc) 3 hrly

     dimx3 = dimsizes(x3)
     NTIM = dimx3(0) ; TOTAL number of time steps
     print("NTIM="+NTIM)
;*******************************************
; Create daily averages
;*******************************************
     ntJump = 8 ; 3-hrly values
     x = x3(::ntJump,:,:) ; trick: create array with meta
     printVarSummary(x) ; values will be overwritten
with averages
     ntStrt = 0
     ntLast = ntJump-1
     do nt=0,NTIM-1,ntJump ; dim_avg_n v5.1.1
        x(nt/ntJump,:,:) = (/ dim_avg_n(x3(ntStrt:ntLast,:,:),
0) /) ; (/.../) ignore meta
        ntStrt = ntStrt+ntJump
        ntLast = ntLast+ntJump
     end do
     x_at_info_tag = "daily average"
    printVarSummary(x)
;*******************************************
; Convert units kg/(m2-s) to mm/day
; multiply by (10^3mm m-1 x 86400 s day-1) and
; divide by density_H2O (1000 kg m-3):
; [kg/m2-s][1000 mm/m][86400 s/day][(1/1000) m3/kg] ==> mm/day
;*******************************************
     x = x*86400.
     x_at_units = "mm/day"
;********************************************
   y= new((/nfil,172,180/), float)
   y(nf,:,:)= (/dim_sum_n(x(:,:,:),0)/)

    delete(x3)
    delete(x)

   end do
   print(y)

   y1D = ndtooned(y)
   PREC = onedtond(y1D,(/40,12,172,180/))
   printVarSummary(PREC)
   print(avg(PREC))
   fout = addfile("aev_pcp_1961-2000.nc","c")
   fout->PREC = (/ PREC /)

end

This program works fine but when I print y outside of the main loop
(loop for nf), y only store the values for the last time step and
rest of the values are missing. How do I fix this problem so that y
store the value for all 480 months.

Thanks
Debasish

Debasish PaiMazumder, PhD
Hydrology & Climate Science
Postdoctoral Researcher at UQÀM/Ouranos
550, Sherbrooke west, 19th floor, west tower,
Montréal, QC, Canada H3A 1B9
Tel: (514) 282-6464-343
      (514) 937-0042 (R)
email: debasish_at_sca.uqam.ca

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 27 2009 - 14:59:46 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 02 2009 - 12:24:39 MDT