MPCObsFile Class Reference

MPC observation file. More...

#include <orsa_file.h>

Inheritance diagram for MPCObsFile:

Inheritance graph
[legend]
Collaboration diagram for MPCObsFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MPCObsFile ()
 MPC observation file.
void Read ()
bool ReadNominalOrbit (OrbitWithEpoch &)
void Open ()
void Close ()
virtual std::string GetFileName () const
virtual void SetFileName (std::string name_in)
virtual void SetFileName (char *name_in)

Public Attributes

std::vector< Observationobs

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

MPC observation file.

Definition at line 222 of file orsa_file.h.


Constructor & Destructor Documentation

MPCObsFile (  ) 

MPC observation file.

Definition at line 839 of file orsa_file.cc.

00839 { }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 841 of file orsa_file.cc.

References Observation::date, Observation::dec, Observation::designation, Observation::discovery_asterisk, File::file, GETS_FILE, Observation::mag, MPCObsFile::obs, Observation::obscode, ReadFile::Open(), orsa::OPEN_R, ORSA_ERROR, Observation::ra, orsa::remove_leading_trailing_spaces(), REWIND_FILE, Angle::SetDPS(), Date::SetGregor(), Angle::SetHMS(), File::status, and orsa::UTC.

00841                         {
00842     
00843     // if (file == 0) Open();
00844     // if (status != OPEN_R) Open();
00845     // if (status == CLOSE) Open();
00846     
00847     Open();
00848     
00849     if (status != OPEN_R) {
00850       ORSA_ERROR("Status error!");
00851       return;
00852     }
00853     
00854     obs.clear();
00855     
00856     REWIND_FILE(file);
00857     
00858     // cerr << "...inside read_MPC()...\n";
00859     
00860     Observation dummy_obs;
00861     // dummy_obs.date.SetTimeScale(UTC); // checked, is UTC
00862     
00863     // double y,m,d;
00864     double gradi,primi,secondi;
00865     
00866     // double tmp;
00867     
00868     char line[256];
00869     
00870     // int entries = 0;
00871     
00872     string number,designation,discovery_asterisk,note1,note2;
00873     string date,ra,dec;
00874     string magnitude;
00875     string observatory_code;
00876     
00877     while (GETS_FILE(line,256,file) != 0) {
00878       
00879       if (strlen(line) < 80) continue; // not a good line, maybe a comment or a white line...
00880       // if (strlen(line) < 79) continue; // not a good line, maybe a comment or a white line...
00881       // if (strlen(line) < 78) continue; // not a good line, maybe a comment or a white line...
00882       
00883       // cerr << "inside while loop..." << endl;
00884       
00885       // entries--;
00886       
00887       number.assign(line,0,5);
00888       // cerr << "...pass (1)" << endl;
00889       // cerr <<"number: " << atoi(number.c_str()) << endl;
00890       designation.assign(line,5,7); 
00891       remove_leading_trailing_spaces(designation);
00892       // cerr <<"designation: " << designation << endl;
00893       discovery_asterisk.assign(line,12,1); 
00894       // cerr << "asterisk: [" << discovery_asterisk << "]\n";
00895       // cerr << "...pass (1/B)" << endl;
00896       note1.assign(line,13,1);
00897       // cerr << "...pass (1/C)" << endl;
00898       note2.assign(line,14,1);
00899       // cerr << "...pass (1/D)" << endl;
00900       date.assign(line,15,17);
00901       // cerr << "...pass (2)" << endl;
00902       // cerr << "date: " << date << endl;
00903       ra.assign(line,32,12);
00904       // cerr << "ra: " << ra << endl;
00905       dec.assign(line,44,12);
00906       // cerr << "dec: " << dec << endl;
00907       magnitude.assign(line,65,6);
00908       // cerr << "magnitude: " << magnitude << endl;
00909       observatory_code.assign(line,77,3);
00910       remove_leading_trailing_spaces(observatory_code);
00911       // cerr << "...pass (3)" << endl;
00912       
00913       dummy_obs.designation        = designation;
00914       dummy_obs.discovery_asterisk = discovery_asterisk;
00915       dummy_obs.obscode            = observatory_code;
00916       
00917       double _tmp = 0.0;
00918       sscanf(magnitude.c_str(),"%lf",&_tmp);
00919       dummy_obs.mag = _tmp;
00920       
00921       // cerr << "DES\n";
00922       
00923       // printf("DATE: %s\n",date.c_str());
00924       double y=0.0, m=0.0, d=0.0;
00925       sscanf(date.c_str(),"%lf %lf %lf",&y,&m,&d);
00926       // printf("LETTI: %f %f %f\n",y,m,d);
00927       //
00928       
00929       // dummy_obs.julian_date = GregorianToSdn((int)y,(int)m,(int)d) + ((d - floor(d)) - 0.5);
00930       // cerr << "JD\n";
00931       dummy_obs.date.SetGregor((int)y,(int)m,d,UTC);
00932       
00933       // cerr << "...pass (5)" << endl;
00934       
00935       // cout << "designation: " << designation << " " << ra << endl;      
00936       sscanf(ra.c_str(),"%lf %lf %lf",&gradi,&primi,&secondi);
00937       // angle_rad_hms(&tmp,gradi,primi,secondi);  //   dummy_obs.alpha
00938       // dummy_obs.alpha = tmp;
00939       dummy_obs.ra.SetHMS(gradi,primi,secondi);
00940       
00941       
00942       // cout <<"designation: " << designation << " " << dec << endl;      
00943       sscanf(dec.c_str(),"%lf %lf %lf",&gradi,&primi,&secondi);
00944       // angle_rad(&tmp,gradi,primi,secondi); //   dummy_obs.delta       
00945       // dummy_obs.delta = tmp;
00946       dummy_obs.dec.SetDPS(gradi,primi,secondi);
00947       
00948       // cerr << "OBS: " << dummy_obs.date.GetJulian() << "  " << dummy_obs.ra.GetRad() << "  " << dummy_obs.dec.GetRad() << endl;
00949       
00950       //check for a good observation
00951       if ((designation != "") && 
00952           (observatory_code != "") &&
00953           (strlen(observatory_code.c_str())) == 3) {
00954         if ( (isalnum(observatory_code[0])) &&
00955              (isalnum(observatory_code[1])) &&
00956              (isalnum(observatory_code[2])) &&
00957              (isspace(line[19])) &&
00958              (isspace(line[22])) &&
00959              (isspace(line[31])) &&
00960              (isspace(line[34])) &&
00961              (isspace(line[37])) &&
00962              (isspace(line[43])) &&
00963              (isspace(line[47])) &&
00964              (isspace(line[50])) &&
00965              (isspace(line[55])) ) {
00966           obs.push_back(dummy_obs);
00967         }
00968       }
00969       // obs->push_back(dummy_obs);
00970       
00971       // cerr << "PB\n";
00972       
00973       // D_ar.Insert(dummy_obs.alpha);
00974       // D_dec.Insert(dummy_obs.delta);
00975       
00976     }
00977     
00978   }

Here is the call graph for this function:

bool ReadNominalOrbit ( OrbitWithEpoch  ) 

Definition at line 980 of file orsa_file.cc.

00980                                                     {
00981     // true if succeed
00982     return false;
00983   }

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().

00115                    {
00116     if (status != CLOSE) {
00117       CLOSE_FILE(file);
00118       status = CLOSE;
00119     }
00120   }

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().

00101                                                         {
00102       if (status != CLOSE) Close();
00103       filename = name_in;
00104     }

Here is the call graph for this function:

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:


Member Data Documentation

std::vector<Observation> obs

Definition at line 234 of file orsa_file.h.

Referenced by MPCObsFile::Read().

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().


The documentation for this class was generated from the following files:
Generated on Wed May 30 13:05:06 2007 for liborsa by  doxygen 1.5.2