src/GamIO/nrpt/Felix.cc
/* These are the functions which will read a "serial" file in Felix fomat.
   A serial file is essentialy stored as block after block after block....
   without any of the Felix matrix structure.  These are typically unprocessed
   data, although they don't have to be.  In a 2D case, the date is normally
   run through a Felix macro which reads the lines successively and processes
   the result into a spectrum for display.

           Input                filename : Input file name
                                fp       : Input file stream
                                block    : Block index desired
                                rowi     : Initial block index desired
                                rows     : Number of blocks desired
          Output                BLK      : 1D or 2D data block containing
                                           block or blocks read in from
                                           specified file or filestream
          Note                           : File assumed Felix serial!        */
These are the functions which will read a "serial" file in Felix fomat.
A serial file is essentialy stored as block after block after block
without any of the Felix matrix structure.  These are typically unprocessed
data, although they don't have to be.  In a 2D case, the date is normally
run through a Felix macro which reads the lines successively and processes
the result into a spectrum for display.


These are the functions which will read a " serial " file in Felix fomat . A serial file is essentialy stored as block after block after block without any of the Felix matrix structure . These are typically unprocessed data although they don ' t have to be . In a 2D case the date is normally run through a Felix macro which reads the lines successively and processes the result into a spectrum for display .
block_1D Felix_1D(const string& filename, int block)
  {
  if(block < 0) block = 0; 			
  fstream fp;					
  fp.open(filename.c_str(), ios::in);		
  if(!fp.is_open()) 				
    {
    FelixErr(1, filename, 1);			
    FelixFatal(7);				
    }
  int i, ncmplx;
  fp.read((char*)&i, sizeof(int));			
  fp.read((char*)&ncmplx, sizeof(int));		
  if(!ncmplx)					
    {
    FelixErr(11,1);				
    FelixFatal(7);		 		
    }
  int is_header = 0;				
  int cmplx = 1;				
  if(ncmplx < 0)				
    {						
    ncmplx = abs(ncmplx);			
    int *header;
    header = new int[2*ncmplx];			
    fp.read((char*)header, 2*ncmplx*sizeof(int));	
    fp.read((char*)&i, sizeof(int));			
    cmplx = header[1];				
    is_header = 1;				
    delete [] header;
    }
  else						
    fp.seekp(0, ios::beg);			
  int j = 0;					
  int fpspot = fp.tellp();			
  int blksize = 3*sizeof(int)			
		+ 2*ncmplx*sizeof(float);	
  while(j < block)				
    {						
    fpspot += blksize;				
    fp.seekp(fpspot, ios::beg);			
    j++;					
    }
  block_1D BLK;					
  BLK = ReadFelixBlk(fp, cmplx);		
  return BLK;
  }
block_1D Felix_1D ( const string & filename , int block ) { if ( block < 0 ) block = 0 ; fstream fp ; fp . open ( filename . c_str ( ) , ios :: in ) ; if ( ! fp . is_open ( ) ) { FelixErr ( 1 , filename , 1 ) ; FelixFatal ( 7 ) ; } int i , ncmplx ; fp . read ( ( char * ) & i , sizeof ( int ) ) ; fp . read ( ( char * ) & ncmplx , sizeof ( int ) ) ; if ( ! ncmplx ) { FelixErr ( 11 , 1 ) ; FelixFatal ( 7 ) ; } int is_header = 0 ; int cmplx = 1 ; if ( ncmplx < 0 ) { ncmplx = abs ( ncmplx ) ; int * header ; header = new int [ 2 * ncmplx ] ; fp . read ( ( char * ) header , 2 * ncmplx * sizeof ( int ) ) ; fp . read ( ( char * ) & i , sizeof ( int ) ) ; cmplx = header [ 1 ] ; is_header = 1 ; delete [ ] header ; } else fp . seekp ( 0 , ios :: beg ) ; int j = 0 ; int fpspot = fp . tellp ( ) ; int blksize = 3 * sizeof ( int ) + 2 * ncmplx * sizeof ( float ) ; while ( j < block ) { fpspot += blksize ; fp . seekp ( fpspot , ios :: beg ) ; j ++ ; } block_1D BLK ; BLK = ReadFelixBlk ( fp , cmplx ) ; return BLK ; }
These are the functions which will read a "serial" file in Felix fomat.
These are the functions which will read a " serial " file in Felix fomat .
// Input		filename : Output file name // 			block    : Data block desired // Output		BLK	 : 1D-data block is returned filled //				   from data in the file "filename" //				   presumed in Felix ".dat" format // Insure a positive block // File handle for input // Open file filename // Insure input file is OK //   Problems with file //   Problems reading .dat file // Storage taken (for FORTRAN) // Read # of complex points // Insure this is OK so far // Problems reading points // Problems reading .dat file // Flag for header existence // Flag for real vs. complex // If ncmplx negative, header // is present .... // This number of header values // Allocate space for header // Read in the header values // Storage taken (for FORTRAN) // This is # of complex points // Flag header  // If no header, then set // the file back to beginning // This is the block index // Get file location // Compute entire block size,  // 3 integers & 2*size floats // Loop block(s) we don't want // to read (by moving fp) // Where next block begins // Skip pointer to next block // This is block we are at now // Declare BLK for output // sosi - out until next time through //    BLK = Felix_parameters(header);		// Set block parameters // Read in data for block