src/GamIO/XWinFid.cc
/* This function will write a binary fid file for a Bruker 1D acqusition
   in XWinNMR.  Typically this is just done during construction of the class.
   However, it is convenient to have an empty class constructor which can be
   used in conjunction with read/write to perform the same feat.  The Bruker
   file "fid" contains values that are read in as re,im,re,im,...., each point
   stored as a 32-bit integer. The fid file should be consistent with the
   corresponding ASCII parameter files, acqu and acqus. However, such details
   should be attended to in higher classes utilizing these functions.        */
This function will write a binary fid file for a Bruker 1D acqusition
in XWinNMR.  Typically this is just done during construction of the class.
However, it is convenient to have an empty class constructor which can be
used in conjunction with read/write to perform the same feat.  The Bruker
file "fid" contains values that are read in as re,im,re,im,...., each point
stored as a 32-bit integer. The fid file should be consistent with the
corresponding ASCII parameter files, acqu and acqus. However, such details
should be attended to in higher classes utilizing these functions.
This function will write a binary fid file for a Bruker 1D acqusition in XWinNMR . Typically this is just done during construction of the class . However it is convenient to have an empty class constructor which can be used in conjunction with read / write to perform the same feat . The Bruker file " fid " contains values that are read in as re im re im .... each point stored as a 32 - bit integer . The fid file should be consistent with the corresponding ASCII parameter files acqu and acqus . However such details should be attended to in higher classes utilizing these functions .
int XWinFid::write(const string& name, const row_vector& vx, int warn)
  {
  ffp.open(name.c_str(), ios::binary|ios::out);
  if(!ffp.good())			
    {
    if(warn)
      {
      XWinFiderror(28,1);		
      XWinFiderror(1,name,1);		
      if(warn>2) XWinFidfatality(29);	
      else       XWinFiderror(29);
      }
    return 0;
    }
  ffname     = name;			
  fbigend    = WeRBigEnd();		
  fbyteordin = fbigend;			
  fdata      = vx;			
  ftotpts    = 2*vx.size();		
  SetPadding();				
  ffp.seekp(0);				
  int npts   = fdata.size();		
  int32_t rval, ival;			
  for(int i=0; i<npts; i++)		
    {
    rval = int32_t(vx.getRe(i));		
    ival = int32_t(vx.getIm(i));		
    ffp.write((char*)&rval, sizeof(int32_t));	
    ffp.write((char*)&ival, sizeof(int32_t));	
    }
  AddPadding();				
  ffp.seekp(0,ios::end);		
  ffsize = ffp.tellp();			
  ffp.close();				
  return 1;
  }
int XWinFid :: write ( const string & name , const row_vector & vx , int warn ) { ffp . open ( name . c_str ( ) , ios :: binary | ios :: out ) ; if ( ! ffp . good ( ) ) { if ( warn ) { XWinFiderror ( 28 , 1 ) ; XWinFiderror ( 1 , name , 1 ) ; if ( warn > 2 ) XWinFidfatality ( 29 ) ; else XWinFiderror ( 29 ) ; } return 0 ; } ffname = name ; fbigend = WeRBigEnd ( ) ; fbyteordin = fbigend ; fdata = vx ; ftotpts = 2 * vx . size ( ) ; SetPadding ( ) ; ffp . seekp ( 0 ) ; int npts = fdata . size ( ) ; int32_t rval , ival ; for ( int i = 0 ; i < npts ; i ++ ) { rval = int32_t ( vx . getRe ( i ) ) ; ival = int32_t ( vx . getIm ( i ) ) ; ffp . write ( ( char * ) & rval , sizeof ( int32_t ) ) ; ffp . write ( ( char * ) & ival , sizeof ( int32_t ) ) ; } AddPadding ( ) ; ffp . seekp ( 0 , ios :: end ) ; ffsize = ffp . tellp ( ) ; ffp . close ( ) ; return 1 ; }
This function will write a binary fid file for a Bruker 1D acqusition
in XWinNMR.
This function will write a binary fid file for a Bruker 1D acqusition in XWinNMR .
// Insure Bruker File is O.K. //   Problems with filestream //   Problems with file //   Can't write a damn thing // Set the Bruker filename // Set output byte order (our arch) // Set input byte order (our arch) // Set our data points // Set points per fid (re + im) // Set padding for data boundary // Set things at file start // Number of points (2*TD) // For point reals,imags // Loop over all points //   Real point as int //   Imag point as int //   Write real point //   Write imag point // Pad to end of block // Go to the end of the file // Get total bytes in the file // Close the file