Index: unk/htdocs2/Classes/Pulsar/ObservationData.php
===================================================================
--- /trunk/htdocs2/Classes/Pulsar/ObservationData.php	(revision 407)
+++ 	(revision )
@@ -1,239 +1,0 @@
-<?php
-
-
-
-require_once 'Classes/Pulsar/ScrunchingParameters.php';
-require_once 'Classes/Pulsar/CPSR2Combiner.php';
-require_once 'Classes/Pulsar/Archive.php';
-require_once 'Classes/Pulsar/ArchiveScruncher.php';
-
-
-/**
- * @class ObservationData
- *
- * This class represents the data from a single observation. This class can
- * return or produce if needed any of the following files
- * - original source file or directory
- * - source file (if the original source was a directory it is psradded to make a single file)
- * - scrunched file
- **/
-class ObservationData
-{
-  // PUBLIC
-
-  public function __construct( ObservationData $rhs = null )
-  {
-    $this->archives = Array();
-    $this->scrunching_parameters = new ScrunchingParameters();
-    $this->path = new File();
-    $this->pre_scr_file = null;
-    
-    if( $rhs != null )
-      $this->Copy( $rhs );
-    
-  }
-  public function Copy( $rhs )
-  {
-    foreach( $this->archives as $next_archive )
-      $this->archives[] = new Archive( $next_archive );
-    
-    $this->scrunching_parameters = new ScrunchingParameters( $rhs->scrunching_parameters );
-    $this->path = new File( $rhs->path );
-    
-    $this->nsub = $rhs->nsub;
-    $this->npol = $rhs->npol;
-    $this->nchan = $rhs->nchan;
-    $this->nbin = $rhs->nbin;
-    $this->pre_scr_file = $rhs->pre_scr_file;
-  }
-  
-  public function SetScrunchingParameters( ScrunchingParameters $s_scrunching_parameters )
-  {
-    if( $s_scrunching_parameters == null )
-      throw new GZ_Exception( 'attempt to set scrunching parameters with null', 'ObservationData::SetScrunchingParameters' );
-    
-    $this->scrunching_parameters = $s_scrunching_parameters;
-  }
-  public function GetScrunchingParameters() { return $this->scrunching_parameters; }
-  
-  public function SetPath( $s_path ) { $this->path = $s_path; $this->ExamineObservation(); }
-  public function GetPath() { return $this->path; }
-  
-  public function SetNSub( $s_nsub ) { $this->nsub = $s_nsub; }
-  public function setNPol( $s_npol ) { $this->npol = $s_npol; }
-  public function SetNBin( $s_nbin ) { $this->nbin = $s_nbin; }
-  public function SetNChan( $s_nchan ) { $this->nchan = $s_nchan; }
-  
-  public function SetDataDir( Dir $s_data_path ) { $this->data_dir = $s_data_path; }
-  
-  //! Make an estimate of the size the downloadable file will be
-  public function EstimateDownloadableSize()
-  {
-    $file_size = 0;
-    
-    if( $this->scrunching_parameters == null )
-      throw new GZ_Exception( 'scrunching paramters not set', 'ObservationData::EstimateDownloadableSize' );
-    
-    // Determine the file size without scrunching
-
-    if( count( $this->archives ) == 1 )
-    {
-      $file_size = $this->archives[0]->GetFileSize();
-    }
-    else
-    {
-      foreach( $this->archives as $next_archive )
-      {
-        $next_size = $next_archive->GetFileSize();
-        $file_size += $next_size;
-      }
-    }
-    
-    // If we have scrunching parameters, adjust the file size to what it will be
-    
-    if( $this->scrunching_parameters->ScrunchingSet() )
-    {
-      if( $this->nsub < 1 || !is_numeric( $this->nsub ) )
-          throw new GZ_Exception( 'nsub is invalid','ObservationData::EstimateDownloadableSize' );
-      
-      if( $this->nbin < 1 || !is_numeric( $this->nbin ) )
-        throw new GZ_Exception( 'nbin is invalid', 'ObservationData::EstimateDownloadableSize' );
-      
-      if( $this->npol < 1 || !is_numeric( $this->npol ) )
-        throw new GZ_Exception( 'npol is invalid', 'ObservationData::EstimateDownloadableSize' );
-      
-      if( $this->nchan < 1 || !is_numeric( $this->nchan )  )
-        throw new GZ_Exception( 'nchan is invalid', 'ObservationData::EstimateDownloadableSize' ); 
-          
-      // correct nsub, should match the number of files
-      if( count( $this->archives ) > 0 )
-        $this->nsub = count( $this->archives );
-      
-      $current_data_size = 2 * $this->nsub * $this->nbin * $this->nchan * $this->npol;
-      $header_size = $file_size - $current_data_size;
-
-      $new_nsub = $this->nsub;
-      $scr_nsub = $this->scrunching_parameters->GetTScrunch();
-      if( $scr_nsub != null )
-        $new_nsub = ceil( $new_nsub / $scr_nsub );
-
-      $new_npol = $this->npol;
-      if( $this->scrunching_parameters->GetPScrunch() )
-	$new_npol = 1;
-
-      $new_nchan = $this->nchan;
-      $scr_nchan = $this->scrunching_parameters->GetFScrunch();
-      if( $scr_nchan != null )
-	$new_nchan = ceil( $new_nchan / $scr_nchan );
-      $new_data_size = 2 * $new_nsub * $new_npol * $this->nbin * $new_nchan;
-      $file_size = $new_data_size + $header_size;
-    }
-
-    return $file_size;
-  }
-  
-  //! If the src we are looking at is a directory(CPSR2 data) combine the files together
-  public function MakeSourceFile()
-  {
-    $this->pre_scr_file = new File( File::ConvertFullPath($this->data_dir->GetPath() .'/'.$this->path->GetFilename()) );
-
-    if( $this->path->IsDir() )
-    {
-      $combiner = new CPSR2Combiner();
-      foreach( $this->archives as $next_archive )
-        $combiner->AddArchive( $next_archive );
-      $combiner->SetDestFile( $this->pre_scr_file );
-      $combiner->Execute();
-    }
-    else
-    {
-      if( count( $this->archives ) == 0 )
-        throw new GZ_Exception( 'dont have any files for archive',
-                                'ObservationData::MakeDownloadableFile' );
-    
-      if( !$this->pre_scr_file->Exists() )
-        symlink( $this->path->GetFullPath(), $this->pre_scr_file->GetFullPath() );
-    }
-  }
-
-  //! Make sure there is a source file (link or combined archive) the scrunch it if need be
-  public function MakeDownloadableFile()
-  {
-    $data_file = null;
-    
-    $this->MakeSourceFile();
-    
-    // create the scrunched version of the file
-	
-    if( $this->scrunching_parameters->ScrunchingSet() )
-    {
-      $scruncher = new ArchiveScruncher();
-      $scruncher->SetParameters( $this->scrunching_parameters );
-      $scruncher->SetSrcFile( $this->pre_scr_file );
-      $scruncher->SetDestFile( $this->GetDataFile() );
-      $scruncher->Execute();
-    }
-  }
-  
-  public function GetDataFile()
-  {
-    $data_file = new File();
-    $data_file->SetPath( $this->data_dir->GetPath() );
-    $data_file->SetFilename( $this->path->GetFilename() );
-    
-    if( $this->scrunching_parameters != null )
-    {
-
-      $data_file->SetFilename( AddPreExtension( $data_file->GetFilename(),
-				   $this->GetScrunchingParameters()->GetTextDescription() ) );
-    }
-  
-    return $data_file;
-  }
-  
-  // PRIVATE
-  
-  private $archives;
-  private $scrunching_parameters;
-  private $path;
-  private $nsub;
-  private $nbin;
-  private $nchan;
-  private $npol;
-  private $data_dir;
-  private $pre_scr_file;
-  
-  private function ExamineObservation()
-  {
-    if( $this->path == null )
-	throw new GZ_Exception( 'No path set', 'ObservationData::ExamineObservation' );
-    
-    $this->archives = Array();
-    
-    if( $this->path->IsDir() )
-    {
-      $dir = Dir::ConvertFile( $this->path );
-
-      foreach( $dir->ListFiles() as $next_filename )
-      {
-	$extension = strword( $next_filename, 1, '.' );
-	if( $extension == 'cfb' || $extension == 'fb' )
-	{
-	  $new_archive = new Archive();
-	  $new_archive->SetPath( $dir->GetPath() );
-	  $new_archive->SetFilename( $next_filename);
-	  $this->archives[] = $new_archive;
-	}
-      }
-    }
-    else
-    {
-      $new_archive = new Archive();
-      $new_archive->SetPath( $this->path->GetPath() );
-      $new_archive->SetFilename( $this->path->GetFilename() );
-      $this->archives[] = $new_archive;
-    }
-  }
-};
-
-?>
