#NEWLINE# def read( filename , ftype = None , ndim = None , NP = None , NI = None , spe = None ) : #NEWLINE# #INDENT# '\n    Read a SIMPSON file.\n\n    Read a NMR data file saved using in a number of formats produced using\n    the SIMPSON simulation program.\n\n    Parameters\n    ----------\n    filename : str\n        Name of SIMPSON file to read data from.\n    ftype : {None, \'TEXT\', \'BINARY\', \'XREIM\', \'XYREIM\', \'RAWBIN\'}, optional\n        A string indicating the type of SIMPSON file:\n\n        ``TEXT`` : SIMPSON text format, no fsave arguments.\n\n        ``BINARY`` : SIMPSON binary format, -binary fsave argument.\n\n        ``XREIM`` : Indexed 1D format, rows of frequency/time, real and\n        imaginary parts of the data.  Saved with -xreim argument.\n\n        ``XYREIM`` : Indexed 2D format, rows of frequency/time (indirect\n        dimension then direct dimension), real and imaginary parts of the\n        data. Saved with -xyreim argument.\n\n        ``RAWBIN`` : Raw binary format.  Saved with -raw_bin argument.  ndim\n        and spe must also be provided.  In addition if ndim is 2, NP and NI\n        must be defined.\n\n        ``None`` : Automatically determine file type.  If this fails the file\n        type should be implicitly provided.\n\n        Other formats of files may be created by SIMPSON, but are not currently\n        supported.\n\n    Other Parameters\n    ----------------\n    ndim : {None, 1, 2}, optional\n        Dimensionality of the data in the file, only used when ftype is\n        "RAWBIN".\n    NP : int, optional\n        Number of points {R|I} in the direct dimension.  Only used when\n        ftype is "RAWBIN" and ndim is 2.\n    NI : int, optional\n        Number of points in the indirect dimension.  Only used when ftype is\n        "RAWBIN" and ndim is 2.\n    spe : bool, optional\n        True when the data is in the frequency domain, False for time domain\n        data.  Only used when ftype is "RAWBIN"\n\n    Returns\n    -------\n    dic : dict\n        Dictionary of spectra parameters.  For some file formats this may be\n        empty.\n    data : ndarray\n        Complex array of spectral data.\n\n    ' #NEWLINE# if ( ftype is None ) : #NEWLINE# #INDENT# ftype = guess_ftype ( filename ) #NEWLINE# #UNINDENT# if ( ftype == 'TEXT' ) : #NEWLINE# #INDENT# return read_text ( filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ftype == 'BINARY' ) : #NEWLINE# #INDENT# return read_binary ( filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ftype == 'XREIM' ) : #NEWLINE# #INDENT# return read_xreim ( filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ftype == 'XYREIM' ) : #NEWLINE# #INDENT# return read_xyreim ( filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ftype == 'RAWBIN' ) : #NEWLINE# #INDENT# if ( spe is None ) : #NEWLINE# #INDENT# raise ValueError ( 'spe must be True or False for raw_bin data' ) #NEWLINE# #UNINDENT# if ( ndim == 1 ) : #NEWLINE# #INDENT# return read_raw_bin_1d ( filename , spe ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ndim == 2 ) : #NEWLINE# #INDENT# if ( ( NP is None ) or ( NI is None ) ) : #NEWLINE# #INDENT# raise ValueError ( 'NP and NI must be given for raw_bin data' ) #NEWLINE# #UNINDENT# return read_raw_bin_2d ( filename , NP , NI , spe ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'ndim must be 1 or 2 for raw_bin data' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'unknown ftype' )