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 osin  ) 

Definition at line 1159 of file orsa_file.cc.

References SWIFTFile::os.

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


Member Function Documentation

int AsteroidsInFile (  ) 

Definition at line 1198 of file orsa_file.cc.

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

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

Here is the call graph for this function:

void Close (  )  [inherited]

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; }

void Open (  )  [inherited]

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 1218 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.

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

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:

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:


Member Data Documentation

FILE_TYPE file [protected, inherited]

std::string filename [protected, inherited]

Definition at line 196 of file orsa_file.h.

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

FILE_STATUS status [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Sat Aug 15 19:04:33 2009 for liborsa by  doxygen 1.5.9