Skip to content

Commit

Permalink
Add dofs vector option to apply_dof.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gmegh committed Oct 16, 2024
1 parent d342959 commit a275610
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-46883.perf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add dofs vector option for `apply_dof.py` script.
20 changes: 17 additions & 3 deletions python/lsst/ts/standardscripts/maintel/apply_dof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions tests/test_maintel_apply_dof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit a275610

Please sign in to comment.