ModeledReferencePR.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ModeledReferencePR.cpp 1379 2008-08-29 17:04:02Z architest $"
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 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2006, 2007, 2008
00027 //
00028 //============================================================================
00029 
00030 
00031 
00032 #include "ModeledReferencePR.hpp"
00033 
00034 using namespace std;
00035 namespace gpstk
00036 {
00037 
00038 
00039       /* Explicit constructor, taking as input reference station
00040        * coordinates, default ionospheric and tropospheric models,
00041        * ephemeris to be used, default observable and whether TGD will
00042        * be computed or not.
00043        *
00044        * This constructor is meant to be used when working with GNSS data
00045        * structures in order to set the basic parameters from the beginning.
00046        *
00047        * @param RxCoordinates Reference station coordinates.
00048        * @param dIonoModel    Ionospheric model to be used by default.
00049        * @param dTropoModel   Tropospheric model to be used by default.
00050        * @param dEphemeris    EphemerisStore object to be used by default.
00051        * @param dObservable   Observable type to be used by default.
00052        * @param usetgd        Whether TGD will be used by default or not.
00053        *
00054        * @sa DataStructures.hpp.
00055        */
00056    ModeledReferencePR::ModeledReferencePR( const Position& RxCoordinates,
00057                                            IonoModelStore& dIonoModel,
00058                                            TropModel& dTropoModel,
00059                                            XvtStore<SatID>& dEphemeris,
00060                                            const TypeID& dObservable,
00061                                            bool usetgd )
00062    {
00063       init();
00064       setInitialRxPosition(RxCoordinates);
00065       setDefaultIonoModel(dIonoModel);
00066       setDefaultTropoModel(dTropoModel);
00067       setDefaultObservable(dObservable);
00068       setDefaultEphemeris(dEphemeris);
00069       useTGD = usetgd;
00070    }
00071 
00072 
00073 
00074       /* Explicit constructor, taking as input reference station
00075        * coordinates, default ionospheric model, ephemeris to be used,
00076        * default observable and whether TGD will be computed or not.
00077        *
00078        * The default tropospheric model will be set to NULL.
00079        *
00080        * This constructor is meant to be used when working with GNSS data
00081        * structures in order to set the basic parameters from the
00082        * beginning.
00083        *
00084        * @param RxCoordinates Reference station coordinates.
00085        * @param dIonoModel    Ionospheric model to be used by default.
00086        * @param dEphemeris    EphemerisStore object to be used by default.
00087        * @param dObservable   Observable type to be used by default.
00088        * @param usetgd        Whether TGD will be used by default or not.
00089        *
00090        * @sa DataStructures.hpp.
00091        */
00092    ModeledReferencePR::ModeledReferencePR( const Position& RxCoordinates,
00093                                            IonoModelStore& dIonoModel,
00094                                            XvtStore<SatID>& dEphemeris,
00095                                            const TypeID& dObservable,
00096                                            bool usetgd )
00097    {
00098       init();
00099       setInitialRxPosition(RxCoordinates);
00100       setDefaultIonoModel(dIonoModel);
00101       setDefaultObservable(dObservable);
00102       setDefaultEphemeris(dEphemeris);
00103       useTGD = usetgd;
00104       pDefaultTropoModel = NULL;
00105    }
00106 
00107 
00108 
00109       /* Explicit constructor, taking as input reference station
00110        * coordinates, default tropospheric model, ephemeris to be used,
00111        * default observable and whether TGD will be computed or not.
00112        *
00113        * The default ionospheric model will be set to NULL.
00114        *
00115        * This constructor is meant to be used when working with GNSS
00116        * data structures in order to set the basic parameters from the
00117        * beginning.
00118        *
00119        * @param RxCoordinates Reference station coordinates.
00120        * @param dTropoModel   Tropospheric model to be used by default.
00121        * @param dEphemeris    EphemerisStore object to be used by default.
00122        * @param dObservable   Observable type to be used by default.
00123        * @param usetgd        Whether TGD will be used by default or not.
00124        *
00125        * @sa DataStructures.hpp.
00126        */
00127    ModeledReferencePR::ModeledReferencePR( const Position& RxCoordinates,
00128                                            TropModel& dTropoModel,
00129                                            XvtStore<SatID>& dEphemeris,
00130                                            const TypeID& dObservable,
00131                                            bool usetgd )
00132    {
00133       init();
00134       setInitialRxPosition(RxCoordinates);
00135       setDefaultTropoModel(dTropoModel);
00136       setDefaultObservable(dObservable);
00137       setDefaultEphemeris(dEphemeris);
00138       useTGD = usetgd;
00139       pDefaultIonoModel = NULL;
00140    }
00141 
00142 
00143 
00144       /* Explicit constructor, taking as input reference station
00145        * coordinates, ephemeris to be used, default observable and
00146        * whether TGD will be computed or not.
00147        *
00148        * Both the tropospheric and ionospheric models will be set to NULL.
00149        *
00150        * This constructor is meant to be used when working with GNSS
00151        * data structures in order to set the basic parameters from the
00152        * beginning.
00153        *
00154        * @param RxCoordinates Reference station coordinates.
00155        * @param dEphemeris    EphemerisStore object to be used by default.
00156        * @param dObservable   Observable type to be used by default.
00157        * @param usetgd        Whether TGD will be used by default or not.
00158        *
00159        * @sa DataStructures.hpp.
00160        */
00161    ModeledReferencePR::ModeledReferencePR( const Position& RxCoordinates,
00162                                            XvtStore<SatID>& dEphemeris,
00163                                            const TypeID& dObservable,
00164                                            bool usetgd )
00165    {
00166       init();
00167       setInitialRxPosition(RxCoordinates);
00168       setDefaultObservable(dObservable);
00169       setDefaultEphemeris(dEphemeris);
00170       useTGD = usetgd;
00171       pDefaultIonoModel = NULL;
00172       pDefaultTropoModel = NULL;
00173    }
00174 
00175 
00176 
00177       /* Compute the modeled pseudoranges, given satellite ID's,
00178        * pseudoranges and other data.
00179        *
00180        * @param Tr            Measured time of reception of the data.
00181        * @param Satellite     Vector of satellites
00182        * @param Pseudorange   Vector of raw pseudoranges (parallel to
00183        *                      satellite), in meters.
00184        * @param Eph           EphemerisStore to be used.
00185        * @param extraBiases   Vector of extra biases to be added to the model.
00186        * @param pTropModel    Pointer to tropospheric model to be used.
00187        *                      By default points to NULL.
00188        * @param pIonoModel    Pointer to ionospheric model to be used.
00189        *                      By default points to NULL.
00190        *
00191        * @return Number of satellites with valid data.
00192        */
00193    int ModeledReferencePR::Compute( const DayTime& Tr,
00194                                     Vector<SatID>& Satellite,
00195                                     Vector<double>& Pseudorange,
00196                                     const XvtStore<SatID>& Eph,
00197                                     const Vector<double>& extraBiases,
00198                                     TropModel *pTropModel,
00199                                     IonoModelStore *pIonoModel )
00200       throw(Exception)
00201    {
00202       try
00203       {
00204 
00205          int N = Satellite.size();
00206          if(N <= 0) return 0;        // No deal if there are no satellites
00207 
00208          int i;
00209             // Maximum valid index of extraBiases vector
00210          int eN = int(extraBiases.size()) - 1;
00211          int validSats(0);
00212             // Some std::vector to hold temporal values (do not confuse
00213             // with gpstk::Vector)
00214          vector<double> vPR;
00215          vector<double> vGeometricRho;
00216          vector<double> vClock;
00217          vector<double> vTGD;
00218          vector<double> vRel;
00219          vector<double> vTrop;
00220          vector<double> vIono;
00221          vector<double> vObservedPR;
00222          vector<double> vModeledPR;
00223          vector<double> vPrefit;
00224          vector<double> vElevation;
00225          vector<double> vAzimuth;
00226          vector<Xvt> vXvt;
00227          vector<DayTime> vTxTime;
00228          vector<SatID> vAvailableSV;
00229          vector<SatID> vRejectedSV;
00230          vector<Triple> vCosines;
00231          vector<Triple>::iterator iter;  // Iterator for vCosines vector
00232             // A lot of the work is done by a CorrectedEphemerisRange object
00233          CorrectedEphemerisRange cerange;
00234          validData = false;
00235 
00236             // Let's make sure everything is clean
00237          rejectedSV.resize(0);
00238          availableSV.resize(0);
00239          geometricRho.resize(0);
00240          svClockBiases.resize(0);
00241          svXvt.resize(0);
00242          svTxTime.resize(0);
00243          svTGD.resize(0);
00244          svRelativity.resize(0);
00245          ionoCorrections.resize(0);
00246          tropoCorrections.resize(0);
00247          observedPseudoranges.resize(0);
00248          modeledPseudoranges.resize(0);
00249          prefitResiduals.resize(0);
00250          elevationSV.resize(0);
00251          azimuthSV.resize(0);
00252          geoMatrix.resize(0, 0);
00253 
00254          for (i=0; i<N; i++)
00255          {
00256                // Skip marked satellites
00257             if(Satellite[i].id <= 0)
00258             {
00259                   // First, make sure we are using a positive satellite id
00260                   SatID tempSat( std::abs(Satellite[i].id),
00261                                  Satellite[i].system);
00262                   vRejectedSV.push_back(tempSat);
00263                   continue;
00264             }
00265 
00266             try
00267             {
00268                   // Scalars to hold temporal values
00269                double tempPR(0.0);
00270                double tempTGD(0.0);
00271                double tempTrop(0.0);
00272                double tempIono(0.0);
00273                double tempModeledPR(0.0);
00274                double tempPrefit(0.0);
00275 
00276                try
00277                {
00278                      // Compute most of the parameters
00279                   tempPR = cerange.ComputeAtTransmitTime( Tr,
00280                                                           Pseudorange[i],
00281                                                           rxPos,
00282                                                           Satellite[i],
00283                                                           Eph );
00284                }
00285                catch(InvalidRequest& e)
00286                {
00287                      // If there were no ephemeris for this satellite,
00288                      // let's mark it
00289                   vRejectedSV.push_back(Satellite[i]);
00290                   continue;
00291                }; // End of "try/catch" for cerange
00292 
00293                   // Let's test if satellite has enough elevation over horizon
00294                if(rxPos.elevationGeodetic(cerange.svPosVel) < (*this).minElev)
00295                {
00296                      // Mark this satellite if it doesn't have
00297                      // enough elevation
00298                   vRejectedSV.push_back(Satellite[i]);
00299                   continue;
00300                };
00301 
00302                   // If given, computes tropospheric model
00303                if(pTropModel)
00304                {
00305                   tempTrop = getTropoCorrections( pTropModel,
00306                                                   cerange.elevationGeodetic );
00307                };
00308 
00309                   // If given, computes ionospheric model
00310                if(pIonoModel)
00311                {
00312                      // Convert Position rxPos to Geodetic rxGeo
00313                   Geodetic rxGeo( rxPos.getGeodeticLatitude(),
00314                                   rxPos.getLongitude(),
00315                                   rxPos.getAltitude() );
00316 
00317                   tempIono = getIonoCorrections( pIonoModel,
00318                                                  Tr,
00319                                                  rxGeo,
00320                                                  cerange.elevationGeodetic,
00321                                                  cerange.azimuthGeodetic );
00322                };
00323 
00324                tempModeledPR = tempPR + tempTrop + tempIono;
00325 
00326                   // Check if there could be an extra bias defined for
00327                   // this satellite
00328                if (i <= eN )
00329                {
00330                   tempModeledPR += extraBiases(i);
00331                };
00332 
00333                   // Computing Total Group Delay (TGD - meters) and adding
00334                   // it to result
00335                if(useTGD)
00336                {
00337                   tempTGD = getTGDCorrections(Tr, Eph, Satellite[i]);
00338                   tempModeledPR += tempTGD;
00339                }
00340 
00341                tempPrefit = Pseudorange[i] - tempModeledPR;
00342 
00343                   // Let's store the results in their corresponding std::vector
00344                vGeometricRho.push_back(cerange.rawrange);
00345                vClock.push_back(cerange.svclkbias);
00346                vXvt.push_back(cerange.svPosVel);
00347                vTxTime.push_back(cerange.transmit);
00348                vTGD.push_back(tempTGD);
00349                   // Relativity was computed with a negative sign added
00350                vRel.push_back(-cerange.relativity);
00351                vIono.push_back(tempIono);
00352                vTrop.push_back(tempTrop);
00353                vObservedPR.push_back(Pseudorange[i]);
00354                vModeledPR.push_back(tempModeledPR);
00355                vPrefit.push_back(tempPrefit);
00356                vElevation.push_back(cerange.elevationGeodetic);
00357                vAzimuth.push_back(cerange.azimuthGeodetic);
00358                vAvailableSV.push_back(Satellite[i]);
00359                vCosines.push_back(cerange.cosines);
00360 
00361                   // If everything is OK, increment valid sat's counter
00362                validSats += 1;
00363 
00364             }   // End of try
00365             catch(InvalidRequest& e)
00366             {
00367                   // If there were no ephemeris for this satellite,
00368                   // let's mark it
00369                vRejectedSV.push_back(Satellite[i]);
00370                continue;
00371             }
00372             catch(...)
00373             {
00374                Exception unknownEx( "An unknown exception has happened in \
00375 ModeledReferencePR object." );
00376                GPSTK_THROW(unknownEx);
00377             }
00378 
00379          }  // End of "for" loop
00380 
00381             // Let's storage results in their corresponding gpstk::Vector
00382          rejectedSV = vRejectedSV;
00383          availableSV = vAvailableSV;
00384          geometricRho = vGeometricRho;
00385          svClockBiases = vClock;
00386          svXvt = vXvt;
00387          svTxTime = vTxTime;
00388          svTGD = vTGD;
00389          svRelativity = vRel;
00390          ionoCorrections = vIono;
00391          tropoCorrections = vTrop;
00392          observedPseudoranges = vObservedPR;
00393          modeledPseudoranges = vModeledPR;
00394          prefitResiduals = vPrefit;
00395          elevationSV = vElevation;
00396          azimuthSV = vAzimuth;
00397 
00398             // Let's fill in the Geometry Matrix
00399             // First, set the correct size
00400          geoMatrix.resize((size_t)validSats, 4);
00401          int counter(0);
00402          for ( iter=vCosines.begin(); iter!=vCosines.end(); iter++ )
00403          {
00404             geoMatrix(counter,0) = (*iter)[0];
00405             geoMatrix(counter,1) = (*iter)[1];
00406             geoMatrix(counter,2) = (*iter)[2];
00407                // When using pseudorange method, this is 1.0
00408             geoMatrix(counter,3) = 1.0;
00409             counter++;
00410          }
00411 
00412          if (validSats >= 4)
00413          {
00414             validData = true;
00415          }
00416 
00417          return validSats;  // Return number of valid satellites
00418 
00419       }  // end of "try"
00420       catch(Exception& e)
00421       {
00422          GPSTK_RETHROW(e);
00423       }
00424 
00425    }  // End of method 'ModeledReferencePR::Compute()'
00426 
00427 
00428 
00429       // Compute the modeled pseudoranges, given satellite ID's,
00430       // pseudoranges and other data.
00431    int ModeledReferencePR::Compute( const DayTime& Tr,
00432                                     Vector<SatID>& Satellite,
00433                                     Vector<double>& Pseudorange,
00434                                     const XvtStore<SatID>& Eph )
00435       throw(Exception)
00436    {
00437 
00438          // Create missing parameters
00439       Vector<double> vectorBIAS(1, 0.0);
00440 
00441          // Let's call the most complete Compute method defined above
00442       return ModeledReferencePR::Compute( Tr,
00443                                           Satellite,
00444                                           Pseudorange,
00445                                           Eph,
00446                                           vectorBIAS );
00447 
00448    }  // End of method 'ModeledReferencePR::Compute()'
00449 
00450 
00451 
00452       // Compute the modeled pseudoranges, given satellite ID's,
00453       // pseudoranges and other data.
00454    int ModeledReferencePR::Compute( const DayTime& Tr,
00455                                     Vector<SatID>& Satellite,
00456                                     Vector<double>& Pseudorange,
00457                                     const XvtStore<SatID>& Eph,
00458                                     TropModel *pTropModel )
00459       throw(Exception)
00460    {
00461 
00462          // Create missing parameters
00463       Vector<double> vectorBIAS(1, 0.0);
00464 
00465          // Let's call the most complete Compute method defined above
00466       return ModeledReferencePR::Compute( Tr,
00467                                           Satellite,
00468                                           Pseudorange,
00469                                           Eph,
00470                                           vectorBIAS,
00471                                           pTropModel );
00472 
00473    }  // End of method 'ModeledReferencePR::Compute()'
00474 
00475 
00476 
00477       // Compute the modeled pseudoranges, given satellite ID's,
00478       // pseudoranges and other data.
00479    int ModeledReferencePR::Compute( const DayTime& Tr,
00480                                     Vector<SatID>& Satellite,
00481                                     Vector<double>& Pseudorange,
00482                                     const XvtStore<SatID>& Eph,
00483                                     const Vector<double>& extraBiases,
00484                                     IonoModelStore *pIonoModel )
00485       throw(Exception)
00486    {
00487 
00488          // Create missing parameters
00489       TropModel *pTropModel=NULL;
00490 
00491          // Let's call the most complete Compute method defined above
00492       return ModeledReferencePR::Compute( Tr,
00493                                           Satellite,
00494                                           Pseudorange,
00495                                           Eph,
00496                                           extraBiases,
00497                                           pTropModel,
00498                                           pIonoModel );
00499 
00500    }  // End of method 'ModeledReferencePR::Compute()'
00501 
00502 
00503 
00504       // Compute the modeled pseudoranges, given satellite ID's,
00505       // pseudoranges and other data.
00506    int ModeledReferencePR::Compute( const DayTime& Tr,
00507                                     Vector<SatID>& Satellite,
00508                                     Vector<double>& Pseudorange,
00509                                     const XvtStore<SatID>& Eph,
00510                                     IonoModelStore *pIonoModel )
00511       throw(Exception)
00512    {
00513 
00514          // Create missing parameters
00515       Vector<double> vectorBIAS(1, 0.0);
00516       TropModel *pTropModel=NULL;
00517 
00518          // Let's call the most complete Compute method defined above
00519       return ModeledReferencePR::Compute( Tr,
00520                                           Satellite,
00521                                           Pseudorange,
00522                                           Eph,
00523                                           vectorBIAS,
00524                                           pTropModel,
00525                                           pIonoModel );
00526 
00527    }  // End of method 'ModeledReferencePR::Compute()'
00528 
00529 
00530 
00531       // Compute the modeled pseudoranges, given satellite ID's,
00532       // pseudoranges and other data.
00533    int ModeledReferencePR::Compute( const DayTime& Tr,
00534                                     Vector<SatID>& Satellite,
00535                                     Vector<double>& Pseudorange,
00536                                     const XvtStore<SatID>& Eph,
00537                                     TropModel *pTropModel,
00538                                     IonoModelStore *pIonoModel )
00539       throw(Exception)
00540    {
00541 
00542          // Create missing parameters
00543       Vector<double> vectorBIAS(1, 0.0);
00544 
00545          // Let's call the most complete Compute method defined above
00546       return ModeledReferencePR::Compute( Tr,
00547                                           Satellite,
00548                                           Pseudorange,
00549                                           Eph,
00550                                           vectorBIAS,
00551                                           pTropModel,
00552                                           pIonoModel );
00553 
00554    }  // End of method 'ModeledReferencePR::Compute()'
00555 
00556 
00557 
00558       /* Compute just one modeled pseudorange, given satellite ID's,
00559        * pseudorange and other data.
00560        *
00561        * @param Tr            Measured time of reception of the data.
00562        * @param Satellite     ID's of satellite
00563        * @param Pseudorange   Pseudorange (parallel to satellite), in meters.
00564        * @param Eph           XvtStore<SatID> to be used.
00565        * @param pTropModel    Pointer to tropospheric model to be used
00566        *                      By default points to NULL.
00567        * @param pIonoModel    Pointer to ionospheric model to be used
00568        *                      By default points to NULL.
00569        * @param extraBiases   Extra bias to be added to the model.
00570        *
00571        * @return
00572        *  1 if satellite has valid data
00573        */
00574    int ModeledReferencePR::Compute( const DayTime& Tr,
00575                                     SatID& Satellite,
00576                                     double& Pseudorange,
00577                                     const XvtStore<SatID>& Eph,
00578                                     const double& extraBiases,
00579                                     TropModel *pTropModel,
00580                                     IonoModelStore *pIonoModel )
00581       throw(Exception)
00582    {
00583 
00584          // Create Vectors from scalar values
00585       Vector<SatID> vectorSV(1, Satellite);
00586       Vector<double> vectorPR(1, Pseudorange);
00587       Vector<double> vectorBIAS(1, extraBiases);
00588 
00589          // Now, let's call one of the Compute methods defined above
00590       return ModeledReferencePR::Compute( Tr,
00591                                           vectorSV,
00592                                           vectorPR,
00593                                           Eph,
00594                                           vectorBIAS,
00595                                           pTropModel,
00596                                           pIonoModel );
00597 
00598    }  // End of method 'ModeledReferencePR::Compute()'
00599 
00600 
00601 
00602       /* Returns a satTypeValueMap object, adding the new data generated
00603        * when calling a modeling object.
00604        *
00605        * @param time      Epoch.
00606        * @param gData     Data object holding the data.
00607        */
00608    satTypeValueMap& ModeledReferencePR::processModel( const DayTime& time,
00609                                                       satTypeValueMap& gData )
00610       throw(Exception)
00611    {
00612 
00613       Vector<SatID> Vsat = gData.getVectorOfSatID();
00614       Vector<double> Vprange=gData.getVectorOfTypeID(getDefaultObservable());
00615 
00616       try
00617       {
00618             // Call the Compute() method with the defaults. Those defaults
00619             // MUST HAVE BEEN previously set, usually when creating this
00620             // object with the appropriate constructor.
00621          Compute( time,
00622                   Vsat,
00623                   Vprange,
00624                   (*(getDefaultEphemeris())),
00625                   extraBiases,
00626                   getDefaultTropoModel(),
00627                   getDefaultIonoModel() );
00628 
00629             // Once we get the result, it may be necessary to make
00630             // some satellite cleanup
00631          SatIDSet rejectedSet;
00632          for (size_t i = 0; i<rejectedSV.size(); ++i)
00633          {
00634             rejectedSet.insert(rejectedSV[i]);
00635          }
00636 
00637             // All rejected satellites are removed
00638          gData.removeSatID(rejectedSet);
00639 
00640             // Now we have to add the new values to the data structure
00641          gData.insertTypeIDVector(TypeID::prefitC, prefitResiduals);
00642          gData.insertTypeIDVector(TypeID::rho, geometricRho);
00643          gData.insertTypeIDVector(TypeID::dtSat, svClockBiases);
00644          gData.insertTypeIDVector(TypeID::rel, svRelativity);
00645          gData.insertTypeIDVector(TypeID::tropoSlant, tropoCorrections);
00646          gData.insertTypeIDVector(TypeID::elevation, elevationSV);
00647          gData.insertTypeIDVector(TypeID::azimuth, azimuthSV);
00648 
00649 
00650             // Get iono and instrumental delays right
00651          TypeID ionoDelayType, instDelayType;
00652 
00653          switch ( getDefaultObservable().type )
00654          {
00655 
00656             case TypeID::C1:
00657             case TypeID::P1:
00658                ionoDelayType = TypeID::ionoL1;
00659                instDelayType = TypeID::instC1;
00660                break;
00661 
00662             case TypeID::C2:
00663             case TypeID::P2:
00664                ionoDelayType = TypeID::ionoL2;
00665                instDelayType = TypeID::instC2;
00666                break;
00667 
00668             case TypeID::C5:
00669                ionoDelayType = TypeID::ionoL5;
00670                instDelayType = TypeID::instC5;
00671                break;
00672 
00673             case TypeID::C6:
00674                ionoDelayType = TypeID::ionoL6;
00675                instDelayType = TypeID::instC6;
00676                break;
00677 
00678             case TypeID::C7:
00679                ionoDelayType = TypeID::ionoL7;
00680                instDelayType = TypeID::instC7;
00681                break;
00682 
00683             case TypeID::C8:
00684                ionoDelayType = TypeID::ionoL8;
00685                instDelayType = TypeID::instC8;
00686                break;
00687 
00688             default:
00689                ionoDelayType = TypeID::ionoL1;
00690                instDelayType = TypeID::instC1;
00691 
00692          }  // End of 'switch ( getDefaultObservable().type )...'
00693 
00694 
00695             // Store ionospheric values in GDS
00696          gData.insertTypeIDVector(ionoDelayType, ionoCorrections);
00697 
00698             // Store TGD values in GDS
00699          if( useTGD )
00700          {
00701             gData.insertTypeIDVector(instDelayType, svTGD);
00702          }
00703 
00704 
00705             // Now, lets insert the geometry matrix
00706          TypeIDSet tSet;
00707          tSet.insert(TypeID::dx);
00708          tSet.insert(TypeID::dy);
00709          tSet.insert(TypeID::dz);
00710          tSet.insert(TypeID::cdt);
00711          gData.insertMatrix(tSet, geoMatrix);
00712 
00713 
00714          return gData;
00715 
00716       }  // End of "try"
00717       catch(Exception& e)
00718       {
00719          GPSTK_RETHROW(e);
00720       }
00721 
00722    }  // End of method 'ModeledReferencePR::processModel()'
00723 
00724 
00725 
00726       // Initialization method
00727    void ModeledReferencePR::init()
00728    {
00729 
00730       setInitialRxPosition();
00731       geometricRho(0);
00732       svClockBiases(0);
00733       svXvt(0);
00734       svTGD(0);
00735       svRelativity(0);
00736       ionoCorrections(0);
00737       tropoCorrections(0);
00738       modeledPseudoranges(0);
00739       prefitResiduals(0);
00740       extraBiases(0);
00741       availableSV(0);
00742       rejectedSV(0);
00743 
00744    }  // End of method 'ModeledReferencePR::init()'
00745 
00746 
00747 
00748       /* Method to set the initial (a priori) position of receiver.
00749        * @return
00750        *  0 if OK
00751        *  -1 if problems arose
00752        */
00753    int ModeledReferencePR::setInitialRxPosition( const double& aRx,
00754                                                  const double& bRx,
00755                                                  const double& cRx,
00756                                                  Position::CoordinateSystem s,
00757                                                  GeoidModel *geoid )
00758    {
00759 
00760       try
00761       {
00762          Position rxpos(aRx, bRx, cRx, s, geoid);
00763          setInitialRxPosition(rxpos);
00764          return 0;
00765       }
00766       catch(GeometryException& e)
00767       {
00768          return -1;
00769       }
00770 
00771    }  // End of method 'ModeledReferencePR::setInitialRxPosition()'
00772 
00773 
00774 
00775       // Method to set the initial (a priori) position of receiver.
00776    int ModeledReferencePR::setInitialRxPosition(const Position& RxCoordinates)
00777    {
00778 
00779       try
00780       {
00781          rxPos = RxCoordinates;
00782          return 0;
00783       }
00784       catch(GeometryException& e)
00785       {
00786          return -1;
00787       }
00788 
00789    }  // End of method 'ModeledReferencePR::setInitialRxPosition()'
00790 
00791 
00792 
00793       // Method to set the initial (a priori) position of receiver.
00794    int ModeledReferencePR::setInitialRxPosition()
00795    {
00796 
00797       try
00798       {
00799          Position rxpos(0.0, 0.0, 0.0, Position::Cartesian, NULL);
00800          setInitialRxPosition(rxpos);
00801          return 0;
00802       }
00803       catch(GeometryException& e)
00804       {
00805          return -1;
00806       }
00807 
00808    }  // End of method 'ModeledReferencePR::setInitialRxPosition()'
00809 
00810 
00811 
00812       // Method to get the tropospheric corrections.
00813    double ModeledReferencePR::getTropoCorrections( TropModel *pTropModel,
00814                                                    double elevation )
00815    {
00816 
00817       double tropoCorr(0.0);
00818 
00819       try
00820       {
00821          tropoCorr = pTropModel->correction(elevation);
00822             // Check validity
00823          if(!(pTropModel->isValid()))
00824          {
00825             tropoCorr = 0.0;
00826          }
00827       }
00828       catch(TropModel::InvalidTropModel& e)
00829       {
00830          tropoCorr = 0.0;
00831       }
00832 
00833       return tropoCorr;
00834 
00835    }  // End of method 'ModeledReferencePR::getTropoCorrections()'
00836 
00837 
00838 
00839       // Method to get the ionospheric corrections.
00840    double ModeledReferencePR::getIonoCorrections( IonoModelStore *pIonoModel,
00841                                                   DayTime Tr,
00842                                                   Geodetic rxGeo,
00843                                                   double elevation,
00844                                                   double azimuth )
00845    {
00846 
00847       double ionoCorr(0.0);
00848 
00849       try
00850       {
00851          ionoCorr = pIonoModel->getCorrection(Tr, rxGeo, elevation, azimuth);
00852       }
00853       catch(IonoModelStore::NoIonoModelFound& e)
00854       {
00855          ionoCorr = 0.0;
00856       }
00857 
00858       return ionoCorr;
00859 
00860    }  // End of method 'ModeledReferencePR::getIonoCorrections()'
00861 
00862 
00863 
00864       // Method to get TGD corrections.
00865    double ModeledReferencePR::getTGDCorrections( DayTime Tr,
00866                                                  const XvtStore<SatID>& Eph,
00867                                                  SatID sat )
00868    {
00869 
00870       try
00871       {
00872          const GPSEphemerisStore& bce =
00873                                  dynamic_cast<const GPSEphemerisStore&>(Eph);
00874 
00875          const EngEphemeris& eph = bce.findEphemeris(sat,Tr);
00876 
00877          return ( bce.findEphemeris(sat,Tr).getTgd() * C_GPS_M );
00878 
00879       }
00880       catch(...)
00881       {
00882          return 0.0;
00883       }
00884 
00885    }  // End of method 'ModeledReferencePR::getTropoCorrections()'
00886 
00887 
00888 }  // End of namespace gpstk

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