Re: reading 3 hourly data

From: <debasish_at_nyahnyahspammersnyahnyah>
Date: Thu, 27 Aug 2009 16:18:49 -0800

Thanks Jess, It works fine now.

Debasish

Quoting Jessica Paxton <jnpaxton_at_ucar.edu>:

> Hi Debasish,
>
> You're declaring the y array each time you go through the loop (and,
> since the dimensions of y are always the same, NCL won't yell at you).
>
> Put: y= new((/nfil,172,180/), float) before the "do" command.
>
> Hope that helps.
>
> Jess
>
> Debasish PaiMazumder wrote:
>> 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 <mailto:debasish_at_sca.uqam.ca>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> *********************************************************
> Jessica N. Mackaro
>
> Climate Analysis Section
> Climate and Global Dynamics Division
> National Center for Atmospheric Research
> P.O. Box 3000
> Boulder, CO 80307
> tel: 303-497-1305 fax: 303-497-1333
> email: jnpaxton_at_ucar.edu
> *********************************************************
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 27 2009 - 18:18:49 MDT

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