Skip to content

Commit

Permalink
fix more lint and mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
weatherhead99 committed Dec 12, 2023
1 parent c8f0610 commit 080e5e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
9 changes: 5 additions & 4 deletions python/lsst/ts/observatory/control/auxtel/atcalsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async def power_sequence_run(self, scriptobj: salobj.BaseScript, **kwargs) -> No
case CalsysScriptIntention.POWER_ON:
await self._chiller_power(True)
await scriptobj.checkpoint("Chiller started")
chiller_start, chiller_end = await self._chiller_settle(True)
chiller_start, chiller_end = await self._chiller_settle()
self.log_event_timings(
self.log,
"chiller cooldown time",
Expand Down Expand Up @@ -253,10 +253,10 @@ async def power_sequence_run(self, scriptobj: salobj.BaseScript, **kwargs) -> No
"lamp commanded off and shutter commanded closed"
)
shutter_wait_fut = asyncio.create_task(
self._lamp_power(False), "lamp stop shutter close"
self._lamp_power(False), name="lamp stop shutter close"
)
lamp_settle_fut = asyncio.create_task(
self._lamp_settle(False), "lamp power settle"
self._lamp_settle(False), name="lamp power settle"
)

shutter_start, shutter_end = await shutter_wait_fut
Expand Down Expand Up @@ -366,9 +366,10 @@ async def _lamp_power(self, onoff: bool) -> Awaitable:
power=self.WHITELIGHT_POWER,
)

timeout = self.CMD_TIMEOUT.to(un.s)
await asyncio.wait(
[shutter_task, lamp_start_task],
timeout=self._cmd_timeout,
timeout=timeout,
return_when=asyncio.FIRST_EXCEPTION,
)

Expand Down
29 changes: 17 additions & 12 deletions python/lsst/ts/observatory/control/base_calsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Optional,
Sequence,
TypeAlias,
TypeVar,
Union,
)

Expand All @@ -29,15 +30,16 @@
from .remote_group import RemoteGroup

Responsivity: TypeAlias = Quantity[ampere / watt]
T = TypeVar("T")


def _calsys_get_parameter(
indct: dict[str, Any],
indct: dict[str, T],
key: str,
factory_callable: Callable,
*factory_args,
**factory_kwargs,
):
*factory_args: Any,
**factory_kwargs: Any,
) -> T:
if indct.get(key, None) is None:
return factory_callable(*factory_args, **factory_kwargs)

Expand Down Expand Up @@ -104,7 +106,7 @@ def end_to_end_throughput(self, wavelen: float, calsys_power: float) -> float:
[
self.detector_throughput,
self.spectrograph_throughput,
self.radiometer_throughput,
self.radiometer_responsivity,
],
)

Expand Down Expand Up @@ -153,7 +155,10 @@ def load_calibration_csv(cls, fname: str) -> Mapping[str, Sequence[float]]:
res = files(cls.BASERES).joinpath(fname)
with res.open("r") as f:
rdr = csv.DictReader(f)
out = {k: [] for k in rdr.fieldnames}
if rdr.fieldnames is None:
raise ValueError("calibration curve has no fieldnames!")

out: dict[str, list[float]] = {k: [] for k in rdr.fieldnames}
for row in rdr:
for k, v in row.items():
val: float = float(v) if len(v) > 0 else 0.0
Expand All @@ -177,12 +182,11 @@ def radiometer_responsivity(self, wavelen: Quantity[un.physical.length]) -> Resp
"radiometer", self.RADIOMETER_CALFILE, "wavelength", "responsivity"
)

wlin: float = wavelen.to(nm).value
Rawout: float = itp(wlin)
return Rawout << un.ampere / un.watt

def maintel_throughput(
self, wavelen: Quantity[un.physical.length], filter_band: chr
self, wavelen: Quantity[un.physical.length], filter_band: str
) -> Quantity[un.dimensionless_unscaled]:
calfilename: str = f"calibration_tput_init_{filter_band}.csv"
itp = self._ensure_itp(
Expand All @@ -204,7 +208,7 @@ class BaseCalsys(RemoteGroup, metaclass=ABCMeta):
def __init__(
self,
intention: CalsysScriptIntention,
components: Iterable[str],
components: list[str],
domain: Optional[salobj.domain.Domain] = None,
cmd_timeout: Optional[int] = 10,
log: Optional[logging.Logger] = None,
Expand Down Expand Up @@ -282,7 +286,7 @@ async def gen():
def _long_wait(
self,
gen: AsyncGenerator,
timeout_seconds,
timeout_seconds: float,
validate_fun: Callable[[Any], bool],
run_immediate: bool = True,
) -> TaskOrCoro:
Expand All @@ -298,7 +302,7 @@ async def completer() -> None:

async def _cal_expose_helper(
self, obj, n: int, cmdname: str, **extra_kwargs
) -> Awaitable[list[str]]:
) -> list[str]:
out_urls: list[str] = []
for i in range(n):
await self._sal_cmd(obj, cmdname, **extra_kwargs)
Expand All @@ -309,7 +313,7 @@ async def _cal_expose_helper(
async def _long_wait_err_handle(
self,
gen: AsyncGenerator,
timeout_seconds,
timeout_seconds: float,
validate_fun: Callable[[Any], bool],
name_of_wait: str,
) -> tuple[datetime, datetime]:
Expand Down Expand Up @@ -366,6 +370,7 @@ def detector_exposure_time_for_nelectrons(

# must have a way to access the calibration data
assert issubclass(type(self), CalsysThroughputCalculationMixin)
raise NotImplementedError("throughput calc for detector not implemented yet!")

def spectrograph_exposure_time_for_nelectrons(self, nelec: float) -> float:
raise NotImplementedError(
Expand Down

0 comments on commit 080e5e0

Please sign in to comment.