00001 #pragma ident "$Id: ComputeWindUp.cpp 2579 2011-04-27 04:02:02Z architest $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "ComputeWindUp.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037
00038 int ComputeWindUp::classIndex = 4500000;
00039
00040
00041
00042 int ComputeWindUp::getIndex() const
00043 { return index; }
00044
00045
00046
00047 std::string ComputeWindUp::getClassName() const
00048 { return "ComputeWindUp"; }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 satTypeValueMap& ComputeWindUp::Process( const DayTime& time,
00059 satTypeValueMap& gData )
00060 throw(ProcessingException)
00061 {
00062
00063 try
00064 {
00065
00066
00067 SunPosition sunPosition;
00068 Triple sunPos(sunPosition.getPosition(time));
00069
00070
00071 Triple svPos(0.0, 0.0, 0.0);
00072
00073 SatIDSet satRejectedSet;
00074
00075
00076 for ( satTypeValueMap::iterator it = gData.begin();
00077 it != gData.end();
00078 ++it )
00079 {
00080
00081
00082 if( satArcMap.find( (*it).first ) == satArcMap.end() )
00083 {
00084
00085 satArcMap[ (*it).first ] = 0.0;
00086 };
00087
00088
00089
00090
00091 if ( (*it).second.find(TypeID::satArc) != (*it).second.end() &&
00092 (*it).second(TypeID::satArc) != satArcMap[ (*it).first ] )
00093 {
00094
00095 satArcMap[ (*it).first ] = (*it).second(TypeID::satArc);
00096
00097
00098 phase_satellite[ (*it).first ].previousPhase = 0.0;
00099 phase_station[ (*it).first ].previousPhase = 0.0;
00100
00101 }
00102
00103
00104
00105 if( ( (*it).second.find(TypeID::satX) == (*it).second.end() ) ||
00106 ( (*it).second.find(TypeID::satY) == (*it).second.end() ) ||
00107 ( (*it).second.find(TypeID::satZ) == (*it).second.end() ) )
00108 {
00109
00110 if(pEphemeris==NULL)
00111 {
00112
00113
00114 satRejectedSet.insert( (*it).first );
00115
00116 continue;
00117
00118 }
00119 else
00120 {
00121
00122
00123
00124 try
00125 {
00126
00127
00128 Xvt svPosVel(pEphemeris->getXvt( (*it).first, time ));
00129
00130
00131 svPos[0] = svPosVel.x.theArray[0];
00132 svPos[1] = svPosVel.x.theArray[1];
00133 svPos[2] = svPosVel.x.theArray[2];
00134
00135 }
00136 catch(...)
00137 {
00138
00139
00140
00141 satRejectedSet.insert( (*it).first );
00142
00143 continue;
00144
00145 }
00146
00147 }
00148
00149 }
00150 else
00151 {
00152
00153
00154 svPos[0] = (*it).second[TypeID::satX];
00155 svPos[1] = (*it).second[TypeID::satY];
00156 svPos[2] = (*it).second[TypeID::satZ];
00157
00158 }
00159
00160
00161
00162
00163 (*it).second[TypeID::windUp] =
00164 getWindUp((*it).first, time, svPos, sunPos);
00165
00166 }
00167
00168
00169 gData.removeSatID(satRejectedSet);
00170
00171 return gData;
00172
00173 }
00174 catch(Exception& u)
00175 {
00176
00177 ProcessingException e( getClassName() + ":"
00178 + StringUtils::asString( getIndex() ) + ":"
00179 + u.what() );
00180
00181 GPSTK_THROW(e);
00182
00183 }
00184
00185 }
00186
00187
00188
00189
00190
00191
00192 ComputeWindUp& ComputeWindUp::setFilename(const string& name)
00193 {
00194
00195 fileData = name;
00196 satData.open(fileData);
00197
00198 return (*this);
00199
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 double ComputeWindUp::getWindUp( const SatID& satid,
00213 const DayTime& time,
00214 const Triple& sat,
00215 const Triple& sunPosition )
00216 {
00217
00218
00219
00220
00221 Triple rxPos(nominalPos.X(), nominalPos.Y(), nominalPos.Z());
00222
00223
00224 Triple gps_sun( sunPosition-sat );
00225
00226
00227 Triple rk( ( (-1.0)*(sat.unitVector()) ) );
00228
00229
00230 Triple rj( (rk.cross(gps_sun)).unitVector() );
00231
00232
00233
00234
00235 Triple ri( (rj.cross(rk)).unitVector() );
00236
00237
00238
00239 Triple rrho( (rxPos-sat).unitVector() );
00240
00241
00242 double zk(rrho.dot(rk));
00243
00244
00245
00246 Triple dpp(rrho-zk*rk);
00247
00248
00249 double xk(dpp.dot(ri));
00250 double yk(dpp.dot(rj));
00251
00252
00253 double alpha1(std::atan2(yk,xk));
00254
00255
00256
00257
00258
00259 rk = (-1.0)*(rxPos.unitVector());
00260
00261
00262
00263 Triple delta(0.0, 0.0, 1.0);
00264
00265
00266 delta =
00267 (delta.R2(nominalPos.geodeticLatitude())).R3(-nominalPos.longitude());
00268
00269
00270
00271
00272 rj = (rk.cross(delta)).unitVector();
00273
00274
00275 ri = (rj.cross(rk)).unitVector();
00276
00277
00278 zk = rrho.dot(rk);
00279
00280
00281
00282 dpp = rrho-zk*rk;
00283
00284
00285 xk = dpp.dot(ri);
00286 yk = dpp.dot(rj);
00287
00288
00289 double alpha2(std::atan2(yk,xk));
00290
00291 double wind_up(0.0);
00292
00293
00294
00295 if(satData.getBlock( satid, time ) == "IIR")
00296 {
00297 wind_up = PI;
00298 }
00299
00300 alpha1 = alpha1 + wind_up;
00301
00302 double da1(alpha1-phase_satellite[satid].previousPhase);
00303
00304 double da2(alpha2-phase_station[satid].previousPhase);
00305
00306
00307 phase_satellite[satid].previousPhase += std::atan2( std::sin(da1),
00308 std::cos(da1) );
00309
00310 phase_station[satid].previousPhase += std::atan2( std::sin(da2),
00311 std::cos(da2) );
00312
00313
00314 wind_up = phase_satellite[satid].previousPhase -
00315 phase_station[satid].previousPhase;
00316
00317 return wind_up;
00318
00319 }
00320
00321
00322
00323 }