[ncl-talk] read separated files

guozfruit guozfruit at aliyun.com
Sat Aug 2 09:37:32 MDT 2014


Hi all,I have 3-hr netcdf data in 12 separated files (ie for 12 months). I'm trying to extract one grid preciptation for the whole year. I have the problem about how to define one variable with different dimensions when I read data from different files. Could you please help me with it? Thanks.As below are the data info, and my script:dimensions:lon = 700 ;lat = 400 ;time = UNLIMITED ;short prec(time, lat, lon) ;    prec:scale_factor = 0.002f ;    prec:add_offset = 50.f ;    prec:_Fill_Value = -32767s ;    prec:missing_value = -32767s ;    prec:units = "mm hr-1" ;    prec:long_name = "Precipitation rate" ;
 year = 2008 mon = 12 nhour = new(mon,integer)
  if(year .eq. 2008) then   day_leap    = (/31,29,31,30,31,30,31,31,30,31,30,31/)   do i = 0,mon-1      nhour(i) = day_leap(i)*8   end do  else   day_nonleap = (/31,28,31,30,31,30,31,31,30,31,30,31/)   do i = 0,mon-1     nhour(i) = day_nonleap(i)*8   end do  end ifpp =  new((/12,nhour/),float)do imon = 1,12     if(imon.lt.10) then       mon3 = "0"+imon     else       mon3 = ""+imon     end if     scrDir0 = "/d1/zhangg/prec/"   do ifl = 0,nhour(imon-1)-1     na  = addfile(scrDir0+"prec_ITPCAS-CMFD_V0105_B-01_"+year+mon3+".nc","r")    pp(imon-1,ifl)  = na->prec(:,107,302)   end do  end do

X
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140802/e21cd3ae/attachment.html 


More information about the ncl-talk mailing list