Bruno,
The Varian/Agilent data that nmrglue reads is the raw unprocessed
time domain data, so any processing performed in VnmrJ is not going to
show up in the data you read in. Rather you will need to perform the
processing in nmrglue or another program that nmrglue can read processed
data from, such as NMRPipe. In addition, although nmrglue reads in the
data as a 3D this is just an artefact of how Varian records metadata.
From your description of the data it sounds like your data is a
pseudo-2D dataset, which is similar to the data in the
seperate_1d_varian example
(
http://jjhelmus.github.io/nmrglue/current/examples/separate_1d_varian.html).
Finally you will need to provide a universal dictionary with the correct
spectral parameter when performing the the conversion from Varian to
NMRPipe data, without one default values are used which give you the
strange ppm scale.
The following script takes each 1D trace from the separate_1d_varian
example data
(
http://nmrglue.googlecode.com/files/example_separate_1d_varian.zip),
converts to NMRPipe format, does some basic processing, creates a plot
of the data with a ppm scale, and saves the plot to file with names
plot_0.png, plot_1.png, .... You should be able to adapt this script to
work with your data.
#! /usr/bin/env python
import numpy as np
import nmrglue as ng
import matplotlib.pyplot as plt
##############################################################################
# read in the arrayed data
#
http://jjhelmus.github.io/nmrglue/current/examples/separate_1d_varian.html
##############################################################################
dir_name = 'arrayed_data.dir' # directory where the Varian data is held.
dic, all_data = ng.varian.read(dir_name, as_2d=True)
# each separated 1D dataset could be written out to its own directory as
# in the example above and then processed in a variety of ways, here all
# the processing and plotting is done by looping over the traces with
# no intermediate writing of the separated data.
# loop over each elements in the arrayed data
for slice_num in range(all_data.shape[0]):
print "Processing and plotting slice_num:", slice_num
###########################################################################
# convert into NMRPipe format
#
http://jjhelmus.github.io/nmrglue/current/examples/agilent2pipe_1d.html
###########################################################################
data = all_data[slice_num]
# Set the spectral parameters, adjust these to reflect the actual
# parameters used.
udic = ng.varian.guess_udic(dic, data)
udic[0]['size'] = 1500 # number of R|I points in the
spectrum
udic[0]['complex'] = True # True if complex data
udic[0]['encoding'] = 'direct' # keep as 'direct'
udic[0]['sw'] = 50000.0 # spectral width in Hz
udic[0]['obs'] = 125.681 # Observation freq. in MHz.
udic[0]['car'] = 99.0 * 125.681 # carrier freq in Hz
udic[0]['label'] = 'C13' # the observed nucleus.
# create the converter object and load in Agilent data
C = ng.convert.converter()
C.from_varian(dic, data, udic)
pdic, pdata = C.to_pipe()
###########################################################################
# process the data
#
http://jjhelmus.github.io/nmrglue/current/examples/process_pipe_1d.html
###########################################################################
# process the direct dimension
# these will need to be changed according to the processing needs of
# your data.
pdic, pdata = ng.pipe_proc.sp(pdic, pdata, off=0.35, end=0.98,
pow=2, c=1.0)
pdic, pdata = ng.pipe_proc.zf(pdic, pdata, auto=True)
pdic, pdata = ng.pipe_proc.ft(pdic, pdata, auto=True)
pdic, pdata =
ng.pipe_proc.ps(pdic, pdata, p0=60.0, p1=0.0)
pdic, pdata = ng.pipe_proc.di(pdic, pdata)
###########################################################################
# plot
#
http://jjhelmus.github.io/nmrglue/current/examples/plot_1d_freq.html
###########################################################################
# create a unit conversion object for the axis
uc = ng.pipe.make_uc(pdic, pdata)
# plot the spectrum
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(uc.ppm_scale(), pdata, 'k-')
ax.set_xlim(200, 0) # change this to good limits for your data
# save the figure
fig.savefig('plot_%i.png' % (slice_num))
plt.close(fig)
Hope this helps, let me know if you have any addition troubles.
- Jonathan Helmus