[ncl-talk] Batch processing

Karin Meier-Fleischer meier-fleischer at dkrz.de
Mon Dec 11 11:52:11 MST 2017


Adam is right, I've missed that you want to convert numerous files. It 
is not possible to have one common ctl file for numerous binary files! 
Each data file has to have its own ctl file. So, follow Adams 
instructions and you'll be fine.

-Karin

Am 11.12.17 um 19:44 schrieb Adam Phillips:
> 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 
> <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 
> <mailto: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 <mailto:ncl-talk at ucar.edu>
>     List instructions, subscriber options, unsubscribe:
>     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
> -- 
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ 
> <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20171211/1337d64a/attachment.html>


More information about the ncl-talk mailing list