AstDySMatrixFile Class Reference

NEODyS and AstDyS .ctc and .ctm files. More...

#include <orsa_file.h>

Inheritance diagram for AstDySMatrixFile:

Inheritance graph
[legend]
Collaboration diagram for AstDySMatrixFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AstDySMatrixFile ()
 ~AstDySMatrixFile ()
void Read ()
virtual void read_progress (int, bool &, bool &)
virtual void read_finished ()
void Open ()
void Close ()
virtual std::string GetFileName () const
virtual void SetFileName (std::string name_in)
virtual void SetFileName (char *name_in)

Public Attributes

AsteroidDatabasedb

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

NEODyS and AstDyS .ctc and .ctm files.

Definition at line 262 of file orsa_file.h.


Constructor & Destructor Documentation

AstDySMatrixFile (  ) 

Definition at line 2353 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

02353                                      : AsteroidDatabaseFile() {
02354     db = new AsteroidDatabase();
02355   }

~AstDySMatrixFile (  ) 

Definition at line 2357 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

02357                                       {
02358     delete db;
02359     db = 0;
02360   }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 2362 of file orsa_file.cc.

References Orbit::a, OrbitWithEpoch::Compute(), AsteroidDatabaseFile::db, Orbit::e, orsa::ECLIPTIC, orsa::EclipticToEquatorial_J2000(), OrbitWithEpoch::epoch, orsa::EQUATORIAL, orsa::Equinoctal, orsa::GetG(), orsa::GetMSun(), Universe::GetReferenceSystem(), GETS_FILE, Orbit::i, Orbit::M, Asteroid::mag, Orbit::mu, Asteroid::n, Asteroid::name, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, Asteroid::orb, ORSA_ERROR, orsa::pi, AsteroidDatabaseFile::read_finished(), AsteroidDatabaseFile::read_progress(), OrbitWithEpoch::RelativePosVel(), orsa::remove_leading_trailing_spaces(), REWIND_FILE, orsa::secure_atan2(), UniverseTypeAwareTime::SetDate(), Date::SetJulian(), File::status, orsa::TDT, orsa::twopi, and orsa::universe.

02362                               {
02363     
02364     Open();
02365     
02366     if (status != OPEN_R) {
02367       ORSA_ERROR("Status error!");
02368       return;
02369     }
02370     
02371     REWIND_FILE(file);
02372     
02373     char line[1024],tag[10];
02374     string stag;
02375     const string end_of_header="END_OF_HEADER";
02376     
02377     // skip header
02378     while (GETS_FILE(line,1024,file)!=0) {
02379       sscanf(line,"%s",tag);
02380       stag = tag;
02381       if (stag == end_of_header) {
02382         break;
02383       }
02384     }
02385     
02386     Asteroid ast;
02387     
02388     double cov_content[21];
02389     int cov_line;
02390     
02391     unsigned int local_index = 0;
02392     bool bool_stop=false;
02393     bool bool_pause=false;
02394     
02395     while (GETS_FILE(line,1024,file)!=0) {
02396       
02397       if (line[0] == '!') continue; // comment/header line
02398       
02399       if (line[0] == ' ') continue; // not the line number
02400       
02401       ++local_index;
02402       read_progress(local_index,bool_pause,bool_stop);
02403       
02404       if (bool_stop) break;
02405       
02406       while (bool_pause) {
02407         sleep(1);
02408         read_progress(local_index,bool_pause,bool_stop);
02409       }
02410       
02411       sscanf(line,"%s",tag);
02412       stag = tag;
02413       remove_leading_trailing_spaces(stag);     
02414       
02415       ast.name = stag;
02416       
02417       {
02418         const string name=stag;
02419         char c;
02420         unsigned int ck;
02421         bool is_only_digit=true;
02422         for (ck=0;ck<name.size();++ck) {
02423           c = name[ck];
02424           if (isalpha(c)) { 
02425             is_only_digit=false;
02426             break;
02427           }
02428         }
02429         
02430         if (is_only_digit) {
02431           ast.n = atoi(name.c_str());
02432         } else {
02433           ast.n = 0;
02434         }
02435       }
02436       
02437 #ifdef HAVE_GSL
02438       OrbitWithCovarianceMatrixGSL orbit;
02439 #else
02440       OrbitWithEpoch orbit;
02441 #endif
02442       
02443       orbit.mu = GetG()*GetMSun();
02444       
02445       cov_line = 0;
02446       
02447       while (GETS_FILE(line,1024,file)!=0) {
02448         
02449         if (line[0] == '!') continue; // comment/header line
02450         
02451         if (line[0] != ' ') break; // new asteroid
02452         
02453         sscanf(line,"%s",tag);
02454         stag = tag;
02455         
02456         if (stag == "EQU") {
02457           
02458           double x[6];
02459           
02460           sscanf(line,"%s %lg %lg %lg %lg %lg %lg",tag,&x[0],&x[1],&x[2],&x[3],&x[4],&x[5]);
02461           
02462           const double omega_tilde = secure_atan2(x[1],x[2]);
02463           
02464           orbit.a                  = x[0];
02465           orbit.e                  = sqrt(x[1]*x[1]+x[2]*x[2]);
02466           orbit.i                  = 2.0*atan(sqrt(x[3]*x[3]+x[4]*x[4]));
02467           orbit.omega_node         = fmod(10.0*twopi+secure_atan2(x[3],x[4]),twopi);
02468           orbit.omega_pericenter   = fmod(10.0*twopi+omega_tilde-orbit.omega_node,twopi);
02469           orbit.M                  = fmod(10.0*twopi+(pi/180)*x[5]-omega_tilde,twopi);
02470           
02471         } else if (stag == "MJD") {
02472           
02473           double epoch_MJD;
02474           sscanf(line,"%s %lg",tag,&epoch_MJD);
02475           Date  epoch;
02476           epoch.SetJulian(epoch_MJD+2400000.5,TDT);
02477           
02478           orbit.epoch.SetDate(epoch);
02479           
02480         } else if (stag == "MAG") {
02481           
02482           double mag, m2;
02483           sscanf(line,"%s %lg %lg",tag,&mag,&m2);
02484           
02485           ast.mag = mag;
02486           
02487         } else if (stag == "COV") {
02488           
02489           double c0,c1,c2;          
02490           
02491           sscanf(line,"%s %lg %lg %lg",tag,&c0,&c1,&c2);
02492           
02493           cov_content[cov_line*3]   = c0;
02494           cov_content[cov_line*3+1] = c1;
02495           cov_content[cov_line*3+2] = c2;
02496           
02497           cov_line++;
02498         }
02499         
02500         if (cov_line==7) break;
02501         
02502       }
02503       
02504 #ifdef HAVE_GSL
02505       if (cov_line==7) {
02506         double covm[6][6];
02507         int i,k;
02508         int ik=0;
02509         for (i=0;i<6;++i) {
02510           for (k=i;k<6;++k) {
02511             // IMPORTANT: units correction
02512             if (i==5) cov_content[ik] *= (pi/180);
02513             if (k==5) cov_content[ik] *= (pi/180);
02514             //
02515             covm[i][k] = cov_content[ik];
02516             covm[k][i] = covm[i][k];
02517             //
02518             ++ik;
02519           }
02520         }       
02521         orbit.SetCovarianceMatrix((double**)covm,Equinoctal);
02522       } else {
02523         ORSA_ERROR("Cannot set covariance matrix for object %s from file %s.",ast.name.c_str(),filename.c_str());
02524       }      
02525 #endif // HAVE_GSL
02526       
02527       ast.orb = orbit;
02528       
02529       // CHECK THIS CODE!
02530       // NB: DON'T KNOW HOW TO 'ROTATE' THE COVARIANCE MATRIX
02531       /* 
02532          switch (universe->GetReferenceSystem()) {
02533          case ECLIPTIC: break;
02534          case EQUATORIAL:
02535          { 
02536          Date tmp_date(TDT);
02537          // cerr << "Rotating astorb orbit..." << endl;
02538          const double obleq_rad = obleq(tmp_date).GetRad();
02539          Vector position,velocity;
02540          ast.orb.RelativePosVel(position,velocity);
02541          position.rotate(0.0,obleq_rad,0.0);
02542          velocity.rotate(0.0,obleq_rad,0.0);
02543          ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
02544          }
02545          break;
02546          }
02547       */
02548       //
02549       switch (universe->GetReferenceSystem()) {
02550       case ECLIPTIC: break;
02551       case EQUATORIAL:
02552         { 
02553           Vector position,velocity;
02554           ast.orb.RelativePosVel(position,velocity);
02555           EclipticToEquatorial_J2000(position);
02556           EclipticToEquatorial_J2000(velocity);
02557           ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
02558         }
02559         break;
02560       }
02561       
02562       db->push_back(ast);
02563     }
02564     
02565     read_finished();
02566   }

Here is the call graph for this function:

virtual void read_progress ( int  ,
bool &  ,
bool &   
) [inline, virtual, inherited]

Definition at line 256 of file orsa_file.h.

Referenced by NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00256 { };

virtual void read_finished (  )  [inline, virtual, inherited]

Definition at line 257 of file orsa_file.h.

Referenced by NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00257 { };

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

AsteroidDatabase* db [inherited]

Definition at line 254 of file orsa_file.h.

Referenced by AstDySMatrixFile::AstDySMatrixFile(), AsteroidDatabaseFile::AsteroidDatabaseFile(), AstorbFile::AstorbFile(), JPLDastcomCometFile::JPLDastcomCometFile(), JPLDastcomNumFile::JPLDastcomNumFile(), JPLDastcomUnnumFile::JPLDastcomUnnumFile(), MPCCometFile::MPCCometFile(), MPCOrbFile::MPCOrbFile(), NEODYSCAT::NEODYSCAT(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), AstDySMatrixFile::~AstDySMatrixFile(), AstorbFile::~AstorbFile(), JPLDastcomCometFile::~JPLDastcomCometFile(), JPLDastcomNumFile::~JPLDastcomNumFile(), JPLDastcomUnnumFile::~JPLDastcomUnnumFile(), MPCCometFile::~MPCCometFile(), MPCOrbFile::~MPCOrbFile(), and NEODYSCAT::~NEODYSCAT().

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:07 2007 for liborsa by  doxygen 1.5.2