diff --git a/doc/news/DM-46883.perf.rst b/doc/news/DM-46883.perf.rst new file mode 100644 index 000000000..b3b8a5735 --- /dev/null +++ b/doc/news/DM-46883.perf.rst @@ -0,0 +1 @@ +Add dofs vector option for `apply_dof.py` script. \ No newline at end of file diff --git a/python/lsst/ts/standardscripts/maintel/apply_dof.py b/python/lsst/ts/standardscripts/maintel/apply_dof.py index 37e5ec9f8..de5e48a68 100644 --- a/python/lsst/ts/standardscripts/maintel/apply_dof.py +++ b/python/lsst/ts/standardscripts/maintel/apply_dof.py @@ -79,6 +79,17 @@ def get_schema(cls) -> typing.Dict[str, typing.Any]: description: Configuration for ApplyDOF Script. type: object properties: + dofs: + type: array + description: >- + Defines a 50-dimensional vector for all DOFs, combining M2, + Camera, M1M3, and M2 bending modes. This overrides individual DOF inputs. + First 5 elements for M2, next 5 for Camera, next 20 for M1M3 bending modes, + last 20 for M2 bending modes. Units: microns or arcsec. + items: + type: number + minItems: 50 + maxItems: 50 M2_dz: type: number description: >- @@ -395,9 +406,12 @@ async def configure(self, config) -> None: # Configure tcs and camera await self.configure_tcs() - # Loop through properties and assign their values to the vector - for key, value in vars(config).items(): - self.dofs[getattr(DOFName, key)] = value + if hasattr(config, "dofs"): + self.dofs = config.dofs + else: + # Loop through properties and assign their values to the vector + for key, value in vars(config).items(): + self.dofs[getattr(DOFName, key)] = value def set_metadata(self, metadata) -> None: """Set script metadata. diff --git a/tests/test_maintel_apply_dof.py b/tests/test_maintel_apply_dof.py index ad4084292..58386878e 100644 --- a/tests/test_maintel_apply_dof.py +++ b/tests/test_maintel_apply_dof.py @@ -69,6 +69,21 @@ async def test_configure(self) -> None: assert all(self.script.dofs == dofs) + async def test_configure_with_dofs_vector(self) -> None: + async with self.make_script(): + dofs = np.zeros(len(DOFName)) + config_dofs = { + "M2_dz": 0.2, + "Cam_dy": 0.3, + "M1M3_B1": 0.5, + "M2_B14": 0.7, + "dofs": dofs, + } + + await self.configure_script(**config_dofs) + + assert all(self.script.dofs == dofs) + async def test_run(self) -> None: # Start the test itself async with self.make_script():