Index: trunk/BNC/src/orbComp/sp3Comp.cpp
===================================================================
--- trunk/BNC/src/orbComp/sp3Comp.cpp	(revision 9865)
+++ trunk/BNC/src/orbComp/sp3Comp.cpp	(revision 10092)
@@ -217,13 +217,32 @@
   // Compute clock residuals
   // -----------------------
+  const string all = "ZZZ";
   for (unsigned ie = 0; ie < epochs.size(); ie++) {
-    map<t_prn, double>& dc = epochs[ie]->_dc;
+    map<t_prn, double>& dc    = epochs[ie]->_dc;
+    map<t_prn, double>& dcRed = epochs[ie]->_dcRed;
+    const map<t_prn, ColumnVector>& dr = epochs[ie]->_dr;
     for (map<t_prn, double>::iterator it = dc.begin(); it != dc.end(); it++) {
       const t_prn& prn = it->first;
       if (satIndex(clkSats, prn) != -1) {
         int  index = epochs.size() + satIndex(clkSats, prn);
-        dc[prn]                      = it->second - xx[ie] - xx[index];
+        dc[prn]    = it->second - xx[ie] - xx[index];
         stat[prn.toString()]._offset = xx[index];
-      }
+        if (dr.find(prn) != dr.end()){
+          dcRed[prn] = dc[prn] - dr.find(prn)->second[0]; // clock minus radial component
+          stat[prn.toString()]._dcRedMean += dcRed[prn];
+          stat[all           ]._dcRedMean += dcRed[prn];
+          stat[prn.toString()]._nc        += 1;
+          stat[all           ]._nc        += 1;
+        }
+      }
+    }
+  }
+
+  // Compute Clock Mean
+  // ------------------
+  for (map<string, t_stat>::iterator it = stat.begin(); it != stat.end(); it++) {
+    t_stat& stat = it->second;
+    if (stat._nc > 0) {
+      stat._dcRedMean = stat._dcRedMean / stat._nc;
     }
   }
@@ -342,9 +361,11 @@
   }
 
-  // Print Residuals
-  // ---------------
+  // Print epoch-wise Clock Residuals
+  // --------------------------------
   const string all = "ZZZ";
 
   out.setf(ios::fixed);
+  out << "!\n! Clock residuals and orbit differences in [m]\n"
+         "! ----------------------------------------------------------------------------\n";
   out << "!\n!  Epoch                PRN  radial   along   out        clk    clkRed   iPRN"
           "\n! ----------------------------------------------------------------------------\n";
@@ -353,4 +374,5 @@
     const map<t_prn, ColumnVector>& dr = epochs[ii]->_dr;
     const map<t_prn, double>&       dc = epochs[ii]->_dc;
+    const map<t_prn, double>&    dcRed = epochs[ii]->_dcRed;
     for (map<t_prn, ColumnVector>::const_iterator it = dr.begin(); it != dr.end(); it++) {
       const t_prn&  prn = it->first;
@@ -362,18 +384,20 @@
             << setw(7) << setprecision(4) << rao[2] << "    ";
         stat[prn.toString()]._rao += SP(rao, rao); // Schur product
+        stat[all           ]._rao += SP(rao, rao);
         stat[prn.toString()]._nr  += 1;
-        stat[all]._rao            += SP(rao, rao);
-        stat[all]._nr             += 1;
-        if (dc.find(prn) != dc.end()) {
+        stat[all           ]._nr  += 1;
+        if (dc.find(prn) != dc.end() && dcRed.find(prn) != dc.end()) {
           double clkRes    = dc.find(prn)->second;
-          double clkResRed = clkRes - it->second[0]; // clock minus radial component
+          double clkResRed = dcRed.find(prn)->second;
           out << setw(7) << setprecision(4) << clkRes << ' '
               << setw(7) << setprecision(4) << clkResRed;
-          stat[prn.toString()]._dc    += clkRes * clkRes;
-          stat[prn.toString()]._dcRed += clkResRed * clkResRed;
-          stat[prn.toString()]._nc    += 1;
-          stat[all]._dc               += clkRes * clkRes;
-          stat[all]._dcRed            += clkResRed * clkResRed;
-          stat[all]._nc               += 1;
+          stat[prn.toString()]._dcRMS     += clkRes * clkRes;
+          stat[all           ]._dcRMS     += clkRes * clkRes;
+          stat[prn.toString()]._dcRedRMS  += clkResRed * clkResRed;
+          stat[all           ]._dcRedRMS  += clkResRed * clkResRed;
+          stat[prn.toString()]._dcRedSig  += (clkResRed - stat[prn.toString()]._dcRedMean) *
+                                             (clkResRed - stat[prn.toString()]._dcRedMean);
+          stat[all           ]._dcRedSig  += (clkResRed - stat[all           ]._dcRedMean) *
+                                             (clkResRed - stat[all           ]._dcRedMean);
         }
         else {
@@ -388,7 +412,9 @@
   // Print Summary
   // -------------
-  out << "!\n! RMS[m]\n";
-  out << "!\n!    PRN  radial   along   out     nOrb    clk   clkRed   nClk    Offset"
-           "\n! ----------------------------------------------------------------------\n";
+  out << "!\n! Summary";
+  out << "\n! -----------------------------------------------------------------------------------------------------------------\n";
+  out << "!\n!     PRN   radialRMS   alongRMS    outRMS     3DRMS      nOrb    clkRMS    clkRedRMS   clkRedSig   nClk    Offset "
+          "\n!              [mm]       [mm]        [mm]      [mm]      [-]      [ns]        [ns]        [ns]      [-]     [ns]  "
+          "\n! -----------------------------------------------------------------------------------------------------------------\n";
   for (map<string, t_stat>::iterator it = stat.begin(); it != stat.end(); it++) {
     const string& prn  = it->first;
@@ -398,22 +424,28 @@
       stat._rao[1] = sqrt(stat._rao[1] / stat._nr);
       stat._rao[2] = sqrt(stat._rao[2] / stat._nr);
+      stat._rao3DRMS = stat._rao.NormFrobenius();
       if (prn == all) {
-        out << "!\n!  Total ";
+        out << "!\n!   Total ";
       }
       else {
-        out << "!    " << prn << ' ';
-      }
-      out << setw(7) << setprecision(4) << stat._rao[0] << ' '
-          << setw(7) << setprecision(4) << stat._rao[1] << ' '
-          << setw(7) << setprecision(4) << stat._rao[2] << ' '
-          << setw(6) << stat._nr << " ";
+        out << "!     " << prn << ' ';
+      }
+      // orbit values in millimeters
+      out << setw(10) << setprecision(1) << stat._rao[0]   * 1e3 << ' '
+          << setw(10) << setprecision(1) << stat._rao[1]   * 1e3 << ' '
+          << setw(10) << setprecision(1) << stat._rao[2]   * 1e3 << ' '
+          << setw(10) << setprecision(1) << stat._rao3DRMS * 1e3 << ' '
+          << setw( 7) << stat._nr << " ";
       if (stat._nc > 0) {
-        stat._dc    = sqrt(stat._dc / stat._nc);
-        stat._dcRed = sqrt(stat._dcRed / stat._nc);
-        out << setw(7) << setprecision(4) << stat._dc << ' '
-            << setw(7) << setprecision(4) << stat._dcRed << ' '
-            << setw(6) << stat._nc << " ";
+        stat._dcRMS    = sqrt(stat._dcRMS    / stat._nc);
+        stat._dcRedRMS = sqrt(stat._dcRedRMS / stat._nc);
+        stat._dcRedSig = sqrt(stat._dcRedSig / stat._nc);
+        // clock values in nano seconds
+        out << setw(10) << setprecision(2) << stat._dcRMS    / t_CST::c * 1e9 << ' '
+            << setw(10) << setprecision(2) << stat._dcRedRMS / t_CST::c * 1e9 << ' '
+            << setw(10) << setprecision(2) << stat._dcRedSig / t_CST::c * 1e9 << ' '
+            << setw( 9) << stat._nc << " ";
         if (prn != all) {
-          out << setw(9) << setprecision(4) << stat._offset;
+          out << setw(9) << setprecision(2) << stat._offset / t_CST::c * 1e9;
         }
       }
