#NEWLINE# def write_fid( filename , dic , data , torder = 'flat' , repack = False , correct = True , overwrite = False ) : #NEWLINE# #INDENT# "\n    Write a Agilent/Varian binary (fid) file.\n\n    Parameters\n    ----------\n    filename : str\n        Filename of Agilent/Varian binary file to write to.\n    dic : dict\n        Dictionary of Agilent/Varian file parameters.\n    data : ndarray\n        Array of NMR data.\n    torder : {'f', 'r', 'o'}\n        Trace ordering.  See :py:func:`read` for details.\n    repack : bool, optional\n        True to repack file and block headers. False leave as is.\n    correct : bool, optional\n        True (the default) will correct mis-sized np and nblocks values in dic.\n        False will write out the incorrect values to the file header and\n        record the full data set, the resulting file will not be readable by\n        nmrglue.\n    overwrite : bool, optional\n        Set True to overwrite an existing file, False will raise a Warning if\n        the file exists.\n\n    See Also\n    --------\n    write_fid_lowmem : Write a Agilent/Varian binary file using mimimal\n        amounts of memory\n    write : Write Agilent/Varian files to a directory.\n\n    " #NEWLINE# data = np . array ( data ) #NEWLINE# if ( data . ndim == 1 ) : #NEWLINE# #INDENT# data = data . reshape ( ( 1 , data . shape [ 0 ] ) ) #NEWLINE# #UNINDENT# if ( data . ndim >= 3 ) : #NEWLINE# #INDENT# data = order_data ( data , torder ) #NEWLINE# #UNINDENT# if ( data . shape [ 1 ] != ( dic [ 'np' ] // 2 ) ) : #NEWLINE# #INDENT# warn ( 'data and np size mismatch' ) #NEWLINE# if correct : #NEWLINE# #INDENT# dic [ 'np' ] = int ( ( data . shape [ 1 ] * 2 ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( data . shape [ 0 ] != dic [ 'nblocks' ] ) : #NEWLINE# #INDENT# warn ( 'data and block size mismatch' ) #NEWLINE# if correct : #NEWLINE# #INDENT# dic [ 'nblocks' ] = int ( data . shape [ 0 ] ) #NEWLINE# #UNINDENT# #UNINDENT# f = fileiobase . open_towrite ( filename , overwrite = overwrite ) #NEWLINE# if repack : #NEWLINE# #INDENT# dic = repack_fileheader ( dic ) #NEWLINE# #UNINDENT# put_fileheader ( f , dic2fileheader ( dic ) ) #NEWLINE# dt = find_dtype ( dic ) #NEWLINE# if ( ( 'blockheader' in dic ) and ( len ( dic [ 'blockheader' ] ) == data . shape [ 0 ] ) ) : #NEWLINE# #INDENT# for i in range ( trace . shape [ 0 ] ) : #NEWLINE# #INDENT# if repack : #NEWLINE# #INDENT# bh = dic2blockheader ( repack_blockheader ( dic [ 'blockheader' ] [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bh = dic2blockheader ( dic [ 'blockheader' ] [ i ] ) #NEWLINE# #UNINDENT# trace = np . array ( interleave_data ( data [ i ] ) , dtype = dt ) #NEWLINE# put_block ( f , trace , dic [ 'nbheaders' ] , bh ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# bh = dic2blockheader ( make_blockheader ( dic , 1 ) ) #NEWLINE# for i in range ( data . shape [ 0 ] ) : #NEWLINE# #INDENT# bh [ 2 ] = int ( ( i + 1 ) ) #NEWLINE# trace = np . array ( interleave_data ( data [ i ] ) , dtype = dt ) #NEWLINE# put_block ( f , trace , dic [ 'nbheaders' ] , bh ) #NEWLINE# #UNINDENT# #UNINDENT# f . close ( ) #NEWLINE# return