ObsClockModel.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ObsClockModel.cpp 279 2006-11-03 18:04:12Z ocibu $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //  
00021 //  Copyright 2004, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 //============================================================================
00026 //
00027 //This software developed by Applied Research Laboratories at the University of
00028 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00029 //Department of Defense. The U.S. Government retains all rights to use,
00030 //duplicate, distribute, disclose, or release this software. 
00031 //
00032 //Pursuant to DoD Directive 523024 
00033 //
00034 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00035 //                           release, distribution is unlimited.
00036 //
00037 //=============================================================================
00038 
00049 #include <math.h>
00050 
00051 #include "ObsClockModel.hpp"
00052 
00053 namespace gpstk
00054 {
00055    using namespace std;
00056 
00057 
00058    ObsClockModel::SvStatus ObsClockModel::getSvStatus(const SatID& svid) const
00059       throw(gpstk::ObjectNotFound)
00060    {
00061       SvStatusMap::const_iterator i = status.find(svid);
00062       if(i == status.end())
00063       {
00064          gpstk::ObjectNotFound e("No status for SV " +
00065                                  StringUtils::asString(svid) +
00066                                  " available.");
00067          GPSTK_THROW(e);
00068       }
00069       else
00070          return i->second;
00071    }
00072 
00073 
00074    ObsClockModel& ObsClockModel::setSvModeMap(const SvModeMap& right)
00075       throw()
00076    {
00077       for(int prn = 1; prn <= gpstk::MAX_PRN; prn++)
00078          modes[SatID(prn, SatID::systemGPS)] = IGNORE;
00079 
00080       for(SvModeMap::const_iterator i = right.begin(); i != right.end(); i++)
00081          modes[i->first] = i->second;
00082 
00083       return *this;
00084    }
00085 
00086 
00087    ObsClockModel::SvMode ObsClockModel::getSvMode(const SatID& svid) const
00088       throw(gpstk::ObjectNotFound)
00089    {
00090       SvModeMap::const_iterator i = modes.find(svid);
00091       if(i == modes.end())
00092       {
00093          gpstk::ObjectNotFound e("No status for SV " +
00094                                  StringUtils::asString(svid) +
00095                                  " available.");
00096          GPSTK_THROW(e);
00097       }
00098       else
00099          return i->second;
00100    }
00101 
00102 
00103    gpstk::Stats<double> ObsClockModel::simpleOrdClock(const ORDEpoch& oe)
00104       throw(gpstk::InvalidValue)
00105    {
00106       gpstk::Stats<double> stat;
00107       
00108       status.clear();
00109 
00110       ORDEpoch::ORDMap::const_iterator itr;
00111       for(itr = oe.ords.begin(); itr != oe.ords.end(); itr++)
00112       {
00113          const SatID& svid = itr->first;
00114          const ObsRngDev& ord=itr->second;
00115          switch (modes[svid])
00116          {
00117             case IGNORE: 
00118                status[svid] = MANUAL;
00119                break;
00120             case ALWAYS:
00121                status[svid] = USED;
00122                break;
00123             case HEALTHY:
00124                // SV Health bits are defined in ICD-GPS-200C-IRN4 20.3.3.3.1.4
00125                // It is a 6-bit value where the MSB (0x20) indicates a summary of
00126                // of NAV data health where 0 = OK, 1 = some or all BAD
00127                if (ord.getHealth().is_valid() && (ord.getHealth() & 0x20)) 
00128                   status[svid] = SVHEALTH;
00129                else
00130                   status[svid] = USED;
00131                break;
00132          }
00133       
00134          if (ord.getElevation() < elvmask)
00135             status[svid] = ELEVATION;
00136 
00137          if (ord.wonky && !useWonkyData)
00138             status[svid] = WONKY;
00139 
00140          if (status[svid] == USED)
00141             stat.Add(ord.getORD());
00142       }
00143    
00144       if (stat.N() > 2)
00145       {
00146          for (itr = oe.ords.begin(); itr != oe.ords.end(); itr++)
00147          {
00148             const SatID& svid = itr->first;
00149 
00150             // don't override other types of stripping
00151             if (status[svid] == USED)
00152             {
00153                // get absolute distance of residual from mean
00154                double res = itr->second.getORD();
00155                double dist = res - stat.Average();
00156                if(fabs(dist) > (sigmam * stat.StdDev()))
00157                   status[svid] = SIGMA;
00158             }
00159          }
00160    
00161          // now, recompute the statistics on unstripped residuals to get
00162          // the clock bias value
00163          stat.Reset();
00164          for (itr = oe.ords.begin(); itr != oe.ords.end(); itr++)
00165             if (status[itr->second.getSvID()] == USED)
00166                stat.Add(itr->second.getORD());
00167       }
00168          
00169       return stat;
00170    }
00171 
00172    void ObsClockModel::dump(ostream& s, short detail) const throw()
00173    {
00174       s << "min elev:" << elvmask
00175         << ", max sigma:" << sigmam
00176         << ", prn/status: ";
00177       
00178       ObsClockModel::SvStatusMap::const_iterator i;
00179       for ( i=status.begin(); i!= status.end(); i++)
00180          s << i->first << "/" << i->second << " ";
00181    }
00182 }
00183 

Generated on Wed Sep 8 03:30:55 2010 for GPS ToolKit Software Library by  doxygen 1.3.9.1