Skip to content

Commit

Permalink
Merge pull request #155 from lsst-ts/tickets/DM-47364
Browse files Browse the repository at this point in the history
Fix signs and make rotation optional in parameter_march
  • Loading branch information
gmegh authored Nov 5, 2024
2 parents a6bd1cc + 2bee9ec commit a621637
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47364.perf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix signs and make rotation optional in parameter_march.py
54 changes: 31 additions & 23 deletions python/lsst/ts/externalscripts/base_parameter_march.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,20 @@ def get_schema(cls) -> dict:
properties:
az:
description: Azimuth position to point to.
type: number
minimum: 0
maximum: 360
anyOf:
- type: number
minimum: 0
maximum: 360
- type: "null"
default: null
el:
description: Elevation position to point to.
type: number
minimum: 0
maximum: 90
anyOf:
- type: number
minimum: 0
maximum: 90
- type: "null"
default: null
filter:
description: Filter name or ID; if omitted the filter is not changed.
anyOf:
Expand Down Expand Up @@ -261,7 +267,7 @@ async def configure(self, config: types.SimpleNamespace) -> None:
self.range = config.range
self.n_steps = config.n_steps
self.step_sequence = np.linspace(
-self.range, self.range, self.n_steps
-self.range / 2, self.range / 2, self.n_steps
).tolist()

if hasattr(config, "rotation_sequence"):
Expand Down Expand Up @@ -393,11 +399,11 @@ async def parameter_march(self) -> None:
if self.rotation_sequence is not None:
await self.track_target_with_rotation(self.rotation_sequence[0])

await self.take_images()
rot_offsets = [
rot - self.rotation_sequence[0] for rot in self.rotation_sequence
]

rot_offsets = [
rot - self.rotation_sequence[0] for rot in self.rotation_sequence
]
await self.take_images()

for self.iterations_executed in range(1, self.n_steps):
await self.checkpoint(f"Step {self.iterations_executed+1}/{self.n_steps}.")
Expand All @@ -416,18 +422,19 @@ async def parameter_march(self) -> None:
# Store the total offset
self.total_offset += offset

rotation = await self.tcs.rem.mtrotator.tel_rotation.next(
flush=True, timeout=self.tcs.long_timeout
)
rot_tracking_correction = (
rotation.actualPosition
- self.rotation_sequence[self.iterations_executed - 1]
)
if self.rotation_sequence is not None:
rotation = await self.tcs.rem.mtrotator.tel_rotation.next(
flush=True, timeout=self.tcs.long_timeout
)
rot_tracking_correction = (
rotation.actualPosition
- self.rotation_sequence[self.iterations_executed - 1]
)

await self.tcs.offset_rot(
rot_offsets[self.iterations_executed] - rot_tracking_correction
)
await self.tcs.check_tracking(track_duration=1.0)
await self.tcs.offset_rot(
rot_offsets[self.iterations_executed] - rot_tracking_correction
)
await self.tcs.check_tracking(track_duration=1.0)

# Take images at the current dof position
await self.take_images()
Expand Down Expand Up @@ -480,7 +487,8 @@ async def cleanup(self):
for i, dof_offset in enumerate(self.dofs * -self.total_offset):
offset_dof_data.value[i] = dof_offset
await self.tcs.rem.mtaos.cmd_offsetDOF.start(data=offset_dof_data)
await self.tcs.offset_rot(0.0)
if self.rotation_sequence is not None:
await self.tcs.offset_rot(0.0)

except Exception:
self.log.exception(
Expand Down
2 changes: 1 addition & 1 deletion tests/maintel/test_maintel_parameter_march_comcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def test_configure(self):
assert self.script.config.exp_time == 30.0
assert np.array_equal(self.script.dofs, [1] * 50)
assert self.script.rotation_sequence == [50] * 11
assert self.script.step_sequence == np.linspace(-1, 1, 11).tolist()
assert self.script.step_sequence == np.linspace(-0.5, 0.5, 11).tolist()
assert self.script.range == 1
assert self.script.n_steps == 11
assert self.script.config.program == "BLOCK-TXXX"
Expand Down
2 changes: 1 addition & 1 deletion tests/maintel/test_maintel_parameter_march_lsstcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def test_configure(self):
assert self.script.config.exp_time == 30.0
assert np.array_equal(self.script.dofs, [1] * 50)
assert self.script.rotation_sequence == [50] * 11
assert self.script.step_sequence == np.linspace(-1, 1, 11).tolist()
assert self.script.step_sequence == np.linspace(-0.5, 0.5, 11).tolist()
assert self.script.range == 1
assert self.script.n_steps == 11
assert self.script.config.program == "BLOCK-TXXX"
Expand Down

0 comments on commit a621637

Please sign in to comment.