nmrglue.varian

Functions for reading and writing Agilent/Varian binary (fid) files and parameter (procpar) files.

This modules is imported as nmrglue.varian and can be called as such. These functions and classes can also be access from nmrglue.agilent.

User Information

User Functions

read([dir, fid_file, procpar_file, ...]) Read Agilent/Varian files in a directory.
write(dir, dic, data[, fid_file, ...]) Write Agilent/Varian files to a directory.
write_lowmem(dir, dic, data[, fid_file, ...]) Write Agilent/Varian files to a directory using mimimal amounts of memory.
read_lowmem([dir, fid_file, procpar_file, ...]) Read Agilent/Varian files in a directory using minimal amount of memory.
read_fid(filename[, shape, torder, as_2d, ...]) Read a Agilent/Varian binary (fid) file.
write_fid(filename, dic, data[, torder, ...]) Write a Agilent/Varian binary (fid) file.
read_fid_lowmem(filename[, shape, torder, ...]) Read a Agilent/Varian binary (fid) file using mimimal amounts of memory.
write_fid_lowmem(filename, dic, data[, ...]) Write a Agilent/Varian binary (fid) file using mimimal amounts of memory.
read_fid_ntraces(filename[, shape, torder, ...]) Read a Agilent/Varian binary (fid) file possibility having multiple traces per block.
read_procpar(filename) Read a procpar file returning a dictionary of procpar parameters.
write_procpar(filename, dic[, overwrite]) Write a Agilent/Varian procpar file from a dictionary
guess_udic(dic, data) Guess parameter of a universal dictionary from dic, data pair.
create_dic(udic) Create a Agilent/Varian parameter dictionary from a universal dictionary.

Developer Infomation

__developer_doc__ = “”” Agilent/Varian file format information ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Both the Agilent/Varian binary and parameter formats are documented in:

  • Varian MR News 2005-04-18 Importing Binary VnmrJ / VNMR FIDs into Third
    Party Software and VnmrJ / VNMR FID Data Format
  • VnmrJ User Programming - Chapter 5: Parameters and Data

These are available (as of 04/2011) online from

Developer Functions

These functions are typically not used directly by users. Developers who want fine control over Agilent/Varian files will be interested in these functions.

create_data(data) Create a Agilent/Varian data array (recast into complex64 array)
create_pdic_param(name, values) Create a fake procpar dictionary element of with given name and values.
find_torder(dic, shape) Find the torder from the procpar dictionary.
torder2i2t(torder) Convert torder to an index2trace function
torder2t2i(torder) Convert torder to a trace2index functions
reorder_data(data, shape, torder) Reorder raw data from file.
order_data(data, torder) Order NMR data for writing to file.
get_nblocks(f, nblocks, pts, nbheaders, dt, ...) Read multiple blocks from a Agilent/Varian binary file.
get_block(f, pts, nbheaders, dt[, ...]) Read a single block from Agilent/Varian binary file.
get_nblocks_ntraces(f, nblocks, ntraces, ...) Read multiple blocks from a Agilent/Varian binary file which may have multiple traces per block.
get_block_ntraces(f, ntraces, pts, nbheaders, dt) Read a single block from Agilent/Varian binary file which may have multiple traces per block.
get_trace(f, pts, dt) Read trace of pts points of dtype dt from Agilent/Varian binary file
get_fileheader(f) Unpack file header parameters into a list.
get_blockheader(f) Unpack block header parameters into a list.
skip_blockheader(f) Read a block header but do not unpack.
get_hyperheader(file) Unpack hypercomplex header parameters to a list.
put_block(f, trace, nbheaders, bh[, hh]) Put blockheader(s) and the trace to file.
put_trace(f, trace) Write a trace to file f.
put_fileheader(f, fh) Write a fileheader list to file (32-bytes written).
put_blockheader(f, bh) Write a blockheader list to file (28-bytes written)
put_hyperheader(f, hh) Write hyperheader list to file (28-bytes written)
hyperheader2dic(head) Convert a hypercomplex block header into a Python dictionary.
repack_hyperheader(dic) Repack a hyperheader dictionary bit flag parameters into status.
dic2hyperheader(dic) Convert a Python dictionary into a hypercomplex block header list.
make_blockheader([filedic, index]) Make a generic blockheader dictionary with a given block index.
blockheader2dic(head) Convert a block header list into a Python dictionary.
repack_blockheader(dic) Repack blockheader dic bit flag parameters into status and mode.
dic2blockheader(dic) Convert a python dictionary into block header list.
fileheader2dic(head) Convert fileheader list into a Python dictionary
repack_fileheader(dic) Repack blockheader dic bit flag parameters into status and mode.
dic2fileheader(dic) Convert a Python dictionary into a fileheader list
find_shape(pdic) Determine the shape of a Agilent/Varian file from the procpar dictionary
find_cdtype(dic) Find the complex dtype from a Agilent/Varian dictionary
find_dtype(dic) Find the real dtype from a dictionary
uninterleave_data(data) Unpack interleaved real, imag data
interleave_data(data_in) Interleave real, imag data
get_parameter(f) Reads a procpar parameter from a file object.

Developer Classes

fid_nd(filename, i2t_func[, fshape, order]) Emulate a ndarray objects without loading data into memory for low memory reading of Agilent/Varian fid files which must have one trace per block.