Skip to content

Commit

Permalink
Take advantage of async readout during calibrations
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jul 13, 2023
1 parent fa6591e commit 239f69d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gort/devices/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,11 @@ async def calibrate(
if "darks" in sequence_config:
self.write_to_log("Taking darks.", level="info")
ndarks = sequence_config["darks"].get("count")
for _ in range(ndarks):
for idark in range(ndarks):
await self.gort.specs.expose(
flavour="dark",
exposure_time=sequence_config["darks"]["exposure_time"],
async_readout=idark == ndarks - 1,
)

for lamp in lamps_config:
Expand All @@ -444,7 +445,9 @@ async def calibrate(
await calib_nps.on(lamp)
await asyncio.sleep(warmup)

for exp_time in lamps_config[lamp]["exposure_times"]:
exp_times = lamps_config[lamp]["exposure_times"]
n_exp_times = len(exp_times)
for ietime, exp_time in enumerate(exp_times):
flavour = lamps_config[lamp]["flavour"]

# Check if we are spinning the fibre selector and,
Expand Down Expand Up @@ -478,6 +481,7 @@ async def calibrate(
flavour=flavour,
exposure_time=exp_time,
show_progress=show_progress,
async_readout=ietime == n_exp_times - 1,
)

if fibsel_task:
Expand All @@ -489,6 +493,10 @@ async def calibrate(
if park_after:
await self.gort.telescopes.park()

if self.last_exposure and not self.last_exposure.done():
self.write_to_log("Awaiting last exposure readout.")
await self.last_exposure

except Exception:
self.write_to_log(
"Errored while executing sequence. "
Expand Down

0 comments on commit 239f69d

Please sign in to comment.