#include <orsa_file.h>
Inheritance diagram for SWIFTFile:
Public Member Functions | |
SWIFTFile (OrbitStream &) | |
void | Read () |
int | AsteroidsInFile () |
void | Open () |
void | Close () |
virtual std::string | GetFileName () const |
virtual void | SetFileName (std::string name_in) |
virtual void | SetFileName (char *name_in) |
Public Attributes | |
OrbitStream * | os |
Protected Attributes | |
std::string | filename |
FILE_TYPE | file |
FILE_STATUS | status |
Definition at line 184 of file orsa_file.h.
SWIFTFile | ( | OrbitStream & | ) |
int AsteroidsInFile | ( | ) |
Definition at line 1196 of file orsa_file.cc.
References File::Close(), File::file, orsa::nast, ReadFile::Open(), REWIND_FILE, and orsa::SWIFTRawReadBinaryFile().
01196 { 01197 01198 // close and reopen to avoid odd zlib problems related to the gzseek function 01199 Close(); 01200 Open(); 01201 01202 int number_of_asteroids_in_file=0; 01203 01204 REWIND_FILE(file); 01205 01206 int good; 01207 while ( (good = SWIFTRawReadBinaryFile(file,2)) != 0) { 01208 if (number_of_asteroids_in_file<nast) number_of_asteroids_in_file = nast; 01209 else if (number_of_asteroids_in_file!=0) break; 01210 } 01211 01212 return (number_of_asteroids_in_file); 01213 }
Here is the call graph for this function:
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 1216 of file orsa_file.cc.
References Orbit::a, OrbitStream::asteroid_number, File::Close(), Orbit::e, orsa::el, OrbitWithEpoch::epoch, File::file, orsa::file_time, Orbit::i, orsa::l_ts, OrbitStream::label, orsa::label(), OrbitWithEpoch::libration_angle, Orbit::M, orsa::nast, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, ORSA_ERROR, SWIFTFile::os, orsa::pi, REWIND_FILE, SEEK_FILE, UniverseTypeAwareTime::SetTime(), File::status, orsa::SWIFTRawReadBinaryFile(), OrbitStream::timestep, WindowParameters::window_amplitude, WindowParameters::window_start, WindowParameters::window_step, and OrbitStream::wp.
01216 { 01217 01218 // close and reopen to avoid odd zlib problems related to the gzseek function 01219 Close(); 01220 Open(); 01221 01222 if (status != OPEN_R) { 01223 ORSA_ERROR("Status error!"); 01224 return; 01225 } 01226 01227 OrbitStream &ost = *os; 01228 01229 const int version = 2; 01230 01231 // cerr << "reading data from the input file...\n"; 01232 01233 OrbitWithEpoch fo; 01234 01235 // double wwj=0,wj=0,cj=0; 01236 // double wtil,crit,wmix; 01237 double time_old = 0, timestep; 01238 01239 int jump = 0, i_jump = 0; 01240 01241 // reset! 01242 // ost.resize(0); 01243 ost.clear(); 01244 ost.timestep = 0.0; 01245 const int asteroid_number = ost.asteroid_number; 01246 // cerr << " SWIFTFile::Read() --> reading object: " << asteroid_number << endl; 01247 char label[10]; 01248 sprintf(label,"%04i",ost.asteroid_number); 01249 ost.label = label; 01250 // cerr << "LABEL: [" << ost.label << "]" << endl; 01251 REWIND_FILE(file); 01252 01253 if ( version == 1 ) 01254 jump = 3*sizeof(int)+7*sizeof(double); 01255 else if ( version == 2 ) 01256 jump = 3*sizeof(int)+9*sizeof(double); 01257 01258 int good = 1, check = 0, number_of_asteroids_in_file = 0; 01259 01260 do { 01261 01262 if (check == 0) { 01263 good = SWIFTRawReadBinaryFile(file,version); 01264 } else { 01265 01266 i_jump = (number_of_asteroids_in_file+asteroid_number-nast-1)%(number_of_asteroids_in_file); 01267 01268 if (i_jump != 0) { 01269 if ( (SEEK_FILE(file,jump*i_jump,SEEK_CUR)) == -1) { 01270 cerr << "setting good=0 from SEEK_FILE..." << endl; 01271 good = 0; 01272 } 01273 } 01274 01275 if (good != 0) { 01276 good = SWIFTRawReadBinaryFile(file,version); 01277 } 01278 01279 } 01280 01281 if ( number_of_asteroids_in_file < nast ) { 01282 number_of_asteroids_in_file = nast; 01283 } else { 01284 check = 1; 01285 } 01286 01287 //// asteroid number too big! 01288 if ( (check == 1) && (asteroid_number > number_of_asteroids_in_file) ) { 01289 ORSA_ERROR("asteroid number too big (%d > %d)", asteroid_number, number_of_asteroids_in_file); 01290 return; 01291 } 01292 01293 if (nast == asteroid_number && good != 0) { 01294 01295 if ((file_time >= time_old) && 01296 (file_time >= ost.wp.window_start)) { 01297 01298 fo.epoch.SetTime(file_time); 01299 fo.a = el[4]; 01300 fo.e = el[3]; 01301 fo.i = (pi/180.0)*el[2]; 01302 fo.omega_node = (pi/180.0)*el[0]; 01303 fo.omega_pericenter = (pi/180.0)*el[1]; 01304 fo.M = (pi/180.0)*el[5]; 01305 // 01306 fo.libration_angle = (pi/180.0)*l_ts; // temporary 01307 01308 ost.push_back(fo); 01309 01310 // QUICK AND DIRTY! 01311 if (fo.e >= 1.0) { 01312 cerr << "reading eccentricity > 1.0, returning." << endl; 01313 return; 01314 } 01315 01316 01317 if ( ((file_time) > (ost.wp.window_amplitude+ost.wp.window_start)) && (ost.wp.window_step == 0.0) ) { 01318 return; 01319 } 01320 } 01321 01322 timestep = file_time - time_old; 01323 time_old = file_time; 01324 // one of all, but not the first... 01325 if (ost.size() == 2) { 01326 ost.timestep = timestep; 01327 } 01328 01329 } 01330 01331 } while (good != 0); 01332 }
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:
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:
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().
Definition at line 196 of file orsa_file.h.
Referenced by SWIFTFile::Read(), and SWIFTFile::SWIFTFile().
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().