SWIFTFile Class Reference

SWIFT integration file. More...

#include <orsa_file.h>

Inheritance diagram for SWIFTFile:

Inheritance graph
[legend]
Collaboration diagram for SWIFTFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SWIFTFile (OrbitStream &)
void Read ()
int AsteroidsInFile ()
void Open ()
void Close ()
virtual std::string GetFileName () const
virtual void SetFileName (std::string name_in)
virtual void SetFileName (char *name_in)

Public Attributes

OrbitStreamos

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

SWIFT integration file.

Definition at line 184 of file orsa_file.h.


Constructor & Destructor Documentation

SWIFTFile ( OrbitStream  ) 

Definition at line 1158 of file orsa_file.cc.

References SWIFTFile::os.

01158                                         : ReadFile() {
01159     os = &osin;
01160     // status = CLOSE;
01161   }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 1217 of file orsa_file.cc.

References Orbit::a, OrbitStream::asteroid_number, File::Close(), Orbit::e, orsa::el, OrbitWithEpoch::epoch, File::file, orsa::file_time, Orbit::i, orsa::l_ts, OrbitStream::label, orsa::label(), OrbitWithEpoch::libration_angle, Orbit::M, orsa::nast, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, ORSA_ERROR, SWIFTFile::os, orsa::pi, REWIND_FILE, SEEK_FILE, UniverseTypeAwareTime::SetTime(), File::status, orsa::SWIFTRawReadBinaryFile(), OrbitStream::timestep, WindowParameters::window_amplitude, WindowParameters::window_start, WindowParameters::window_step, and OrbitStream::wp.

01217                        {
01218     
01219     // close and reopen to avoid odd zlib problems related to the gzseek function
01220     Close();
01221     Open();
01222     
01223     if (status != OPEN_R) {
01224       ORSA_ERROR("Status error!");
01225       return;
01226     }
01227     
01228     OrbitStream &ost = *os;
01229     
01230     const int version = 2;
01231     
01232     // cerr << "reading data from the input file...\n";
01233     
01234     OrbitWithEpoch fo;
01235     
01236     // double wwj=0,wj=0,cj=0;
01237     // double wtil,crit,wmix;
01238     double time_old = 0, timestep;
01239     
01240     int jump = 0, i_jump = 0;
01241     
01242     // reset!
01243     // ost.resize(0);
01244     ost.clear();
01245     ost.timestep = 0.0;
01246     const int asteroid_number =  ost.asteroid_number;
01247     // cerr << " SWIFTFile::Read() --> reading object: " << asteroid_number << endl;
01248     char label[10];
01249     sprintf(label,"%04i",ost.asteroid_number);
01250     ost.label = label;
01251     // cerr << "LABEL: [" << ost.label << "]" << endl;
01252     REWIND_FILE(file);
01253     
01254     if ( version == 1 )
01255       jump = 3*sizeof(int)+7*sizeof(double);
01256     else if ( version == 2 )
01257       jump = 3*sizeof(int)+9*sizeof(double);
01258     
01259     int  good = 1, check = 0, number_of_asteroids_in_file = 0;
01260     
01261     do {
01262       
01263       if (check == 0) {
01264         good = SWIFTRawReadBinaryFile(file,version);    
01265       } else {
01266         
01267         i_jump = (number_of_asteroids_in_file+asteroid_number-nast-1)%(number_of_asteroids_in_file);
01268         
01269         if (i_jump != 0) {
01270           if ( (SEEK_FILE(file,jump*i_jump,SEEK_CUR)) == -1) {
01271             cerr << "setting good=0 from SEEK_FILE..." << endl;
01272             good = 0; 
01273           }
01274         }
01275         
01276         if (good != 0) {
01277           good = SWIFTRawReadBinaryFile(file,version);
01278         }
01279         
01280       }
01281       
01282       if ( number_of_asteroids_in_file < nast ) {
01283         number_of_asteroids_in_file = nast;
01284       } else {
01285         check = 1;
01286       }
01287       
01288       //// asteroid number too big!
01289       if ( (check == 1) && (asteroid_number > number_of_asteroids_in_file) ) {
01290         ORSA_ERROR("asteroid number too big (%d > %d)", asteroid_number, number_of_asteroids_in_file);
01291         return;
01292       }
01293       
01294       if (nast == asteroid_number && good != 0) {
01295         
01296         if ((file_time >= time_old) && 
01297             (file_time >= ost.wp.window_start)) {
01298           
01299           fo.epoch.SetTime(file_time);
01300           fo.a                = el[4];
01301           fo.e                = el[3];
01302           fo.i                = (pi/180.0)*el[2];
01303           fo.omega_node       = (pi/180.0)*el[0];
01304           fo.omega_pericenter = (pi/180.0)*el[1];
01305           fo.M                = (pi/180.0)*el[5];
01306           //
01307           fo.libration_angle  = (pi/180.0)*l_ts; // temporary
01308           
01309           ost.push_back(fo);
01310           
01311           // QUICK AND DIRTY!
01312           if (fo.e >= 1.0) {
01313             cerr << "reading eccentricity > 1.0, returning." << endl;
01314             return;
01315           }
01316           
01317           
01318           if ( ((file_time) > (ost.wp.window_amplitude+ost.wp.window_start)) && (ost.wp.window_step == 0.0) ) {
01319             return;
01320           }
01321         }
01322         
01323         timestep = file_time - time_old;
01324         time_old = file_time;
01325         // one of all, but not the first...
01326         if (ost.size() == 2) {
01327           ost.timestep = timestep;
01328         }
01329         
01330       }
01331       
01332     } while (good != 0);
01333   }

Here is the call graph for this function:

int AsteroidsInFile (  ) 

Definition at line 1197 of file orsa_file.cc.

References File::Close(), File::file, orsa::nast, ReadFile::Open(), REWIND_FILE, and orsa::SWIFTRawReadBinaryFile().

01197                                  {
01198     
01199     // close and reopen to avoid odd zlib problems related to the gzseek function
01200     Close();
01201     Open();
01202     
01203     int number_of_asteroids_in_file=0;
01204     
01205     REWIND_FILE(file);
01206     
01207     int good;
01208     while ( (good = SWIFTRawReadBinaryFile(file,2)) != 0) {
01209       if (number_of_asteroids_in_file<nast) number_of_asteroids_in_file = nast;
01210       else if (number_of_asteroids_in_file!=0) break;
01211     }
01212     
01213     return (number_of_asteroids_in_file);
01214   }

Here is the call graph for this function:

void Open (  )  [inherited]

Definition at line 60 of file orsa_file.cc.

References orsa::CLOSE, File::file, File::filename, OPEN_FILE, orsa::OPEN_R, OPEN_READ, ORSA_ERROR, and File::status.

Referenced by SWIFTFile::AsteroidsInFile(), Mercury5IntegrationFile::Read(), TLEFile::Read(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), RadauModIntegrationFile::Read(), SWIFTFile::Read(), LocationFile::Read(), RWOFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00060                       {
00061     if (status != CLOSE) return;
00062     
00063     file = OPEN_FILE(filename.c_str(),OPEN_READ);
00064     
00065     if (file == 0) { 
00066       ORSA_ERROR("Can't open file %s",filename.c_str());
00067     } else {
00068       status = OPEN_R;
00069     }
00070   }

void Close (  )  [inherited]

Definition at line 115 of file orsa_file.cc.

References orsa::CLOSE, CLOSE_FILE, File::file, and File::status.

Referenced by SWIFTFile::AsteroidsInFile(), ReadWriteFile::Open(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), Config::read_from_file(), File::SetFileName(), OrsaFile::Write(), OrsaConfigFile::Write(), Config::write_to_file(), and File::~File().

00115                    {
00116     if (status != CLOSE) {
00117       CLOSE_FILE(file);
00118       status = CLOSE;
00119     }
00120   }

virtual std::string GetFileName (  )  const [inline, virtual, inherited]

Definition at line 99 of file orsa_file.h.

References File::filename.

Referenced by OrsaFile::Read().

00099 { return filename; }

virtual void SetFileName ( std::string  name_in  )  [inline, virtual, inherited]

Definition at line 101 of file orsa_file.h.

References File::Close(), orsa::CLOSE, File::filename, and File::status.

Referenced by OrsaConfigFile::OrsaConfigFile(), and File::SetFileName().

00101                                                         {
00102       if (status != CLOSE) Close();
00103       filename = name_in;
00104     }

Here is the call graph for this function:

virtual void SetFileName ( char *  name_in  )  [inline, virtual, inherited]

Definition at line 106 of file orsa_file.h.

References File::SetFileName().

00106                                                      {
00107       std::string n = name_in;
00108       SetFileName (n);
00109     }

Here is the call graph for this function:


Member Data Documentation

OrbitStream* os

Definition at line 196 of file orsa_file.h.

Referenced by SWIFTFile::Read(), and SWIFTFile::SWIFTFile().

std::string filename [protected, inherited]

Definition at line 112 of file orsa_file.h.

Referenced by File::GetFileName(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), and File::SetFileName().

FILE_TYPE file [protected, inherited]

Definition at line 113 of file orsa_file.h.

Referenced by SWIFTFile::AsteroidsInFile(), File::Close(), File::File(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), RWOFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), OrsaFile::Write(), and OrsaConfigFile::Write().

FILE_STATUS status [protected, inherited]

Definition at line 114 of file orsa_file.h.

Referenced by File::Close(), File::File(), Mercury5IntegrationFile::Mercury5IntegrationFile(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), TLEFile::Read(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), RadauModIntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), File::SetFileName(), OrsaFile::Write(), and OrsaConfigFile::Write().


The documentation for this class was generated from the following files:
Generated on Wed May 30 13:05:06 2007 for liborsa by  doxygen 1.5.2