diff --git a/python/lsst/ts/standardscripts/auxtel/calibrations/power_on_atcalsys.py b/python/lsst/ts/standardscripts/auxtel/calibrations/power_on_atcalsys.py index cd74a5931..1a5881649 100644 --- a/python/lsst/ts/standardscripts/auxtel/calibrations/power_on_atcalsys.py +++ b/python/lsst/ts/standardscripts/auxtel/calibrations/power_on_atcalsys.py @@ -29,9 +29,11 @@ from lsst.ts import salobj +track_lamp_warmup = 60 + class PowerOnATCalSys(salobj.BaseScript): - """Powers on the ATCalSys dome flat illuminator + """Powers on the ATCalSys dome flat illuminator (ATWhiteLight and ATMonochromator) required to perform image calibrations over white light. @@ -55,22 +57,26 @@ def __init__(self, index): self.monochromator = None self.timeout_lamp_warm_up = 60 * 15 - self.track_lamp_warmup = 60 self.cmd_timeout = 30 - # # Chiller config + # Chiller config self.timeout_chiller_cool_down = 60 * 10 self.chiller_temp_tolerance_relative = 0.1 - # if self.white_light_source is None: - # self.white_light_source = salobj.Remote( - # domain=self.domain, name="ATWhiteLight" - # ) + if self.white_light_source is None: + self.white_light_source = salobj.Remote( + domain=self.domain, name="ATWhiteLight" + ) - # if self.monochromator is None: - # self.monochromator = salobj.Remote( - # domain=self.domain, name="ATMonochromator" - # ) + if self.monochromator is None: + self.monochromator = salobj.Remote( + domain=self.domain, name="ATMonochromator" + ) + + asyncio.gather( + self.white_light_source.start_task, + self.monochromator.start_task, + ) @classmethod def get_schema(cls): @@ -89,9 +95,9 @@ def get_schema(cls): default: 20 minimum: 15 - whitelight_power: - description: White light power. - type: number + whitelight_power: + description: White light power. + type: number default: 910 minimum: 0 @@ -145,20 +151,17 @@ async def configure(self, config): self.entrance_slit_width = config.entrance_slit_width self.exit_slit_width = config.exit_slit_width - if self.white_light_source is None: - self.white_light_source = salobj.Remote( - domain=self.domain, name="ATWhiteLight" - ) + # if self.white_light_source is None: + # self.white_light_source = salobj.Remote( + # domain=self.domain, name="ATWhiteLight" + # ) - if self.monochromator is None: - self.monochromator = salobj.Remote( - domain=self.domain, name="ATMonochromator" - ) + # if self.monochromator is None: + # self.monochromator = salobj.Remote( + # domain=self.domain, name="ATMonochromator" + # ) - await asyncio.gather( - self.white_light_source.start_task, - self.monochromator.start_task, - ) + self.config = config @@ -175,7 +178,7 @@ def set_metadata(self, metadata): async def run(self): """Run script.""" - await self.assert_components_enabled() + #await self.assert_components_enabled() await self.checkpoint("Starting chiller") await self.start_chiller() @@ -202,10 +205,9 @@ async def start_chiller(self): await self.white_light_source.cmd_startChiller.set_start() async def wait_for_chiller_temp_within_tolerance(self): - chiller_temp_within_tolerance = False start_time_chill_time = time.time() - while time.time() - start_time_chill_time < timeout_chiller_cool_down: - chiller_temps = await white_light_source.tel_chillerTemperatures.aget() + while time.time() - start_time_chill_time < self.timeout_chiller_cool_down: + chiller_temps = await self.white_light_source.tel_chillerTemperatures.aget() tel_chiller_temp = chiller_temps.supplyTemperature if ( chiller_temps.setTemperature @@ -214,35 +216,36 @@ async def wait_for_chiller_temp_within_tolerance(self): < chiller_temps.setTemperature * (1.0 + self.chiller_temp_tolerance_relative) ): - chiller_temp_within_tolerance = True chill_time = time.time() - start_time_chill_time self.log.info( - f"Chiller reached target temperature {tel_chiller_temp} within tolerance in {chill_time} s" + f"Chiller reached target temperature {tel_chiller_temp}" + f"within tolerance in {chill_time} s" ) break else: continue else: raise TimeoutError( - f"Gave up waiting after {timeout_chiller_cool_down} for the chiller to chill to {self.chiller_temperature}. Stayed at {tel_chiller_temp}" + f"Gave up waiting after {self.timeout_chiller_cool_down}" + f"for the chiller to chill to {self.chiller_temperature}." + f"Stayed at {tel_chiller_temp}" ) async def open_white_light_shutter(self): await self.white_light_source.cmd_openShutter.set_start() - ## Should we include a check that the shutter is open or not necessary? + # Q? Should we include a check that the shutter is open? async def switch_lamp_on(self): await self.white_light_source.cmd_turnLampOn.set_start( - power=self.whitelight_power, timeout=timeout_lamp_warm_up + power=self.whitelight_power, timeout=self.timeout_lamp_warm_up ) async def wait_for_lamp_to_warm_up(self): self.white_light_source.evt_lampState.flush() - start_time_lamp_warm_up = time.time() - while time.time() - start_time_lamp_warm_up < timeout_lamp_warm_up: + while time.time() - start_time_lamp_warm_up < self.timeout_lamp_warm_up: lamp_state = await self.white_light_source.evt_lampState.next( - flush=False, timeout=timeout_lamp_warm_up + flush=False, timeout=self.timeout_lamp_warm_up ) if lamp_state.basicState == ATWhiteLight.LampBasicState.WARMUP: warmup_time_left = ( @@ -256,16 +259,16 @@ async def wait_for_lamp_to_warm_up(self): f"White Light Lamp is on after a warm up of {time.time() - start_time_lamp_warm_up} s" ) else: - raise ValueError(f"White Light Lamp is not warming up or turning on") + raise ValueError("White Light Lamp is not warming up or turning on") else: raise TimeoutError( - f"White Light Lamp failed to turn on after {timeout_lamp_warm_up} s" + f"White Light Lamp failed to turn on after {self.timeout_lamp_warm_up} s" ) async def configure_atmonochromator(self): await self.monochromator.cmd_selectGrating.set_start( - gratingType=self.grating, timeout=cmd_timeout + gratingType=self.grating, timeout=self.cmd_timeout ) await self.monochromator.cmd_changeWavelength.set_start( @@ -283,7 +286,10 @@ async def configure_atmonochromator(self): params = await self.get_monochromator_parameters() self.log.info( - f"ATMonochromator grating is {params[0]}, wavelength is {params[1]} nm with entry slit width {params[2]} and exit slit width {params[3]}" + f"ATMonochromator grating is {params[0]}, " + f"wavelength is {params[1]} nm " + f"with entry slit width {params[2]} " + f"and exit slit width {params[3]}" ) async def get_monochromator_parameters(self): @@ -293,11 +299,11 @@ async def get_monochromator_parameters(self): tmp4 = await self.monochromator.evt_exitSlitWidth.aget() return (tmp1.gratingType, tmp2.wavelength, tmp3.width, tmp4.width) - async def assert_components_enabled(): + async def assert_components_enabled(self): """Check if ATWhiteLight and ATMonochromator are ENABLED""" - for component in [self.white_light_source, self.monochromator]: - summary_state = await component.evt_summaryState.aget() + for comp in [self.white_light_source, self.monochromator]: + summary_state = await comp.evt_summaryState.aget() if salobj.State(summary_state.summaryState) != salobj.State( salobj.State.ENABLED ): - raise Exception(f"{component} is not ENABLED") + raise Exception(f"{comp} is not ENABLED")