From 4777508a0f6175ee0ce381dea98df0677eb46d91 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bayle <j2b.bayle@gmail.com> Date: Sun, 3 Apr 2022 21:57:45 +0200 Subject: [PATCH] Add error when fplan file is incomplete --- lisainstrument/instrument.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index ee86523..dca24db 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -517,17 +517,21 @@ class Instrument: interpolate = lambda x: InterpolatedUnivariateSpline(times, x, k=1, ext='raise')(self.physics_t) lock_beatnotes = {} # Go through all MOSAs and pick locking beatnotes - for mosa in self.MOSAS: - if self.lock[mosa] == 'cavity': - # No offset for primary laser - lock_beatnotes[mosa] = 0.0 - elif self.lock[mosa] == 'distant': - lock_beatnotes[mosa] = interpolate(fplanf[self.lock_config][f'isi_{mosa}']) - elif self.lock[mosa] == 'adjacent': - # Fplan files only contain the one (left) RFI beatnote - left_mosa = ForEachSC.left_mosa(ForEachMOSA.sc(mosa)) - sign = +1 if left_mosa == mosa else -1 - lock_beatnotes[mosa] = interpolate(sign * fplanf[self.lock_config][f'rfi_{left_mosa}']) + try: + for mosa in self.MOSAS: + if self.lock[mosa] == 'cavity': + # No offset for primary laser + lock_beatnotes[mosa] = 0.0 + elif self.lock[mosa] == 'distant': + lock_beatnotes[mosa] = 1E6 * interpolate(fplanf[self.lock_config][f'isi_{mosa}']) + elif self.lock[mosa] == 'adjacent': + # Fplan files only contain the one (left) RFI beatnote + left_mosa = ForEachSC.left_mosa(ForEachMOSA.sc(mosa)) + sign = +1 if left_mosa == mosa else -1 + lock_beatnotes[mosa] = 1E6 * sign * interpolate(fplanf[self.lock_config][f'rfi_{left_mosa}']) + except ValueError as error: + logger.error("Missing frequency-plan information at \n%s") + raise ValueError("missing frequency-plan information, use longer file or adjust sampling") from error self.fplan = ForEachMOSA(lock_beatnotes) else: raise ValueError(f"unsupported frequency-plan file version '{version}'") -- GitLab