[ncl-talk] help required

Wei Huang huangwei at ucar.edu
Mon May 11 21:04:57 MDT 2015


Try the script below.

Wei

----------

 fn = "your-wrf-file-to-be-splited"

 f = addfile(fn, "r")

 times = f->Times

 ntimes = dimsizes(times)

 print("dimsizes(times)=" + dimsizes(times))

;------------------------------------------------------------
 fvarnames = getfilevarnames(f)
;print(fvarnames)

 fattnames = getvaratts(f)
;print(fattnames)

 fAtt               = True            ; assign file attributes

 do n = 0, dimsizes(fattnames) - 1
    fAtt@$fattnames(n)$ = f@$fattnames(n)$
 end do

 do i = 0, ntimes(0) - 1
    fon = fi + "_part_" + i + ".nc"

    system("/bin/rm -f " + fon)
    fo = addfile(fon, "c")

    fileattdef(fo, fAtt)

    do n = 0, dimsizes(fvarnames) - 1
       vn = str_sub_str(fvarnames(n), "/", "")
       vdims := getfilevardims(f, vn)
       nvdims := dimsizes(vdims)
       print("Processing var " + n + ": <" + vn + ">, nvdims = " + nvdims)

       if(nvdims .eq. 1) then
          v := f->$vn$(i:i)
       end if
       if(nvdims .eq. 2) then
          v := f->$vn$(i:i, :)
       end if
       if(nvdims .eq. 3) then
          v := f->$vn$(i:i, :, :)
       end if
       if(nvdims .eq. 4) then
          v := f->$vn$(i:i, :, :, :)
       end if
       if(nvdims .eq. 5) then
          v := f->$vn$(i:i, :, :, :, :)
       end if
       fo->$vn$ = v
    end do
 end do

 delete(fAtt)
 delete(fvarnames)
 delete(fattnames)


================================================
1850 Table Mesa Dr.
Boulder, CO 80307
Phone: 303-497-8924

On Sat, Apr 18, 2015 at 8:51 AM, Muhammad Omer Mughal <
m.mughal1 at postgrad.curtin.edu.au> wrote:

>  Hi All
>
>
>  I tried to split the wrf out file using the following script.
>
>
>  #!/bin/bash
>
> n=136
>
> for ((i=1; i<=n; i++)){
> ncks -O -d Time,$i wrfout_d01_2009-07-08_00:00:00.nc  $i.nc
> }
>
> I am now trying to rename the file similar to  wrfout_d01_2009-07-08_00:00:
> 00.nc .I am now trying to renam all the files such that I am able to
> update date and hour in the wrf output file format.I am using the following
> for it.
>
> foreach file('ls *.nc')
> ? ncra -n 136,5,3  wrfout_d01_2009-07-0*.nc  wrfout_d01_2009-07-08_00:00:
> 00.nc
> ? end
> but this is'nt working .I also wrote the attached ncl script and tried to
> link that to csh but that also didn't worked . I would appreciate if some
> one can help me urgently.
>
>
>> Muhammad Omer Mughal
>  MSc BSc Mechanical Engineering
> PhD  Research Scholar
>  Remote Sensing and Satellite Research Group
>  Department of Imaging and Applied Physics
> Curtin University
>
> Curtin University
> Tel | +61 8 9266 7962
> Fax | +61 8 9266 2377
> Mobile | 0470 237 525
>
> _______________________________________________
> 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/20150512/e9f62d87/attachment.html 


More information about the ncl-talk mailing list