From e139cae363a825020e082026456a0c9004619820 Mon Sep 17 00:00:00 2001
From: Olaf Hartwig <olaf.hartwig@aei.mpg.de>
Date: Mon, 15 Nov 2021 20:58:10 +0100
Subject: [PATCH] Fix bug in laser locking

---
 lisainstrument/instrument.py | 58 +++++++-----------------------------
 1 file changed, 11 insertions(+), 47 deletions(-)

diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py
index 2e797df..5d42096 100644
--- a/lisainstrument/instrument.py
+++ b/lisainstrument/instrument.py
@@ -703,6 +703,17 @@ class Instrument:
         logger.info("Simulating local beams")
         self.simulate_locking()
 
+        ## simulate sidebands
+
+        logger.debug("Computing upper sideband offsets for primary local beam")
+        self.local_usb_offsets = self.local_carrier_offsets \
+            + self.modulation_freqs * (1 + self.clock_noise_offsets)
+
+        logger.debug("Computing upper sideband fluctuations for primary local beam")
+        self.local_usb_fluctuations = \
+            self.local_carrier_fluctuations \
+            + self.modulation_freqs * (self.clock_noise_fluctuations + self.modulation_noises)
+
         ## Propagation to distant MOSA
 
         logger.info("Propagating local beams to distant MOSAs")
@@ -1310,8 +1321,6 @@ class Instrument:
         Args:
             mosa: laser index
         """
-        sc = ForEachMOSA.sc
-
         logger.info("Generating laser noise for laser %s", mosa)
         self.laser_noises[mosa] = noises.laser(self.physics_fs, self.physics_size, self.laser_asds[mosa])
 
@@ -1322,14 +1331,6 @@ class Instrument:
         self.local_carrier_fluctuations[mosa] = \
             self.laser_noises[mosa] + self.glitch_lasers[mosa] + self.tdir_tones[mosa]
 
-        logger.debug("Computing upper sideband offsets for primary local beam %s", mosa)
-        self.local_usb_offsets[mosa] = self.offsets_freqs[mosa] \
-            + self.modulation_freqs[mosa] * (1 + self.clock_noise_offsets[sc(mosa)])
-
-        logger.debug("Computing upper sideband fluctuations for primary local beam %s", mosa)
-        self.local_usb_fluctuations[mosa] = \
-            self.laser_noises[mosa] + self.glitch_lasers[mosa] + self.tdir_tones[mosa] \
-            + self.modulation_freqs[mosa] * (self.clock_noise_fluctuations[sc(mosa)] + self.modulation_noises[mosa])
 
     def lock_on_adjacent(self, mosa):
         """Compute carrier and upper sideband offsets and fluctuations for laser locked to adjacent beam.
@@ -1355,20 +1356,6 @@ class Instrument:
             + self.central_freq * self.oms_ref_carrier_noises[mosa] \
             + self.tdir_tones[mosa]
 
-        logger.debug("Computing upper sideband offsets for local beam %s "
-                     "locked on adjacent beam %s", mosa, adjacent(mosa))
-        self.local_usb_offsets[mosa] = \
-            self.local_usb_offsets[adjacent(mosa)] \
-            + self.offsets_freqs[mosa] * (1 + self.clock_noise_offsets[sc(mosa)])
-
-        logger.debug("Computing upper sideband fluctuations for local beam %s "
-                     "locked on adjacent beam %s", mosa, adjacent(mosa))
-        adjacent_usb_fluctuations = self.local_usb_fluctuations[adjacent(mosa)] \
-            + self.central_freq * self.backlink_noises[mosa]
-        self.local_usb_fluctuations[mosa] = adjacent_usb_fluctuations \
-            + self.offsets_freqs[mosa] * self.clock_noise_fluctuations[sc(mosa)] \
-            + self.central_freq * self.oms_ref_usb_noises[mosa] \
-            + self.tdir_tones[mosa]
 
     def lock_on_distant(self, mosa):
         """Compute carrier and upper sideband offsets and fluctuations for locked laser to distant beam.
@@ -1403,29 +1390,6 @@ class Instrument:
             + self.central_freq * self.oms_isc_carrier_noises[mosa] \
             + self.tdir_tones[mosa]
 
-        logger.debug("Computing upper sideband offsets for local beam %s "
-                     "locked on distant beam %s", mosa, distant(mosa))
-        usb_offsets = self.local_usb_offsets[distant(mosa)]
-        distant_usb_offsets = \
-            -self.d_pprs[mosa] * self.central_freq \
-            + (1 - self.d_pprs[mosa]) * self.interpolate(usb_offsets, -self.pprs[mosa])
-        self.local_usb_offsets[mosa] = distant_usb_offsets \
-            + self.offsets_freqs[mosa] * (1 + self.clock_noise_offsets[sc(mosa)])
-
-        logger.debug("Computing upper sideband fluctuations for local beam %s "
-                     "locked on distant beam %s", mosa, distant(mosa))
-        usb_fluctuations = \
-            self.local_usb_fluctuations[distant(mosa)] \
-            - (self.central_freq + self.local_usb_offsets[distant(mosa)]) \
-                * self.distant_ttls[distant(mosa)] / c
-        distant_usb_fluctuations = \
-            + (1 - self.d_pprs[mosa]) * self.interpolate(usb_fluctuations, -self.pprs[mosa]) \
-            - (self.central_freq + self.local_usb_offsets[mosa]) * self.gws[mosa] \
-            - (self.central_freq + self.local_usb_offsets[mosa]) * self.local_ttls[mosa] / c
-        self.local_usb_fluctuations[mosa] = distant_usb_fluctuations \
-            + self.offsets_freqs[mosa] * self.clock_noise_fluctuations[sc(mosa)] \
-            + self.central_freq * self.oms_isc_usb_noises[mosa] \
-            + self.tdir_tones[mosa]
 
     def simulate_locking(self):
         """Simulate local beams from the locking configuration."""
-- 
GitLab