NEODYSCAT Class Reference

NEODyS and AstDyS .cat file. More...

#include <orsa_file.h>

Inheritance diagram for NEODYSCAT:

Inheritance graph
[legend]
Collaboration diagram for NEODYSCAT:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 NEODYSCAT ()
 ~NEODYSCAT ()
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 .cat file.

Definition at line 272 of file orsa_file.h.


Constructor & Destructor Documentation

NEODYSCAT (  ) 

Definition at line 3046 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

03046                        : AsteroidDatabaseFile() {
03047     // status = CLOSE;
03048     db = new AsteroidDatabase();
03049   }

~NEODYSCAT (  ) 

Definition at line 3051 of file orsa_file.cc.

References AsteroidDatabaseFile::db.

03051                         {
03052     delete db;
03053     db = 0;
03054   }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 3056 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, 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, and orsa::universe.

03056                        {
03057     
03058     // if (status == CLOSE) Open();
03059     
03060     Open();
03061     
03062     if (status != OPEN_R) {
03063       ORSA_ERROR("Status error!");
03064       return;
03065     }
03066     
03067     db->clear();
03068     
03069     char line[300];
03070     
03071     double a,e,i,omega_node,omega_pericenter,M;
03072     // int    n;
03073     string number,name,orbit_computer,absolute_magnitude,arc,numobs,epoch;
03074     string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis;
03075     // string ceu;
03076     
03077     string year,month,day;
03078     // int    y,m,d;
03079     
03080     Asteroid ast;
03081     
03082     // Date tmp_date(TDT);
03083     Date tmp_date;
03084     
03085     unsigned int local_index = 0;
03086     bool bool_stop=false;
03087     bool bool_pause=false;
03088     REWIND_FILE(file);
03089     while ((GETS_FILE(line,300,file)) != 0) {
03090       
03091       if (strlen(line) < 100) continue; // not a good line, maybe a comment or a white line...
03092       
03093       if (line[0]=='!') continue; // comment
03094       
03095       local_index++;
03096       read_progress(local_index,bool_pause,bool_stop);
03097       
03098       if (bool_stop) break;
03099       
03100       while (bool_pause) {
03101         sleep(1);
03102         read_progress(local_index,bool_pause,bool_stop);
03103       }
03104       
03105       // uncomment the ones used
03106       // number.assign(line,0,5);
03107       name.assign(line,0,12); 
03108       //
03109       {
03110         // remove -->'<--
03111         string::size_type pos;
03112         while ((pos=name.find("'",0)) != string::npos) {
03113           // cerr << "name: " << name << "  pos: " << pos << endl;
03114           name.erase(pos,1);
03115         }
03116         // cerr << "final name: " << name << endl;
03117       }
03118       
03119       // orbit_computer.assign(line,25,15);
03120       // absolute_magnitude.assign(line,41,5);
03121       //
03122       // arc.assign(line,94,5);
03123       // numobs.assign(line,99,5);
03124       //
03125       epoch.assign(line,13,15);
03126       //
03127       semimajor_axis.assign(line,29,25);
03128       eccentricity.assign(line,54,25);
03129       inclination.assign(line,79,25);
03130       node.assign(line,104,25);
03131       pericenter.assign(line,129,25);
03132       mean_anomaly.assign(line,154,25);
03133       //////////////
03134       
03135       // ast.n = atoi(number.c_str());
03136       // ast.n = 0;
03137       {
03138         char c;
03139         unsigned int ck;
03140         bool is_only_digit=true;
03141         for (ck=0;ck<name.size();++ck) {
03142           c = name[ck];
03143           if (isalpha(c)) { 
03144             is_only_digit=false;
03145             break;
03146           }
03147         }
03148         
03149         if (is_only_digit) {
03150           ast.n = atoi(name.c_str());
03151         } else {
03152           ast.n = 0;
03153         }
03154       }
03155       
03156       ast.name = name;
03157       remove_leading_trailing_spaces(ast.name);
03158       
03159       // ast.ceu  = atof(ceu.c_str());
03160       
03161       // ast.mag  = atof(absolute_magnitude.c_str());
03162       
03163       a                = atof(semimajor_axis.c_str());
03164       e                = atof(eccentricity.c_str());
03165       i                = (pi/180)*atof(inclination.c_str());
03166       omega_node       = (pi/180)*atof(node.c_str());
03167       omega_pericenter = (pi/180)*atof(pericenter.c_str());
03168       M                = (pi/180)*atof(mean_anomaly.c_str());
03169       
03170       ast.orb.a                = FromUnits(a,AU);
03171       ast.orb.e                = e;
03172       ast.orb.i                = i;
03173       ast.orb.omega_node       = omega_node;
03174       ast.orb.omega_pericenter = omega_pericenter;
03175       ast.orb.M                = M;
03176       
03177       // year.assign(epoch,0,4);
03178       // month.assign(epoch,4,2);
03179       // day.assign(epoch,6,2);
03180       
03181       // y = atoi(year.c_str());
03182       // m = atoi(month.c_str());
03183       // d = atoi(day.c_str());
03184       
03185       tmp_date.SetJulian(2400000.5+atof(epoch.c_str()),TDT);
03186       ast.orb.epoch.SetDate(tmp_date);
03187       // ast.orb.T = sqrt(4*pisq/(GetG()*GetMSun())*pow(FromUnits(ast.orb.a,AU),3));
03188       ast.orb.mu = GetG()*GetMSun();
03189       // ast.orb.ref_body = orb_ref_body;
03190       
03191       /* 
03192          switch (universe->GetReferenceSystem()) {
03193          case ECLIPTIC: break;
03194          case EQUATORIAL:
03195          { 
03196          // cerr << "Rotating astorb orbit..." << endl;
03197          const double obleq_rad = obleq(tmp_date).GetRad();
03198          Vector position,velocity;
03199          ast.orb.RelativePosVel(position,velocity);
03200          position.rotate(0.0,obleq_rad,0.0);
03201          velocity.rotate(0.0,obleq_rad,0.0);
03202          ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
03203          }
03204          
03205          break;
03206          }
03207       */
03208       
03209       switch (universe->GetReferenceSystem()) {
03210       case ECLIPTIC: break;
03211       case EQUATORIAL:
03212         { 
03213           Vector position,velocity;
03214           ast.orb.RelativePosVel(position,velocity);
03215           EclipticToEquatorial_J2000(position);
03216           EclipticToEquatorial_J2000(velocity);
03217           ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
03218         }
03219         break;
03220       }
03221       
03222       db->push_back(ast);
03223     }
03224     
03225     read_finished();
03226   }

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 Thu Feb 14 21:41:46 2008 for liborsa by  doxygen 1.5.5