CorrectCodeBiases.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: CorrectCodeBiases.cpp 2939 2011-10-23 19:55:11Z yanweignss $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //
00026 //  Wei Yan - Chinese Academy of Sciences . 2009, 2010
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "CorrectCodeBiases.hpp"
00032 #include "icd_200_constants.hpp"
00033 
00034 namespace gpstk
00035 {
00036          // Index initially assigned to this class
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),  // L1
00041         +L1_FREQ*L1_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),  // L2
00042         +0.0,                                                  // L3
00043         -1.0,                                                  // L4
00044         -L1_FREQ*L2_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),  // L5
00045          0.0                                                   // L6
00046       };
00047 
00048       const double CorrectCodeBiases::factorP1C1[6]={
00049         +1.0,                                                   // L1
00050         +0.0,                                                   // L2
00051         +L1_FREQ*L1_FREQ/(L1_FREQ*L1_FREQ - L2_FREQ*L2_FREQ),   // L3
00052         +1.0,                                                   // L4
00053         +L1_FREQ/(L1_FREQ-L2_FREQ),                             // L5
00054         -L1_FREQ/(L1_FREQ+L2_FREQ)                              // L6
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          // Returns an index identifying this object.
00067       int CorrectCodeBiases::getIndex() const
00068       { return index; }
00069 
00070 
00071          // Returns a string identifying this object.
00072       std::string CorrectCodeBiases::getClassName() const
00073       { return "CorrectCodeBiases"; }
00074 
00075          // Default constructor
00076       CorrectCodeBiases::CorrectCodeBiases() 
00077          : usingC1(false), 
00078          receiverName(""),
00079          crossCorrelationReceiver(false)
00080       {}
00081 
00082          // Default deconstructor
00083       CorrectCodeBiases::~CorrectCodeBiases()
00084       {
00085             // make sure the files are closed
00086          dcbP1P2.close();
00087          dcbP1C1.close();
00088       }
00089    
00090          /* Sets name of file containing DCBs data.
00091           * @param name      Name of the file containing DCB(P1-P2)
00092           * @param name      Name of the file containing DCB(P1-C1)
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          /* Returns a satTypeValueMap object, adding the new data generated
00104           *  when calling this object.
00105           *
00106           * @param time      Epoch corresponding to the data.
00107           * @param gData     Data object holding the data.
00108           */
00109       satTypeValueMap& CorrectCodeBiases::Process( const DayTime& time,
00110                                                    satTypeValueMap& gData )
00111          throw(ProcessingException)
00112       {
00113          try
00114          {
00115             SatIDSet satRejectedSet;
00116 
00117             // Loop through all the satellites
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                   //itt->second += getDCBCorrection(receiverName, sat, type, usingC1);
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             }  // End of 'for (it = gData.begin(); it != gData.end(); ++it)'
00143 
00144             // Remove satellites with missing data
00145             gData.removeSatID(satRejectedSet);
00146 
00147             return gData;
00148 
00149          }
00150          catch(Exception& u)
00151          {
00152 
00153             // Throw an exception if something unexpected happens
00154             ProcessingException e( getClassName() + ":"
00155                + StringUtils::asString( getIndex() ) + ":"
00156                + u.what() );
00157 
00158             GPSTK_THROW(e);
00159 
00160          }
00161 
00162 
00163       }  // End of method 'CorrectCodeBiases::Process()'
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             // exception
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);    // ns -> meter
00240 
00241       }  // End of method 'CorrectCodeBiases::getDCBCorrection()'
00242 
00243 }
00244 

Generated on Tue May 22 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1