问题
I have around 500 netcdf(.nc) files.I need to combine all of them to a single file.I am new to programming and I don't have sufficient knowledge in merging these files.Can anybody please explain how we can merge these files and extract to a csv file or excel sheet.Which function we can use for merging of files.Any help will be really appreciated.
回答1:
NCO's ncecat can combine any number of netCDF files together with
ncecat in1.nc in2.nc ... inN.nc out.nc
ncecat in*.nc out.nc
Switches and other options are described in the documentation.
回答2:
you can merge files which have different variables using
cdo merge in1.nc in2.nc ... inN.nc out.nc
or if they are the same variable for different time periods, you can merge along the time axis with
cdo mergetime in1.nc in2.nc ... inN.nc out.nc
Note though, that in order to do this CDO has to have all input files open at once, and on some systems, the limit on the number of open files is 256. So in order to merge 500 files you would need to do it in 2 or more steps.
回答3:
Try this shell script to get merge the 500 netcdf files you have. It is a rough idea of what you could do:
i=1
for X in `ls -1 *nc`
do
cdo merge $X temp.nc out.nc
i=`expr $i+1`
if [i!=500]; #This is the run so you want to keep out as your final output
then
mv out.nc temp.nc ##### for use in future merges. This will build up as $X nc files get merged to it.
done
来源:https://stackoverflow.com/questions/17408587/merging-of-netcdf-files