Kartik Chhajed
Kartik Chhajed

Reputation: 183

Merging netCDF files with different dimension size into a single file via nco

I have netCDF files, each with different dimensions which I would like to combine in one single file.

The example of two files are

netcdf network0005.vm {
dimensions:
    cell\ type\ index = 1 ;
    cell\ type\ index2 = 1 ;
    vertex\ index = 799 ;
    cell\ index = 400 ;
    bond\ index = 2398 ;
variables:
    double Network\:\:time ;
    int Network\:\:numDeadCells ;
    int Network\:\:nClones ;
    double Frame\:\:xWidth ;
    double Frame\:\:yWidth ;
    ... (lines skipped)

and

netcdf network0004.vm {
dimensions:
    cell\ type\ index = 1 ;
    cell\ type\ index2 = 1 ;
    vertex\ index = 800 ;
    cell\ index = 400 ;
    bond\ index = 2400 ;
variables:
    double Network\:\:time ;
    int Network\:\:numDeadCells ;
    int Network\:\:nClones ;
    double Frame\:\:xWidth ;
    double Frame\:\:yWidth ;
    ... (lines skipped)

Each file contains the same dimension and variable names, however, the size of the dimension differs. I have tried combining them with ncecat -u time network????.vm.nc, but they show errors because of dimension mismatch.

I would be interested in knowing how to combine/merge them into a single file?

Upvotes: 0

Views: 1020

Answers (2)

Charlie Zender
Charlie Zender

Reputation: 6322

The only way to aggregate multiple files together, when those files contain multiples dimensions with differing sizes, is to use "group aggregation" (gag) as described here. Make sure the output is netCDF4 format, and this should work:

ncecat -4 --gag network????.vm.nc out.nc

Upvotes: 2

Kartik Chhajed
Kartik Chhajed

Reputation: 183

You can add --gag into your command.

Upvotes: 1

Related Questions