Personal tools
You are here: Home CDAT Tips and Tricks File I/O Tips Concatenating NetCDF files
Document Actions

Concatenating NetCDF files

In this example we will concatenate data split between 3 files into one

  Table of Contents Previous Next
Contents Previous Next

Goal: Learn how to concatenate NetCDF files in CDAT.

import cdms

path=sys.prefix+'/sample_data/'

files = [ path+'u_2000.nc',
path+'u_2001.nc',
path+'u_2002.nc',
       ]

# First let's open the output file for writing (and possibly erase existing file)
fout=cdms.open('u_concatenated.nc','w')

for file in files:
    f=cdms.open(file)
    u=f('u')
    f.close()
    fout.write(u)

fout.close()


  Table of Contents Previous Next
Contents Previous Next

Powered by Plone