Skip to content

Commit

Permalink
A few other changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanmartim committed Jul 25, 2024
1 parent 33516f6 commit 70acaa1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
32 changes: 19 additions & 13 deletions python/lsst/ts/externalscripts/base_take_ptc_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import abc
import asyncio
import types

import yaml
from lsst.ts import salobj
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -358,14 +359,15 @@ 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
----------
config : `types.SimpleNamespace`
Script configuration, as defined by `schema`.
"""

await self.configure_camera()

if hasattr(config, "electrometer_scan"):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 13 additions & 10 deletions tests/maintel/test_take_ptc_flats_comcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 70acaa1

Please sign in to comment.