Index: trunk/BNC/CHANGELOG.md
===================================================================
--- trunk/BNC/CHANGELOG.md	(revision 11109)
+++ trunk/BNC/CHANGELOG.md	(revision 11110)
@@ -13,5 +13,5 @@
 - CHANGED: Combination: the random walk of the AC satellite offsets is defined per time (1 cm per 10 s) instead of per epoch, so the result no longer depends on the sampling interval (at 5 s the offsets were sqrt(2) noisier per hour)
 - CHANGED: Combination: an AC excluded from the clock datum because of inconsistent code biases is used again only after 12 passing checks in a row (1 hour), not after the first one (a borderline AC changed the clock datum every 5 minutes)
-- CHANGED: Combination: attitude consistency correction dC_att of the clocks reactivated: a yaw angle difference between an AC and the master orbit AC (SSR yaw angle or BNC's attitude model, as selected in 'Attitude') changes the ionosphere-free phase wind-up and thus the AC's clock (lambda_IF * dyaw / 2pi), zero for ACs using the same attitude model
+- CHANGED: Combination: attitude consistency correction dC_att of the clocks reactivated: a yaw angle difference between an AC and the master orbit AC (SSR yaw angle or BNC's attitude model, as selected in 'Attitude') changes the ionosphere-free phase wind-up and thus the AC's clock (lambda_IF * dyaw / 2pi, yaw difference followed over time, so a turn in the opposite direction leaves one cycle), zero for ACs using the same attitude model
 - ADDED: Combination of APC (SSRA) and CoM (SSRC) streams together: with an ANTEX file the combination is done in the CoM frame, the orbits of the APC streams are converted to CoM; ACs not combined because of a different reference point are reported
 - ADDED: Option 'Reference Signals' (key ssrRefSignals): reference signals of the satellite clocks per GNSS for the combination (AC clock referral, code biases from the Bias SINEX file) and the SSR QC, default IGS Real-Time convention G:1W&2W R:1P&2P E:1C&5Q C:2I&6I J:1C&2L S:1C&5Q, e.g. for a switch of BDS to C1X/C5X or of QZSS to L1/L5
@@ -37,4 +37,6 @@
 - FIXED: Combination: the satellite offset of an AC was not reset after an outlier
 - FIXED: Combination: text of the combination logfile was lost
+- FIXED: GPS attitude model ('Computed'): at the end of a noon/midnight turn the yaw jumped to the nominal yaw (e.g. by 95 deg); the satellite now keeps yawing at its maximum rate until it has caught up with the nominal yaw
+- FIXED: GLONASS attitude model ('Computed'): the yaw was frozen while the nominal yaw rate exceeded the maximum rate and then jumped to the nominal yaw; now following Dilssner et al. (2011), the satellite yaws at the maximum rate (0.25 deg/s) during noon turns until it has caught up, and in the Earth's shadow until it reaches the nominal yaw at shadow exit
 - FIXED: Upload of raw streams lost data chunks
 - FIXED: RTCM3 decoder: a 0xD3 byte followed by a zero length field at the end of the received data caused an endless loop until std::bad_alloc, and the stream was deleted
Index: trunk/BNC/src/bncantex.cpp
===================================================================
--- trunk/BNC/src/bncantex.cpp	(revision 11109)
+++ trunk/BNC/src/bncantex.cpp	(revision 11110)
@@ -385,21 +385,14 @@
 }
 
-// GLONASS Yaw Angle (Sun-pointing law overridden near noon/midnight when
-// the satellite cannot mechanically keep up, following the GLONASS-M
-// "yaw-fixed" behaviour described in Dilssner, Springer, Flohrer, Dow
-// (2011), "The GLONASS-M satellite yaw-attitude model", Advances in Space
-// Research 47(1), 160-171.
-//
-// Unlike GPS/Galileo/BeiDou, which are commonly approximated by the
-// nominal Sun-pointing yaw-steering law of Bar-Sever (1996) at all times,
-// GLONASS-M has been found to stop tracking that law and hold a constant
-// (frozen) yaw angle whenever the required yaw rate would exceed the
-// satellite's slew capability - which happens close to the orbit
-// noon/midnight points whenever the Sun's elevation above the orbital
-// plane (the "beta" angle) is small. The maximum yaw rate used below
-// (0.25 deg/s) and the general approach follow that paper; satellite
-// telemetry was not available to validate the exact rate against this
-// installation's GLONASS satellites, so it should be checked against
-// independently-known attitude/orbit residuals if high accuracy matters.
+// GLONASS Yaw Angle following the GLONASS-M yaw-attitude model of Dilssner,
+// Springer, Gienger, Dow (2011), "The GLONASS-M satellite yaw-attitude
+// model", Advances in Space Research 47(1), 160-171:
+//  - noon turn: when the nominal yaw rate exceeds the maximum hardware rate
+//    (0.25 deg/s), the satellite yaws at that rate in the direction of the
+//    nominal yaw rate until it has caught up with the nominal yaw;
+//  - midnight turn: in the Earth's shadow the satellite yaws at the maximum
+//    rate until it reaches the nominal yaw at shadow exit and holds it until
+//    leaving the shadow.
+// The maximum rate is applied to all GLONASS satellites (K/K2 like M).
 ////////////////////////////////////////////////////////////////////////////
 double bncAntex::glonassYawAngle(const QString& prn, double Mjd,
@@ -411,10 +404,9 @@
 
   // This bounds the gap BETWEEN CONSECUTIVE CALLS for a given satellite
-  // (not how long the freeze itself has lasted - a real low-beta passage
-  // can legitimately stay frozen far longer than this). If there was no
+  // (not how long a turn lasts). If there was no
   // call for longer than this, something else interrupted normal epoch-by-
   // epoch processing (a stream outage, a maneuver-flagged-unhealthy
-  // period, ...), so the stored frozen value is more likely stale than a
-  // still-valid freeze, and we fall back to the current nominal value
+  // period, ...), so the stored yaw is more likely stale than a
+  // still-valid turn, and we fall back to the current nominal value
   // instead of trusting it indefinitely.
   const double MAX_CALL_GAP = 1800.0 / 86400.0; // 30 minutes, in days
@@ -460,41 +452,90 @@
                   : 1e9;
 
+  // Sign of the nominal yaw rate: dPsi/dt = nRate * tanBeta * cos(mu) / denom
+  double psiDotNomSign = (tanBeta * cos(mu) >= 0.0) ? 1.0 : -1.0;
+
+  // Earth's shadow (cylinder): around midnight for |mu| < muShadow
+  // ----------------------------------------------------------------
+  const double RE = 6378137.0;
+  double cosMuShadow = sqrt(std::max(0.0, 1.0 - RE * RE / (r * r))) / cos(beta);
+  bool   inShadow    = (cosMuShadow < 1.0 && cos(mu) > cosMuShadow);
+  double muExit      = (cosMuShadow < 1.0) ? acos(cosMuShadow) : 0.0;
+  double psiExit     = atan2(-tanBeta, sin(muExit)); // nominal yaw at shadow exit
+
   t_glonassYaw& st = _glonassYaw[prn];
   double callGap = st.valid ? (Mjd - st.lastCallMjd) : 0.0;
+  if (st.valid && callGap > MAX_CALL_GAP) {
+    _glonassYawLog += QString().asprintf(
+      "%s glonassYaw STALE-RESET  Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f"
+      " old=%7.2f new=%7.2f gap=%.1fmin\n",
+      prn.toLatin1().data(), Mjd, beta*180.0/M_PI, mu*180.0/M_PI,
+      psiRate*180.0/M_PI, st.yaw*180.0/M_PI, psiNom*180.0/M_PI,
+      callGap*1440.0);
+    st.valid = false;
+    st.fixed = false;
+  }
+  double step = MAX_YAW_RATE * callGap * 86400.0;  // max. yaw change since the last call
   double psiEff;
-  if (psiRate > MAX_YAW_RATE) {
-    if (!st.valid || callGap > MAX_CALL_GAP) {
-      if (st.valid) { // i.e. it was a genuine gap, not cold-start
-        _glonassYawLog += QString().asprintf(
-          "%s glonassYaw STALE-RESET  Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f"
-          " old=%7.2f new=%7.2f gap=%.1fmin\n",
-          prn.toLatin1().data(), Mjd, beta*180.0/M_PI, mu*180.0/M_PI,
-          psiRate*180.0/M_PI, st.yaw*180.0/M_PI, psiNom*180.0/M_PI,
-          callGap*1440.0);
-      }
-      st.yaw = psiNom; // no prior history, or the gap is too long to trust it
-    }
+
+  if (inShadow) {
+    // Midnight turn: in the shadow the satellite yaws at the maximum rate
+    // until it reaches the nominal yaw at shadow exit and holds it there
     if (!st.fixed) {
+      st.yaw      = st.valid ? st.yaw : psiNom;
+      st.turnSign = psiDotNomSign;
+      st.fixed    = true;
       _glonassYawLog += QString().asprintf(
-        "%s glonassYaw FIXED-ENTER  Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f yaw=%7.2f\n",
+        "%s glonassYaw SHADOW-ENTER Mjd=%.6f beta=%6.3f mu=%7.2f yaw=%7.2f exit=%7.2f\n",
+        prn.toLatin1().data(), Mjd, beta*180.0/M_PI, mu*180.0/M_PI,
+        st.yaw*180.0/M_PI, psiExit*180.0/M_PI);
+      psiEff = st.yaw;
+    }
+    else if (remainder(st.turnSign * (psiExit - st.yaw), 2.0 * M_PI) > step) {
+      psiEff = st.yaw + st.turnSign * step;
+    }
+    else {
+      psiEff = psiExit;
+    }
+  }
+  else if (psiRate > MAX_YAW_RATE) {
+    // Noon turn (or shadow-free midnight turn): the satellite yaws at the
+    // maximum rate in the direction of the nominal yaw rate
+    if (!st.valid || !st.fixed) {
+      st.yaw      = st.valid ? st.yaw : psiNom;
+      st.turnSign = psiDotNomSign;
+      st.fixed    = true;
+      _glonassYawLog += QString().asprintf(
+        "%s glonassYaw TURN-ENTER   Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f yaw=%7.2f\n",
         prn.toLatin1().data(), Mjd, beta*180.0/M_PI, mu*180.0/M_PI,
         psiRate*180.0/M_PI, st.yaw*180.0/M_PI);
-      st.fixed = true;
-    }
-    psiEff = st.yaw;    // hold the frozen yaw angle
+      psiEff = st.yaw;
+    }
+    else {
+      psiEff = st.yaw + st.turnSign * step;
+    }
+  }
+  else if (st.valid && st.fixed &&
+           remainder(st.turnSign * (psiNom - st.yaw), 2.0 * M_PI) > step) {
+    // after the turn or shadow exit, the satellite still lags behind and
+    // keeps yawing at the maximum rate until it has caught up
+    psiEff = st.yaw + st.turnSign * step;
   }
   else {
+    // Nominal tracking
     if (st.fixed) {
       _glonassYawLog += QString().asprintf(
-        "%s glonassYaw FIXED-EXIT   Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f"
-        " frozen=%7.2f nominal=%7.2f\n",
+        "%s glonassYaw TURN-EXIT    Mjd=%.6f beta=%6.3f mu=%7.2f rate=%6.3f"
+        " yaw=%7.2f nominal=%7.2f\n",
         prn.toLatin1().data(), Mjd, beta*180.0/M_PI, mu*180.0/M_PI,
         psiRate*180.0/M_PI, st.yaw*180.0/M_PI, psiNom*180.0/M_PI);
       st.fixed = false;
     }
-    st.yaw = psiNom;
     psiEff = psiNom;
   }
-  st.lastCallMjd = Mjd; // update on every call, fixed or not, to detect gaps
+  while (psiEff >  M_PI) psiEff -= 2.0 * M_PI;
+  while (psiEff < -M_PI) psiEff += 2.0 * M_PI;
+
+  st.yaw         = psiEff;
+  st.lastCallMjd = Mjd; // update on every call to detect gaps
   st.valid       = true;
 
@@ -607,11 +648,21 @@
         psiNom*180.0/M_PI, psiEff*180.0/M_PI,
         psiDotNomAbs*psiDotNomSign*180.0/M_PI, psiDotMax*180.0/M_PI);
-      st.inTurn = true;
+      st.inTurn   = true;
+      st.turnSign = psiDotNomSign;
     } else {
       // Continuing the turn: integrate at constrained rate
       double dt  = callGap * 86400.0; // [s]
-      psiEff = st.yaw + psiDotNomSign * psiDotMax * dt;
+      psiEff = st.yaw + st.turnSign * psiDotMax * dt;
     }
     // Wrap to [-pi, pi]
+    while (psiEff >  M_PI) psiEff -= 2.0 * M_PI;
+    while (psiEff < -M_PI) psiEff += 2.0 * M_PI;
+  }
+  else if (st.valid && st.inTurn &&
+           remainder(st.turnSign * (psiNom - st.yaw), 2.0 * M_PI) > psiDotMax * callGap * 86400.0) {
+    // End of the turn: the nominal yaw rate is below the maximum again, but
+    // the satellite still lags behind and keeps yawing at the maximum rate
+    // until it has caught up with the nominal yaw (Kouba 2009)
+    psiEff = st.yaw + st.turnSign * psiDotMax * callGap * 86400.0;
     while (psiEff >  M_PI) psiEff -= 2.0 * M_PI;
     while (psiEff < -M_PI) psiEff += 2.0 * M_PI;
@@ -628,5 +679,4 @@
       st.inTurn = false;
     }
-    st.yaw = psiNom;
   }
 
@@ -837,5 +887,5 @@
       // ATT_NOMINAL: simple nominal Sun-pointing for all systems.
       // ATT_COMPUTED or ATT_EXTERNAL: use per-system attitude models.
-      //   GLONASS  → yaw-fixed model (Dilssner et al. 2011)
+      //   GLONASS  → noon/shadow turn model (Dilssner et al. 2011)
       //   GPS      → noon/midnight turn model (Kouba 2009/2015)
       //   others   → simple nominal Sun-pointing
Index: trunk/BNC/src/bncantex.h
===================================================================
--- trunk/BNC/src/bncantex.h	(revision 11109)
+++ trunk/BNC/src/bncantex.h	(revision 11110)
@@ -57,5 +57,5 @@
   // Attitude model selection for satCoMcorrection().
   enum e_attMode {
-    ATT_COMPUTED = 0,  // full model: GLONASS yaw-fixed + GPS noon/midnight turn
+    ATT_COMPUTED = 0,  // full model: GLONASS noon/shadow turns, GPS noon/midnight turns, Galileo/BDS orbit-normal mode
     ATT_NOMINAL  = 1,  // simple nominal Sun-pointing only (no maneuver model)
     ATT_EXTERNAL = 2,  // use caller-supplied externalYaw angle [rad]
@@ -89,6 +89,6 @@
 
  private:
-  // Per-satellite GLONASS yaw state: freezes the yaw angle while the
-  // satellite cannot follow the nominal Sun-pointing law (Dilssner 2011).
+  // Per-satellite GLONASS yaw state: rate-limited yaw during noon turns and
+  // in the Earth's shadow (Dilssner 2011).
   class t_glonassYaw {
    public:
@@ -98,9 +98,11 @@
       valid       = false;
       fixed       = false;
+      turnSign    = 1.0;
     }
     double yaw;
     double lastCallMjd; // Mjd of the most recent call (any branch) for this PRN
     bool   valid;
-    bool   fixed;   // true while the yaw-fixed override is currently active
+    bool   fixed;     // true during a noon/midnight turn or the catch-up after it
+    double turnSign;  // direction of the turn (sign of the nominal yaw rate at its start)
   };
 
@@ -115,9 +117,11 @@
       valid       = false;
       inTurn      = false;
+      turnSign    = 1.0;
     }
     double yaw;
     double lastCallMjd;
     bool   valid;
-    bool   inTurn;  // true while in a constrained noon/midnight turn
+    bool   inTurn;    // true while in a constrained noon/midnight turn
+    double turnSign;  // direction of the turn (sign of the nominal yaw rate at its start)
   };
 
Index: trunk/BNC/src/bnchelp.html
===================================================================
--- trunk/BNC/src/bnchelp.html	(revision 11109)
+++ trunk/BNC/src/bnchelp.html	(revision 11110)
@@ -7986,5 +7986,5 @@
 </pre>
   <pre>
- dC_att = (yawAngle_AC - yawAngle_MasterAC) / (2*PI) * wavelength(IF)
+ dC_att = (yawAngle_MasterAC - yawAngle_AC) / (2*PI) * wavelength(IF)
 </pre>
   <p>
@@ -7992,5 +7992,6 @@
     ionosphere-free combination of the reference signals (about 10.7 cm for GPS). The yaw angle of each AC is taken
     from its attitude selected in the 'Attitude' field (SSR yaw angle, or BNC's 'Computed' or 'Nominal' model); the
-    yaw angle difference is reduced to +-180 degrees. dC_att is therefore zero for two ACs with the same attitude model
+    yaw angle difference is followed continuously over time, so a turn of the AC in the opposite direction than
+    the master orbit AC leaves one full cycle (wavelength(IF)) in its clock, as observed in the clocks. dC_att is therefore zero for two ACs with the same attitude model
     and differs from zero mainly during eclipse seasons and noon/midnight turns, if an AC sends its yaw angles and
     'SSR' is selected for it. A constant part is absorbed by the AC's satellite offset. dC_att requires an ANTEX file.
@@ -8320,5 +8321,5 @@
     <li><b>Computed</b> (default): BNC applies its own kinematic attitude model:
       GPS noon/midnight turn manoeuvres (Kouba 2009/2015, Bar-Sever 1996),
-      GLONASS yaw-fixed mode (Dilssner et al. 2011), and
+      GLONASS-M noon turns and midnight turns in the Earth's shadow (Dilssner et al. 2011), and
       Galileo / BDS orbit-normal mode switching (Kouba 2017, Dai et al. 2015, Steigenberger et al. 2018).</li>
     <li><b>Nominal</b>: a simplified, continuous Sun-pointing model is used without any manoeuvre modelling.</li>
@@ -9287,6 +9288,8 @@
     yaw attitude. BNC assumes the nominal Sun-pointing yaw-steering law used for the other GNSS systems, except
     close to the orbit noon and midnight points when the Sun's elevation above the orbital plane (the 'beta'
-    angle) is small. There, GLONASS-M satellites are known to stop tracking that law and instead hold the yaw
-    angle fixed, following the model described in Dilssner, Springer, Flohrer, Dow (2011), 'The GLONASS-M
+    angle) is small. There, GLONASS-M satellites cannot follow that law: at noon they yaw at their maximum rate
+    in the direction of the nominal yaw rate until they have caught up with the nominal yaw; in the Earth's shadow
+    they yaw at the maximum rate until they reach the nominal yaw at shadow exit and hold it until leaving the
+    shadow. This follows the model described in Dilssner, Springer, Gienger, Dow (2011), 'The GLONASS-M
     satellite yaw-attitude model', Advances in Space Research 47(1), 160-171. Without that correction, the
     converted GLONASS CoM position can be off by several decimeters in the along-track and cross-track
Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 11109)
+++ trunk/BNC/src/bncwindow.cpp	(revision 11110)
@@ -1740,5 +1740,5 @@
   // WhatsThis, Combine Corrections
   // ------------------------------
-  _cmbTable->setWhatsThis(tr("<p>BNC allows to process several orbit and clock correction streams in real-time to produce, encode, upload and save a combination of correctors coming from different providers. </p><p>To add a line to the 'Combine Corrections' table hit the 'Add Row' button, double click on the 'Mountpoint' field to specify a Broadcast Ephemeris Correction mountpoint from the 'Streams' section below and hit Enter. Then double click on the 'AC Name' field to enter your choice of an abbreviation for the Analysis Center (AC) providing the stream. Double click on the 'Weight Factor' field to enter a weight factor to be applied for this stream in the combination. A Factor greater than 1 will enlarge the sigma of the clock pseudo-observations and with it down-weight its contribution. Finally, double click on the 'Exclude Satellites' field and specify satellites, to exclude them for an individual AC. An entry 'G04,G31,R' means to excludes GPS satellites PRN 4 and 31 as well as all GLONASS satellites from one individual AC. Default is an empty option field, meaning that no satellite is excluded from this individual AC.</p><p>Use the 'Attitude' field to select how satellite attitude is modelled when converting Antenna Phase Center (APC) corrections to Center-of-Mass (CoM) positions for SP3 output. 'Computed' (default) applies BNC's kinematic attitude model, including GPS noon/midnight turn manoeuvres, GLONASS yaw-fixed mode, and Galileo/BDS orbit-normal mode switching. 'Nominal' uses a simplified continuous Sun-pointing model without manoeuvre modelling. 'SSR' uses the yaw angle transmitted in the SSR phase bias message; select this option only if you trust the yaw values provided by the AC. If no yaw angle is available for a particular satellite in a given epoch, BNC falls back to 'Computed'. Note that the attitude model affects APC-referenced streams only; for CoM-referenced streams the AC has already applied attitude before encoding.</p><p>Note that the orbit information in the resulting combination stream is just copied from one of the incoming streams. The stream used for providing the orbits may vary over time: if the orbit providing stream has an outage then BNC switches to the next remaining stream for getting hold of the orbit information.</p><p>The combination process requires Broadcast Ephemeris. Besides orbit and clock correction streams BNC should therefore pull a stream carrying Broadcast Ephemeris in the form of RTCM Version 3 messages.</p><p>It is possible to specify only one Broadcast Ephemeris Correction stream in the 'Combine Corrections' table. Instead of combining corrections BNC will then add the corrections to the Broadcast Ephemeris with the possibility to save final orbit and clock results in SP3 and/or Clock RINEX format. <i>[key: cmbStreams]</i></p>"));
+  _cmbTable->setWhatsThis(tr("<p>BNC allows to process several orbit and clock correction streams in real-time to produce, encode, upload and save a combination of correctors coming from different providers. </p><p>To add a line to the 'Combine Corrections' table hit the 'Add Row' button, double click on the 'Mountpoint' field to specify a Broadcast Ephemeris Correction mountpoint from the 'Streams' section below and hit Enter. Then double click on the 'AC Name' field to enter your choice of an abbreviation for the Analysis Center (AC) providing the stream. Double click on the 'Weight Factor' field to enter a weight factor to be applied for this stream in the combination. A Factor greater than 1 will enlarge the sigma of the clock pseudo-observations and with it down-weight its contribution. Finally, double click on the 'Exclude Satellites' field and specify satellites, to exclude them for an individual AC. An entry 'G04,G31,R' means to excludes GPS satellites PRN 4 and 31 as well as all GLONASS satellites from one individual AC. Default is an empty option field, meaning that no satellite is excluded from this individual AC.</p><p>Use the 'Attitude' field to select how satellite attitude is modelled when converting Antenna Phase Center (APC) corrections to Center-of-Mass (CoM) positions for SP3 output. 'Computed' (default) applies BNC's kinematic attitude model, including GPS noon/midnight turn manoeuvres, GLONASS-M noon/shadow turns, and Galileo/BDS orbit-normal mode switching. 'Nominal' uses a simplified continuous Sun-pointing model without manoeuvre modelling. 'SSR' uses the yaw angle transmitted in the SSR phase bias message; select this option only if you trust the yaw values provided by the AC. If no yaw angle is available for a particular satellite in a given epoch, BNC falls back to 'Computed'. Note that the attitude model affects APC-referenced streams only; for CoM-referenced streams the AC has already applied attitude before encoding.</p><p>Note that the orbit information in the resulting combination stream is just copied from one of the incoming streams. The stream used for providing the orbits may vary over time: if the orbit providing stream has an outage then BNC switches to the next remaining stream for getting hold of the orbit information.</p><p>The combination process requires Broadcast Ephemeris. Besides orbit and clock correction streams BNC should therefore pull a stream carrying Broadcast Ephemeris in the form of RTCM Version 3 messages.</p><p>It is possible to specify only one Broadcast Ephemeris Correction stream in the 'Combine Corrections' table. Instead of combining corrections BNC will then add the corrections to the Broadcast Ephemeris with the possibility to save final orbit and clock results in SP3 and/or Clock RINEX format. <i>[key: cmbStreams]</i></p>"));
   addCmbRowButton->setWhatsThis(tr("<p>Hit 'Add Row' button to add another line to the 'Combine Corrections' table.</p>"));
   delCmbRowButton->setWhatsThis(tr("<p>Hit 'Delete' button to delete the highlighted line(s) from the 'Combine Corrections' table.</p>"));
Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 11109)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 11110)
@@ -1698,15 +1698,12 @@
         continue;
       }
-      QString glonassYawLog = _antex->takeGlonassYawLog();
-      if (!glonassYawLog.isEmpty()) {
-        emit newMessage(("bncComb: " + glonassYawLog.trimmed()).toLatin1(), false);
-      }
-      QString gpsYawLog = _antex->takeGpsYawLog();
-      if (!gpsYawLog.isEmpty()) {
-        emit newMessage(("bncComb: " + gpsYawLog.trimmed()).toLatin1(), false);
-      }
-      QString onYawLog = _antex->takeOnYawLog();
-      if (!onYawLog.isEmpty()) {
-        emit newMessage(("bncComb: " + onYawLog.trimmed()).toLatin1(), false);
+      // transitions of the output attitude only, not of the AC attitudes
+      // used for the clock consistency (state keys "<AC>:att")
+      QStringList yawLogs = (_antex->takeGlonassYawLog() + _antex->takeGpsYawLog() +
+                             _antex->takeOnYawLog()).split('\n', Qt::SkipEmptyParts);
+      for (const QString& line : yawLogs) {
+        if (!line.contains(":att:")) {
+          emit newMessage(("bncComb: " + line.trimmed()).toLatin1(), false);
+        }
       }
     }
@@ -1885,7 +1882,22 @@
     double dC_att = 0.0;
     if (corr->_attYawValid && masterCorr[prn]->_attYawValid) {
-      double dPsi = remainder(corr->_attYaw - masterCorr[prn]->_attYaw, 2.0 * M_PI);
+      // unwrapped over time: a turn in opposite directions accumulates a
+      // full cycle of wind-up, which stays in the clock (reset after 30 min);
+      // sign confirmed with the clocks of an AC turning opposite to the master;
+      // a yaw rotation +dpsi (right-handed about the antenna boresight) shifts
+      // the carrier phase by -dpsi/2pi cycles; an AC modelling its yaw larger by
+      // dpsi gets its clock (IGS sense) smaller by lambda_IF * dpsi / 2pi:
+      // dClk_AC - dClk_master = lambda_IF * (psi_master - psi_AC) / 2pi.
+      // Chen et al. (2022, EPS 74:142, Eq. 4) give the opposite
+      // sign, but did not apply the correction (no attitude products).
+      double  dPsi = remainder(masterCorr[prn]->_attYaw - corr->_attYaw, 2.0 * M_PI);
+      QString key  = corr->_acName + ' ' + masterCorr[prn]->_acName + ' ' + prn;
+      if (_dPsiLast.contains(key) && corr->_time - _dPsiLast[key].second <= 1800.0) {
+        double last = _dPsiLast[key].first;
+        dPsi = last + remainder(dPsi - last, 2.0 * M_PI);
+      }
+      _dPsiLast[key] = QPair<double, bncTime>(dPsi, corr->_time);
       dC_att = corr->_lambdaIF * dPsi / (2.0 * M_PI);
-      if (fabs(dC_att) > 1.e-6) fprintf(stderr, "DCATT %s %s %s %s %.4f %.2f\n", corr->_time.timestr().c_str(), corr->_acName.toLatin1().data(), masterCorr[prn]->_acName.toLatin1().data(), prn.toLatin1().data(), dC_att, dPsi*180/M_PI);
+      if (getenv("DCATT") && prn.startsWith(getenv("DCATT"))) fprintf(stderr, "DCATT %s %s %s %s %.4f %.2f %.2f %.2f\n", corr->_time.timestr().c_str(), corr->_acName.toLatin1().data(), masterCorr[prn]->_acName.toLatin1().data(), prn.toLatin1().data(), dC_att, dPsi*180/M_PI, corr->_attYaw*180/M_PI, masterCorr[prn]->_attYaw*180/M_PI); // TEMPORARY
     }
     double dC_apriori_corr = dC_orb + dC_att;
Index: trunk/BNC/src/combination/bnccomb.h
===================================================================
--- trunk/BNC/src/combination/bnccomb.h	(revision 11109)
+++ trunk/BNC/src/combination/bnccomb.h	(revision 11110)
@@ -297,4 +297,5 @@
   QMap<char, QVector<cmbParam*>>              _params;
   QMap<QString, QMap<t_prn, t_orbCorr> >     _orbCorrections;
+  QMap<QString, QPair<double, bncTime> >      _dPsiLast; // yaw difference to the master orbit AC per AC, master and satellite, unwrapped over time
   QMap<QString, QMap<t_prn, t_orbCorr> >     _orbCorrectionsPrev; // latest orbit of the previous IOD per AC and satellite
   QMap<QString, QMap<t_prn, t_satCodeBias>>  _satCodeBiases;
