COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
World Magnetic Model function declarations
Collaboration diagram for World Magnetic Model function declarations:

Functions

int32_t geomag_front (gvector pos, double year, rvector &comp)
 

Detailed Description

Function Documentation

int32_t geomag_front ( gvector  pos,
double  time,
rvector comp 
)

Main function to compute the magnetic field from the World Magnetic Model

Input: Position, time | output: Mag Field

Parameters
posgeodetic position (lon, lat, alt) in (rad, rad, meters)
timein decimal year, ex. use mjd2year(currentmjd())
compare the magnetic field x,y,z components in Topocentric System
100 {
101  static int maxdeg, itime;
102  static float alt, dec, dip, ti, gv, bx, by, bz;
103 
104  // this reads the coefficients, specify path if neccessary
105  itime = 5 * (int)(time/5.);
106  string rname;
107  int32_t iretn = get_cosmosresources(rname);
108  if (iretn < 0)
109  {
110  return iretn;
111  }
112  sprintf(fname, "%s/general/wmm_%04d.cof", rname.c_str(), itime);
113 
114  /* INITIALIZE GEOMAG ROUTINE */
115 
116 
117  maxdeg = 12;
118  // warn_H = 0;
119  // warn_H_val = 99999.0;
120  // warn_H_strong = 0;
121  // warn_H_strong_val = 99999.0;
122  // warn_P = 0;
123 
124  if (!initialized)
125  {
126  iretn = geomag(&maxdeg);
127  if (iretn < 0)
128  {
129  return iretn;
130  }
131  initialized = 1;
132  }
133 
134 
135  // convert alt to km
136  alt = (float)(pos.h/1000.);
137  // !!! add comment/description to each filed
138  iretn = geomg1(alt, // altitude in km
139  (float)pos.lat, // lattitude in rad?
140  (float)pos.lon, // longitude in rad?
141  (float)time, // time in decimal year
142  &dec,
143  &dip,
144  &ti,
145  &gv,
146  &bx,
147  &by,
148  &bz);
149  if (iretn < 0)
150  {
151  return iretn;
152  }
153  // time = time1 + 1.0;
154 
155 
156  /*COMPUTE X, Y, Z, AND H COMPONENTS OF THE MAGNETIC FIELD*/
157  // ti *= 1e-9;
158  // comp->col[0] = ti*(cos(dec)*cos(dip));
159  // comp->col[1] = ti*(cos(dip)*sin(dec));
160  // comp->col[2] = ti*(sin(dip));
161  comp.col[0] = static_cast <double>(bx * 1e-9f);
162  comp.col[1] = static_cast <double>(by * 1e-9f);
163  comp.col[2] = static_cast <double>(bz * 1e-9f);
164 
165  /*
166  if (length_rv(lcomp) != 0. && lcomp.col[0] != comp->col[0] && lcomp.col[1] != comp->col[1] &&lcomp.col[2] != comp->col[2])
167  {
168  dcomp = rv_smult(1./(time-ltime),rv_sub(*comp,lcomp));
169  lperiod = .001*length_rv(*comp)/length_rv(dcomp);
170  }
171  ltime = time;
172  lcomp = *comp;
173  */
174  return 0;
175 }
Definition: eci2kep_test.cpp:33
int iretn
Definition: rw_test.cpp:37
string get_cosmosresources(bool create_flag)
Return COSMOS Resources Directory.
Definition: datalib.cpp:1337
static char fname[100]
Definition: geomag.cpp:89
static int initialized
Definition: geomag.cpp:88
double h
Height in meters.
Definition: vector.h:229
double lon
Longitude in radians.
Definition: vector.h:227
double lat
Latitude in radians.
Definition: vector.h:225
int32_t geomag(int *maxdeg)
Definition: geomag.cpp:476
double col[3]
Definition: vector.h:55
int32_t geomg1(float alt, float rlat, float rlon, float time, float *dec, float *dip, float *ti, float *gv, float *bx, float *by, float *bz)
Definition: geomag.cpp:483