Skip to content

Commit

Permalink
spacers should not be overlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Nov 8, 2022
1 parent 8614434 commit 9dd39ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions iblrig/spacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ def __init__(self, dt_start=.02, dt_end=.4, n_pulses=8, tup=.05):
self.dt_end = dt_end
self.n_pulses = n_pulses
self.tup = tup
assert np.all(np.diff(self.times) > self.tup), 'Spacers are overlapping'

def __repr__(self):
return f"Spacer(dt_start={self.dt_start}, dt_end={self.dt_end}, n_pulses={self.n_pulses}, tup={self.tup})"

@property
def times(self):
def times(self, latency=0):
"""
Computes spacer up times using a chirp up and down pattern
:return: numpy arrays of times
Expand All @@ -61,7 +62,6 @@ def generate_template(self, fs=1000):
"""
t = self.times
ns = int((t[-1] + self.tup * 10) * fs)
np.cumsum(np.linspace(self.dt_start, self.dt_end, self.n_pulses) + self.tup)
sig = np.zeros(ns, )
sig[(t * fs).astype(np.int32)] = 1
sig[((t + self.tup) * fs).astype(np.int32)] = -1
Expand All @@ -77,7 +77,7 @@ def add_spacer_states(self, sma=None, next_state="exit"):
"""
assert next_state is not None
t = self.times
dt = np.diff(t, append=t[-1] + self.tup)
dt = np.diff(t, append=t[-1] + self.tup * 2)
for i, time in enumerate(t):
if sma is None:
print(i, time, dt[i])
Expand All @@ -91,7 +91,7 @@ def add_spacer_states(self, sma=None, next_state="exit"):
)
sma.add_state(
state_name=f"spacer_low_{i:02d}",
state_timer=dt[i],
state_timer=dt[i] - self.tup,
state_change_conditions={"Tup": next_loop},
output_actions=[],
)

0 comments on commit 9dd39ec

Please sign in to comment.