merging of Netcdf files

大兔子大兔子 提交于 2020-01-16 03:49:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!