StochasticModel.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: StochasticModel.cpp 2580 2011-04-28 14:53:04Z architest $"
00002 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "StochasticModel.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038 
00039       // Get element of the process noise matrix Q
00040    double RandomWalkModel::getQ()
00041    {
00042 
00043          // Compute current variance
00044       double variance(qprime*std::abs(currentTime - previousTime));
00045 
00046          // Return variance
00047       return variance;
00048 
00049    }  // End of method 'PhaseAmbiguityModel::getQ()'
00050 
00051 
00052 
00053       /* This method provides the stochastic model with all the available
00054        * information and takes appropriate actions.
00055        *
00056        * @param sat        Satellite.
00057        * @param gData      Data object holding the data.
00058        *
00059        */
00060    void RandomWalkModel::Prepare( const SatID& sat,
00061                                   gnssSatTypeValue& gData )
00062    {
00063 
00064          // Update previous epoch
00065       setPreviousTime(currentTime);
00066 
00067       setCurrentTime(gData.header.epoch);
00068 
00069       return;
00070 
00071    }  // End of method 'RandomWalkModel::Prepare()'
00072 
00073 
00074 
00075       /* This method provides the stochastic model with all the available
00076        * information and takes appropriate actions.
00077        *
00078        * @param sat        Satellite.
00079        * @param gData      Data object holding the data.
00080        *
00081        */
00082    void RandomWalkModel::Prepare( const SatID& sat,
00083                                   gnssRinex& gData )
00084    {
00085 
00086          // Update previous epoch
00087       setPreviousTime(currentTime);
00088 
00089       setCurrentTime(gData.header.epoch);
00090 
00091       return;
00092 
00093    }  // End of method 'RandomWalkModel::Prepare()'
00094 
00095 
00096 
00097       // Get element of the state transition matrix Phi
00098    double PhaseAmbiguityModel::getPhi()
00099    {
00100 
00101          // Check if there is a cycle slip
00102       if(cycleSlip)
00103       {
00104          return 0.0;
00105       }
00106       else
00107       {
00108          return 1.0;
00109       }
00110 
00111    }  // End of method 'PhaseAmbiguityModel::getPhi()'
00112 
00113 
00114 
00115       // Get element of the process noise matrix Q
00116    double PhaseAmbiguityModel::getQ()
00117    {
00118 
00119          // Check if there is a cycle slip
00120       if(cycleSlip)
00121       {
00122          return variance;
00123       }
00124       else
00125       {
00126          return 0.0;
00127       }
00128 
00129    }  // End of method 'PhaseAmbiguityModel::getQ()'
00130 
00131 
00132 
00133       /* This method checks if a cycle slip happened.
00134        *
00135        * @param sat        Satellite.
00136        * @param data       Object holding the data.
00137        * @param source     Object holding the source of data.
00138        *
00139        */
00140    void PhaseAmbiguityModel::checkCS( const SatID& sat,
00141                                       satTypeValueMap& data,
00142                                       SourceID& source )
00143    {
00144 
00145       try
00146       {
00147 
00148             // By default, assume there is no cycle slip
00149          setCS(false);
00150 
00151             // Check if satellite is present at this epoch
00152          if( data.find(sat) == data.end() )
00153          {
00154             // If satellite is not present, declare CS and exit
00155             setCS(true);
00156 
00157             return;
00158          }
00159 
00160 
00161          if (!watchSatArc)
00162          {
00163                // In this case, we only use cycle slip flags
00164                // Check if there was a cycle slip
00165             if (data(sat)(csFlagType) > 0.0)
00166             {
00167                setCS(true);
00168             }
00169 
00170          }
00171          else
00172          {
00173                // Check if this satellite has previous entries
00174             if( satArcMap[ source ].find(sat) == satArcMap[ source ].end() )
00175             {
00176                   // If it doesn't have an entry, insert one
00177                satArcMap[ source ][ sat ] = 0.0;
00178             };
00179 
00180                // Check if arc number is different than arc number in storage
00181             if ( data(sat)(TypeID::satArc) != satArcMap[ source ][ sat ] )
00182             {
00183                setCS(true);
00184                satArcMap[ source ][ sat ] = data(sat)(TypeID::satArc);
00185             }
00186 
00187          }
00188 
00189 
00190       }
00191       catch(Exception& e)
00192       {
00193          setCS(true);
00194       }
00195 
00196       return;
00197 
00198    } // End of method 'PhaseAmbiguityModel::checkCS()'
00199 
00200 
00201 
00202       /* Set the value of process spectral density for ALL current sources.
00203        *
00204        * @param qp         Process spectral density: d(variance)/d(time) or
00205        *                   d(sigma*sigma)/d(time).
00206        *
00207        * \warning Beware of units: Process spectral density units are
00208        * sigma*sigma/time, while other models take plain sigma as input.
00209        * Sigma units are usually given in meters, but time units MUST BE
00210        * in SECONDS.
00211        *
00212        * \warning By default, process spectral density for zenital wet
00213        * tropospheric delay is set to 3e-8 m*m/s (equivalent to about
00214        * 1.0 cm*cm/h).
00215        *
00216        */
00217    TropoRandomWalkModel& TropoRandomWalkModel::setQprime(double qp)
00218    {
00219 
00220          // Look at each source being currently managed
00221       for( std::map<SourceID, tropModelData>::iterator it = tmData.begin();
00222            it != tmData.end();
00223            ++it )
00224       {
00225             // Assign new process spectral density value
00226          (*it).second.qprime = qp;
00227       }
00228 
00229       return (*this);
00230 
00231    }  // End of method 'TropoRandomWalkModel::setQprime()'
00232 
00233 
00234 
00235       /* This method provides the stochastic model with all the available
00236        *  information and takes appropriate actions.
00237        *
00238        * @param sat        Satellite.
00239        * @param gData      Data object holding the data.
00240        *
00241        */
00242    void TropoRandomWalkModel::Prepare( const SatID& sat,
00243                                        gnssSatTypeValue& gData )
00244    {
00245 
00246          // First, get current source
00247       SourceID source( gData.header.source );
00248 
00249          // Second, let's update current epoch for this source
00250       setCurrentTime(source, gData.header.epoch );
00251 
00252          // Third, compute Q value
00253       computeQ(sat, gData.body, source);
00254 
00255          // Fourth, prepare for next iteration updating previous epoch
00256       setPreviousTime(source, tmData[source].currentTime);
00257 
00258       return;
00259 
00260    }  // End of method 'TropoRandomWalkModel::Prepare()'
00261 
00262 
00263 
00264       /* This method provides the stochastic model with all the available
00265        *  information and takes appropriate actions.
00266        *
00267        * @param sat        Satellite.
00268        * @param gData      Data object holding the data.
00269        *
00270        */
00271    void TropoRandomWalkModel::Prepare( const SatID& sat,
00272                                        gnssRinex& gData )
00273    {
00274 
00275          // First, get current source
00276       SourceID source( gData.header.source );
00277 
00278          // Second, let's update current epoch for this source
00279       setCurrentTime(source, gData.header.epoch );
00280 
00281          // Third, compute Q value
00282       computeQ(sat, gData.body, source);
00283 
00284          // Fourth, prepare for next iteration updating previous epoch
00285       setPreviousTime(source, tmData[source].currentTime);
00286 
00287       return;
00288 
00289    }  // End of method 'TropoRandomWalkModel::Prepare()'
00290 
00291 
00292 
00293       /* This method computes the right variance value to be returned
00294        *  by method 'getQ()'.
00295        *
00296        * @param sat        Satellite.
00297        * @param data       Object holding the data.
00298        * @param source     Object holding the source of data.
00299        *
00300        */
00301    void TropoRandomWalkModel::computeQ( const SatID& sat,
00302                                         satTypeValueMap& data,
00303                                         SourceID& source )
00304    {
00305 
00306          // Compute current variance
00307       variance = tmData[ source ].qprime
00308                  * std::abs( tmData[ source ].currentTime
00309                            - tmData[ source ].previousTime );
00310 
00311       return;
00312 
00313    }  // End of method 'TropoRandomWalkModel::computeQ()'
00314 
00315 
00316 
00317 }  // End of namespace gpstk

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