Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
linenumberstrue
collapsetrue
cdo mergetime infile1 infile2 infile3 infile4 outfile


Another option could be NCO (NetCDF Operators) ncrcat. Be sure that the files are unpacked before merging them. Here an example of merging for ERA5 nc files:

...

Code Block
languagepy
titleERA5 CDS API ERA5 request
linenumberstrue
collapsetrue
import cdsapi
c = cdsapi.Client()
c.retrieve(    
	'reanalysis-era5-single-levels',    
	{
		'product_type': 'reanalysis',        
		'variable': ['surface_latent_heat_flux', 'surface_sensible_heat_flux',],        
		'year': ['2018'],        
		'month': ['01'],        
		'day': ['31'],        
		'time': ['19:00','20:00','21:00','22:00','23:00'],        
		'format': 'netcdf',    
},    
'ERA5_slhf_sshf_01.nc')
    
c.retrieve(    
	'reanalysis-era5-single-levels',    {        
	{
		'product_type': 'reanalysis',        
		'variable': ['surface_latent_heat_flux', 'surface_sensible_heat_flux',],        
		'year': ['2018'],        
		'month': ['02'],        
		'day': ['01'],        
		'time': ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00',        ],        
		'format': 'netcdf',    
	},    
'ERA5_slhf_sshf_02.nc')



Set record dimension in each file (this is the dimension to merge along):

...