0

I have daily data in NETCDF format and every ".nc" file include one year of data while I have data for 1948 to 2017. The name of files are like this: tmax.2m.gauss.1948.nc tmax.2m.gauss.1949.nc .. tmax.2m.gauss.2017.nc

I want to merge all of them into one ".nc" file. I don't know how exactly I can work with "CDO" or "ncrcat". I wrote this:

for year in range(1948,2017):
    year_files = glob.glob('D:/Dissertation/Data/NCEP-NCAR/tmax.2m.gauss.}.nc'.format (year))
    subprocess.call(['ncrcat'] + year_files + ['-O'])
    ncfile = netCDF4.Dataset(year_files, 'r')

But I received error and it does not work. Does anyone know how exactly I can merge all 70 NETCDF files into one file?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Amy
  • 119
  • 1
  • 1
  • 6
  • 1
    This mentioned question is not the same as mine "This question already has an answer here: Python subprocess throws [Errno 2] No such file or directory, error generated only when it on a remote host 1 answer" – Amy Nov 14 '17 at 17:50
  • ncrcat in*.nc out.nc – Charlie Zender Nov 15 '17 at 23:29
  • *"I received error"*; what kind of error? You are missing a `{` on your `files = ...` line, should be `tmax.2m.gauss.{}.nc` or something like `tmax.2m.gauss.{0:04d}.nc`. – Bart Nov 16 '17 at 07:25

0 Answers0