Jimbo
Jimbo

Reputation: 67

How to concatenate multiple netCDF files with varying dimension sizes?

I have 20 netCDF files containing oceanographic CTD data. Each file contains the same dimension and variable names, however they differ in the size of the vertical coordinate (ie. CTD profiles inshore have a smaller depth range than profiles offshore). I need to concatenate these separate files into one netCDF file with a record variable "station".

I have tried:

ncecat -u station *.nc outfile.nc

This concatenates the files in the correct way, but it takes the dimension size of the first netCDF file (which is the smallest) and so I lose the data below the depth of the shallowest CTD profile for the rest of the netCDF files.

I'm assuming I need to add FillValues (or similar) in place of the data that is shallower than the maximum depth of the deepest CTD profile.

Is there a way to do this using ncecat?

Upvotes: 4

Views: 2069

Answers (1)

Charlie Zender
Charlie Zender

Reputation: 6322

The closest you can get with ncecat alone is to use group aggregation to store each station profile as its own group in a netCDF4 file. Then you do not need to search for and fill-in any missing data:

ncecat --gag *.nc outfile.nc

Upvotes: 2

Related Questions