• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • satellites
  • sgp4
sgp4io.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------
2 *
3 * sgp4io.cpp
4 *
5 * this file contains a function to read two line element sets. while
6 * not formerly part of the sgp4 mathematical theory, it is
7 * required for practical implementation.
8 *
9 * companion code for
10 * fundamentals of astrodynamics and applications
11 * 2007
12 * by david vallado
13 *
14 * (w) 719-573-2600, email dvallado@agi.com
15 *
16 * current :
17 * 3 sep 08 david vallado
18 * add operationmode for afspc (a) or improved (i)
19 * changes :
20 * 9 may 07 david vallado
21 * fix year correction to 57
22 * 27 mar 07 david vallado
23 * misc fixes to manual inputs
24 * 14 aug 06 david vallado
25 * original baseline
26 * ---------------------------------------------------------------- */
27 
28 #include "sgp4io.h"
29 
30 /* -----------------------------------------------------------------------------
31 *
32 * function twoline2rv
33 *
34 * this function converts the two line element set character string data to
35 * variables and initializes the sgp4 variables. several intermediate varaibles
36 * and quantities are determined. note that the result is a structure so multiple
37 * satellites can be processed simultaneously without having to reinitialize. the
38 * verification mode is an important option that permits quick checks of any
39 * changes to the underlying technical theory. this option works using a
40 * modified tle file in which the start, stop, and delta time values are
41 * included at the end of the second line of data. this only works with the
42 * verification mode. the catalog mode simply propagates from -1440 to 1440 min
43 * from epoch and is useful when performing entire catalog runs.
44 *
45 * author : david vallado 719-573-2600 1 mar 2001
46 *
47 * inputs :
48 * longstr1 - first line of the tle
49 * longstr2 - second line of the tle
50 * typerun - type of run verification 'v', catalog 'c',
51 * manual 'm'
52 * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
53 * opsmode - mode of operation afspc or improved 'a', 'i'
54 * whichconst - which set of constants to use 72, 84
55 *
56 * outputs :
57 * satrec - structure containing all the sgp4 satellite information
58 *
59 * coupling :
60 * getgravconst-
61 * days2mdhms - conversion of days to month, day, hour, minute, second
62 * jday - convert day month year hour minute second into julian date
63 * sgp4init - initialize the sgp4 variables
64 *
65 * references :
66 * norad spacetrack report #3
67 * vallado, crawford, hujsak, kelso 2006
68  --------------------------------------------------------------------------- */
69 
70 void twoline2rv
71  (
72  char longstr1[130], char longstr2[130],
73  char typerun, char typeinput, char opsmode,
74  gravconsttype whichconst,
75  double& startmfe, double& stopmfe, double& deltamin,
76  elsetrec& satrec
77  )
78  {
79  const double deg2rad = M_PI / 180.0; // 0.0174532925199433
80  const double xpdotp = 1440.0 / (2.0 *M_PI); // 229.1831180523293
81 
82  double sec, mu, radiusearthkm, tumin, xke, j2, j3, j4, j3oj2;
83  double startsec, stopsec, startdayofyr, stopdayofyr, jdstart, jdstop;
84  int startyear, stopyear, startmon, stopmon, startday, stopday,
85  starthr, stophr, startmin, stopmin;
86  int cardnumb, numb, j;
87  long revnum = 0, elnum = 0;
88  char classification, intldesg[11];
89  int year = 0;
90  int mon, day, hr, minute, nexp, ibexp;
91 
92  getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
93 
94  satrec.error = 0;
95 
96  // set the implied decimal points since doing a formated read
97  // fixes for bad input data values (missing, ...)
98  for (j = 10; j <= 15; j++)
99  if (longstr1[j] == ' ')
100  longstr1[j] = '_';
101 
102  if (longstr1[44] != ' ')
103  longstr1[43] = longstr1[44];
104  longstr1[44] = '.';
105  if (longstr1[7] == ' ')
106  longstr1[7] = 'U';
107  if (longstr1[9] == ' ')
108  longstr1[9] = '.';
109  for (j = 45; j <= 49; j++)
110  if (longstr1[j] == ' ')
111  longstr1[j] = '0';
112  if (longstr1[51] == ' ')
113  longstr1[51] = '0';
114  if (longstr1[53] != ' ')
115  longstr1[52] = longstr1[53];
116  longstr1[53] = '.';
117  longstr2[25] = '.';
118  for (j = 26; j <= 32; j++)
119  if (longstr2[j] == ' ')
120  longstr2[j] = '0';
121  if (longstr1[62] == ' ')
122  longstr1[62] = '0';
123  if (longstr1[68] == ' ')
124  longstr1[68] = '0';
125 
126  sscanf(longstr1,"%2d %5ld %1c %10s %2d %12lf %11lf %7lf %2d %7lf %2d %2d %6ld ",
127  &cardnumb,&satrec.satnum,&classification, intldesg, &satrec.epochyr,
128  &satrec.epochdays,&satrec.ndot, &satrec.nddot, &nexp, &satrec.bstar,
129  &ibexp, &numb, &elnum );
130 
131  if (typerun == 'v') // run for specified times from the file
132  {
133  if (longstr2[52] == ' ')
134  sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld %lf %lf %lf \n",
135  &cardnumb,&satrec.satnum, &satrec.inclo,
136  &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no,
137  &revnum, &startmfe, &stopmfe, &deltamin );
138  else
139  sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld %lf %lf %lf \n",
140  &cardnumb,&satrec.satnum, &satrec.inclo,
141  &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no,
142  &revnum, &startmfe, &stopmfe, &deltamin );
143  }
144  else // simply run -1 day to +1 day or user input times
145  {
146  if (longstr2[52] == ' ')
147  sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld \n",
148  &cardnumb,&satrec.satnum, &satrec.inclo,
149  &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no,
150  &revnum );
151  else
152  sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld \n",
153  &cardnumb,&satrec.satnum, &satrec.inclo,
154  &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no,
155  &revnum );
156  }
157 
158  // ---- find no, ndot, nddot ----
159  satrec.no = satrec.no / xpdotp; //* rad/min
160  satrec.nddot= satrec.nddot * pow(10.0, nexp);
161  satrec.bstar= satrec.bstar * pow(10.0, ibexp);
162 
163  // ---- convert to sgp4 units ----
164  satrec.a = pow( satrec.no*tumin , (-2.0/3.0) );
165  satrec.ndot = satrec.ndot / (xpdotp*1440.0); //* ? * minperday
166  satrec.nddot= satrec.nddot / (xpdotp*1440.0*1440);
167 
168  // ---- find standard orbital elements ----
169  satrec.inclo = satrec.inclo * deg2rad;
170  satrec.nodeo = satrec.nodeo * deg2rad;
171  satrec.argpo = satrec.argpo * deg2rad;
172  satrec.mo = satrec.mo * deg2rad;
173 
174  satrec.alta = satrec.a*(1.0 + satrec.ecco) - 1.0;
175  satrec.altp = satrec.a*(1.0 - satrec.ecco) - 1.0;
176 
177  // ----------------------------------------------------------------
178  // find sgp4epoch time of element set
179  // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
180  // and minutes from the epoch (time)
181  // ----------------------------------------------------------------
182 
183  // ---------------- temp fix for years from 1957-2056 -------------------
184  // --------- correct fix will occur when year is 4-digit in tle ---------
185  if (satrec.epochyr < 57)
186  year= satrec.epochyr + 2000;
187  else
188  year= satrec.epochyr + 1900;
189 
190  days2mdhms ( year,satrec.epochdays, mon,day,hr,minute,sec );
191  jday( year,mon,day,hr,minute,sec, satrec.jdsatepoch );
192 
193  // ---- input start stop times manually
194  if ((typerun != 'v') && (typerun != 'c'))
195  {
196  // ------------- enter start/stop ymd hms values --------------------
197  if (typeinput == 'e')
198  {
199  printf("input start prop year mon day hr min sec \n");
200  // make sure there is no space at the end of the format specifiers in scanf!
201  scanf( "%i %i %i %i %i %lf",&startyear, &startmon, &startday, &starthr, &startmin, &startsec);
202  fflush(stdin);
203  jday( startyear,startmon,startday,starthr,startmin,startsec, jdstart );
204 
205  printf("input stop prop year mon day hr min sec \n");
206  scanf( "%i %i %i %i %i %lf",&stopyear, &stopmon, &stopday, &stophr, &stopmin, &stopsec);
207  fflush(stdin);
208  jday( stopyear,stopmon,stopday,stophr,stopmin,stopsec, jdstop );
209 
210  startmfe = (jdstart - satrec.jdsatepoch) * 1440.0;
211  stopmfe = (jdstop - satrec.jdsatepoch) * 1440.0;
212 
213  printf("input time step in minutes \n");
214  scanf( "%lf",&deltamin );
215  }
216  // -------- enter start/stop year and days of year values -----------
217  if (typeinput == 'd')
218  {
219  printf("input start year dayofyr \n");
220  scanf( "%i %lf",&startyear, &startdayofyr );
221  printf("input stop year dayofyr \n");
222  scanf( "%i %lf",&stopyear, &stopdayofyr );
223 
224  days2mdhms ( startyear,startdayofyr, mon,day,hr,minute,sec );
225  jday( startyear,mon,day,hr,minute,sec, jdstart );
226  days2mdhms ( stopyear,stopdayofyr, mon,day,hr,minute,sec );
227  jday( stopyear,mon,day,hr,minute,sec, jdstop );
228 
229  startmfe = (jdstart - satrec.jdsatepoch) * 1440.0;
230  stopmfe = (jdstop - satrec.jdsatepoch) * 1440.0;
231 
232  printf("input time step in minutes \n");
233  scanf( "%lf",&deltamin );
234  }
235  // ------------------ enter start/stop mfe values -------------------
236  if (typeinput == 'm')
237  {
238  printf("input start min from epoch \n");
239  scanf( "%lf",&startmfe );
240  printf("input stop min from epoch \n");
241  scanf( "%lf",&stopmfe );
242  printf("input time step in minutes \n");
243  scanf( "%lf",&deltamin );
244  }
245  }
246 
247  // ------------ perform complete catalog evaluation, -+ 1 day -----------
248  if (typerun == 'c')
249  {
250  startmfe = -1440.0;
251  stopmfe = 1440.0;
252  deltamin = 10.0;
253  }
254 
255  // ---------------- initialize the orbit at sgp4epoch -------------------
256  sgp4init( whichconst, opsmode, satrec.satnum, satrec.jdsatepoch-2433281.5, satrec.bstar,
257  satrec.ecco, satrec.argpo, satrec.inclo, satrec.mo, satrec.no,
258  satrec.nodeo, satrec);
259  } // end twoline2rv
260 
261 
elsetrec::a
double a
Definition: sgp4unit.h:88
elsetrec
Definition: sgp4unit.h:63
elsetrec::nddot
double nddot
Definition: sgp4unit.h:88
elsetrec::bstar
double bstar
Definition: sgp4unit.h:88
elsetrec::no
double no
Definition: sgp4unit.h:88
elsetrec::argpo
double argpo
Definition: sgp4unit.h:88
elsetrec::epochdays
double epochdays
Definition: sgp4unit.h:88
elsetrec::alta
double alta
Definition: sgp4unit.h:88
elsetrec::epochyr
int epochyr
Definition: sgp4unit.h:66
elsetrec::mo
double mo
Definition: sgp4unit.h:88
jday
void jday(int year, int mon, int day, int hr, int minute, double sec, double &jd)
Definition: sgp4ext.cpp:566
gravconsttype
gravconsttype
Definition: sgp4unit.h:56
sgp4init
bool sgp4init(gravconsttype whichconst, char opsmode, const int satn, const double epoch, const double xbstar, const double xecco, const double xargpo, const double xinclo, const double xmo, const double xno, const double xnodeo, elsetrec &satrec)
Definition: sgp4unit.cpp:1339
twoline2rv
void twoline2rv(char longstr1[130], char longstr2[130], char typerun, char typeinput, char opsmode, gravconsttype whichconst, double &startmfe, double &stopmfe, double &deltamin, elsetrec &satrec)
Definition: sgp4io.cpp:71
elsetrec::altp
double altp
Definition: sgp4unit.h:88
elsetrec::error
int error
Definition: sgp4unit.h:67
deg2rad
double deg2rad
Definition: dateline.cpp:52
elsetrec::ndot
double ndot
Definition: sgp4unit.h:88
elsetrec::inclo
double inclo
Definition: sgp4unit.h:88
elsetrec::jdsatepoch
double jdsatepoch
Definition: sgp4unit.h:88
elsetrec::satnum
long int satnum
Definition: sgp4unit.h:65
M_PI
#define M_PI
Definition: GeoDataCoordinates.h:26
elsetrec::nodeo
double nodeo
Definition: sgp4unit.h:88
days2mdhms
void days2mdhms(int year, double days, int &mon, int &day, int &hr, int &minute, double &sec)
Definition: sgp4ext.cpp:617
getgravconst
void getgravconst(gravconsttype whichconst, double &tumin, double &mu, double &radiusearthkm, double &xke, double &j2, double &j3, double &j4, double &j3oj2)
Definition: sgp4unit.cpp:2059
elsetrec::ecco
double ecco
Definition: sgp4unit.h:88
sgp4io.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal