From f0b088f97cc1c712571a74d51b75e072aee80b22 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Bayle <j2b.bayle@gmail.com>
Date: Fri, 29 Sep 2023 09:21:20 +0200
Subject: [PATCH] Fix coupling to link responses

---
 lisainstrument/instrument.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py
index a636fbe..3c69295 100755
--- a/lisainstrument/instrument.py
+++ b/lisainstrument/instrument.py
@@ -1030,10 +1030,11 @@ class Instrument:
         logger.info("Propagating local beams to distant MOSAs")
 
         logger.debug("Propagating carrier offsets to distant MOSAs")
+        delayed_distant_carrier_offsets = self.local_carrier_offsets.distant() \
+            .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
         self.distant_carrier_offsets = \
             -self.d_pprs * self.central_freq \
-            + (1 - self.d_pprs) * self.local_carrier_offsets.distant() \
-            .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
+            + (1 - self.d_pprs) * delayed_distant_carrier_offsets
 
         logger.debug("Propagating carrier fluctuations to distant MOSAs")
         carrier_fluctuations = \
@@ -1044,14 +1045,15 @@ class Instrument:
             .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
         self.distant_carrier_fluctuations = \
             propagated_carrier_fluctuations \
-            - (self.central_freq + self.local_carrier_offsets) * self.gws \
+            - (self.central_freq + delayed_distant_carrier_offsets) * self.gws \
             - (self.central_freq + self.local_carrier_offsets) * self.local_ttls / c
 
         logger.debug("Propagating upper sideband offsets to distant MOSAs")
+        delayed_distant_usb_offsets = self.local_usb_offsets.distant() \
+            .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
         self.distant_usb_offsets = \
             -self.d_pprs * self.central_freq \
-            + (1 - self.d_pprs) * self.local_usb_offsets.distant() \
-            .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
+            + (1 - self.d_pprs) * delayed_distant_usb_offsets
 
         logger.debug("Propagating upper sideband fluctuations to distant MOSAs")
         usb_fluctuations = \
@@ -1062,7 +1064,7 @@ class Instrument:
             .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent)
         self.distant_usb_fluctuations = \
             propagated_usb_fluctuations \
-            - (self.central_freq + self.local_usb_offsets) * self.gws \
+            - (self.central_freq + delayed_distant_usb_offsets) * self.gws \
             - (self.central_freq + self.local_usb_offsets) * self.local_ttls / c
 
         logger.debug("Propagating local THEs with respect to TPS to distant MOSAs")
-- 
GitLab