nmrglue.convert

Functions to convert between NMR file formats

This modules is imported as nmrglue.convert and can be called as such.

User Information

User Classes

This class is targetted for users of nmrglue.

class nmrglue.fileio.convert.converter[source]

Object which allows conversion between NMR file formats, including low memory data objects.

Conversion between NMR file formats with this class involves three steps. First a new converter object must be created. Then the converter must be loaded with data using a from_ method. Finally, the dictionary and data representation of a NMR data in the desired format is extracted using a to_ method. This can then be written to disk.

Example conversion:

vdic, vdata = ng.varian.read("varian_dir")
C = ng.convert.converter()
C.from_varian(vdic, vdata)
pdic, pdata = C.to_pipe()
ng.pipe.write("test.fid", pdic, pdata)

Spectral parameters can be provided directly by passing a Universal dictionary to any of the from_ methods. If not provided the spectral parameters are guessed from the file format’s dictionary of parameters.

from_bruker(dic, data, udic=None)[source]

Load converter with Bruker data.

Parameters :

dic : dict

Dictionary of Bruker parameters.

data : array_like

NMR data.

udic : dict, optional

Universal dictionary, if not provided will be guesses from dic.

from_pipe(dic, data, udic=None)[source]

Load converter with NMRPipe data.

Parameters :

dic : dict

Dictionary of NMRPipe parameters.

data : array_like

NMR data.

udic : dict, optional

Universal dictionary, if not provided will be guesses from dic.

from_rnmrtk(dic, data, udic=None, agilent_compatible=False)[source]

Load converter with RNMRTK data.

Parameters :

dic : dict

Dictionary of RNMRTK parameters.

data : array_like

NMR data.

udic : dict, optional

Universal dictionary, if not provided will be guesses from dic.

agilent_compatible : bool, optional

True when RNMRTK data is being compared to Agilent/Varian data.

from_sparky(dic, data, udic=None)[source]

Load converter with Sparky data.

Parameters :

dic : dict

Dictionary of Sparky parameters.

data : array_like

NMR data.

udic : dict, optional

Universal dictionary, if not provided will be guesses from dic.

from_universal(dic, data)[source]

Load converter with Universal data.

Parameters :

dic : dict

Dictionary of universal parameters.

data : array_like

NMR data.

from_varian(dic, data, udic=None)[source]

Load converter with Agilent/Varian data.

Parameters :

dic : dict

Dictionary of Agilent/Varian parameters.

data : array_like

NMR data.

udic : dict, optional

Universal dictionary, if not provided will be guesses from dic.

to_bruker()[source]

Return Bruker format data.

Returns :

dic : dict

Dictionary of Bruker parameters.

data : array_like

NMR data in Bruker format.

to_pipe(datetimeobj=datetime.datetime(2013, 10, 10, 20, 51, 50, 404633))[source]

Return NMRPipe format data.

Parameters :

datetime : datetime object, optional

Datetime object to include in the NMRPipe parameters. The current date and time is used by default.

Returns :

dic : dict

Dictionary of NMRPipe parameters.

data : array_like

NMR data in NMRPipe format.

to_rnmrtk(agilent_compatible=False, dim_order=None)[source]

Return RNMRTK format data.

Parameters :

agilent_compatible : bool, optional

True when RNMRTK data is being compared to Agilent/Varian data.

dim_order : list, optional

List mapping axis numbers in the universal dictionary to the to the order in which they will appear in the RNMRTK dictionary. If None, the default, [0, 1, 2, ...] will be used.

Returns :

dic : dict

Dictionary of RNMRTK parameters.

data : array_like

NMR data in RNMRTK format.

to_sparky(datetimeobj=datetime.datetime(2013, 10, 10, 20, 51, 50, 404636), user='user')[source]

Return Sparky format data.

Parameters :

datetime : datetime object, optional

Datetime object to include in the Sparky parameters. The current date and time is used by default.

user : str, optional

Username to include in the Sparky parameters. ‘user’ is the default.

Returns :

dic : dict

Dictionary of Sparky parameters.

data : array_like

NMR data in Sparky format.

to_universal()[source]

Return Universal format data.

Returns :

dic : dict

Dictionary of Universal parameters.

data : array_like

NMR data in format as provided.

to_varian()[source]

Return Agilent/Varian format data.

Returns :

dic : dict

Dictionary of Agilent/Varian parameters.

data : array_like

NMR data in Agilent/Varian format.

Developer Information

Developer Classes

These classes are typically not used directly by users. Developers who want fine control over file conversion will be interested in these classes

class nmrglue.fileio.convert.udata_nd(edata, iproc, oproc, odtype, order=None)[source]

Wrap other fileiobase.data_nd derived objects with input/output conversion when slices are requested.

  • slicing operations return ndarray objects.
  • can iterate over with expected results.
  • transpose and swapaxes methods create a new objects with correct axes ordering.
  • has ndim, shape, and dtype attributes.
Parameters :

edata : fileiobase.data_nd derived object

Data object to wrap.

iproc : dict

Dictionary of processing required by input format.

oproc : :

Dictionary of processing required by output format.

odtype : dtype

Output dtype.

order : tuple

Axis ordering relative to input data.

Notes

The iproc and oproc dictionary can contains the following keys and values.

key value Description
alt_id_sign True/False True alternates signs along indirect dims.
realfactor float Real channel scaling factor.
imagfactor float Imaginary channel scaling factor.

Table Of Contents

Previous topic

nmrglue.fileio.bruker.bruker_nd

Next topic

nmrglue.fileiobase

This Page