#include <orsa_file.h>
Inheritance diagram for MPCCometFile:
Public Member Functions | |
MPCCometFile () | |
~MPCCometFile () | |
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 | |
AsteroidDatabase * | db |
Protected Attributes | |
std::string | filename |
FILE_TYPE | file |
FILE_STATUS | status |
Definition at line 362 of file orsa_file.h.
MPCCometFile | ( | ) |
Definition at line 635 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
00635 : AsteroidDatabaseFile() { 00636 db = new AsteroidDatabase(); 00637 // status = CLOSE; 00638 }
~MPCCometFile | ( | ) |
void Read | ( | ) | [virtual] |
Implements ReadFile.
Definition at line 651 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, File::file, 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, Orbit::Period(), orsa::pi, AsteroidDatabaseFile::read_finished(), AsteroidDatabaseFile::read_progress(), OrbitWithEpoch::RelativePosVel(), orsa::remove_leading_trailing_spaces(), REWIND_FILE, UniverseTypeAwareTime::SetDate(), Date::SetGregor(), File::status, orsa::TDT, UniverseTypeAwareTime::Time(), orsa::twopi, and orsa::universe.
00651 { 00652 00653 // if (status == CLOSE) Open(); 00654 00655 Open(); 00656 00657 if (status != OPEN_R) { 00658 ORSA_ERROR("Status error!"); 00659 return; 00660 } 00661 00662 db->clear(); 00663 00664 char line[300]; 00665 00666 double a,e,i,omega_node,omega_pericenter,M; 00667 string number,type,name,orbit_computer,absolute_magnitude,arc,numobs,epoch; 00668 string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis; 00669 // string ceu; 00670 string pericenter_distance,pericenter_epoch; 00671 00672 string year,month,day; 00673 int y=0,m=0,d=0; 00674 double frac_day; 00675 00676 Asteroid ast; 00677 00678 double q; 00679 00680 REWIND_FILE(file); 00681 00682 // Date tmp_date(TDT); 00683 Date tmp_date; 00684 00685 bool have_perturbed_solution_epoch; 00686 00687 unsigned int local_index = 0; 00688 bool bool_stop=false; 00689 bool bool_pause=false; 00690 00691 while ( (GETS_FILE(line,300,file)) != 0 ) { 00692 00693 if (strlen(line) < 90) continue; // not a good line, maybe a comment or a white line... 00694 00695 ++local_index; 00696 read_progress(local_index,bool_pause,bool_stop); 00697 00698 if (bool_stop) break; 00699 00700 while (bool_pause) { 00701 // cerr << "AstorbFile::Read() sleeping..." << endl; 00702 sleep(1); 00703 read_progress(local_index,bool_pause,bool_stop); 00704 } 00705 00706 // uncomment the ones used 00707 number.assign(line,0,4); 00708 type.assign(line,4,1); 00709 // name.assign(line,5,7); 00710 name.assign(line,102,strlen(line)-102-1); // the last -1 is set to avoid the '\n' character in the name 00711 // cerr << "comet name: " << name << endl; 00712 pericenter_epoch.assign(line,14,15); 00713 pericenter_distance.assign(line,30,9); 00714 eccentricity.assign(line,41,8); 00715 pericenter.assign(line,51,8); 00716 node.assign(line,61,8); 00717 inclination.assign(line,71,8); 00718 // 00719 epoch.assign(line,81,8); 00720 00721 // conversions 00722 00723 ast.name = name; 00724 remove_leading_trailing_spaces(ast.name); 00725 00726 ast.n = 0; // arbitrary, for the moment 00727 00728 ast.mag = atof(absolute_magnitude.c_str()); 00729 00730 // a = atof(semimajor_axis.c_str()); 00731 e = atof(eccentricity.c_str()); 00732 00733 // to be tested... 00734 q = atof(pericenter_distance.c_str()); 00735 if (e == 1.0) { 00736 a = q; 00737 } else { 00738 a = q/fabs(1.0-e); 00739 } 00740 00741 i = (pi/180)*atof(inclination.c_str()); 00742 omega_node = (pi/180)*atof(node.c_str()); 00743 omega_pericenter = (pi/180)*atof(pericenter.c_str()); 00744 // M = (pi/180)*atof(mean_anomaly.c_str()); 00745 00746 year.assign(epoch,0,4); 00747 month.assign(epoch,4,2); 00748 day.assign(epoch,6,2); 00749 00750 y = atoi(year.c_str()); 00751 m = atoi(month.c_str()); 00752 d = atoi(day.c_str()); 00753 00754 // check on the presence of the 'perturbed solutions' epoch... 00755 if (y < 1700) { 00756 have_perturbed_solution_epoch=false; 00757 } else { 00758 have_perturbed_solution_epoch=true; 00759 } 00760 00761 tmp_date.SetGregor(y,m,d,TDT); 00762 00763 year.assign(pericenter_epoch,0,4); 00764 month.assign(pericenter_epoch,5,2); 00765 day.assign(pericenter_epoch,8,7); 00766 00767 y = atoi(year.c_str()); 00768 m = atoi(month.c_str()); 00769 frac_day = atof(day.c_str()); 00770 00771 Date peri_date; 00772 peri_date.SetGregor(y,m,frac_day,TDT); 00773 UniverseTypeAwareTime pericenter_passage(peri_date); 00774 00775 if (have_perturbed_solution_epoch) { 00776 ast.orb.epoch.SetDate(tmp_date); 00777 } else { 00778 ast.orb.epoch.SetDate(peri_date); 00779 } 00780 00781 ast.orb.mu = GetG()*GetMSun(); 00782 00783 ast.orb.a = FromUnits(a,AU); 00784 ast.orb.e = e; 00785 ast.orb.i = i; 00786 ast.orb.omega_node = omega_node; 00787 ast.orb.omega_pericenter = omega_pericenter; 00788 // 00789 if (have_perturbed_solution_epoch) { 00790 M = ((ast.orb.epoch.Time() - pericenter_passage.Time())/ast.orb.Period())*twopi; 00791 M = fmod(10*twopi+fmod(M,twopi),twopi); 00792 // 00793 ast.orb.M = M; 00794 } else { 00795 ast.orb.M = 0.0; 00796 } 00797 00798 // cerr << "comet: " << ast.name << " q: " << q << " e: " << e << " i: " << i*(180/pi) << endl; 00799 00800 /* 00801 switch (universe->GetReferenceSystem()) { 00802 case ECLIPTIC: break; 00803 case EQUATORIAL: 00804 { 00805 // cerr << "Rotating astorb orbit..." << endl; 00806 const double obleq_rad = obleq(tmp_date).GetRad(); 00807 Vector position,velocity; 00808 ast.orb.RelativePosVel(position,velocity); 00809 position.rotate(0.0,obleq_rad,0.0); 00810 velocity.rotate(0.0,obleq_rad,0.0); 00811 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00812 } 00813 break; 00814 } 00815 */ 00816 00817 switch (universe->GetReferenceSystem()) { 00818 case ECLIPTIC: break; 00819 case EQUATORIAL: 00820 { 00821 Vector position,velocity; 00822 ast.orb.RelativePosVel(position,velocity); 00823 EclipticToEquatorial_J2000(position); 00824 EclipticToEquatorial_J2000(velocity); 00825 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00826 } 00827 break; 00828 } 00829 00830 db->push_back(ast); 00831 00832 } 00833 00834 read_finished(); 00835 }
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().
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().
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().
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().
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:
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().