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