Save out put merged nc files on NCL

381 Views Asked by At

I have tried to merge multiple nc file using ncl in ubuntu windows 10 platform. i have used the following simple code.

fils = systemfunc("ls *.nc") ; checks all files with nc file extensions f1 = addfiles(fils,"r") ; reads the files and assigns them to f1 prec = f1[:]->pr(:,{55:70},{134:149}) ; merges all files with variable name "pr" and saves it into prec

printVarSummary(prec)

Is anyone who can give me a hint on how to save the output into nc file?

1

There are 1 best solutions below

0
On BEST ANSWER

As you also added the cdo tag, I presume you are open to a cdo soln in which case you can just use

 cdo merge *.nc output.nc 

to do this from the command line.

If you want to stick with ncl, there is a page here which explains how to write netcdf files either using a fast simple way, or a more involved way that gives you more control: https://www.ncl.ucar.edu/Applications/write_netcdf.shtml

That said, ncl as a language is now frozen, since they have now moved over to developing two packages in python (PyNGL and PyNIO) at NCAR, so if you want to stay in that framework, rather than learning how to do this in ncl, I would strongly recommend shifting to the package PyNIO in python.