1D visualization examples¶
Introduction¶
These two examples are taken from Listing S2 and S3 in the 2013 JBNMR nmrglue paper. In the first example a the 1D time domain signal from a NMRPipe file (test.fid) is visualized using the plot_1d_pipe_time.py script. In the second example a portion of a 1D 13C CP MAS NMR spectrum is visualized from the NMRPipe file test.ft using the script plot_1d_pipe_freq.py
Instructions¶
Execute python plot_1d_pipe_time.py to visualize the data in the file test.fid. The resulting file fid.png is presented as Figure 2 in the paper.
Execute python plot_1d_pipe_spectrum.py to visualize the data in the file test.ft. The resulting file spectrum.png is presented as Figure 3 in the paper.
The data used in this example is available for download.
Listing S2
import nmrglue as ng
import matplotlib.pyplot as plt
# read in the data from a NMRPipe file
dic, data = ng.pipe.read("test.fid")
# make a unit conversion object for the axis
uc = ng.pipe.make_uc(dic, data)
# plot the spectrum
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(uc.ms_scale(), data.real, 'k-')
# decorate axes
ax.set_yticklabels([])
ax.set_xlabel("Time (ms)")
ax.set_ylim(-100000, 100000)
# save the figure
fig.savefig("fid.png")
Listing S3
import nmrglue as ng
import matplotlib.pyplot as plt
# read in the data from a NMRPipe file
dic, data = ng.pipe.read("test.ft")
# create a unit conversion object for the axis
uc = ng.pipe.make_uc(dic, data)
# plot the spectrum
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(uc.ppm_scale(), data, 'k-')
# decorate axes
ax.set_yticklabels([])
ax.set_xlabel("13C ppm")
ax.set_xlim(200, 0)
ax.set_ylim(-80000, 2500000)
# save the figure
fig.savefig("spectrum.png")