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 840 of file orsa_file.cc.

00840 { }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 842 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.

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

Here is the call graph for this function:

bool ReadNominalOrbit ( OrbitWithEpoch  ) 

Definition at line 981 of file orsa_file.cc.

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

void Open (  )  [inherited]

void Close (  )  [inherited]

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]

FILE_TYPE file [protected, inherited]

FILE_STATUS status [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Mon Apr 28 20:03:54 2008 for liborsa by  doxygen 1.5.5