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