00001 #pragma ident "$Id: CorrectCodeBiases.cpp 2939 2011-10-23 19:55:11Z yanweignss $"
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 "CorrectCodeBiases.hpp"
00032 #include "icd_200_constants.hpp"
00033
00034 namespace gpstk
00035 {
00036
00037 int CorrectCodeBiases::classIndex = 4800000;
00038
00039 const double CorrectCodeBiases::factoP1P2[6] = {
00040 +L2_FREQ*L2_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),
00041 +L1_FREQ*L1_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),
00042 +0.0,
00043 -1.0,
00044 -L1_FREQ*L2_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),
00045 0.0
00046 };
00047
00048 const double CorrectCodeBiases::factorP1C1[6]={
00049 +1.0,
00050 +0.0,
00051 +L1_FREQ*L1_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),
00052 +1.0,
00053 +L1_FREQ/(L1_FREQ-L2_FREQ),
00054 -L1_FREQ/(L1_FREQ+L2_FREQ)
00055 };
00056
00057 const double CorrectCodeBiases::factorC1X2[6]={
00058 +1.0,
00059 +1.0,
00060 +1.0,
00061 +0.0,
00062 +1.0,
00063 -1.0
00064 };
00065
00066
00067 int CorrectCodeBiases::getIndex() const
00068 { return index; }
00069
00070
00071
00072 std::string CorrectCodeBiases::getClassName() const
00073 { return "CorrectCodeBiases"; }
00074
00075
00076 CorrectCodeBiases::CorrectCodeBiases()
00077 : usingC1(false),
00078 receiverName(""),
00079 crossCorrelationReceiver(false)
00080 {}
00081
00082
00083 CorrectCodeBiases::~CorrectCodeBiases()
00084 {
00085
00086 dcbP1P2.close();
00087 dcbP1C1.close();
00088 }
00089
00090
00091
00092
00093
00094 CorrectCodeBiases& CorrectCodeBiases::setDCBFile( const string& fileP1P2,
00095 const string& fileP1C1)
00096 {
00097 dcbP1P2.open(fileP1P2);
00098 dcbP1C1.open(fileP1C1);
00099
00100 return (*this);
00101 }
00102
00103
00104
00105
00106
00107
00108
00109 satTypeValueMap& CorrectCodeBiases::Process( const DayTime& time,
00110 satTypeValueMap& gData )
00111 throw(ProcessingException)
00112 {
00113 try
00114 {
00115 SatIDSet satRejectedSet;
00116
00117
00118 satTypeValueMap::iterator it;
00119 for (it = gData.begin(); it != gData.end(); ++it)
00120 {
00121 SatID sat = it->first;
00122 for(typeValueMap::iterator itt = it->second.begin();
00123 itt != it->second.end();
00124 ++itt)
00125 {
00126 TypeID type = itt->first;
00127
00128
00129 if( (type == TypeID::C1) || (type == TypeID::P1))
00130 {
00131 gData[sat][TypeID::instC1] = getDCBCorrection(receiverName,
00132 sat, type, usingC1);
00133 }
00134 else if(type == TypeID::P2)
00135 {
00136 gData[sat][TypeID::instC2] = getDCBCorrection(receiverName,
00137 sat, type, usingC1);
00138 }
00139
00140 }
00141
00142 }
00143
00144
00145 gData.removeSatID(satRejectedSet);
00146
00147 return gData;
00148
00149 }
00150 catch(Exception& u)
00151 {
00152
00153
00154 ProcessingException e( getClassName() + ":"
00155 + StringUtils::asString( getIndex() ) + ":"
00156 + u.what() );
00157
00158 GPSTK_THROW(e);
00159
00160 }
00161
00162
00163 }
00164
00165 double CorrectCodeBiases::getDCBCorrection(const string& receiver,
00166 const SatID& sat,
00167 const TypeID& type,
00168 const bool& useC1)
00169 {
00170 double satP1P2(0.0);
00171 double satP1C1(0.0);
00172 double receiverP1P2(0.0);
00173
00174 try
00175 {
00176 satP1P2 = dcbP1P2.getDCB(sat);
00177 satP1C1 = dcbP1C1.getDCB(sat);
00178 receiverP1P2 = dcbP1P2.getDCB(receiver, SatID::systemGPS);
00179 }
00180 catch(...)
00181 {
00182
00183 satP1P2 = 0.0;
00184 satP1C1 = 0.0;
00185 }
00186
00187 int ind = -1;
00188
00189 if( (type == TypeID::C1) ||
00190 (type == TypeID::P1) ||
00191 (type == TypeID::GRAPHIC1) )
00192 {
00193 ind = 0;
00194 }
00195 else if( (type == TypeID::P2) ||
00196 (type == TypeID::GRAPHIC2) )
00197 {
00198 ind = 1;
00199 }
00200 else if( type == TypeID::PC )
00201 {
00202 ind = 2;
00203 }
00204 else if( type == TypeID::PI)
00205 {
00206 ind = 3;
00207 }
00208 else if( type == TypeID::MWubbena )
00209 {
00210 ind = 5;
00211 }
00212 else
00213 {
00214 ind = -1;
00215
00216 return 0.0;
00217 }
00218
00219 double dcb1(0.0), dcb2(0.0), dcb3(0.0);
00220 if(ind >= 0)
00221 {
00222 dcb1 = factoP1P2[ind];
00223 dcb2 = factorP1C1[ind];
00224 dcb3 = factorC1X2[ind];
00225 }
00226
00227 if( !useC1 && (type==TypeID::P1))
00228 {
00229 dcb2 = 0.0;
00230 }
00231
00232 if(crossCorrelationReceiver)
00233 {
00234 dcb2 = dcb3;
00235 }
00236
00237 double dcb = dcb1 * (satP1P2 + receiverP1P2) + dcb2 * satP1C1;
00238
00239 return -1.0 * dcb * (C_GPS_M * 1.0e-9);
00240
00241 }
00242
00243 }
00244