From 2bee9ec3a01060b2dcce9dee98574e2080128a2f Mon Sep 17 00:00:00 2001 From: gmegh Date: Mon, 4 Nov 2024 14:40:01 -0800 Subject: [PATCH] Fix signs and make rotation optional in parameter_march --- doc/news/DM-47364.perf.rst | 1 + .../externalscripts/base_parameter_march.py | 54 +++++++++++-------- .../test_maintel_parameter_march_comcam.py | 2 +- .../test_maintel_parameter_march_lsstcam.py | 2 +- 4 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 doc/news/DM-47364.perf.rst diff --git a/doc/news/DM-47364.perf.rst b/doc/news/DM-47364.perf.rst new file mode 100644 index 000000000..06e706d88 --- /dev/null +++ b/doc/news/DM-47364.perf.rst @@ -0,0 +1 @@ +Fix signs and make rotation optional in parameter_march.py \ No newline at end of file diff --git a/python/lsst/ts/externalscripts/base_parameter_march.py b/python/lsst/ts/externalscripts/base_parameter_march.py index 9a96aa438..b45dcdd79 100644 --- a/python/lsst/ts/externalscripts/base_parameter_march.py +++ b/python/lsst/ts/externalscripts/base_parameter_march.py @@ -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: @@ -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"): @@ -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}.") @@ -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() @@ -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( diff --git a/tests/maintel/test_maintel_parameter_march_comcam.py b/tests/maintel/test_maintel_parameter_march_comcam.py index 5630b7d31..c06a0c35f 100644 --- a/tests/maintel/test_maintel_parameter_march_comcam.py +++ b/tests/maintel/test_maintel_parameter_march_comcam.py @@ -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" diff --git a/tests/maintel/test_maintel_parameter_march_lsstcam.py b/tests/maintel/test_maintel_parameter_march_lsstcam.py index 9c43ce6dd..0c5c86a1e 100644 --- a/tests/maintel/test_maintel_parameter_march_lsstcam.py +++ b/tests/maintel/test_maintel_parameter_march_lsstcam.py @@ -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"