Skip to content

Commit

Permalink
Merge pull request #307 from spc-group/auto_gain
Browse files Browse the repository at this point in the history
Fixed some bugs in the ``auto_gain`` plan.
  • Loading branch information
canismarko authored Nov 19, 2024
2 parents 7cddd5b + f31c451 commit 7c5d70f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 49 deletions.
16 changes: 8 additions & 8 deletions src/haven/devices/srs570.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class Cal(str, Enum):
("20", "pA/V", "HIGH BW"): 0.5,
("50", "pA/V", "HIGH BW"): 0.5,
("100", "pA/V", "HIGH BW"): 0.5,
("200", "pA/V", "HIGH BW"): 0.3,
("500", "pA/V", "HIGH BW"): 0.3,
("200", "pA/V", "HIGH BW"): 0.5,
("500", "pA/V", "HIGH BW"): 0.5,
("1", "pA/V", "LOW NOISE"): 3.0,
("2", "pA/V", "LOW NOISE"): 2.5,
("5", "pA/V", "LOW NOISE"): 2.0,
Expand All @@ -78,35 +78,35 @@ class Cal(str, Enum):
settling_times.update(
{
# nA/V, high bandwidth
(gain_values[idx], "nA/V", "HIGH BW"): 0.3
(gain_values[idx], "nA/V", "HIGH BW"): 0.5
for idx in range(9)
}
)
settling_times.update(
{
# nA/V, low noise
(gain_values[idx], "nA/V", "LOW NOISE"): 0.3
(gain_values[idx], "nA/V", "LOW NOISE"): 0.5
for idx in range(9)
}
)
settling_times.update(
{
# μA/V, high bandwidth
(gain_values[idx], "uA/V", "HIGH BW"): 0.3
(gain_values[idx], "uA/V", "HIGH BW"): 0.5
for idx in range(9)
}
)
settling_times.update(
{
# μA/V, low noise
(gain_values[idx], "uA/V", "LOW NOISE"): 0.3
(gain_values[idx], "uA/V", "LOW NOISE"): 0.5
for idx in range(9)
}
)
settling_times.update(
{
("1", "mA/V", "HIGH BW"): 0.3,
("1", "mA/V", "LOW NOISE"): 0.3,
("1", "mA/V", "HIGH BW"): 0.5,
("1", "mA/V", "LOW NOISE"): 0.5,
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/haven/plans/auto_gain.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def next_gain(self, df: pd.DataFrame):
values_in_range = df[(df.volts < self.volts_max) & (df.volts > self.volts_min)]
needed_gains = np.arange(
df[df.volts < self.volts_min].gain.max() + 1,
df[df.volts > self.volts_max].gain.max(),
df[df.volts > self.volts_max].gain.min(),
)
missing_gains = [
gain for gain in needed_gains if gain not in values_in_range.gain
Expand Down
4 changes: 4 additions & 0 deletions src/haven/tests/test_auto_gain_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ def test_recommender_fill_missing_gains(recommender):
[9],
[12],
[10],
# Put in one that's really high to make sure skipped points aren't included
[16],
]
volts = [
[0.3],
[5.2],
[1.5],
# Put in one that's really high to make sure skipped points aren't included
[7.0],
]
recommender.tell_many(gains, volts)
# Does it recommend the missing gain value?
Expand Down
80 changes: 40 additions & 40 deletions src/haven/tests/test_srs570.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ async def preamp():
("20", "pA/V", "HIGH BW"): 0.5,
("50", "pA/V", "HIGH BW"): 0.5, # 50 pA/V
("100", "pA/V", "HIGH BW"): 0.5,
("200", "pA/V", "HIGH BW"): 0.3,
("500", "pA/V", "HIGH BW"): 0.3,
("200", "pA/V", "HIGH BW"): 0.5,
("500", "pA/V", "HIGH BW"): 0.5,
# nA/V
("1", "nA/V", "HIGH BW"): 0.3,
("2", "nA/V", "HIGH BW"): 0.3, # 2 nA/V
("5", "nA/V", "HIGH BW"): 0.3,
("10", "nA/V", "HIGH BW"): 0.3,
("20", "nA/V", "HIGH BW"): 0.3,
("50", "nA/V", "HIGH BW"): 0.3,
("100", "nA/V", "HIGH BW"): 0.3, # 100 nA/V
("200", "nA/V", "HIGH BW"): 0.3,
("500", "nA/V", "HIGH BW"): 0.3,
("1", "nA/V", "HIGH BW"): 0.5,
("2", "nA/V", "HIGH BW"): 0.5, # 2 nA/V
("5", "nA/V", "HIGH BW"): 0.5,
("10", "nA/V", "HIGH BW"): 0.5,
("20", "nA/V", "HIGH BW"): 0.5,
("50", "nA/V", "HIGH BW"): 0.5,
("100", "nA/V", "HIGH BW"): 0.5, # 100 nA/V
("200", "nA/V", "HIGH BW"): 0.5,
("500", "nA/V", "HIGH BW"): 0.5,
# μA/V
("1", "uA/V", "HIGH BW"): 0.3,
("2", "uA/V", "HIGH BW"): 0.3,
("5", "uA/V", "HIGH BW"): 0.3, # 5 μA/V
("10", "uA/V", "HIGH BW"): 0.3,
("20", "uA/V", "HIGH BW"): 0.3,
("50", "uA/V", "HIGH BW"): 0.3,
("100", "uA/V", "HIGH BW"): 0.3,
("200", "uA/V", "HIGH BW"): 0.3, # 200 μA/V
("500", "uA/V", "HIGH BW"): 0.3,
("1", "uA/V", "HIGH BW"): 0.5,
("2", "uA/V", "HIGH BW"): 0.5,
("5", "uA/V", "HIGH BW"): 0.5, # 5 μA/V
("10", "uA/V", "HIGH BW"): 0.5,
("20", "uA/V", "HIGH BW"): 0.5,
("50", "uA/V", "HIGH BW"): 0.5,
("100", "uA/V", "HIGH BW"): 0.5,
("200", "uA/V", "HIGH BW"): 0.5, # 200 μA/V
("500", "uA/V", "HIGH BW"): 0.5,
# mA/V
("1", "mA/V", "HIGH BW"): 0.3,
("1", "mA/V", "HIGH BW"): 0.5,
("2", "mA/V", "HIGH BW"): None,
("5", "mA/V", "HIGH BW"): None,
("10", "mA/V", "HIGH BW"): None,
Expand All @@ -67,27 +67,27 @@ async def preamp():
("200", "pA/V", "LOW NOISE"): 0.5,
("500", "pA/V", "LOW NOISE"): 0.5,
# nA/V
("1", "nA/V", "LOW NOISE"): 0.3,
("2", "nA/V", "LOW NOISE"): 0.3,
("5", "nA/V", "LOW NOISE"): 0.3,
("10", "nA/V", "LOW NOISE"): 0.3,
("20", "nA/V", "LOW NOISE"): 0.3,
("50", "nA/V", "LOW NOISE"): 0.3,
("100", "nA/V", "LOW NOISE"): 0.3,
("200", "nA/V", "LOW NOISE"): 0.3,
("500", "nA/V", "LOW NOISE"): 0.3,
("1", "nA/V", "LOW NOISE"): 0.5,
("2", "nA/V", "LOW NOISE"): 0.5,
("5", "nA/V", "LOW NOISE"): 0.5,
("10", "nA/V", "LOW NOISE"): 0.5,
("20", "nA/V", "LOW NOISE"): 0.5,
("50", "nA/V", "LOW NOISE"): 0.5,
("100", "nA/V", "LOW NOISE"): 0.5,
("200", "nA/V", "LOW NOISE"): 0.5,
("500", "nA/V", "LOW NOISE"): 0.5,
# μA/V
("1", "uA/V", "LOW NOISE"): 0.3,
("2", "uA/V", "LOW NOISE"): 0.3,
("5", "uA/V", "LOW NOISE"): 0.3,
("10", "uA/V", "LOW NOISE"): 0.3,
("20", "uA/V", "LOW NOISE"): 0.3,
("50", "uA/V", "LOW NOISE"): 0.3,
("100", "uA/V", "LOW NOISE"): 0.3,
("200", "uA/V", "LOW NOISE"): 0.3,
("500", "uA/V", "LOW NOISE"): 0.3,
("1", "uA/V", "LOW NOISE"): 0.5,
("2", "uA/V", "LOW NOISE"): 0.5,
("5", "uA/V", "LOW NOISE"): 0.5,
("10", "uA/V", "LOW NOISE"): 0.5,
("20", "uA/V", "LOW NOISE"): 0.5,
("50", "uA/V", "LOW NOISE"): 0.5,
("100", "uA/V", "LOW NOISE"): 0.5,
("200", "uA/V", "LOW NOISE"): 0.5,
("500", "uA/V", "LOW NOISE"): 0.5,
# mA/V
("1", "mA/V", "LOW NOISE"): 0.3,
("1", "mA/V", "LOW NOISE"): 0.5,
("2", "mA/V", "LOW NOISE"): None,
("5", "mA/V", "LOW NOISE"): None,
("10", "mA/V", "LOW NOISE"): None,
Expand Down

0 comments on commit 7c5d70f

Please sign in to comment.