#include <orsa_file.h>
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 | |
AsteroidDatabase * | db |
Protected Attributes | |
std::string | filename |
FILE_TYPE | file |
FILE_STATUS | status |
Definition at line 295 of file orsa_file.h.
Definition at line 2866 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
02866 : AsteroidDatabaseFile() { 02867 db = new AsteroidDatabase(); 02868 }
~JPLDastcomCometFile | ( | ) | [virtual] |
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 }
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 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 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; }
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().
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 }
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().