MPCOrbFile Class Reference

MPC asteroids database file. More...

#include <orsa_file.h>

Inheritance diagram for MPCOrbFile:

Inheritance graph
[legend]
Collaboration diagram for MPCOrbFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MPCOrbFile ()
 ~MPCOrbFile ()
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

MPC asteroids database file.

Definition at line 343 of file orsa_file.h.


Constructor & Destructor Documentation

MPCOrbFile  ) 
 

Definition at line 379 of file orsa_file.cc.

00379                          : AsteroidDatabaseFile() {
00380     db = new AsteroidDatabase();
00381   }

~MPCOrbFile  ) 
 

Definition at line 383 of file orsa_file.cc.

00383                           {
00384     delete db;
00385     db = 0;
00386   }


Member Function Documentation

void Close  )  [inherited]
 

Definition at line 114 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().

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

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

Definition at line 99 of file orsa_file.h.

References File::filename.

Referenced by LocationFile::ObsPos(), and OrsaFile::Read().

00099 { return filename; }

void Open  )  [inherited]
 

Definition at line 59 of file orsa_file.cc.

References orsa::CLOSE, OPEN_FILE, orsa::OPEN_R, OPEN_READ, and ORSA_ERROR.

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().

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

void Read  )  [virtual]
 

Implements ReadFile.

Definition at line 388 of file orsa_file.cc.

References Orbit::a, orsa::AU, OrbitWithEpoch::Compute(), Orbit::e, orsa::ECLIPTIC, orsa::EclipticToEquatorial_J2000(), OrbitWithEpoch::epoch, orsa::EQUATORIAL, orsa::FromUnits(), orsa::GetG(), orsa::GetMSun(), Universe::GetReferenceSystem(), GETS_FILE, Orbit::i, Orbit::M, orsa::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, UniverseTypeAwareTime::SetDate(), Date::SetGregor(), orsa::TDT, and orsa::universe.

00388                         {
00389     
00390     Open();
00391     
00392     if (status != OPEN_R) {
00393       ORSA_ERROR("Status error!");
00394       return;
00395     }
00396     
00397     db->clear();
00398     
00399     // Body orb_ref_body("",GetMSun());
00400     
00401     // unsigned int local_index;
00402     
00403     char line[300];
00404     
00405     double a,e,i,omega_node,omega_pericenter,M;
00406     // int    n;
00407     string number,name,orbit_computer,absolute_magnitude,arc,numobs,epoch;
00408     string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis;
00409     // string ceu;
00410     
00411     string year,month,day;
00412     int    y=0,m=0,d=0;
00413     
00414     // AstorbDataEntry ast;
00415     Asteroid ast;
00416     
00417     unsigned int local_index = 0;
00418     bool bool_stop=false;
00419     bool bool_pause=false;
00420 
00421     REWIND_FILE(file);
00422     
00423     // Date tmp_date(TDT);
00424     Date tmp_date;
00425     
00426     /* // skip header, not needed with the check on (strlen(line) < 201)...
00427        do { 
00428        GETS_FILE(line,300,file);
00429        } while (line[0] != '-');
00430        cerr << "below the header..." << endl;
00431     */
00432     
00433     while ( (GETS_FILE(line,300,file)) != 0 ) {
00434       
00435       // cerr << "line: -->" << line << "<--" << endl; 
00436       
00437       ++local_index;
00438       
00439       if (strlen(line) < 201) continue; // not a good line, maybe a comment or a white line...
00440       
00441       // cerr << "strlen(line): " << strlen(line) << endl;
00442       
00443       // cerr << "line: -->" << line << "<--" << endl; 
00444       
00445       read_progress(local_index,bool_pause,bool_stop);
00446       
00447       if (bool_stop) break;
00448       
00449       while (bool_pause) {
00450         sleep(1);
00451         read_progress(local_index,bool_pause,bool_stop);
00452       }
00453       
00454       // uncomment the ones used
00455       number.assign(line,0,7);
00456       absolute_magnitude.assign(line,8,5);
00457       epoch.assign(line,20,5);
00458       //
00459       mean_anomaly.assign(line,26,9);
00460       pericenter.assign(line,37,9);
00461       node.assign(line,48,9);
00462       inclination.assign(line,59,9);
00463       eccentricity.assign(line,70,9);
00464       semimajor_axis.assign(line,92,11);
00465       //
00466       numobs.assign(line,117,5);
00467       orbit_computer.assign(line,150,10);
00468       
00469       if (strlen(line) > 160) {
00470         name.assign(line,166,28);
00471       } else {
00472         name = "";      
00473       }
00474       
00475       // conversions
00476       
00477       {
00478         // remove -->(NUMBER)<--
00479         
00480         string::size_type pos_open  = name.find("(",0);
00481         string::size_type pos_close = name.find(")",0);
00482         
00483         if ( (pos_open  != pos_close) &&
00484              (pos_open  != string::npos) &&
00485              (pos_close != string::npos) ) {
00486           
00487           name.erase(pos_open,pos_close-pos_open+1);
00488         }
00489       }    
00490       //
00491       ast.name = name;
00492       remove_leading_trailing_spaces(ast.name);
00493       
00494       // ast.n = 0; // arbitrary, for the moment
00495       ast.n = atoi(number.c_str());
00496       
00497       ast.mag  = atof(absolute_magnitude.c_str());
00498          
00499       a                = atof(semimajor_axis.c_str());
00500       e                = atof(eccentricity.c_str());
00501       i                = (pi/180)*atof(inclination.c_str());
00502       omega_node       = (pi/180)*atof(node.c_str());
00503       omega_pericenter = (pi/180)*atof(pericenter.c_str());
00504       M                = (pi/180)*atof(mean_anomaly.c_str());
00505       
00506       ast.orb.a                = FromUnits(a,AU);
00507       ast.orb.e                = e;
00508       ast.orb.i                = i;
00509       ast.orb.omega_node       = omega_node;
00510       ast.orb.omega_pericenter = omega_pericenter;
00511       ast.orb.M                = M;
00512 
00513       int ch;
00514       // cerr << "epoch string: " << epoch << endl;
00515       //// epoch
00516       // year
00517       year.assign(epoch,0,1);
00518       ch = (int)year.c_str()[0];
00519       // cerr << "ch: " << ch << "  " << ((int)('I')) << endl;
00520       switch (ch) {
00521       case 'I': y=1800; break; 
00522       case 'J': y=1900; break;
00523       case 'K': y=2000; break;
00524       }
00525       //
00526       year.assign(epoch,1,2);
00527       y += atoi(year.c_str());
00528       // month
00529       month.assign(epoch,3,1);
00530       ch = (int)month.c_str()[0];
00531       switch (ch) {
00532       case '1': m=1;  break;
00533       case '2': m=2;  break;
00534       case '3': m=3;  break;
00535       case '4': m=4;  break;
00536       case '5': m=5;  break;
00537       case '6': m=6;  break;
00538       case '7': m=7;  break;
00539       case '8': m=8;  break;
00540       case '9': m=9;  break;
00541       case 'A': m=10; break; 
00542       case 'B': m=11; break;
00543       case 'C': m=12; break;
00544       }
00545       // day
00546       day.assign(epoch,4,1);
00547       ch = (int)day.c_str()[0];
00548       switch (ch) {
00549       case '1': d=1;  break;
00550       case '2': d=2;  break;
00551       case '3': d=3;  break;
00552       case '4': d=4;  break;
00553       case '5': d=5;  break;
00554       case '6': d=6;  break;
00555       case '7': d=7;  break;
00556       case '8': d=8;  break;
00557       case '9': d=9;  break;
00558       case 'A': d=10; break; 
00559       case 'B': d=11; break;
00560       case 'C': d=12; break;
00561       case 'D': d=13; break;
00562       case 'E': d=14; break;
00563       case 'F': d=15; break;
00564       case 'G': d=16; break;
00565       case 'H': d=17; break;
00566       case 'I': d=18; break;
00567       case 'J': d=19; break;
00568       case 'K': d=20; break;
00569       case 'L': d=21; break;
00570       case 'M': d=22; break;
00571       case 'N': d=23; break;
00572       case 'O': d=24; break;
00573       case 'P': d=25; break;
00574       case 'Q': d=26; break;
00575       case 'R': d=27; break;
00576       case 'S': d=28; break;
00577       case 'T': d=29; break;
00578       case 'U': d=30; break;
00579       case 'V': d=31; break;
00580       }
00581       //
00582       // cerr << "MPC::Read() --> y: " << y << "  m: " << m << "  d: " << d << endl;
00583       // ast.orb.time = FromUnits(GregorianToSdn(y,m,d)-0.5,DAY);
00584       tmp_date.SetGregor(y,m,d,TDT);
00585       ast.orb.epoch.SetDate(tmp_date);
00586       
00587       // ast.orb.T = sqrt(4*pisq/(GetG()*GetMSun())*pow(FromUnits(ast.orb.a,AU),3));
00588       ast.orb.mu = GetG()*GetMSun();
00589       // ast.orb.ref_body.mass=GetMSun();
00590       // ast.orb.ref_body = Body("",GetMSun());
00591       // ast.orb.ref_body = orb_ref_body;
00592       
00593       /* 
00594          switch (universe->GetReferenceSystem()) {
00595          case ECLIPTIC: break;
00596          case EQUATORIAL:
00597          { 
00598          // cerr << "Rotating astorb orbit..." << endl;
00599          const double obleq_rad = obleq(tmp_date).GetRad();
00600          Vector position,velocity;
00601          ast.orb.RelativePosVel(position,velocity);
00602          position.rotate(0.0,obleq_rad,0.0);
00603          velocity.rotate(0.0,obleq_rad,0.0);
00604          ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
00605          }
00606          break;
00607          }
00608       */
00609       
00610       switch (universe->GetReferenceSystem()) {
00611       case ECLIPTIC: break;
00612       case EQUATORIAL:
00613         { 
00614           Vector position,velocity;
00615           ast.orb.RelativePosVel(position,velocity);
00616           EclipticToEquatorial_J2000(position);
00617           EclipticToEquatorial_J2000(velocity);
00618           ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
00619         }
00620         break;
00621       }
00622       
00623       // cerr << "adding object: " << ast.name << "  a: " << ast.orb.a << endl;
00624       
00625       db->push_back(ast);
00626       
00627     }
00628     
00629     read_finished();
00630   }

Here is the call graph for this function:

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

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

AsteroidDatabase* db [inherited]
 

Definition at line 254 of file orsa_file.h.

Referenced by AsteroidDatabaseFile::AsteroidDatabaseFile().

FILE_TYPE file [protected, inherited]
 

Definition at line 113 of file orsa_file.h.

Referenced by File::Close(), and File::File().

std::string filename [protected, inherited]
 

Definition at line 112 of file orsa_file.h.

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

FILE_STATUS status [protected, inherited]
 

Definition at line 114 of file orsa_file.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:28:37 2005 for liborsa by  doxygen 1.4.0