Index: /trunk/BNC/src/PPP/pppClient.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppClient.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppClient.cpp	(revision 8956)
@@ -160,4 +160,5 @@
   // -------
   epoTime.reset();
+  clearObs();
 
   // Create vector of valid observations
@@ -174,48 +175,4 @@
       }
     }
-  }
-
-  // (re)set reference satellites per system if required
-  // ---------------------------------------------------
-  if (_opt->_refSatRequired) {
-    // reference satellite definition per system
-    for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
-      char system = _opt->systems()[iSys];
-      bool refSatDefined = false;
-      t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
-      for (unsigned ii = 0; ii < obsVector.size(); ii++) {
-        const t_pppSatObs* satObs = obsVector.at(ii);
-        // reference satellite is unchanged
-        if      (!_obsPool->refSatChangeRequired() && refSat->prn() == satObs->prn()) {
-          refSatDefined = true;
-          obsVector[ii]->setAsReference();
-          refSat->setStatus(t_pppRefSat::unchanged);
-        }
-        // reference satellite has changed
-        else if ( _obsPool->refSatChangeRequired() && refSat->prn() != satObs->prn()) {
-          if (satObs->prn().system() == system) {
-            refSatDefined = true;
-            obsVector[ii]->setAsReference();
-            refSat->setStatus(t_pppRefSat::changed);
-            refSat->setPrn(satObs->prn());
-          }
-        }
-        if (refSatDefined) {
-          break;
-        }
-      }
-      // reference satellite has to be initialized
-      if (!refSatDefined) {
-        for (unsigned ii = 0; ii < obsVector.size(); ii++) {
-          const t_pppSatObs* satObs = obsVector.at(ii);
-          if (satObs->prn().system() == system) {
-            obsVector[ii]->setAsReference();
-            refSat->setStatus(t_pppRefSat::initialized);
-            refSat->setPrn(satObs->prn());
-          }
-        }
-      }
-    }
-    _obsPool->setRefSatChangeRequired(false);
   }
 
@@ -497,9 +454,4 @@
         satObs->eleSat() >= _opt->_minEle &&
         modelSetup == success) {
-      if (satObs->isReference() && _opt->_pseudoObsIono) {
-        char system = satObs->prn().system();
-        t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
-        refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
-      }
       ++it;
     }
@@ -517,4 +469,5 @@
 void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
 
+  _historicalRefSats.clear();
   try {
     initOutput(output);
@@ -524,4 +477,9 @@
     do {
       num++;
+      if (num == 1) {
+        LOG << "\nPPP of Epoch ";
+        if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
+        LOG << "\n---------------------------------------------------------------\n";
+      }
 
       // Prepare Observations of the Rover
@@ -530,8 +488,4 @@
         return finish(failure);
       }
-
-      LOG << "\nPPP of Epoch ";
-      if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
-      LOG << "\n---------------------------------------------------------------\n";
 
       for (int iter = 1; iter <= 2; iter++) {
@@ -548,13 +502,6 @@
       _offGG = cmpOffGG(_obsRover);
 
-      // Prepare Pseudo Observations of the Rover
-      // ----------------------------------------
-      _pseudoObsIono = preparePseudoObs(_obsRover);
-      if (int(_obsRover.size()) < _opt->_minObs) {
-        LOG << "t_pppClient::processEpoch not enough observations" << endl;
-        return finish(failure);
-      }
-
       if (_opt->_refSatRequired) {
+        setRefSatellites(_obsRover);
         LOG.setf(ios::fixed);
         QMapIterator<char, t_pppRefSat*> it(_obsPool->getRefSatMap());
@@ -563,12 +510,29 @@
           char   sys = it.key();
           string prn = it.value()->prn().toString();
+          if (num == 1) {
+            LOG << "set   ";
+          }
+          else {
+            LOG << "reset ";
+          }
           LOG << string(_epoTimeRover) << " REFSAT  " << sys << ": " << prn << endl;
         }
       }
+
+
+      // Prepare Pseudo Observations of the Rover
+      // ----------------------------------------
+      _pseudoObsIono = preparePseudoObs(_obsRover);
+
+      if (int(_obsRover.size()) < _opt->_minObs) {
+        LOG << "t_pppClient::processEpoch not enough observations" << endl;
+        return finish(failure);
+      }
+
 
       // Store last epoch of data
       // ------------------------
-      //_obsRover.resize(2);
       _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
+      _obsPool->setHistoricalRefSatList(_historicalRefSats);
 
       // Process Epoch in Filter
@@ -582,14 +546,15 @@
       if (_obsPool->refSatChangeRequired()) {
         epochReProcessing = true;
+        _obsPool->deleteLastEpoch();
+        QMapIterator<char, t_pppRefSat*> it(_obsPool->getRefSatMap());
+        while (it.hasNext()) {
+          it.next();
+          _historicalRefSats.append(it.value()->prn());
+        }
       }
       else {
         epochReProcessing = false;
-      }
-      // Datum transformation required?
-      // ------------------------------
-      if (num > 1 && epochReProcessing) {
-        _filter->datumTransformation();
-      }
-
+
+      }
     } while (epochReProcessing);
   }
@@ -694,4 +659,59 @@
 //
 //////////////////////////////////////////////////////////////////////////////
+void t_pppClient::setRefSatellites(std::vector<t_pppSatObs*>& obsVector) {
+
+  // reference satellite definition per system
+  for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
+    char system = _opt->systems()[iSys];
+    bool refSatDefined = false;
+    t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
+    for (unsigned ii = 0; ii < obsVector.size(); ii++) {
+      t_pppSatObs* satObs = obsVector.at(ii);
+      if (satObs->eleSat() < _opt->_minEle) {continue;}
+      // reference satellite is unchanged
+      if      (!_obsPool->refSatChangeRequired() &&  refSat->prn() == satObs->prn()) {
+        refSatDefined = true;
+        obsVector[ii]->setAsReference();
+      }
+      // reference satellite has changed
+      else if ( _obsPool->refSatChangeRequired() && refSat->prn() != satObs->prn() && !_historicalRefSats.contains(satObs->prn())) {
+        if (satObs->prn().system() == system) {
+          refSatDefined = true;
+          obsVector[ii]->setAsReference();
+          refSat->setPrn(satObs->prn());
+        }
+      }
+      if (refSatDefined) {
+        if (OPT->_pseudoObsIono) {
+          refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
+        }
+        break;
+      }
+    }
+    // reference satellite has to be initialized
+    if (!refSatDefined) {
+      for (unsigned ii = 0; ii < obsVector.size(); ii++) {
+        t_pppSatObs* satObs = obsVector.at(ii);
+        if (satObs->eleSat() < _opt->_minEle) {
+          continue;
+        }
+        if (satObs->prn().system() == system) {
+          obsVector[ii]->setAsReference();
+          refSat->setPrn(satObs->prn());
+          if (OPT->_pseudoObsIono) {
+            refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
+          }
+          refSatDefined = true;
+          break;
+        }
+      }
+    }
+  }
+  _obsPool->setRefSatChangeRequired(false);
+
+}
+
+//
+//////////////////////////////////////////////////////////////////////////////
 void t_pppClient::reset() {
 
Index: /trunk/BNC/src/PPP/pppClient.h
===================================================================
--- /trunk/BNC/src/PPP/pppClient.h	(revision 8955)
+++ /trunk/BNC/src/PPP/pppClient.h	(revision 8956)
@@ -60,4 +60,5 @@
                     ColumnVector& xyzc, bool print);
   double cmpOffGG(std::vector<t_pppSatObs*>& obsVector);
+  void setRefSatellites(std::vector<t_pppSatObs*>& obsVector);
 
   t_output*                 _output;
@@ -74,4 +75,5 @@
   t_tides*                  _tides;
   bool                      _pseudoObsIono;
+  QList<t_prn>              _historicalRefSats;
 };
 
Index: /trunk/BNC/src/PPP/pppFilter.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppFilter.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppFilter.cpp	(revision 8956)
@@ -83,5 +83,5 @@
   // Set Parameters
   // --------------
-  _parlist->set(_epoTime, allObs);
+  _parlist->set(_epoTime, allObs, _obsPool->getRefSatMap());
   const vector<t_pppParam*>& params = _parlist->params();
 
@@ -90,4 +90,5 @@
   ColumnVector    xFltOld = _xFlt;
   SymmetricMatrix QFltOld = _QFlt;
+
   _QFlt.ReSize(_parlist->nPar()); _QFlt = 0.0;
   _xFlt.ReSize(_parlist->nPar()); _xFlt = 0.0;
@@ -114,4 +115,20 @@
   predictCovCrdPart(QFltOld);
 
+  // Init Datum Trafo
+  // ----------------------------------------
+  if ((OPT->_obsModelType == OPT->DCMcodeBias ||
+       OPT->_obsModelType == OPT->DCMphaseBias) &&
+      (_numEpoProcessing == 1)) {
+    _numAllUsedLCs = 0;
+    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
+      char system = OPT->systems()[iSys];
+      _numAllUsedLCs += OPT->LCs(system).size();
+      if (OPT->_pseudoObsIono && !epoch->pseudoObsIono()) {
+        _numAllUsedLCs -= 1;  // GIM not used
+      }
+    }
+    int maxObs = allObs.size() * _numAllUsedLCs;
+    _datumTrafo->initAA(maxObs, _parlist->nPar());
+  }
 
   // Pre-Process Satellite Systems separately
@@ -121,13 +138,12 @@
       OPT->_obsModelType == OPT->DCMphaseBias) {
     preProcessing = true;
-    _numAllUsedLCs = 0;
     for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
+      (iSys) ? _datumTrafo->setFirstSystem(false) : _datumTrafo->setFirstSystem(true);
       char system = OPT->systems()[iSys];
-      _numAllUsedLCs += OPT->LCs(system).size();
-      if (OPT->_pseudoObsIono && !epoch->pseudoObsIono()) {
-        _numAllUsedLCs -= 1;  // GIM not used
-      }
       if (OPT->_refSatRequired) {
         _refPrn = (_obsPool->getRefSatMapElement(system))->prn();
+        if (_obsPool->hasHistoricalRefSat(_refPrn)) {
+          return failure;
+        }
       }
       vector<t_pppSatObs*> obsVector;
@@ -142,9 +158,15 @@
       }
     }
-  }
-
-  if (_numEpoProcessing == 1) {
-    int maxObs = allObs.size() * _numAllUsedLCs;
-    _datumTrafo->initAA(maxObs, _parlist->nPar());
+    // refSat change required?
+    // -----------------------
+    if (_obsPool->refSatChangeRequired()) {
+      _xFlt = xFltOld;
+      _QFlt = QFltOld;
+      return success;
+    }
+    else if (!_obsPool->refSatChangeRequired() &&
+             _numEpoProcessing > 1) {
+      datumTransformation(xFltOld, QFltOld);
+    }
   }
 
@@ -154,6 +176,4 @@
   for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
     char system = OPT->systems()[iSys];
-    (iSys) ? _datumTrafo->setFirstSystem(false) :
-    		 _datumTrafo->setFirstSystem(true);
     if (OPT->_refSatRequired) {
       _refPrn = (_obsPool->getRefSatMapElement(system))->prn();
@@ -174,17 +194,9 @@
   }
 
-  // refSat change required?
-  // -----------------------
-  if (_obsPool->refSatChangeRequired()) {
-    _xFlt = xFltOld;
-    _QFlt = QFltOld;
-  }
   // close epoch processing
   // ----------------------
-  else {
-    cmpDOP(allObs);
-    _parlist->printResult(_epoTime, _QFlt, _xFlt);
-    _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
-  }
+  cmpDOP(allObs);
+  _parlist->printResult(_epoTime, _QFlt, _xFlt);
+  _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
 
   return success;
@@ -198,9 +210,9 @@
                                  bool pseudoObsIonoAvailable,
                                  bool preProcessing) {
-  qDebug() << "======t_pppFilter::processSystem=======";
   LOG.setf(ios::fixed);
 
   // Detect Cycle Slips
   // ------------------
+
   if (detectCycleSlips(LCs, obsVector, refPrn, preProcessing) != success) {
     return failure;
@@ -221,11 +233,8 @@
     maxObs -= 1;
   }
-  qDebug() << "par.size()      : " << _parlist->nPar() << " LCs.size(): " << usedLCs;
-  qDebug() << "obsVector.size(): " << obsVector.size() << " maxObs    : " << maxObs;
 
   // Outlier Detection Loop
   // ----------------------
   for (unsigned iOutlier = 0; iOutlier < maxObs; iOutlier++) {
-    qDebug() << "iOutlier: " << iOutlier;
 
     if (iOutlier > 0) {
@@ -236,16 +245,7 @@
     // First-Design Matrix, Terms Observed-Computed, Weight Matrix
     // -----------------------------------------------------------
-    qDebug() << "A(" << maxObs << "," << _parlist->nPar() << ")";
     Matrix                AA(maxObs, _parlist->nPar());
     ColumnVector          ll(maxObs);
     DiagonalMatrix        PP(maxObs); PP = 0.0;
-
-    // TETSPLOT
-    for (unsigned iPar = 0; iPar < params.size(); iPar++) {
-      const t_pppParam* par = params[iPar];
-      cout << "  " << par->toString() <<endl;
-    }
-    cout << endl;
-    //END TETSPLOT
 
     int iObs = -1;
@@ -253,5 +253,5 @@
     vector<t_lc::type>   usedTypes;
     for (unsigned ii = 0; ii < obsVector.size(); ii++) {
-      t_pppSatObs* obs = obsVector[ii]; qDebug() << "SATELLITE: " << obs->prn().toString().c_str() << "isRef: " << obs->isReference();
+      t_pppSatObs* obs = obsVector[ii];
       if (!obs->outlier()) {
         for (unsigned jj = 0; jj < usedLCs; jj++) {
@@ -263,21 +263,19 @@
           for (unsigned iPar = 0; iPar < params.size(); iPar++) {
             const t_pppParam* par = params[iPar];
-            AA[iObs][iPar] = par->partial(_epoTime, obs, tLC);
-            cout << setw(10) << par->partial(_epoTime, obs, tLC);
-          }
-          cout << endl;
+            AA[iObs][iPar] = par->partial(_epoTime, obs, tLC, refPrn);
+          }
           ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs+1));
           PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC));
-          //qDebug() << "ll[iObs]: " << ll[iObs];
-          //qDebug() << "PP[iObs]: " << PP[iObs];
-        }
-      }
-    }
-
-    if ((!preProcessing) &&
-       (OPT->_obsModelType == OPT->DCMcodeBias ||
-        OPT->_obsModelType == OPT->DCMphaseBias)) {
+        }
+      }
+    }
+
+    if ((preProcessing && ! iOutlier) &&
+        (OPT->_obsModelType == OPT->DCMcodeBias || OPT->_obsModelType == OPT->DCMphaseBias)) {
    	  _datumTrafo->updateIndices(maxObs);
       _datumTrafo->prepareAA(AA, _numEpoProcessing, _parlist->nPar());
+      if (_obsPool->refSatChangeRequired()) { // from detectCycleSlips()
+        return success;
+      }
     }
 
@@ -331,23 +329,25 @@
         }
       }
-      if      (par && preProcessing) {
-        if (par->prn() == refPrn) {
+      if (preProcessing) {
+        if (par && obs->prn() == refPrn) {
           _obsPool->setRefSatChangeRequired(true);
-        }
-      }
-      else if (par && !preProcessing) {
-        if (par->ambResetCandidate()) {
-          resetAmb(par->prn(), obsVector, &QSav, &xSav);
+          break;
+        }
+      }
+      else {
+        if (par) {
+          if (par->ambResetCandidate() || _obsPool->hasHistoricalRefSat(par->prn())) {
+            resetAmb(par->prn(), obsVector, &QSav, &xSav);
+          }
+          else {
+            par->setAmbResetCandidate();
+            obs->setOutlier();
+          }
         }
         else {
-          par->setAmbResetCandidate();
           obs->setOutlier();
         }
       }
-      else if (!par && !preProcessing){
-        obs->setOutlier();
-      }
-    }
-
+    }
     // Print Residuals
     // ---------------
@@ -381,8 +381,15 @@
                                     const t_prn& refPrn,
                                     bool preProcessing) {
-
-  const double            SLIP       = 20.0;  // slip threshold
+  if (_obsPool->hasHistoricalRefSat(refPrn)) {
+    return success;
+  }
+
+  double                  SLIP       = 20.0;  // slip threshold
   string                  epoTimeStr = string(_epoTime);
   const vector<t_pppParam*>& params  = _parlist->params();
+
+  if (preProcessing) {
+    SLIP += 10.0;
+  }
 
   for (unsigned ii = 0; ii < LCs.size(); ii++) {
@@ -391,4 +398,6 @@
       for (unsigned iObs = 0; iObs < obsVector.size(); iObs++) {
         const t_pppSatObs* obs = obsVector[iObs];
+
+        if (preProcessing && obs->prn() != refPrn) {continue;}
 
         // Check set Slips and Jump Counters
@@ -405,5 +414,7 @@
           slip = true;
         }
-        _slips[obs->prn()]._obsSlipCounter = obs->slipCounter();
+        if (!preProcessing) {
+          _slips[obs->prn()]._obsSlipCounter = obs->slipCounter();
+        }
 
         if (_slips[obs->prn()]._biasJumpCounter != -1 &&
@@ -412,12 +423,12 @@
           slip = true;
         }
-
+        if (!preProcessing) {
+          _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter();
+        }
         // Slip Set
         // --------
         if (slip) {
           if (preProcessing) {
-            if (obs->prn() == refPrn) {
-              _obsPool->setRefSatChangeRequired(true);
-            }
+            _obsPool->setRefSatChangeRequired(true);
           }
           else {
@@ -431,13 +442,12 @@
           for (unsigned iPar = 0; iPar < params.size(); iPar++) {
             const t_pppParam* par = params[iPar];
-            AA[iPar] = par->partial(_epoTime, obs, tLC);
-          }
+            AA[iPar] = par->partial(_epoTime, obs, tLC, refPrn);
+          }
+
           double ll = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA);
           double vv = DotProduct(AA, _xFlt) - ll;
           if (fabs(vv) > SLIP) {
             if (preProcessing) {
-              if (obs->prn() == refPrn) {
-                _obsPool->setRefSatChangeRequired(true);
-              }
+              _obsPool->setRefSatChangeRequired(true);
             }
             else {
@@ -451,5 +461,4 @@
     }
   }
-
   return success;
 }
@@ -459,4 +468,5 @@
 t_irc t_pppFilter::resetAmb(t_prn prn, const vector<t_pppSatObs*>& obsVector,
                             SymmetricMatrix* QSav, ColumnVector* xSav) {
+
   t_irc irc = failure;
   vector<t_pppParam*>& params = _parlist->params();
@@ -504,9 +514,14 @@
     for (unsigned ii = 0; ii < obsVector.size(); ii++) {
       t_pppSatObs* obs = obsVector[ii];
+      char system = obs->prn().system();
+      t_prn refPrn = t_prn();
+      if (OPT->_refSatRequired) {
+        refPrn = _obsPool->getRefSatMapElement(system)->prn();
+      }
       if (obs->isValid() && !obs->outlier()) {
         ++_numSat;
         for (unsigned iPar = 0; iPar < numPar; iPar++) {
           const t_pppParam* par = _parlist->params()[iPar];
-          AA[_numSat-1][iPar] = par->partial(_epoTime, obs, t_lc::c1);
+          AA[_numSat-1][iPar] = par->partial(_epoTime, obs, t_lc::c1, refPrn);
         }
       }
@@ -571,6 +586,28 @@
 // Compute datum transformation
 ////////////////////////////////////////////////////////////////////////////
-void t_pppFilter::datumTransformation(void) {
-  _QFlt = _datumTrafo->varCov(Q());
-}
-
+void t_pppFilter::datumTransformation(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld) {
+
+  Matrix D21 = _datumTrafo->computeTrafoMatrix();
+  _QFlt << D21 * QFltOld * D21.t();
+  _xFlt = D21 * xFltOld;
+}
+
+
+// Reset Ambiguity Parameter (cycle slip)
+////////////////////////////////////////////////////////////////////////////
+t_irc t_pppFilter::addInfiniteNoise(t_pppParam::e_type para) {
+  t_irc irc = failure;
+  vector<t_pppParam*>& params = _parlist->params();
+  for (unsigned iPar = 0; iPar < params.size(); iPar++) {
+    t_pppParam* par = params[iPar];
+    if (par->type() == para) {
+      int ind = par->indexNew();
+      if (ind < 0) {
+        return irc;
+      }
+      _QFlt(ind+1,ind+1) += par->sigma0() * par->sigma0();
+      irc = success;
+    }
+  }
+  return irc;
+}
Index: /trunk/BNC/src/PPP/pppFilter.h
===================================================================
--- /trunk/BNC/src/PPP/pppFilter.h	(revision 8955)
+++ /trunk/BNC/src/PPP/pppFilter.h	(revision 8956)
@@ -22,5 +22,5 @@
   t_irc processEpoch(int num);
 
-  void datumTransformation();
+  void datumTransformation(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld);
 
   const ColumnVector&    x() const {return _xFlt;}
@@ -75,5 +75,5 @@
   };
 
-  class t_datumTrafo{
+  class t_datumTrafo {
   public:
     t_datumTrafo () {initIndices();}
@@ -82,5 +82,5 @@
     bool firstSystem() {return _firstSys;}
     void updateIndices(int maxObs) {
-      if (_firstSys) {
+      if (firstSystem()) {
         initIndices();
       }
@@ -94,14 +94,24 @@
       _AA2.ReSize(maxObs, numPar); _AA2 = 0.0;
     }
-    void prepareAA(Matrix& AA, int _numEpoProcessing, int nPar) {
-      Matrix& Prep = _AA2;
-      if (_numEpoProcessing == 1) {
-        Prep = _AA1;
+    void prepareAA(const Matrix& AA, int numEpoProcessing, int nPar) {
+      Matrix* Prep = &_AA2;
+      if (numEpoProcessing == 1) {
+        Prep = &_AA1;
       }
-      Prep.SubMatrix(_firstRow, _lastRow, 1, nPar) = AA;
+      Prep->SubMatrix(_firstRow, _lastRow, 1, nPar) << AA;
     }
-    Matrix varCov(const SymmetricMatrix& QFlt) {
+
+    Matrix computeTrafoMatrix() {
       Matrix D21 = (_AA2.t() * _AA2).i() * _AA2.t() * _AA1;
-      return D21 * QFlt * D21.t();
+      return D21;
+    }
+
+    static void printMatrix(const Matrix& X, int nRow, int nCol) {
+      for (int rr = 0; rr < nRow; rr++) {
+        for (int cc = 0; cc < nCol; cc++) {
+          cout << setw(7) << setprecision(4) << X[rr][cc] << " ";
+        }
+        cout << endl;      }
+      cout << endl;
     }
     int     _firstRow;
@@ -130,4 +140,6 @@
   void predictCovCrdPart(const SymmetricMatrix& QFltOld);
 
+  t_irc addInfiniteNoise(t_pppParam::e_type para);
+
   bncTime         _epoTime;
   t_pppParlist*   _parlist;
Index: /trunk/BNC/src/PPP/pppObsPool.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppObsPool.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppObsPool.cpp	(revision 8956)
@@ -100,9 +100,6 @@
   const unsigned MAXSIZE = 2;
 
-  if (refSatChangeRequired()) {
-    delete _epochs.back();
-    _epochs.pop_back();
-  }
-  _epochs.push_back(new t_epoch(epoTime, obsVector,pseudoObsIono));
+  _epochs.push_back(new t_epoch(epoTime, obsVector, pseudoObsIono));
+
   if (_epochs.size() > MAXSIZE) {
     delete _epochs.front();
@@ -110,2 +107,12 @@
   }
 }
+
+//
+/////////////////////////////////////////////////////////////////////////////
+void t_pppObsPool::deleteLastEpoch() {
+
+  if (!_epochs.empty()) {
+    delete _epochs.back();
+    _epochs.pop_back();
+  }
+}
Index: /trunk/BNC/src/PPP/pppObsPool.h
===================================================================
--- /trunk/BNC/src/PPP/pppObsPool.h	(revision 8955)
+++ /trunk/BNC/src/PPP/pppObsPool.h	(revision 8956)
@@ -38,4 +38,6 @@
                 bool pseudoObs);
 
+  void deleteLastEpoch();
+
   const t_satCodeBias* satCodeBias(const t_prn& prn) const {
     return _satCodeBiases[prn.toInt()];
@@ -76,4 +78,8 @@
   bool refSatChangeRequired() {return _refSatChangeRequired;}
 
+  void setHistoricalRefSatList(QList<t_prn>& historicalRefSats) {_historicalRefSats = historicalRefSats;}
+
+  bool hasHistoricalRefSat(t_prn prn) {return _historicalRefSats.contains(prn);}
+
  private:
   t_satCodeBias*           _satCodeBiases[t_prn::MAXPRN+1];
@@ -83,4 +89,5 @@
   QMap<char, t_pppRefSat*> _refSatMap;
   bool                     _refSatChangeRequired;
+  QList<t_prn>             _historicalRefSats;
 };
 
Index: /trunk/BNC/src/PPP/pppParlist.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppParlist.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppParlist.cpp	(revision 8956)
@@ -123,5 +123,5 @@
 ////////////////////////////////////////////////////////////////////////////
 double t_pppParam::partial(const bncTime& /* epoTime */, const t_pppSatObs* obs,
-                           const t_lc::type& tLC) const {//qDebug() << "t_pppParam::partial: " << tLC;
+                           const t_lc::type& tLC, const t_prn refPrn) const {
 
   // Special Case - Melbourne-Wuebbena
@@ -184,5 +184,5 @@
     return  1.0 / sin(obs->eleSat());
   case ion:
-//    qDebug() << "refPrn: " << _refPrn.toString().c_str();
+
     if (obs->prn() == _prn) {
       if      (tLC == t_lc::c1) {
@@ -202,5 +202,5 @@
       }
     }
-    if (tLC == t_lc::GIM && _prn == _refPrn) {
+    if (tLC == t_lc::GIM && _prn == refPrn) {
       return  1.0;
     }
@@ -296,5 +296,6 @@
 ////////////////////////////////////////////////////////////////////////////
 t_irc t_pppParlist::set(const bncTime& epoTime,
-    const std::vector<t_pppSatObs*>& obsVector) {
+    const std::vector<t_pppSatObs*>& obsVector,
+    const QMap<char, t_pppRefSat*>& refSatMap) {
 
   // Remove some Parameters
@@ -310,9 +311,19 @@
     }
 
-    else if (par->type() == t_pppParam::amb ||
-             par->type() == t_pppParam::crdX ||
+    else if (par->type() == t_pppParam::crdX ||
              par->type() == t_pppParam::crdY ||
              par->type() == t_pppParam::crdZ) {
       if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
+        remove = true;
+      }
+    }
+    else if (par->type() == t_pppParam::amb) {
+      char system = par->prn().system();
+      t_prn refPrn = t_prn();
+      if (OPT->_refSatRequired) {
+        refPrn = (refSatMap[system])->prn();
+      }
+      if ((par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) ||
+          ( refPrn == par->prn())) {
         remove = true;
       }
Index: /trunk/BNC/src/PPP/pppParlist.h
===================================================================
--- /trunk/BNC/src/PPP/pppParlist.h	(revision 8955)
+++ /trunk/BNC/src/PPP/pppParlist.h	(revision 8956)
@@ -7,4 +7,5 @@
 #include "t_prn.h"
 #include "bnctime.h"
+#include "pppRefSat.h"
 
 namespace BNC_PPP {
@@ -23,5 +24,6 @@
   e_type type() const {return _type;}
   double x0()  const {return _x0;}
-  double partial(const bncTime& epoTime, const t_pppSatObs* obs, const t_lc::type& tLC) const;
+  double partial(const bncTime& epoTime, const t_pppSatObs* obs,
+                 const t_lc::type& tLC, const t_prn refPrn) const;
   bool   epoSpec() const {return _epoSpec;}
   bool   isEqual(const t_pppParam* par2) const {
@@ -51,5 +53,4 @@
   unsigned ambNumEpo() const           {return _ambInfo ? _ambInfo->_numEpo : 0;}
   void     stepAmbNumEpo()             {if (_ambInfo) _ambInfo->_numEpo += 1;}
-  void     setRefPrn(t_prn prn)        {_refPrn = prn;}
 
   static bool sortFunction(const t_pppParam* p1, const t_pppParam* p2) {
@@ -81,5 +82,4 @@
   e_type       _type;
   t_prn        _prn;
-  t_prn        _refPrn;
   t_lc::type   _tLC;
   double       _x0;
@@ -99,5 +99,6 @@
   ~t_pppParlist();
 
-  t_irc set(const bncTime& epoTime, const std::vector<t_pppSatObs*>& obsVector);
+  t_irc set(const bncTime& epoTime, const std::vector<t_pppSatObs*>& obsVector,
+            const QMap<char, t_pppRefSat*>& refSatMap);
   unsigned nPar() const {return _params.size();}
   const std::vector<t_pppParam*>& params() const {return _params;}
Index: /trunk/BNC/src/PPP/pppRefSat.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppRefSat.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppRefSat.cpp	(revision 8956)
@@ -14,5 +14,4 @@
 ////////////////////////////////////////////////////////////////////////////
 t_pppRefSat::t_pppRefSat() {
-  _status     = undefined;
   _prn        = t_prn();
   _stecValue  = 0.0;
Index: /trunk/BNC/src/PPP/pppRefSat.h
===================================================================
--- /trunk/BNC/src/PPP/pppRefSat.h	(revision 8955)
+++ /trunk/BNC/src/PPP/pppRefSat.h	(revision 8956)
@@ -17,7 +17,4 @@
   t_pppRefSat ();
   ~t_pppRefSat();
-  enum     e_status {undefined, initialized, changed, unchanged};// ev. wieder löschen
-  e_status status() const {return _status;}
-  void     setStatus(e_status status) {_status = status;}
   t_prn    prn() {return _prn;}
   void     setPrn(t_prn prn) {_prn = prn;}
@@ -25,5 +22,4 @@
   void     setStecValue(double stecValue) {_stecValue = stecValue;}
 private:
-  e_status _status;
   t_prn    _prn;
   double   _stecValue;
Index: /trunk/BNC/src/PPP/pppSatObs.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppSatObs.cpp	(revision 8955)
+++ /trunk/BNC/src/PPP/pppSatObs.cpp	(revision 8956)
@@ -342,5 +342,5 @@
   }
   if (tLC == t_lc::GIM) {
-    retVal = 3 * (OPT->_sigmaGIMdiff * OPT->_sigmaGIMdiff);
+    retVal = 3.0 * OPT->_sigmaGIMdiff * OPT->_sigmaGIMdiff;
   }
   return sqrt(retVal);
@@ -495,5 +495,5 @@
   _model._set = true;
 
-  printModel();
+  //printModel();
 
   return success;
@@ -503,10 +503,11 @@
 ////////////////////////////////////////////////////////////////////////////
 void t_pppSatObs::printModel() const {
-// TODO: cout should be LOG
-  cout.setf(ios::fixed);
-  cout << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
-       << "======================= " << endl
-       << "PPP STRATEGY  : " <<  OPT->_obsmodelTypeStr.at((int)OPT->_obsModelType).toLocal8Bit().constData()
-       <<  ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "")  <<  endl
+
+  LOG.setf(ios::fixed);
+  LOG << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "")
+
+      << "======================= " << endl
+      << "PPP STRATEGY  : " <<  OPT->_obsmodelTypeStr.at((int)OPT->_obsModelType).toLocal8Bit().constData()
+      <<  ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "")  <<  endl
       << "RHO           : " << setw(12) << setprecision(3) << _model._rho              << endl
       << "ELE           : " << setw(12) << setprecision(3) << _model._eleSat * RHO_DEG << endl
@@ -528,5 +529,5 @@
       string frqStr = t_frequency::toString(t_frequency::type(iFreq));
       if (_prn.system() == frqStr[0]) {
-      cout << "PCO           : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq]       << endl
+      LOG << "PCO           : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq]       << endl
            << "BIAS CODE     : " << frqStr << setw(12) << setprecision(3) << _model._codeBias[iFreq]     << endl
            << "BIAS PHASE    : " << frqStr << setw(12) << setprecision(3) << _model._phaseBias[iFreq]    << endl
Index: /trunk/BNC/src/pppMain.cpp
===================================================================
--- /trunk/BNC/src/pppMain.cpp	(revision 8955)
+++ /trunk/BNC/src/pppMain.cpp	(revision 8956)
@@ -416,8 +416,9 @@
     opt->_aprSigCodeBias  = 1000.0;
     opt->_aprSigPhaseBias = 1000.0;
-    opt->_noiseIon        = 1.0;
-    opt->_noiseCodeBias   = 1.0;
-    opt->_noisePhaseBias  = 0.1;
-    opt->_sigmaGIMdiff    = 0.05; // pseudo observation GIM: STEC(ref_sat) - STEC(sat)
+    // TODO: Find realistic values!!!!!!
+    opt->_noiseIon        = 10.0;
+    opt->_noiseCodeBias   = 1.00;
+    opt->_noisePhaseBias  = 5.00;
+    opt->_sigmaGIMdiff    = 2.00; //pseudo observation GIM: STEC(ref_sat) - STEC(sat)
 
     _options << opt;
