Changeset 6345 in ntrip


Ignore:
Timestamp:
Nov 26, 2014, 5:37:10 PM (9 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/src/orbComp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/orbComp/sp3Comp.cpp

    r6344 r6345  
    105105}
    106106
    107 //// Satellite Index in clkSats set
    108 //////////////////////////////////////////////////////////////////////////////////
    109 //int satIndex(const set<GPSS::t_prn>& clkSats, const GPSS::t_prn& prn) {
    110 //  int ret = 0;
    111 //  for (set<GPSS::t_prn>::const_iterator it = clkSats.begin(); it != clkSats.end(); it++) {
    112 //    if ( *it == prn) {
    113 //      return ret;
    114 //    }
    115 //    ++ret;
    116 //  }
    117 //  cerr << "satellite not found in used Sats " << prn << endl;
    118 //  exit(1);
    119 //}
    120 //
    121 //// Estimate Clock Offsets
    122 //////////////////////////////////////////////////////////////////////////////////
    123 //void processClocks(const set<GPSS::t_prn>& clkSats, vector<t_epoch*>& epochs,
    124 //                   map<string, t_stat>& stat) {
    125 //
    126 //  if (clkSats.size() == 0) {
    127 //    return;
    128 //  }
    129 //
    130 //  int nPar = epochs.size() + clkSats.size();
    131 //  SymmetricMatrix NN(nPar); NN = 0.0;
    132 //  ColumnVector    bb(nPar); bb = 0.0;
    133 //
    134 //  // Create Matrix A'A and vector b
    135 //  // ------------------------------
    136 //  for (unsigned ie = 0; ie < epochs.size(); ie++) {
    137 //    const GPSS::t_gpstime&          tt = epochs[ie]->_tt;
    138 //    const map<GPSS::t_prn, double>& dc = epochs[ie]->_dc;
    139 //    Matrix       AA(dc.size(), nPar); AA = 0.0;
    140 //    ColumnVector ll(dc.size());       ll = 0.0;
    141 //    map<GPSS::t_prn, double>::const_iterator it; int ii;
    142 //    for (it = dc.begin(), ii = 0; it != dc.end(); it++, ii++) {
    143 //      const GPSS::t_prn& prn = it->first;
    144 //      int index = epochs.size() + satIndex(clkSats, prn);
    145 //      AA[ii][ie]    = 1.0; // epoch-specfic offset (common for all satellites)
    146 //      AA[ii][index] = 1.0; // satellite-specific offset (common for all epochs)
    147 //      ll[ii]        = it->second;
    148 //    }
    149 //    SymmetricMatrix dN; dN << AA.t() * AA;
    150 //    NN += dN;
    151 //    bb += AA.t() * ll;
    152 //  }
    153 //
    154 //  // Regularize NN
    155 //  // -------------
    156 //  RowVector HH(nPar);
    157 //  HH.columns(1, epochs.size())      = 0.0;
    158 //  HH.columns(epochs.size()+1, nPar) = 1.0;
    159 //  SymmetricMatrix dN; dN << HH.t() * HH;
    160 //  NN += dN;
    161 //
    162 //  // Estimate Parameters
    163 //  // -------------------
    164 //  ColumnVector xx = NN.i() * bb;
    165 //
    166 //  // Compute clock residuals
    167 //  // -----------------------
    168 //  for (unsigned ie = 0; ie < epochs.size(); ie++) {
    169 //    const GPSS::t_gpstime&  tt     = epochs[ie]->_tt;
    170 //    map<GPSS::t_prn, double>& dc = epochs[ie]->_dc;
    171 //    for (map<GPSS::t_prn, double>::iterator it = dc.begin(); it != dc.end(); it++) {
    172 //      const GPSS::t_prn& prn = it->first;
    173 //      int  index = epochs.size() + satIndex(clkSats, prn);
    174 //      dc[prn]           = it->second - xx[ie] - xx[index];
    175 //      stat[prn]._offset = xx[index];
    176 //    }
    177 //  }
    178 //}
    179 //
     107// Satellite Index in clkSats set
     108////////////////////////////////////////////////////////////////////////////////
     109int t_sp3Comp::satIndex(const set<t_prn>& clkSats, const t_prn& prn) const {
     110  int ret = 0;
     111  for (set<t_prn>::const_iterator it = clkSats.begin(); it != clkSats.end(); it++) {
     112    if ( *it == prn) {
     113      return ret;
     114    }
     115    ++ret;
     116  }
     117  throw "satellite not found " + prn.toString();
     118}
     119
     120// Estimate Clock Offsets
     121////////////////////////////////////////////////////////////////////////////////
     122void t_sp3Comp::processClocks(const set<t_prn>& clkSats, vector<t_epoch*>& epochs,
     123                              map<string, t_stat>& stat) const {
     124
     125  if (clkSats.size() == 0) {
     126    return;
     127  }
     128
     129  int nPar = epochs.size() + clkSats.size();
     130  SymmetricMatrix NN(nPar); NN = 0.0;
     131  ColumnVector    bb(nPar); bb = 0.0;
     132
     133  // Create Matrix A'A and vector b
     134  // ------------------------------
     135  for (unsigned ie = 0; ie < epochs.size(); ie++) {
     136    ///    const bncTime&          tt = epochs[ie]->_tt;
     137    const map<t_prn, double>& dc = epochs[ie]->_dc;
     138    Matrix       AA(dc.size(), nPar); AA = 0.0;
     139    ColumnVector ll(dc.size());       ll = 0.0;
     140    map<t_prn, double>::const_iterator it; int ii;
     141    for (it = dc.begin(), ii = 0; it != dc.end(); it++, ii++) {
     142      const t_prn& prn = it->first;
     143      int index = epochs.size() + satIndex(clkSats, prn);
     144      AA[ii][ie]    = 1.0; // epoch-specfic offset (common for all satellites)
     145      AA[ii][index] = 1.0; // satellite-specific offset (common for all epochs)
     146      ll[ii]        = it->second;
     147    }
     148    SymmetricMatrix dN; dN << AA.t() * AA;
     149    NN += dN;
     150    bb += AA.t() * ll;
     151  }
     152
     153  // Regularize NN
     154  // -------------
     155  RowVector HH(nPar);
     156  HH.columns(1, epochs.size())      = 0.0;
     157  HH.columns(epochs.size()+1, nPar) = 1.0;
     158  SymmetricMatrix dN; dN << HH.t() * HH;
     159  NN += dN;
     160 
     161  // Estimate Parameters
     162  // -------------------
     163  ColumnVector xx = NN.i() * bb;
     164
     165  // Compute clock residuals
     166  // -----------------------
     167  for (unsigned ie = 0; ie < epochs.size(); ie++) {
     168    // const bncTime&  tt     = epochs[ie]->_tt;
     169    map<t_prn, double>& dc = epochs[ie]->_dc;
     170    for (map<t_prn, double>::iterator it = dc.begin(); it != dc.end(); it++) {
     171      const t_prn& prn = it->first;
     172      int  index = epochs.size() + satIndex(clkSats, prn);
     173      dc[prn]                      = it->second - xx[ie] - xx[index];
     174      stat[prn.toString()]._offset = xx[index];
     175    }
     176  }
     177}
     178
    180179//// Program
    181180//////////////////////////////////////////////////////////////////////////////////
    182181//int main(int argc, char* argv[]) {
    183182//
    184 //  GPSS::t_sysout* sysout = new GPSS::t_sysout("", 0, false);
    185 //  GPSS::rtnet_core_log  = sysout->getSysoutCore();
     183//  t_sysout* sysout = new t_sysout("", 0, false);
     184//  rtnet_core_log  = sysout->getSysoutCore();
    186185//
    187186//  // Parse Input Options
     
    196195//  // Synchronize reading of two sp3 files
    197196//  // ------------------------------------
    198 //  vector<GPSS::t_prn> prnList;
    199 //  for (unsigned prn = 1; prn <= GPSS::t_prn::MAXPRN; prn++) {
    200 //    prnList.push_back(GPSS::t_prn(prn));
    201 //  }
    202 //  GPSS::t_sp3 in1(prnList); if (in1.assignFile(OPT["sp3File1"].c_str())) return 1;
    203 //  GPSS::t_sp3 in2(prnList); if (in2.assignFile(OPT["sp3File2"].c_str())) return 1;
     197//  vector<t_prn> prnList;
     198//  for (unsigned prn = 1; prn <= t_prn::MAXPRN; prn++) {
     199//    prnList.push_back(t_prn(prn));
     200//  }
     201//  t_sp3 in1(prnList); if (in1.assignFile(OPT["sp3File1"].c_str())) return 1;
     202//  t_sp3 in2(prnList); if (in2.assignFile(OPT["sp3File2"].c_str())) return 1;
    204203//
    205204//  vector<t_epoch*> epochs;
    206 //  set<GPSS::t_prn> clkSats;
     205//  set<t_prn> clkSats;
    207206//  while (true) {
    208207//    in1.readNextEpoch();
    209 //    GPSS::t_gpstime tt = in1.etime();
     208//    bncTime tt = in1.etime();
    210209//    if (!tt.valid()) {
    211210//      break;
     
    214213//      t_epoch* epo = new t_epoch; epo->_tt = tt;
    215214//      bool epochOK = false;
    216 //      for (unsigned iPrn = 1; iPrn <= GPSS::t_prn::MAXPRN; iPrn++) {
    217 //        GPSS::t_prn prn(iPrn);
     215//      for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN; iPrn++) {
     216//        t_prn prn(iPrn);
    218217//        ColumnVector xyz1(3), xyz2(3);
    219218//        ColumnVector vel1(3), vel2(3);
     
    261260//    }
    262261//    double dt = epoch->_tt - epoch2->_tt;
    263 //    map<GPSS::t_prn, ColumnVector>& dr   = epoch->_dr;
    264 //    map<GPSS::t_prn, ColumnVector>& xyz  = epoch->_xyz;
    265 //    map<GPSS::t_prn, ColumnVector>& xyz2 = epoch2->_xyz;
    266 //    for (map<GPSS::t_prn, ColumnVector>::const_iterator it = dr.begin(); it != dr.end(); it++) {
    267 //      const GPSS::t_prn&  prn = it->first;
     262//    map<t_prn, ColumnVector>& dr   = epoch->_dr;
     263//    map<t_prn, ColumnVector>& xyz  = epoch->_xyz;
     264//    map<t_prn, ColumnVector>& xyz2 = epoch2->_xyz;
     265//    for (map<t_prn, ColumnVector>::const_iterator it = dr.begin(); it != dr.end(); it++) {
     266//      const t_prn&  prn = it->first;
    268267//      if (xyz2.find(prn) != xyz2.end()) {
    269268//        const ColumnVector  dx = dr[prn];
     
    271270//        const ColumnVector& x2 = xyz2[prn];
    272271//        ColumnVector vel = (x1 - x2) / dt;
    273 //        GPSS::t_astro::XYZ_to_RSW(x1, vel, dx, dr[prn]);
     272//        t_astro::XYZ_to_RSW(x1, vel, dx, dr[prn]);
    274273//      }
    275274//      else {
     
    294293//  for (unsigned ii = 0; ii < epochs.size(); ii++) {
    295294//    const t_epoch* epo = epochs[ii];
    296 //    const map<GPSS::t_prn, ColumnVector>& dr = epochs[ii]->_dr;
    297 //    const map<GPSS::t_prn, double>&       dc = epochs[ii]->_dc;
    298 //    for (map<GPSS::t_prn, ColumnVector>::const_iterator it = dr.begin(); it != dr.end(); it++) {
    299 //      const GPSS::t_prn&  prn = it->first;
     295//    const map<t_prn, ColumnVector>& dr = epochs[ii]->_dr;
     296//    const map<t_prn, double>&       dc = epochs[ii]->_dc;
     297//    for (map<t_prn, ColumnVector>::const_iterator it = dr.begin(); it != dr.end(); it++) {
     298//      const t_prn&  prn = it->first;
    300299//      const ColumnVector& rao = it->second;
    301300//      cout << setprecision(6) << epo->_tt.mjddec() << ' ' << prn << ' '
  • trunk/BNC/src/orbComp/sp3Comp.h

    r6344 r6345  
    2727
    2828#include <map>
     29#include <set>
     30#include <vector>
     31#include <string>
    2932#include <QtCore>
    3033#include <newmat.h>
     
    7780  };
    7881
     82  int  satIndex(const std::set<t_prn>& clkSats, const t_prn& prn) const;
     83  void processClocks(const std::set<t_prn>& clkSats, std::vector<t_epoch*>& epochs,
     84                     std::map<std::string, t_stat>& stat) const;
     85
    7986  QStringList  _sp3FileNames;
    8087  QString      _logFileName;
Note: See TracChangeset for help on using the changeset viewer.