Skip to content

Commit

Permalink
refactor taking n exposures in spectrometer and electrometer
Browse files Browse the repository at this point in the history
  • Loading branch information
weatherhead99 committed Dec 12, 2023
1 parent 36f7666 commit 07b0db3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
27 changes: 9 additions & 18 deletions python/lsst/ts/observatory/control/auxtel/atcalsys.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List, Optional, NamedTuple, TYPE_CHECKING
from typing import List, Optional, NamedTuple
from ..base_calsys import BaseCalsys, HardcodeCalsysThroughput, CalibrationSequenceStepBase
from ..base_calsys import CalsysScriptIntention, _calsys_get_parameter
from lsst.ts import salobj
from lsst.ts.idl.enums import ATMonochromator, Electrometer
from lsst.ts.idl.enums import ATMonochromator
from lsst.ts.idl.enums import ATWhiteLight
import asyncio
import astropy.units as un
Expand All @@ -16,6 +16,7 @@ class ATSpectrographSlits(NamedTuple):
FRONTENTRANCE: float
FRONTEXIT: float


@dataclass
class ATCalibrationSequenceStep(CalibrationSequenceStepBase):
grating: ATMonochromator.Grating
Expand Down Expand Up @@ -108,7 +109,7 @@ async def setup_for_wavelength(
self.spectrograph_n_exps_for_nelectrons, nelec)
self._n_elec_exps = _calsys_get_parameter(override_kwargs, "n_elec_exps",
self.pd_n_exps_for_nelectrons, nelec)



def calculate_slit_width(self,wavelen: float, spectral_res: float, grating) -> Optional[ATSpectrographSlits]:
Expand All @@ -128,31 +129,21 @@ def calculate_grating_type(self, wavelen: float, spectral_res: float) -> ATMonoc
async def _electrometer_expose(self) -> Awaitable[list[str]]:
assert self._n_elec_exps is not None
assert self._elecsposure_time is not None
out_urls: list[str] = []
return await self._cal_expose_helper(self.Electrometer, self._n_elec_exps,
"startScanDt", scanDuration=self._elecsposure_time)

for i in range(self._n_elec_exps):
await self._sal_cmd(self.Electrometer, "startScanDt", scanDuration=self._elecsposure_time)
lfa_obj_fut = await self._sal_waitevent(self.Electrometer, "largeFileObjectAvailable")
out_urls.append(lfa_obj_fut.url)
return out_urls

async def _spectrograph_expose(self) -> Awaitable[list[str]]:
assert self._n_spec_exps is not None
assert self._specsposure_time is not None

out_urls: list[str] = []
for i in range(self._n_spec_exps):
await self._sal_cmd(self.ATSpectrograph, "expose", numExposures = numExposures)
lfa_obj_fut = await self._sal_waitevent(self.ATSpectrograph, "largeFileObjectAvailable",
run_immediate=true)

out_urls.append(lfa_obj_fut.url)
return out_urls
return await self._cal_expose_helper(self.ATSpectrograph, self._n_spec_exps,
"expose", numExposures=1, duration=self._specsposure_time)

@property
def _electrometer_object(self):
return self.Electrometer

@property
def script_time_estimate_s(self) -> float:
"""Property that returns the estimated time for the script to run in units of seconds
Expand Down
8 changes: 8 additions & 0 deletions python/lsst/ts/observatory/control/base_calsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ async def completer() -> None:
return asyncio.create_task(coro)
return coro

async def _cal_expose_helper(self, obj, n: int, cmdname: str, **extra_kwargs) -> Awaitable[list[str]]:
out_urls: list[str] = []
for i in range(n):
await self._sal_cmd(obj, cmdname, **extra_kwargs)
lfa_obj = await self._sal_waitevent(obj, "largeFileObjectAvailable")
out_urls.append(lfa_obj.url)
return out_urls

async def _long_wait_err_handle(self, gen: AsyncGenerator, timeout_seconds,
validate_fun: Callable[[Any], bool], name_of_wait: str) -> tuple[datetime,datetime]:
starttime = datetime.now()
Expand Down

0 comments on commit 07b0db3

Please sign in to comment.