diff --git a/python/lsst/ts/externalscripts/base_take_ptc_flats.py b/python/lsst/ts/externalscripts/base_take_ptc_flats.py index b1ea0af37..9f47e3fe4 100644 --- a/python/lsst/ts/externalscripts/base_take_ptc_flats.py +++ b/python/lsst/ts/externalscripts/base_take_ptc_flats.py @@ -22,6 +22,7 @@ import abc import asyncio +import types import yaml from lsst.ts import salobj @@ -257,21 +258,21 @@ async def configure_camera(self): """ raise NotImplementedError() - async def configure_electrometer(self, elec_index): + async def configure_electrometer(self, index): """Configure the Electrometer remote object.""" if self.electrometer is None: self.log.debug( - f"Configuring remote for Electrometer index: {elec_index}" + f"Configuring remote for Electrometer index: {index}" ) self.electrometer = salobj.Remote( - self.domain, name="Electrometer", index=elec_index + self.domain, name="Electrometer", index=index ) await self.electrometer.start_task else: self.log.debug("Electrometer already configured. Ignoring.") @classmethod - def get_schema(cls) -> dict: + def get_schema(cls): default_flats_exp_times_str = ", ".join( map(str, cls.DEFAULT_PTC_EXP_TIMES) ) @@ -323,8 +324,8 @@ def get_schema(cls) -> dict: minimum: 1 mode: description: > - Electrometer measurement mode as a string. Valid options are - "CURRENT" and "CHARGE". + Electrometer measurement mode as a string. Valid options + are "CURRENT" and "CHARGE". type: string enum: ["CURRENT", "CHARGE"] default: "CURRENT" @@ -358,7 +359,7 @@ def get_schema(cls) -> dict: return schema_dict - async def configure(self, config) -> None: + async def configure(self, config: types.SimpleNamespace): """Configure script components including camera and electrometer. Parameters @@ -366,6 +367,7 @@ async def configure(self, config) -> None: config : `types.SimpleNamespace` Script configuration, as defined by `schema`. """ + await self.configure_camera() if hasattr(config, "electrometer_scan"): @@ -406,12 +408,16 @@ async def configure(self, config) -> None: "be a scalar." ) - if not isinstance(config.dark_exp_times, list): - config.dark_exp_times = ( - [config.dark_exp_times] * config.n_darks + if not isinstance(config.interleave_darks.dark_exp_times, list): + config.interleave_darks.dark_exp_times = ( + [config.interleave_darks.dark_exp_times] * ( + config.interleave_darks.n_darks + ) ) else: - config.n_darks = len(config.dark_exp_times) + config.interleave_darks.n_darks = len( + config.interleave_darks.dark_exp_times + ) self.config = config @@ -581,8 +587,8 @@ async def take_ptc_flats(self): mode=self.config.electrometer_scan.mode, range=self.config.electrometer_scan.range, integration_time=( - self.config.electrometer_scan.integration_time, - ) + self.config.electrometer_scan.integration_time + ), ) for i in range(0, len(self.config.flats_exp_times), 2): diff --git a/python/lsst/ts/externalscripts/maintel/take_ptc_flats_comcam.py b/python/lsst/ts/externalscripts/maintel/take_ptc_flats_comcam.py index c7bfc777a..56b1afbe3 100644 --- a/python/lsst/ts/externalscripts/maintel/take_ptc_flats_comcam.py +++ b/python/lsst/ts/externalscripts/maintel/take_ptc_flats_comcam.py @@ -61,7 +61,7 @@ def get_schema(cls): type: object properties: filter: - description: Filter name or ID. Default: "r_03" + description: Filter name or ID. anyOf: - type: string - type: integer diff --git a/tests/maintel/test_take_ptc_flats_comcam.py b/tests/maintel/test_take_ptc_flats_comcam.py index 856b830ae..d0fc80fc9 100644 --- a/tests/maintel/test_take_ptc_flats_comcam.py +++ b/tests/maintel/test_take_ptc_flats_comcam.py @@ -35,20 +35,23 @@ def mock_electrometer(self): self.script.electrometer.evt_largeFileObjectAvailable = mock.Mock() async def test_configure(self): + electrometer_config = { + "index": 1, + "mode": "CURRENT", + "range": -1, + "integration_time": 0.1 + } + interleave_darks_config = { + "dark_exp_times": 30, + "n_darks": 2 + } + config = { "filter": "r_03", "flats_exp_times": [7.25, 7.25], - "electrometer_scan": { - "index": 1, - "mode": "CURRENT", - "range": -1, - "integration_time": 0.1 - }, - "interleave_darks": { - "dark_exp_times": 30, - "n_darks": 2 + "electrometer_scan": electrometer_config, + "interleave_darks": interleave_darks_config, } - } async with self.make_script(): await self.configure_script(**config)