JPLDastcomCometFile Class Reference

#include <orsa_file.h>

Inheritance diagram for JPLDastcomCometFile:
Inheritance graph
[legend]
Collaboration diagram for JPLDastcomCometFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JPLDastcomCometFile ()
virtual ~JPLDastcomCometFile ()
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

Definition at line 295 of file orsa_file.h.


Constructor & Destructor Documentation

Definition at line 2866 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

02866                                            : AsteroidDatabaseFile() {
02867     db = new AsteroidDatabase();
02868   }

~JPLDastcomCometFile (  )  [virtual]

Definition at line 2870 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

02870                                             {
02871     delete db;
02872     db = 0;
02873   }


Member Function Documentation

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 2875 of file orsa_file.cc.

References Orbit::a, orsa::AU, OrbitWithEpoch::Compute(), AsteroidDatabaseFile::db, 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, Orbit::mu, Asteroid::n, Asteroid::name, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, Asteroid::orb, ORSA_ERROR, Orbit::Period(), orsa::pi, AsteroidDatabaseFile::read_finished(), AsteroidDatabaseFile::read_progress(), OrbitWithEpoch::RelativePosVel(), orsa::remove_leading_trailing_spaces(), REWIND_FILE, UniverseTypeAwareTime::SetDate(), Date::SetJulian(), File::status, orsa::TDT, UniverseTypeAwareTime::Time(), orsa::twopi, and orsa::universe.

02875                                  {
02876       
02877     Open();
02878     
02879     if (status != OPEN_R) {
02880       ORSA_ERROR("Status error!");
02881       return;
02882     }
02883     
02884     db->clear();
02885     
02886     char line[300];
02887     
02888     double a,e,i,omega_node,omega_pericenter,M;
02889     string number,type,name,orbit_computer,absolute_magnitude,arc,numobs,epoch;
02890     string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis;
02891     // string ceu;
02892     string pericenter_distance,pericenter_epoch;
02893     
02894     string year,month,day;
02895     int    y=0,m=0;
02896     double frac_day;
02897     
02898     Asteroid ast;
02899     
02900     double q;
02901     
02902     REWIND_FILE(file);
02903     
02904     // Date tmp_date(TDT);
02905     Date tmp_date;
02906     
02907     unsigned int local_index = 0;
02908     bool bool_stop=false;
02909     bool bool_pause=false;
02910     
02911     while ( (GETS_FILE(line,300,file)) != 0 ) {
02912       
02913       // if (strlen(line) < 90) continue; // not a good line, maybe a comment or a white line...
02914       
02915       if (line[0]=='-') continue; // comment
02916       
02917       ++local_index;
02918       read_progress(local_index,bool_pause,bool_stop);
02919       
02920       if (bool_stop) break;
02921       
02922       while (bool_pause) {
02923         // cerr << "AstorbFile::Read() sleeping..." << endl;
02924         sleep(1);
02925         read_progress(local_index,bool_pause,bool_stop);
02926       }
02927       
02928       // uncomment the ones used
02929       // number.assign(line,0,4);
02930       // type.assign(line,4,1);
02931       // name.assign(line,5,7);
02932       name.assign(line,0,37);
02933       epoch.assign(line,38,5);
02934       // cerr << "comet name: " << name << endl;
02935       pericenter_distance.assign(line,44,10);
02936       eccentricity.assign(line,55,10);
02937       inclination.assign(line,66,9);
02938       pericenter.assign(line,76,9);
02939       node.assign(line,86,9);
02940       //
02941       pericenter_epoch.assign(line,96,14);
02942       
02943       // conversions
02944       
02945       ast.name = name;
02946       remove_leading_trailing_spaces(ast.name);
02947       
02948       // ast.n = 0; // arbitrary, for the moment
02949       ast.n = 0;
02950       
02951       // ast.mag  = atof(absolute_magnitude.c_str());
02952       
02953       // a                = atof(semimajor_axis.c_str());
02954       e  = atof(eccentricity.c_str());
02955       
02956       // to be tested...
02957       q = atof(pericenter_distance.c_str());
02958       if (e == 1.0) {
02959         a = q;
02960       } else {
02961         a = q/fabs(1.0-e);
02962       }
02963       
02964       // checks
02965       if ((q==0.0)) {
02966         // bad line...
02967         continue;
02968       }
02969       
02970       i                = (pi/180)*atof(inclination.c_str());
02971       omega_node       = (pi/180)*atof(node.c_str());
02972       omega_pericenter = (pi/180)*atof(pericenter.c_str());
02973       // M                = (pi/180)*atof(mean_anomaly.c_str());
02974       
02975       tmp_date.SetJulian(2400000.5+atof(epoch.c_str()),TDT);
02976       ast.orb.epoch.SetDate(tmp_date);
02977       
02978       year.assign(pericenter_epoch,0,4);
02979       month.assign(pericenter_epoch,4,2);
02980       day.assign(pericenter_epoch,6,8);
02981       
02982       y = atoi(year.c_str());
02983       m = atoi(month.c_str());
02984       frac_day = atof(day.c_str());
02985       
02986       Date peri_date;
02987       peri_date.SetGregor(y,m,frac_day,TDT);
02988       UniverseTypeAwareTime pericenter_passage(peri_date);
02989       
02990       ast.orb.mu = GetG()*GetMSun();
02991       
02992       ast.orb.a                = FromUnits(a,AU);
02993       ast.orb.e                = e;
02994       ast.orb.i                = i;
02995       ast.orb.omega_node       = omega_node;
02996       ast.orb.omega_pericenter = omega_pericenter;
02997       //
02998       M = ((ast.orb.epoch.Time() - pericenter_passage.Time())/ast.orb.Period())*twopi;  
02999       M = fmod(10*twopi+fmod(M,twopi),twopi);
03000       //
03001       ast.orb.M                = M;
03002       
03003       // cerr << "comet: " << ast.name << "  q: " << q << "  e: " << e << "  i: " << i*(180/pi) << endl;
03004       
03005       /* 
03006          switch (universe->GetReferenceSystem()) {
03007          case ECLIPTIC: break;
03008          case EQUATORIAL:
03009          { 
03010          // cerr << "Rotating astorb orbit..." << endl;
03011          const double obleq_rad = obleq(tmp_date).GetRad();
03012          Vector position,velocity;
03013          ast.orb.RelativePosVel(position,velocity);
03014          position.rotate(0.0,obleq_rad,0.0);
03015          velocity.rotate(0.0,obleq_rad,0.0);
03016          ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
03017          }
03018          break;
03019          }
03020       */
03021       
03022       switch (universe->GetReferenceSystem()) {
03023       case ECLIPTIC: break;
03024       case EQUATORIAL:
03025         { 
03026           Vector position,velocity;
03027           ast.orb.RelativePosVel(position,velocity);
03028           EclipticToEquatorial_J2000(position);
03029           EclipticToEquatorial_J2000(velocity);
03030           ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
03031         }
03032         break;
03033       }
03034       
03035       db->push_back(ast);
03036       
03037     }
03038     
03039     read_finished();
03040   }

Here is the call graph for this function:

virtual void read_finished (  )  [inline, virtual, inherited]
virtual void read_progress ( int  ,
bool &  ,
bool &   
) [inline, virtual, inherited]
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]
FILE_TYPE file [protected, inherited]
std::string filename [protected, inherited]
FILE_STATUS status [protected, inherited]

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

Generated on Fri Nov 6 11:19:50 2009 for liborsa by  doxygen 1.6.1