1

I have two NetCDF files of the Greenland ice sheet velocities, one from 2015 and one from 2016. These files contain grided data where the velocity is plotted with x,y coordinates. However, no time dimension is included. How can I merge these two files into 1, where the final file has a time dimension? So in stead of two separate x,y,z grids, I would like to have one x,y,z,t data structure, where time = 2.

Thanks!

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Yoni Verhaegen
  • 111
  • 1
  • 11

2 Answers2

3

If the files contain the same variables and are the same size, try ncecat

ncecat -u time file1.nc file2.nc out.nc
Charlie Zender
  • 5,929
  • 14
  • 19
2

You can add a time dimension to a file with ncap2:

ncap2 -s 'defdim("time",1);time[time]=74875.0;time@long_name="Time"; etc.etc.etc.' -O ~/nco/data/in.nc ~/foo.nc

I suggest reading this thread for more details: https://sourceforge.net/p/nco/discussion/9830/thread/cee4e1ad/

After you have done that you can merge them together either using the ncrcat command (see https://linux.die.net/man/1/ncrcat) or also with cdo

cdo mergetime file1.nc file2.nc combined_file.nc 
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • Hi, I did the following: ncap2 -Oh -s 'defdim("time",1); time[time]=41911.0; time@standard_name=“time"; time@long_name=“time"; time@units=“days since 1900-01-01 00:00:00.0”; time@calender=“standard”; time@axis=“T”;' greenland_latlon20142015.nc greenland_latlon20142015_time.nc But this gives me an error: Command-line script line 1, column 59: unexpected character '?' – Yoni Verhaegen Jul 15 '19 at 12:00
  • Hi, it is difficult to help without a link to an example nc file to try out the commands. Did the solution of Charlie work by the way? – ClimateUnboxed Jul 16 '19 at 08:04