[ncl-talk] Batch processing

Adam Phillips asphilli at ucar.edu
Mon Dec 11 11:44:10 MST 2017


Hi Arka,
To be clear to everyone on ncl-talk you are asking how to convert numerous
dat files to .nc files using a single control file and the CDO
import_binary option whose use is illustrated here:
https://www.ncl.ucar.edu/Applications/grads.shtml

You can write a script (in any language, NCL, c-shell, etc) that runs a do
loop for each .dat file, that will create a new ctl file and  convert to a
NetCDF file:

; UNTESTED. You will need to alter the following to suit your needs.
fn = (/"file1.dat","file2.dat","file3.dat"/)

ctl = new(8,string)    ; set up control file (or alternatively read in
existing one)
ctl(1) = "UNDEF 1E30"
ctl(2) = "XDEF 128 LINEAR 0.0 2.8125"
.....  <snip>
ctl(5) = "VARS 1"
ctl(6) = "z 1 99 sea surface temperature"
ctl(7) = "ENDVARS"

do gg = 0,dimsizes(fn)-1
    ctl(0) = "DSET "+fn(gg)
    asciiwrite("file.ctl",ctl)
    system("cdo -f nc import_binary file.ctl "+fn(gg)+".nc")
    system("rm file.ctl")   ; optional
end do

Hope that helps. If you have any further questions please respond to
ncl-talk.
Adam



On Mon, Dec 11, 2017 at 11:25 AM, Arka Banerjee <arka354deb at gmail.com>
wrote:

> Hi..
>
> How to convert .dat files to .nc files using one .ctl file?
>
> Thanks
> Arka
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171211/8f2f5799/attachment.html>


More information about the ncl-talk mailing list