00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "orsa_file.h"
00026
00027 #include <iostream>
00028
00029 using namespace std;
00030
00031 namespace orsa {
00032
00033
00034
00035 Mercury5IntegrationFile::Mercury5IntegrationFile(OrbitStream &osin) {
00036 os = &osin;
00037 cols = C10;
00038 status = CLOSE;
00039 }
00040
00041 Mercury5IntegrationFile::Mercury5IntegrationFile(OrbitStream &osin, M5COLS c_in) {
00042 os = &osin;
00043 cols = c_in;
00044 status = CLOSE;
00045 }
00046
00047 void Mercury5IntegrationFile::Read() {
00048
00049
00050 if (status == CLOSE) Open();
00051
00052 if (status != OPEN_R){
00053 cerr << "problems encountered when opening file.\n" << endl;
00054 }
00055
00056 os->resize(0);
00057 os->timestep = 0.0;
00058 OrbitWithEpoch fo;
00059 REWIND_FILE(file);
00060
00061
00062 int l;
00063 char line[1024],label[1024];
00064 for (l=0;l<4;l++) {
00065 GETS_FILE(line,1024,file);
00066 if (l==1) {
00067 sscanf(line,"%s",label);
00068 os->label = label;
00069
00070 }
00071 }
00072
00073 double a,e,i,omega_per,omega_nod,M;
00074 double time,time_old=0,timestep;
00075
00076
00077 if (cols == C7) {
00078 while (GETS_FILE(line,1024,file) != 0) {
00079
00080
00081
00082
00083
00084 sscanf(line,"%lf %lf %lf %lf %lf %lf %lf",
00085 &time,&a,&e,&i,&omega_per,&omega_nod,&M);
00086
00087 timestep = time - time_old;
00088 time_old = time;
00089 if (os->size() == 2) {
00090 os->timestep = FromUnits(timestep,DAY);
00091 cerr << "timestep set to: " << os->timestep << endl;
00092 }
00093
00094 fo.epoch.SetTime(FromUnits(time,DAY));
00095
00096 fo.a = FromUnits(a,AU);
00097 fo.e = e;
00098 fo.i = (pi/180.0)*i;
00099 fo.omega_node = (pi/180.0)*omega_nod;
00100 fo.omega_pericenter = (pi/180.0)*omega_per;
00101 fo.M = (pi/180.0)*M;
00102
00103 os->push_back(fo);
00104 }
00105 }
00106
00107 if (cols == C10) {
00108 double dummy;
00109 while (GETS_FILE(line,1024,file) != 0) {
00110
00111
00112
00113
00114 sscanf(line,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
00115 &time,&a,&e,&i,&omega_per,&omega_nod,&M,&dummy,&dummy,&dummy);
00116
00117 timestep = time - time_old;
00118 time_old = time;
00119 if (os->size() == 2) {
00120 os->timestep = FromUnits(timestep,DAY);
00121 cerr << "timestep set to: " << os->timestep << endl;
00122 }
00123
00124 fo.epoch.SetTime(FromUnits(time,DAY));
00125
00126 fo.a = FromUnits(a,AU);
00127 fo.e = e;
00128 fo.i = (pi/180.0)*i;
00129 fo.omega_node = (pi/180.0)*omega_nod;
00130 fo.omega_pericenter = (pi/180.0)*omega_per;
00131 fo.M = (pi/180.0)*M;
00132
00133 os->push_back(fo);
00134 }
00135 }
00136 }
00137
00138 }