Changeset 6344 in ntrip


Ignore:
Timestamp:
Nov 26, 2014, 5:28:23 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

    r6342 r6344  
    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//
     180//// Program
     181//////////////////////////////////////////////////////////////////////////////////
     182//int main(int argc, char* argv[]) {
     183//
     184//  GPSS::t_sysout* sysout = new GPSS::t_sysout("", 0, false);
     185//  GPSS::rtnet_core_log  = sysout->getSysoutCore();
     186//
     187//  // Parse Input Options
     188//  // -------------------
     189//  map<string, string> OPT;
     190//  parseCmdLine(argc, argv, OPT);
     191//  if (OPT.find("sp3File1") == OPT.end() || OPT.find("sp3File2") == OPT.end()) {
     192//    cerr << "usage: sp3comp --sp3File1 <fileName> --sp3File2 <fileName> " << endl;
     193//    return 1;
     194//  }
     195//
     196//  // Synchronize reading of two sp3 files
     197//  // ------------------------------------
     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;
     204//
     205//  vector<t_epoch*> epochs;
     206//  set<GPSS::t_prn> clkSats;
     207//  while (true) {
     208//    in1.readNextEpoch();
     209//    GPSS::t_gpstime tt = in1.etime();
     210//    if (!tt.valid()) {
     211//      break;
     212//    }
     213//    if (in2.readEpoch(tt) == t_irc::success) {
     214//      t_epoch* epo = new t_epoch; epo->_tt = tt;
     215//      bool epochOK = false;
     216//      for (unsigned iPrn = 1; iPrn <= GPSS::t_prn::MAXPRN; iPrn++) {
     217//        GPSS::t_prn prn(iPrn);
     218//        ColumnVector xyz1(3), xyz2(3);
     219//        ColumnVector vel1(3), vel2(3);
     220//        double       clk1, clk2;
     221//        bool         posSet1, posSet2;
     222//        bool         clkSet1, clkSet2;
     223//        bool         velSet1, velSet2;
     224//        if (in1.position(prn, xyz1[0], xyz1[1], xyz1[2], posSet1, clk1, clkSet1,
     225//                         vel1[0], vel1[1], vel1[2], velSet1) == 0 &&
     226//            in2.position(prn, xyz2[0], xyz2[1], xyz2[2], posSet2, clk2, clkSet2,
     227//                         vel1[0], vel1[1], vel1[2], velSet1) == 0) {
     228//          if (posSet1 && posSet2) {
     229//            epochOK       = true;
     230//            epo->_dr[prn]  = xyz1 - xyz2;
     231//            epo->_xyz[prn] = xyz1;
     232//            if (clkSet1 && clkSet2) {
     233//              epo->_dc[prn] = (clk1 - clk2) * t_genConst::c;
     234//              clkSats.insert(prn);
     235//            }
     236//          }
     237//        }
     238//      }
     239//      if (epochOK) {
     240//        epochs.push_back(epo);
     241//      }
     242//      else {
     243//        delete epo;
     244//      }
     245//    }
     246//    if (in1.finished()) {
     247//      break;
     248//    }
     249//  }
     250//
     251//  // Transform xyz into radial, along-track, and out-of-plane
     252//  // --------------------------------------------------------
     253//  for (unsigned ie = 0; ie < epochs.size(); ie++) {
     254//    t_epoch* epoch  = epochs[ie];
     255//    t_epoch* epoch2 = 0;
     256//    if (ie == 0 && epochs.size() > 1) {
     257//      epoch2 = epochs[ie+1];
     258//    }
     259//    else {
     260//      epoch2 = epochs[ie-1];
     261//    }
     262//    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;
     268//      if (xyz2.find(prn) != xyz2.end()) {
     269//        const ColumnVector  dx = dr[prn];
     270//        const ColumnVector& x1 = xyz[prn];
     271//        const ColumnVector& x2 = xyz2[prn];
     272//        ColumnVector vel = (x1 - x2) / dt;
     273//        GPSS::t_astro::XYZ_to_RSW(x1, vel, dx, dr[prn]);
     274//      }
     275//      else {
     276//        cerr << "not found: " << prn << endl;
     277//      }
     278//    }
     279//  }
     280//
     281//  map<string, t_stat> stat;
     282//
     283//  // Estimate Clock Offsets
     284//  // ----------------------
     285//  processClocks(clkSats, epochs, stat);
     286//
     287//  // Print Residuals
     288//  // ---------------
     289//  const string all = "ZZZ";
     290//
     291//  cout.setf(ios::fixed);
     292//  cout << "!\n!  MJD       PRN  radial   along   out        clk    clkRed   iPRN"
     293//           "\n! ----------------------------------------------------------------\n";
     294//  for (unsigned ii = 0; ii < epochs.size(); ii++) {
     295//    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;
     300//      const ColumnVector& rao = it->second;
     301//      cout << setprecision(6) << epo->_tt.mjddec() << ' ' << prn << ' '
     302//           << setw(7) << setprecision(4) << rao[0] << ' '
     303//           << setw(7) << setprecision(4) << rao[1] << ' '
     304//           << setw(7) << setprecision(4) << rao[2] << "    ";
     305//      stat[prn]._rao += SP(rao, rao); // Schur product
     306//      stat[prn]._nr  += 1;
     307//      stat[all]._rao += SP(rao, rao);
     308//      stat[all]._nr  += 1;
     309//      if (dc.find(prn) != dc.end()) {
     310//        double clkRes    = dc.find(prn)->second;
     311//        double clkResRed = clkRes - it->second[0]; // clock minus radial component
     312//        cout << setw(7) << setprecision(4) << clkRes << ' '
     313//             << setw(7) << setprecision(4) << clkResRed;
     314//        stat[prn]._dc    += clkRes * clkRes;
     315//        stat[prn]._dcRed += clkResRed * clkResRed;
     316//        stat[prn]._nc    += 1;
     317//        stat[all]._dc    += clkRes * clkRes;
     318//        stat[all]._dcRed += clkResRed * clkResRed;
     319//        stat[all]._nc    += 1;
     320//      }
     321//      else {
     322//        cout << "  .       .    ";
     323//      }
     324//      cout << "    " << setw(2) << int(prn) << endl;
     325//    }
     326//    delete epo;
     327//  }
     328//
     329//  // Print Summary
     330//  // -------------
     331//  cout << "!\n! RMS:\n";
     332//  for (map<string, t_stat>::iterator it = stat.begin(); it != stat.end(); it++) {
     333//    const string& prn  = it->first;
     334//    t_stat&       stat = it->second;
     335//    if (stat._nr > 0) {
     336//      stat._rao[0] = sqrt(stat._rao[0] / stat._nr);
     337//      stat._rao[1] = sqrt(stat._rao[1] / stat._nr);
     338//      stat._rao[2] = sqrt(stat._rao[2] / stat._nr);
     339//      if (prn == all) {
     340//        cout << "!\n!          Total ";
     341//      }
     342//      else {
     343//        cout << "!            " << prn << ' ';
     344//      }
     345//      cout << setw(7) << setprecision(4) << stat._rao[0] << ' '
     346//           << setw(7) << setprecision(4) << stat._rao[1] << ' '
     347//           << setw(7) << setprecision(4) << stat._rao[2] << "    ";
     348//      if (stat._nc > 0) {
     349//        stat._dc    = sqrt(stat._dc / stat._nc);
     350//        stat._dcRed = sqrt(stat._dcRed / stat._nc);
     351//        cout << setw(7) << setprecision(4) << stat._dc << ' '
     352//             << setw(7) << setprecision(4) << stat._dcRed;
     353//        if (prn != all) {
     354//          cout << "    offset " << setw(7) << setprecision(4) << stat._offset;
     355//        }
     356//      }
     357//      else {
     358//        cout << "  .       .    ";
     359//      }
     360//      cout << endl;
     361//    }
     362//  }
     363//
     364//  return 0;
     365//}
  • trunk/BNC/src/orbComp/sp3Comp.h

    r6339 r6344  
    2626#define SP3COMP_H
    2727
     28#include <map>
    2829#include <QtCore>
     30#include <newmat.h>
     31#include "bnctime.h"
     32#include "t_prn.h"
    2933
    3034class t_sp3Comp : public QThread {
     
    4650 
    4751 private:
     52  class t_epoch {
     53   public:
     54    bncTime                  _tt;
     55    std::map<t_prn, ColumnVector> _dr;
     56    std::map<t_prn, ColumnVector> _xyz;
     57    std::map<t_prn, double>       _dc;
     58  };
     59
     60  class t_stat {
     61   public:
     62    t_stat() {
     63      _rao.ReSize(3);
     64      _rao    = 0.0;
     65      _dc     = 0.0;
     66      _dcRed  = 0.0;
     67      _offset = 0.0;
     68      _nr     = 0;
     69      _nc     = 0;
     70    }
     71    ColumnVector _rao;
     72    double       _dc;
     73    double       _dcRed;
     74    double       _offset;
     75    int          _nr;
     76    int          _nc;
     77  };
     78
    4879  QStringList  _sp3FileNames;
    4980  QString      _logFileName;
Note: See TracChangeset for help on using the changeset viewer.