Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/DM-45823: Establish um as the unit for hexapod offsets in BaseFocusSweep and implement conversion to mm for auxtel in FocusSweepLatiss #233

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/news/DM-45823.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Establish ``µm`` as the unit for hexapod offsets (configuration attributes ``focus_window`` and ``focus_step_sequence``) in ``BaseFocusSweep`` and implement conversion to ``mm`` for AuxTel in ``FocusSweepLatiss``.
29 changes: 29 additions & 0 deletions python/lsst/ts/standardscripts/auxtel/focus_sweep_latiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ def get_schema(cls) -> dict:
schema_dict["properties"].update(additional_properties)
return schema_dict

async def configure(self, config):
"""Configure script.

Parameters
----------
config : `types.SimpleNamespace`
Script configuration, as defined by `schema`.
"""
await super().configure(config=config)
original_focus_window = self.config.focus_window
original_focus_step_sequence = self.config.focus_step_sequence
self.config.focus_window *= 0.001 # Transform from um to mm
self.config.focus_step_sequence = [
step * 0.001 for step in self.config.focus_step_sequence # Transform to mm
]
self.log.debug(
f"""Applying unit conversion from um to mm for ATHexapod use.

Original values in um from base class configuration are:

focus_window = {original_focus_window} um
focus_step_sequence = {original_focus_step_sequence} um

Converted values:
focus_window = {self.config.focus_window} mm
focus_step_sequence = {self.config.focus_step_sequence} mm
"""
)

def get_instrument_configuration(self) -> dict:
return dict(
filter=self.config.filter,
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ts/standardscripts/base_focus_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ def get_schema(cls) -> dict:
type: string
enum: ["x", "y", "z", "u", "v"]
focus_window:
description: Total range (window) for the focus sweep.
description: Total range (window) measured in um for the focus sweep.
type: number
n_steps:
description: Number of steps to take inside the focus window.
type: number
minimum: 2
focus_step_sequence:
description: >-
User-provided sequence of focus steps to take for the focus sweep,
User-provided sequence of focus steps measured in um to take for the focus sweep,
used for unevenly spaced steps.
type: array
items:
Expand Down
38 changes: 23 additions & 15 deletions tests/test_auxtel_focus_sweep_latiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def mock_ocps(self):
async def test_configure(self):
config = {
"axis": "x",
"focus_window": 700,
"focus_window": 700, # Value measured in um
"n_steps": 7,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand All @@ -74,7 +74,9 @@ async def test_configure(self):
await self.configure_script(**config)

assert self.script.config.axis == "x"
assert self.script.config.focus_window == 700
self.assertAlmostEqual(
self.script.config.focus_window, 0.7
) # Checks that translation to mm was made
assert self.script.config.n_steps == 7
assert self.script.config.exp_time == 10.0
assert self.script.config.filter == "SDSSr_65mm"
Expand All @@ -84,19 +86,21 @@ async def test_configure(self):
async def test_configure_focus_step_sequence(self):
config = {
"axis": "x",
"focus_step_sequence": [-0.2, -0.1, 0, 0.1, 0.2],
"focus_step_sequence": [-200, -100, 0, 100, 200], # Measured in um
"exp_time": 10.0,
"filter": "SDSSr_65mm",
"grating": 1,
"n_images_per_step": 1,
}

expected_step_sequence = [-0.2, -0.1, 0, 0.1, 0.2]
expected_step_sequence = [-0.2, -0.1, 0, 0.1, 0.2] # Measured in mm
async with self.make_script():
await self.configure_script(**config)

assert self.script.config.axis == "x"
assert self.script.config.focus_window == 0.4
self.assertAlmostEqual(
self.script.config.focus_window, 0.4
) # Measured in mm
assert self.script.config.n_steps == 5
for step, expected_step in zip(
self.script.config.focus_step_sequence, expected_step_sequence
Expand All @@ -110,7 +114,7 @@ async def test_configure_focus_step_sequence(self):
async def test_configure_focus_step_sequence_with_window(self):
config = {
"axis": "x",
"focus_window": 0.4,
"focus_window": 400, # Measured in um
"n_steps": 5,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand All @@ -123,7 +127,9 @@ async def test_configure_focus_step_sequence_with_window(self):
await self.configure_script(**config)

assert self.script.config.axis == "x"
assert self.script.config.focus_window == 0.4
self.assertAlmostEqual(
self.script.config.focus_window, 0.4 # Measured in mm
)
assert self.script.config.n_steps == 5
for step, expected_step in zip(
self.script.config.focus_step_sequence, expected_step_sequence
Expand All @@ -137,7 +143,7 @@ async def test_configure_focus_step_sequence_with_window(self):
async def test_configure_ignore(self):
config = {
"axis": "x",
"focus_window": 700,
"focus_window": 700, # Measured in um
"n_steps": 7,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand All @@ -154,7 +160,9 @@ async def test_configure_ignore(self):
await self.configure_script(**config)

assert self.script.config.axis == "x"
assert self.script.config.focus_window == 700
self.assertAlmostEqual(
self.script.config.focus_window, 0.7 # Measured in mm
)
assert self.script.config.n_steps == 7
assert self.script.config.exp_time == 10.0
assert self.script.config.filter == "SDSSr_65mm"
Expand All @@ -169,7 +177,7 @@ async def test_invalid_configuration(self):
bad_configs = [
{
"axis": "invalid_axis",
"focus_window": 700,
"focus_window": 700, # Measured in um
"n_steps": 7,
"exp_time": 10,
"filter": "SDSSr_65mm",
Expand All @@ -178,7 +186,7 @@ async def test_invalid_configuration(self):
},
{
"axis": "z",
"focus_window": 700,
"focus_window": 700, # Measured in um
"n_steps": 1,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand All @@ -195,9 +203,9 @@ async def test_invalid_configuration(self):
async def test_invalid_configuration_steps_and_window(self):
bad_config = {
"axis": "x",
"focus_window": 0.4,
"focus_window": 400, # Measured in um
"n_steps": 5,
"focus_step_sequence": [-0.2, -0.1, 0, 0.1, 0.2],
"focus_step_sequence": [-200, -100, 0, 100, 200], # Measured in um
"exp_time": 10,
"filter": "SDSSr_65mm",
"grating": "blue300lpmm_qn1",
Expand All @@ -211,7 +219,7 @@ async def test_invalid_configuration_steps_and_window(self):
async def test_focus_sweep(self):
config = {
"axis": "x",
"focus_window": 700,
"focus_window": 700, # Measured in um
"n_steps": 7,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand All @@ -235,7 +243,7 @@ async def test_focus_sweep(self):
async def test_cleanup(self):
config = {
"axis": "x",
"focus_window": 700,
"focus_window": 700, # Measured in um
"n_steps": 7,
"exp_time": 10.0,
"filter": "SDSSr_65mm",
Expand Down
Loading