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-48018: Script for balanced AOS triplets. #253

Closed
wants to merge 11 commits into from
Closed
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/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ New Features
- Update HomeBothAxis script to re-enable the force balance system after homing the mount. (`DM-47641 <https://rubinobs.atlassian.net/browse/DM-47641>`_)
- In base_track_target, update track_azel routine to remove stop_tracking before start_tracking. (`DM-47641 <https://rubinobs.atlassian.net/browse/DM-47641>`_)
- In maintel/base_close_loop.py, make filter required. (`DM-47641 <https://rubinobs.atlassian.net/browse/DM-47641>`_)
- Add ``maintel/take_aos_sequence_balanced_comcam.py``, which takes AOS triplets while evenly dividing dz offsets between the camera and M2 hexapods. (`DM-48018 <https://rubinobs.atlassian.net/browse/DM-48018>`_)


Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
# This file is part of ts_standardscripts
#
# Developed for the LSST Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import asyncio

from lsst.ts.standardscripts.maintel import TakeAOSSequenceComCam

asyncio.run(TakeAOSSequenceComCam.amain())
1 change: 1 addition & 0 deletions python/lsst/ts/standardscripts/maintel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from .standby_mtcs import *
from .stop import *
from .stop_rotator import *
from .take_aos_sequence_balanced_comcam import *
from .take_aos_sequence_comcam import *
from .take_image_anycam import *
from .take_image_comcam import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file is part of ts_standardscripts
#
# Developed for the LSST Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = ["TakeAOSSequenceBalancedComCam"]


from lsst.ts.standardscripts.maintel.take_aos_sequence_comcam import (
TakeAOSSequenceComCam,
)


class TakeAOSSequenceBalancedComCam(TakeAOSSequenceComCam):
"""Take aos sequence, either triplet (intra-focal, extra-focal
and in-focus images), intra doublets (intra and in-focus) or extra
doublets (extra and in-focus) sequences with ComCam.

This version splits the dz offset evenly between the camera and M2
hexapods.

Parameters
----------
index : `int`
Index of Script SAL component.

Notes
-----
**Checkpoints**

* sequence {n} of {m}: before taking a sequence.

"""

async def _apply_z_offset(self, z_offset: float) -> None:
"""Apply dz offset.

Parameters
----------
z_offset : float
dz offset to apply, in microns.
"""
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset / 2, u=0, v=0)
await self.mtcs.offset_m2_hexapod(x=0, y=0, z=z_offset / 2, u=0, v=0)
16 changes: 13 additions & 3 deletions python/lsst/ts/standardscripts/maintel/take_aos_sequence_comcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ async def configure_tcs(self) -> None:
else:
self.log.debug("MTCS already defined, skipping.")

async def _apply_z_offset(self, z_offset: float) -> None:
"""Apply dz offset.

Parameters
----------
z_offset : float
dz offset to apply, in microns.
"""
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset, u=0, v=0)

async def take_aos_sequence(self) -> None:
"""Take out-of-focus sequence images."""
supplemented_group_id = self.next_supplemented_group_id()
Expand All @@ -257,7 +267,7 @@ async def take_aos_sequence(self) -> None:

# Move the hexapod to the target z position
z_offset = -self.dz - self.current_z_position
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset, u=0, v=0)
self._apply_z_offset(z_offset)
self.current_z_position = -self.dz

self.log.info("Taking in-focus image")
Expand All @@ -281,7 +291,7 @@ async def take_aos_sequence(self) -> None:

# Move the hexapod to the target z position
z_offset = self.dz - self.current_z_position
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset, u=0, v=0)
self._apply_z_offset(z_offset)
self.current_z_position = self.dz

self.log.info("Taking extra-focal image")
Expand Down Expand Up @@ -340,7 +350,7 @@ async def take_aos_sequence(self) -> None:

# Move the hexapod to the target z position
z_offset = -self.current_z_position
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset, u=0, v=0)
self._apply_z_offset(z_offset)
self.current_z_position = 0

if self.mode != Mode.PAIR:
Expand Down
21 changes: 17 additions & 4 deletions tests/test_maintel_take_aos_sequence_comcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,29 @@
import unittest
from unittest.mock import patch

from lsst.ts import standardscripts
from lsst.ts.idl.enums.Script import ScriptState
from lsst.ts.observatory.control.maintel.comcam import ComCam, ComCamUsages
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages
from lsst.ts.standardscripts.maintel import Mode, TakeAOSSequenceComCam
from lsst.ts.utils import index_generator

from lsst.ts import standardscripts
from lsst.ts.standardscripts.maintel import (
Mode,
TakeAOSSequenceBalancedComCam,
TakeAOSSequenceComCam,
)

index_gen = index_generator()


class TestTakeAOSSequenceComCam(
standardscripts.BaseScriptTestCase, unittest.IsolatedAsyncioTestCase
):
ScriptClass = TakeAOSSequenceComCam
scriptName = "take_aos_sequence_comcam.py"

async def basic_make_script(self, index):
self.script = TakeAOSSequenceComCam(index=index)
self.script = self.ScriptClass(index=index)

self.script.mtcs = MTCS(
domain=self.script.domain,
Expand Down Expand Up @@ -260,9 +268,14 @@ async def test_take_doublet(self):
async def test_executable_lsstcam(self) -> None:
"""Test that the script is executable."""
scripts_dir = standardscripts.get_scripts_dir()
script_path = scripts_dir / "maintel" / "take_aos_sequence_comcam.py"
script_path = scripts_dir / "maintel" / self.scriptName
await self.check_executable(script_path)


class TestTakeAOSSequenceBalancedComCam(TestTakeAOSSequenceComCam):
ScriptClass = TakeAOSSequenceBalancedComCam
scriptName = "take_aos_sequence_balanced_comcam.py"


if __name__ == "__main__":
unittest.main()
Loading