ComputeSimpleWeights.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: $"
00002 
00010 //============================================================================
00011 //
00012 //  This file is part of GPSTk, the GPS Toolkit.
00013 //
00014 //  The GPSTk is free software; you can redistribute it and/or modify
00015 //  it under the terms of the GNU Lesser General Public License as published
00016 //  by the Free Software Foundation; either version 2.1 of the License, or
00017 //  any later version.
00018 //
00019 //  The GPSTk is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU Lesser General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU Lesser General Public
00025 //  License along with GPSTk; if not, write to the Free Software Foundation,
00026 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 //
00028 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2011
00029 //
00030 //============================================================================
00031 
00032 
00033 #include "ComputeSimpleWeights.hpp"
00034 
00035 
00036 namespace gpstk
00037 {
00038 
00039       // Index initially assigned to this class
00040    int ComputeSimpleWeights::classIndex = 6300000;
00041 
00042 
00043       // Returns an index identifying this object.
00044    int ComputeSimpleWeights::getIndex() const
00045    { return index; }
00046 
00047 
00048       // Returns a string identifying this object.
00049    std::string ComputeSimpleWeights::getClassName() const
00050    { return "ComputeSimpleWeights"; }
00051 
00052 
00053 
00054       /* Returns a satTypeValueMap object, adding the new data
00055        * generated when calling this object.
00056        *
00057        * @param time      Epoch corresponding to the data.
00058        * @param gData     Data object holding the data.
00059        */
00060    satTypeValueMap& ComputeSimpleWeights::Process( const DayTime& time,
00061                                                  satTypeValueMap& gData )
00062       throw(ProcessingException)
00063    {
00064 
00065       try
00066       {
00067 
00068             // If we are using a 5th order Taylor-based differencing filter, the
00069             // corresponding scale factor to convert from covariance matrix to
00070             // double-differenced covariance matrix is 1.509551839.
00071          double scaleFact( 1.509551839 );
00072 
00073             // Declare some important constants
00074          double tropoVar( 0.0004 );    // (0.02 m)^2
00075          double multiVar( 0.000025 );  // (0.005 m)^2
00076 
00077             // We need a NBTropModel initialized with dummy values
00078          NBTropModel tropoObj(0.0, 0.0, 1);
00079 
00080          SatIDSet satRejectedSet;
00081 
00082 
00083             // Loop through all the satellites
00084          for( satTypeValueMap::iterator it = gData.begin();
00085               it != gData.end();
00086               ++it )
00087          {
00088 
00089             double elevP( 0.0 );
00090 
00091             try
00092             {
00093                elevP = gData.getValue( (*it).first, TypeID::elevation );
00094             }
00095             catch(...)
00096             {
00097 
00098                   // If some value is missing, then schedule this satellite
00099                   // for removal
00100                satRejectedSet.insert( (*it).first );
00101 
00102                continue;
00103 
00104             }
00105 
00106                // If everything is OK, then compute the weight value and
00107                // put it into the GDS structure
00108             double mt( tropoObj.dry_mapping_function(elevP) );
00109 
00110             double weight( 1.0 / ( scaleFact*( mt*mt*tropoVar + multiVar ) ) );
00111 
00112             (*it).second[TypeID::weight] = weight;
00113 
00114          }
00115 
00116             // Remove satellites with missing data
00117          gData.removeSatID(satRejectedSet);
00118 
00119          return gData;
00120 
00121       }
00122       catch(Exception& u)
00123       {
00124             // Throw an exception if something unexpected happens
00125          ProcessingException e( getClassName() + ":"
00126                                 + StringUtils::asString( getIndex() ) + ":"
00127                                 + u.what() );
00128 
00129          GPSTK_THROW(e);
00130 
00131       }
00132 
00133    }  // End of method 'ComputeSimpleWeightsWeights::Process()'
00134 
00135 
00136 
00137       /* Returns a gnnsSatTypeValue object, adding the new data
00138        * generated when calling this object.
00139        *
00140        * @param gData    Data object holding the data.
00141        */
00142    gnssSatTypeValue& ComputeSimpleWeights::Process(gnssSatTypeValue& gData)
00143       throw(ProcessingException)
00144    {
00145 
00146       try
00147       {
00148 
00149          Process(gData.header.epoch, gData.body);
00150 
00151          return gData;
00152 
00153       }
00154       catch(Exception& u)
00155       {
00156             // Throw an exception if something unexpected happens
00157          ProcessingException e( getClassName() + ":"
00158                                 + StringUtils::asString( getIndex() ) + ":"
00159                                 + u.what() );
00160 
00161          GPSTK_THROW(e);
00162 
00163       }
00164 
00165    }  // End of method 'ComputeSimpleWeightsWeights::Process()'
00166 
00167 
00168 
00169       /* Returns a gnnsRinex object, adding the new data generated
00170        * when calling this object.
00171        *
00172        * @param gData    Data object holding the data.
00173        */
00174    gnssRinex& ComputeSimpleWeights::Process(gnssRinex& gData)
00175       throw(ProcessingException)
00176    {
00177 
00178       try
00179       {
00180 
00181          Process(gData.header.epoch, gData.body);
00182 
00183          return gData;
00184 
00185       }
00186       catch(Exception& u)
00187       {
00188             // Throw an exception if something unexpected happens
00189          ProcessingException e( getClassName() + ":"
00190                                 + StringUtils::asString( getIndex() ) + ":"
00191                                 + u.what() );
00192 
00193          GPSTK_THROW(e);
00194 
00195       }
00196 
00197    }  // End of method 'ComputeSimpleWeightsWeights::Process()'
00198 
00199 
00200 }  // End of namespace gpstk

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