Clear Filters
Clear Filters

Adding multiple Netcdf4 files into a single file

1 view (last 30 days)
Hi,
I have downloaded multiple Merra-2 files in a netcdf4 format (.nc4 file extension). In total I have 2 sets of 365 files. Each of the 365 files stands for one day in a year and contains 24 time steps with different parameters e.g. temperature, humidity etc. The 2 sets have different parameteres, but both are for the exact same region (one set contains temperature, huidity etc. the other set different radiative fluxes.).
The files start at the 01.03.2010 and end on the 28.02.2011 and the filenames in set 1 look like this 'MERRA2_300.tavg1_2d_rad_Nx.20100301.nc4.nc4' and in set 2 like this 'MERRA2_300.inst1_2d_lfo_Nx.20100301.nc4.nc4'.
The Files in set 1 have a size of 300kb per file and in set 2 of 60kb per file.
Do you have an idea how to add first all 365 files from 1 set into a single file? And the next step would be to add the files from the 2 sets together?

Answers (1)

MJFcoNaN
MJFcoNaN on 14 Apr 2022
I suggest nco tools (a collection of utilities to manipulate and analyze netCDF files, but not a matlab toolbox) to do this kind of tasks which is flexible and easy to use.
This is the website: nco guide
You can search "ncrcat" to get examples and explains, such as
ncrcat foo_??.nc out.nc

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!