coadd example: coadd_2d_pipeΒΆ

This example shows how to use nmrglue to coadd a series of 2d NMRPipe files. All files matching the test*.fid pattern will be coadded into a file named coadded.fid.

The data used in this example is available for download.

[source code]

#! /usr/bin/env python

import nmrglue as ng
import numpy as np
import glob

# create a list of files to coadd
flist = glob.glob("test*.fid")

# initilize the new data
dic, data =[0])
coadd_data = np.zeros_like(data)
coadd_dic = dict(dic)

# loop over the files, adding them to the coadded array
for f in flist:
    print "Coadding file:", f
    dic, data =
    coadd_data += data / len(flist)

# write out the file
print "Writing out coadded data"
ng.pipe.write("coadded.fid", coadd_dic, coadd_data, overwrite=True)