#include <orsa_file.h>
Public Member Functions | |
AstDySMatrixFile () | |
~AstDySMatrixFile () | |
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 262 of file orsa_file.h.
AstDySMatrixFile | ( | ) |
Definition at line 2354 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
02354 : AsteroidDatabaseFile() { 02355 db = new AsteroidDatabase(); 02356 }
~AstDySMatrixFile | ( | ) |
void Read | ( | ) | [virtual] |
Implements ReadFile.
Definition at line 2363 of file orsa_file.cc.
References Orbit::a, OrbitWithEpoch::Compute(), AsteroidDatabaseFile::db, Orbit::e, orsa::ECLIPTIC, orsa::EclipticToEquatorial_J2000(), OrbitWithEpoch::epoch, orsa::EQUATORIAL, orsa::Equinoctal, orsa::GetG(), orsa::GetMSun(), Universe::GetReferenceSystem(), GETS_FILE, Orbit::i, Orbit::M, Asteroid::mag, Orbit::mu, Asteroid::n, Asteroid::name, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, Asteroid::orb, ORSA_ERROR, orsa::pi, AsteroidDatabaseFile::read_finished(), AsteroidDatabaseFile::read_progress(), OrbitWithEpoch::RelativePosVel(), orsa::remove_leading_trailing_spaces(), REWIND_FILE, orsa::secure_atan2(), UniverseTypeAwareTime::SetDate(), Date::SetJulian(), File::status, orsa::TDT, orsa::twopi, and orsa::universe.
02363 { 02364 02365 Open(); 02366 02367 if (status != OPEN_R) { 02368 ORSA_ERROR("Status error!"); 02369 return; 02370 } 02371 02372 REWIND_FILE(file); 02373 02374 char line[1024],tag[10]; 02375 string stag; 02376 const string end_of_header="END_OF_HEADER"; 02377 02378 // skip header 02379 while (GETS_FILE(line,1024,file)!=0) { 02380 sscanf(line,"%s",tag); 02381 stag = tag; 02382 if (stag == end_of_header) { 02383 break; 02384 } 02385 } 02386 02387 Asteroid ast; 02388 02389 double cov_content[21]; 02390 int cov_line; 02391 02392 unsigned int local_index = 0; 02393 bool bool_stop=false; 02394 bool bool_pause=false; 02395 02396 while (GETS_FILE(line,1024,file)!=0) { 02397 02398 if (line[0] == '!') continue; // comment/header line 02399 02400 if (line[0] == ' ') continue; // not the line number 02401 02402 ++local_index; 02403 read_progress(local_index,bool_pause,bool_stop); 02404 02405 if (bool_stop) break; 02406 02407 while (bool_pause) { 02408 sleep(1); 02409 read_progress(local_index,bool_pause,bool_stop); 02410 } 02411 02412 sscanf(line,"%s",tag); 02413 stag = tag; 02414 remove_leading_trailing_spaces(stag); 02415 02416 ast.name = stag; 02417 02418 { 02419 const string name=stag; 02420 char c; 02421 unsigned int ck; 02422 bool is_only_digit=true; 02423 for (ck=0;ck<name.size();++ck) { 02424 c = name[ck]; 02425 if (isalpha(c)) { 02426 is_only_digit=false; 02427 break; 02428 } 02429 } 02430 02431 if (is_only_digit) { 02432 ast.n = atoi(name.c_str()); 02433 } else { 02434 ast.n = 0; 02435 } 02436 } 02437 02438 #ifdef HAVE_GSL 02439 OrbitWithCovarianceMatrixGSL orbit; 02440 #else 02441 OrbitWithEpoch orbit; 02442 #endif 02443 02444 orbit.mu = GetG()*GetMSun(); 02445 02446 cov_line = 0; 02447 02448 while (GETS_FILE(line,1024,file)!=0) { 02449 02450 if (line[0] == '!') continue; // comment/header line 02451 02452 if (line[0] != ' ') break; // new asteroid 02453 02454 sscanf(line,"%s",tag); 02455 stag = tag; 02456 02457 if (stag == "EQU") { 02458 02459 double x[6]; 02460 02461 sscanf(line,"%s %lg %lg %lg %lg %lg %lg",tag,&x[0],&x[1],&x[2],&x[3],&x[4],&x[5]); 02462 02463 const double omega_tilde = secure_atan2(x[1],x[2]); 02464 02465 orbit.a = x[0]; 02466 orbit.e = sqrt(x[1]*x[1]+x[2]*x[2]); 02467 orbit.i = 2.0*atan(sqrt(x[3]*x[3]+x[4]*x[4])); 02468 orbit.omega_node = fmod(10.0*twopi+secure_atan2(x[3],x[4]),twopi); 02469 orbit.omega_pericenter = fmod(10.0*twopi+omega_tilde-orbit.omega_node,twopi); 02470 orbit.M = fmod(10.0*twopi+(pi/180)*x[5]-omega_tilde,twopi); 02471 02472 } else if (stag == "MJD") { 02473 02474 double epoch_MJD; 02475 sscanf(line,"%s %lg",tag,&epoch_MJD); 02476 Date epoch; 02477 epoch.SetJulian(epoch_MJD+2400000.5,TDT); 02478 02479 orbit.epoch.SetDate(epoch); 02480 02481 } else if (stag == "MAG") { 02482 02483 double mag, m2; 02484 sscanf(line,"%s %lg %lg",tag,&mag,&m2); 02485 02486 ast.mag = mag; 02487 02488 } else if (stag == "COV") { 02489 02490 double c0,c1,c2; 02491 02492 sscanf(line,"%s %lg %lg %lg",tag,&c0,&c1,&c2); 02493 02494 cov_content[cov_line*3] = c0; 02495 cov_content[cov_line*3+1] = c1; 02496 cov_content[cov_line*3+2] = c2; 02497 02498 cov_line++; 02499 } 02500 02501 if (cov_line==7) break; 02502 02503 } 02504 02505 #ifdef HAVE_GSL 02506 if (cov_line==7) { 02507 double covm[6][6]; 02508 int i,k; 02509 int ik=0; 02510 for (i=0;i<6;++i) { 02511 for (k=i;k<6;++k) { 02512 // IMPORTANT: units correction 02513 if (i==5) cov_content[ik] *= (pi/180); 02514 if (k==5) cov_content[ik] *= (pi/180); 02515 // 02516 covm[i][k] = cov_content[ik]; 02517 covm[k][i] = covm[i][k]; 02518 // 02519 ++ik; 02520 } 02521 } 02522 orbit.SetCovarianceMatrix((double**)covm,Equinoctal); 02523 } else { 02524 ORSA_ERROR("Cannot set covariance matrix for object %s from file %s.",ast.name.c_str(),filename.c_str()); 02525 } 02526 #endif // HAVE_GSL 02527 02528 ast.orb = orbit; 02529 02530 // CHECK THIS CODE! 02531 // NB: DON'T KNOW HOW TO 'ROTATE' THE COVARIANCE MATRIX 02532 /* 02533 switch (universe->GetReferenceSystem()) { 02534 case ECLIPTIC: break; 02535 case EQUATORIAL: 02536 { 02537 Date tmp_date(TDT); 02538 // cerr << "Rotating astorb orbit..." << endl; 02539 const double obleq_rad = obleq(tmp_date).GetRad(); 02540 Vector position,velocity; 02541 ast.orb.RelativePosVel(position,velocity); 02542 position.rotate(0.0,obleq_rad,0.0); 02543 velocity.rotate(0.0,obleq_rad,0.0); 02544 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 02545 } 02546 break; 02547 } 02548 */ 02549 // 02550 switch (universe->GetReferenceSystem()) { 02551 case ECLIPTIC: break; 02552 case EQUATORIAL: 02553 { 02554 Vector position,velocity; 02555 ast.orb.RelativePosVel(position,velocity); 02556 EclipticToEquatorial_J2000(position); 02557 EclipticToEquatorial_J2000(velocity); 02558 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 02559 } 02560 break; 02561 } 02562 02563 db->push_back(ast); 02564 } 02565 02566 read_finished(); 02567 }
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().