Skip to content

Commit

Permalink
couple more mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weatherhead99 committed Dec 12, 2023
1 parent 79bbd14 commit c8f0610
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
44 changes: 23 additions & 21 deletions python/lsst/ts/observatory/control/auxtel/atcalsys.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from typing import List, Optional, NamedTuple
import asyncio
from collections.abc import Awaitable
from dataclasses import dataclass
from datetime import datetime
from typing import List, NamedTuple, Optional

import astropy.units as un
from astropy.units import Quantity
from lsst.ts import salobj
from lsst.ts.idl.enums import ATMonochromator, ATWhiteLight

from ..base_calsys import (
BaseCalsys,
HardcodeCalsysThroughput,
CalibrationSequenceStepBase,
CalsysScriptIntention,
HardcodeCalsysThroughput,
_calsys_get_parameter,
)
from ..base_calsys import CalsysScriptIntention, _calsys_get_parameter
from lsst.ts import salobj
from lsst.ts.idl.enums import ATMonochromator
from lsst.ts.idl.enums import ATWhiteLight
import asyncio
import astropy.units as un
from astropy.units import Quantity
from datetime import datetime
from collections.abc import Awaitable
from dataclasses import dataclass


class ATSpectrographSlits(NamedTuple):
Expand Down Expand Up @@ -83,7 +85,7 @@ async def setup_for_wavelength(
slit_widths = _calsys_get_parameter(
override_kwargs,
"slit_widths",
self.calculate_slit_widths,
self.calculate_slit_width,
wavelen,
spectral_res,
grating,
Expand All @@ -95,7 +97,7 @@ async def setup_for_wavelength(
self.log.debug(f"calculated grating is {grating}")

monoch_fut = self._sal_cmd(
self.ATMonoChromator,
self.ATMonochromator,
"updateMonochromatorSetup",
gratingType=grating,
frontExitSlitWidth=slit_widths.FRONTEXIT,
Expand Down Expand Up @@ -160,7 +162,7 @@ def calculate_grating_type(
async def _electrometer_expose(self) -> Awaitable[list[str]]:
assert self._n_elec_exps is not None
assert self._elecsposure_time is not None
return await self._cal_expose_helper(
return self._cal_expose_helper(
self.Electrometer,
self._n_elec_exps,
"startScanDt",
Expand All @@ -171,7 +173,7 @@ async def _spectrograph_expose(self) -> Awaitable[list[str]]:
assert self._n_spec_exps is not None
assert self._specsposure_time is not None

return await self._cal_expose_helper(
return self._cal_expose_helper(
self.ATSpectrograph,
self._n_spec_exps,
"expose",
Expand Down Expand Up @@ -204,7 +206,7 @@ def script_time_estimate_s(self) -> float:
"don't know how to handle this script intention"
)

async def power_sequence_run(self, scriptobj: salobj.BaseScript):
async def power_sequence_run(self, scriptobj: salobj.BaseScript, **kwargs) -> None:
match (self._intention):
case CalsysScriptIntention.POWER_ON:
await self._chiller_power(True)
Expand All @@ -220,10 +222,10 @@ async def power_sequence_run(self, scriptobj: salobj.BaseScript):

await scriptobj.checkpoint("Chiller setpoint temperature reached")
shutter_wait_fut = asyncio.create_task(
self._lamp_power(True), "lamp_start_shutter_open"
self._lamp_power(True), name="lamp_start_shutter_open"
)
lamp_settle_fut = asyncio.create_task(
self._lamp_settle(True), "lamp_power_settle"
self._lamp_settle(True), name="lamp_power_settle"
)
shutter_start, shutter_end = await shutter_wait_fut
self.log_event_timings(
Expand Down Expand Up @@ -340,7 +342,7 @@ async def _chiller_settle(self) -> Awaitable[tuple[datetime, datetime]]:
chiller_wait_timeout: float = self.CHILLER_COOLDOWN_TIMEOUT.to(un.s).value
chiller_temp_gen = self._sal_telem_gen(self.ATWhiteLight, "chillerTemperatures")

return await self._long_wait_err_handle(
return self._long_wait_err_handle(
chiller_temp_gen,
chiller_wait_timeout,
self._chiller_temp_check,
Expand Down Expand Up @@ -400,7 +402,7 @@ def lamp_verify(evt):
lamp_evt_gen, lamp_settle_timeout, lamp_verify, lamp_transition_name
)

async def take_calibration_data(self) -> Awaitable[dict[str, list[str]]]:
async def take_calibration_data(self) -> dict[str, list[str]]:
spec_fut = self._spectrograph_expose()
elec_fut = self._electrometer_expose()

Expand Down
35 changes: 22 additions & 13 deletions python/lsst/ts/observatory/control/base_calsys.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import asyncio
import csv
import enum
import logging
from abc import ABCMeta, abstractmethod
from collections.abc import AsyncGenerator, Callable, Coroutine
from dataclasses import dataclass
from .remote_group import RemoteGroup
from typing import Iterable, Optional, Union
from typing import Sequence, Mapping, TypeAlias, Any, Awaitable
from datetime import datetime
from functools import reduce
from collections.abc import Coroutine, Callable, AsyncGenerator
from importlib.resources import files
from itertools import count
from typing import (
Any,
Awaitable,
Iterable,
Mapping,
Optional,
Sequence,
TypeAlias,
Union,
)

import astropy.units as un
from astropy.units import Quantity, ampere, nm, watt
from lsst.ts import salobj
from lsst.ts.idl.enums import Electrometer
import logging
import asyncio
from importlib.resources import files
import csv
from scipy.interpolate import InterpolatedUnivariateSpline
from astropy.units import ampere, watt, nm, Quantity
import astropy.units as un
import enum
from datetime import datetime
from itertools import count

from .remote_group import RemoteGroup

Responsivity: TypeAlias = Quantity[ampere / watt]

Expand Down

0 comments on commit c8f0610

Please sign in to comment.