00001 #pragma ident "$Id: ObsClockModel.cpp 279 2006-11-03 18:04:12Z ocibu $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
00125
00126
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
00151 if (status[svid] == USED)
00152 {
00153
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
00162
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