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

Definition at line 2354 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

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

~AstDySMatrixFile (  ) 

Definition at line 2358 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

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


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

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

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

Here is the call graph for this function:

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

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

void Open (  )  [inherited]

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

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]

std::string filename [protected, inherited]

FILE_TYPE file [protected, inherited]

FILE_STATUS status [protected, inherited]


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

Generated on Sat May 10 00:04:09 2008 for liborsa by  doxygen 1.5.5