[ncl-talk] read separated files

Dennis Shea shea at ucar.edu
Mon Aug 4 08:55:42 MDT 2014


"ListSet Type" could be used  but the following may be easier.
https://www.ncl.ucar.edu/Document/Functions/Built-in/ListSetType.shtml

Also, your dats is type "short"
https://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml

========
Please see 'addfiles'

https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml

===
   scrDir0 = "/d1/zhangg/prec/"
   scrFile0= systemfunc("cd "+ scrDir0 +" ; ls
TPCAS-CMFD_V0105_B-01_"+year+".nc"
   print(srcFile0)

   na = addfiles(srcDir0+srcFile0, "r")

*   pp = short2flt( na[:}->prec(:,107,302))*

*   printVarSummary(pp)*





On Sat, Aug 2, 2014 at 10:35 AM, Yuqiang Zhang <yuqiangzhang.thu at gmail.com>
wrote:

> Hi,
>
>
>
> You can use this function “ListSetType” to read different dimensions data
> from multi files.
>
>
>
> Regards,
>
> Yuqiang
>
>
>
> *From:* ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] *On
> Behalf Of *guozfruit
> *Sent:* Saturday, August 02, 2014 11:38 AM
> *To:* NCL
> *Subject:* [ncl-talk] read separated files
>
>
>
> 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 if
>
>
>
> *pp =  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
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140804/5bf2441c/attachment.html 


More information about the ncl-talk mailing list