00001 #pragma ident "$Id: IonexModel.cpp 1804 2009-03-17 15:13:29Z coandrei $"
00002
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "IonexModel.hpp"
00033 #include "icd_200_constants.hpp"
00034
00035
00036 namespace gpstk
00037 {
00038
00039
00040 int IonexModel::classIndex = 5100000;
00041
00042
00043
00044 int IonexModel::getIndex() const
00045 { return index; }
00046
00047
00048
00049 std::string IonexModel::getClassName() const
00050 { return "IonexModel"; }
00051
00052
00053
00054
00055
00056 IonexModel::IonexModel(const Position& RxCoordinates)
00057 throw(Exception)
00058 {
00059
00060 pDefaultMaps = NULL;
00061 defaultObservable = TypeID::P1;
00062 useDCB = true;
00063 setIonoMapType("NONE");
00064 setInitialRxPosition(RxCoordinates);
00065 setIndex();
00066
00067 }
00068
00069
00070
00082 IonexModel::IonexModel( const Position& RxCoordinates,
00083 IonexStore& istore,
00084 const TypeID& dObservable,
00085 const bool& applyDCB,
00086 const std::string& ionoMap)
00087 throw(Exception)
00088 {
00089
00090 setInitialRxPosition(RxCoordinates);
00091 setDefaultMaps(istore);
00092 defaultObservable = dObservable;
00093 useDCB = applyDCB;
00094 setIonoMapType(ionoMap);
00095 setIndex();
00096
00097 }
00098
00099
00100
00107 satTypeValueMap& IonexModel::Process( const DayTime& time,
00108 satTypeValueMap& gData )
00109 throw(Exception)
00110 {
00111
00112 SatIDSet satRejectedSet;
00113
00114 try
00115 {
00116
00117
00118 satTypeValueMap::iterator stv;
00119 for(stv = gData.begin(); stv != gData.end(); ++stv)
00120 {
00121
00122
00123 if(pDefaultMaps==NULL)
00124 {
00125
00126
00127 satRejectedSet.insert( stv->first );
00128
00129 continue;
00130
00131 }
00132
00133
00134 if( stv->second.find(TypeID::elevation) == stv->second.end() ||
00135 stv->second.find(TypeID::azimuth) == stv->second.end() )
00136 {
00137
00138 satRejectedSet.insert( stv->first );
00139
00140 continue;
00141
00142 }
00143 else
00144 {
00145
00146
00147
00148 double elevation( stv->second(TypeID::elevation) );
00149 double azimuth( stv->second(TypeID::azimuth) );
00150 double ionoMap(0.0);
00151 double ionexL1(0.0), ionexL2(0.0), ionexL5(0.0);
00152 double ionexL6(0.0), ionexL7(0.0), ionexL8(0.0);
00153
00154
00155
00156 Position IPP = rxPos.getIonosphericPiercePoint( elevation,
00157 azimuth,
00158 ionoHeight);
00159
00160
00161
00162
00163
00164
00165
00166 Position pos(IPP);
00167 pos.transformTo(Position::Geocentric);
00168 Triple val = pDefaultMaps->getIonexValue( time, pos );
00169
00170
00171 double tecval = val[0];
00172
00173 try
00174 {
00175
00176 ionoMap = pDefaultMaps->iono_mapping_function( elevation,
00177 ionoMapType);
00178
00179
00180 ionexL1 = pDefaultMaps->getIonoL1( elevation,
00181 tecval,
00182 ionoMapType);
00183
00184 ionexL2 = pDefaultMaps->getIonoL2( elevation,
00185 tecval,
00186 ionoMapType);
00187
00188 ionexL5 = pDefaultMaps->getIonoL5( elevation,
00189 tecval,
00190 ionoMapType);
00191
00192 ionexL6 = pDefaultMaps->getIonoL6( elevation,
00193 tecval,
00194 ionoMapType);
00195
00196 ionexL7 = pDefaultMaps->getIonoL7( elevation,
00197 tecval,
00198 ionoMapType);
00199
00200 ionexL8 = pDefaultMaps->getIonoL8( elevation,
00201 tecval,
00202 ionoMapType);
00203
00204 }
00205 catch(InvalidRequest)
00206 {
00207
00208
00209
00210 satRejectedSet.insert( stv->first );
00211
00212 continue;
00213
00214 }
00215
00216
00217
00218 (*stv).second[TypeID::ionoTEC] = tecval;
00219 (*stv).second[TypeID::ionoMap] = ionoMap;
00220 (*stv).second[TypeID::ionoL1] = ionexL1;
00221 (*stv).second[TypeID::ionoL2] = ionexL2;
00222 (*stv).second[TypeID::ionoL5] = ionexL5;
00223 (*stv).second[TypeID::ionoL6] = ionexL6;
00224 (*stv).second[TypeID::ionoL7] = ionexL7;
00225 (*stv).second[TypeID::ionoL8] = ionexL8;
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 double tempDCB( getDCBCorrections( time,
00239 (*pDefaultMaps),
00240 stv->first) );
00241
00242
00243
00244
00245 if(useDCB)
00246 {
00247
00248
00249
00250 double kappa2(-1.0/0.646944444);
00251 double dcb(tempDCB * C_GPS_M * 1e-9);
00252
00253 if( stv->second.find(TypeID::instC1) == stv->second.end() )
00254 {
00255 stv->second[TypeID::instC1] = (kappa2 * dcb);
00256 }
00257 else
00258 {
00259 stv->second[TypeID::instC1] += (kappa2 * dcb);
00260 }
00261
00262 }
00263
00264 }
00265
00266 }
00267
00268
00269
00270 gData.removeSatID(satRejectedSet);
00271
00272 return gData;
00273
00274 }
00275 catch(Exception& e)
00276 {
00277
00278 GPSTK_RETHROW(e);
00279
00280 }
00281
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291 int IonexModel::setInitialRxPosition(const Position& RxCoordinates)
00292 throw(GeometryException)
00293 {
00294
00295 try
00296 {
00297
00298 rxPos = RxCoordinates;
00299
00300 return 0;
00301
00302 }
00303 catch(GeometryException)
00304 {
00305 return -1;
00306 }
00307
00308 }
00309
00310
00311
00312
00313 int IonexModel::setInitialRxPosition(void)
00314 throw(GeometryException)
00315 {
00316
00317 try
00318 {
00319
00320 Position rxpos(0.0, 0.0, 0.0, Position::Cartesian, NULL);
00321
00322 setInitialRxPosition(rxpos);
00323
00324 return 0;
00325
00326 }
00327 catch(GeometryException)
00328 {
00329 return -1;
00330 }
00331
00332 }
00333
00334
00335
00344 IonexModel& IonexModel::setIonoMapType(const std::string& ionoMap)
00345 {
00346
00347
00348 ionoMapType = ( ionoMap != "NONE" && ionoMap != "SLM" &&
00349 ionoMap != "MSLM" && ionoMap != "ESM") ? "NONE" :
00350 ionoMap;
00351
00352
00353 ionoHeight = (ionoMap == "MSLM") ? 506700.0 : 450000.0;
00354
00355 return (*this);
00356
00357 }
00358
00359
00360
00369 double IonexModel::getDCBCorrections( const DayTime& time,
00370 const IonexStore& Maps,
00371 SatID sat )
00372 throw()
00373 {
00374
00375 try
00376 {
00377
00378 double dcb = Maps.findDCB(sat,time);
00379
00380 return dcb;
00381
00382 }
00383 catch(...)
00384 {
00385
00386 return 0.0;
00387
00388 }
00389
00390 }
00391
00392
00393
00394 }