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