#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 2865 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
02865 : AsteroidDatabaseFile() { 02866 db = new AsteroidDatabase(); 02867 }
~JPLDastcomCometFile | ( | ) | [virtual] |
void Read | ( | ) | [virtual] |
Implements ReadFile.
Definition at line 2874 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.
02874 { 02875 02876 Open(); 02877 02878 if (status != OPEN_R) { 02879 ORSA_ERROR("Status error!"); 02880 return; 02881 } 02882 02883 db->clear(); 02884 02885 char line[300]; 02886 02887 double a,e,i,omega_node,omega_pericenter,M; 02888 string number,type,name,orbit_computer,absolute_magnitude,arc,numobs,epoch; 02889 string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis; 02890 // string ceu; 02891 string pericenter_distance,pericenter_epoch; 02892 02893 string year,month,day; 02894 int y=0,m=0; 02895 double frac_day; 02896 02897 Asteroid ast; 02898 02899 double q; 02900 02901 REWIND_FILE(file); 02902 02903 // Date tmp_date(TDT); 02904 Date tmp_date; 02905 02906 unsigned int local_index = 0; 02907 bool bool_stop=false; 02908 bool bool_pause=false; 02909 02910 while ( (GETS_FILE(line,300,file)) != 0 ) { 02911 02912 // if (strlen(line) < 90) continue; // not a good line, maybe a comment or a white line... 02913 02914 if (line[0]=='-') continue; // comment 02915 02916 ++local_index; 02917 read_progress(local_index,bool_pause,bool_stop); 02918 02919 if (bool_stop) break; 02920 02921 while (bool_pause) { 02922 // cerr << "AstorbFile::Read() sleeping..." << endl; 02923 sleep(1); 02924 read_progress(local_index,bool_pause,bool_stop); 02925 } 02926 02927 // uncomment the ones used 02928 // number.assign(line,0,4); 02929 // type.assign(line,4,1); 02930 // name.assign(line,5,7); 02931 name.assign(line,0,37); 02932 epoch.assign(line,38,5); 02933 // cerr << "comet name: " << name << endl; 02934 pericenter_distance.assign(line,44,10); 02935 eccentricity.assign(line,55,10); 02936 inclination.assign(line,66,9); 02937 pericenter.assign(line,76,9); 02938 node.assign(line,86,9); 02939 // 02940 pericenter_epoch.assign(line,96,14); 02941 02942 // conversions 02943 02944 ast.name = name; 02945 remove_leading_trailing_spaces(ast.name); 02946 02947 // ast.n = 0; // arbitrary, for the moment 02948 ast.n = 0; 02949 02950 // ast.mag = atof(absolute_magnitude.c_str()); 02951 02952 // a = atof(semimajor_axis.c_str()); 02953 e = atof(eccentricity.c_str()); 02954 02955 // to be tested... 02956 q = atof(pericenter_distance.c_str()); 02957 if (e == 1.0) { 02958 a = q; 02959 } else { 02960 a = q/fabs(1.0-e); 02961 } 02962 02963 // checks 02964 if ((q==0.0)) { 02965 // bad line... 02966 continue; 02967 } 02968 02969 i = (pi/180)*atof(inclination.c_str()); 02970 omega_node = (pi/180)*atof(node.c_str()); 02971 omega_pericenter = (pi/180)*atof(pericenter.c_str()); 02972 // M = (pi/180)*atof(mean_anomaly.c_str()); 02973 02974 tmp_date.SetJulian(2400000.5+atof(epoch.c_str()),TDT); 02975 ast.orb.epoch.SetDate(tmp_date); 02976 02977 year.assign(pericenter_epoch,0,4); 02978 month.assign(pericenter_epoch,4,2); 02979 day.assign(pericenter_epoch,6,8); 02980 02981 y = atoi(year.c_str()); 02982 m = atoi(month.c_str()); 02983 frac_day = atof(day.c_str()); 02984 02985 Date peri_date; 02986 peri_date.SetGregor(y,m,frac_day,TDT); 02987 UniverseTypeAwareTime pericenter_passage(peri_date); 02988 02989 ast.orb.mu = GetG()*GetMSun(); 02990 02991 ast.orb.a = FromUnits(a,AU); 02992 ast.orb.e = e; 02993 ast.orb.i = i; 02994 ast.orb.omega_node = omega_node; 02995 ast.orb.omega_pericenter = omega_pericenter; 02996 // 02997 M = ((ast.orb.epoch.Time() - pericenter_passage.Time())/ast.orb.Period())*twopi; 02998 M = fmod(10*twopi+fmod(M,twopi),twopi); 02999 // 03000 ast.orb.M = M; 03001 03002 // cerr << "comet: " << ast.name << " q: " << q << " e: " << e << " i: " << i*(180/pi) << endl; 03003 03004 /* 03005 switch (universe->GetReferenceSystem()) { 03006 case ECLIPTIC: break; 03007 case EQUATORIAL: 03008 { 03009 // cerr << "Rotating astorb orbit..." << endl; 03010 const double obleq_rad = obleq(tmp_date).GetRad(); 03011 Vector position,velocity; 03012 ast.orb.RelativePosVel(position,velocity); 03013 position.rotate(0.0,obleq_rad,0.0); 03014 velocity.rotate(0.0,obleq_rad,0.0); 03015 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 03016 } 03017 break; 03018 } 03019 */ 03020 03021 switch (universe->GetReferenceSystem()) { 03022 case ECLIPTIC: break; 03023 case EQUATORIAL: 03024 { 03025 Vector position,velocity; 03026 ast.orb.RelativePosVel(position,velocity); 03027 EclipticToEquatorial_J2000(position); 03028 EclipticToEquatorial_J2000(velocity); 03029 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 03030 } 03031 break; 03032 } 03033 03034 db->push_back(ast); 03035 03036 } 03037 03038 read_finished(); 03039 }
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().
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().