Skip to content

Commit

Permalink
Merge pull request #156 from lsst-ts/tickets/DM-46978
Browse files Browse the repository at this point in the history
Tickets/dm 46978
  • Loading branch information
tribeiro authored Nov 4, 2024
2 parents bda33ce + 072238b commit a6bd1cc
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-46978.bugfix.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing call to RA in parameter_march_comcam.py.
1 change: 1 addition & 0 deletions doc/news/DM-46978.bugfix.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In base_parameter_march.py, wait for tracking to start to continue.
1 change: 1 addition & 0 deletions doc/news/DM-46978.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing signs in intra/extra focal images.
1 change: 1 addition & 0 deletions doc/news/DM-46978.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In base_parameter_march, use offset_rot instead of slewing to a new target every time..
1 change: 1 addition & 0 deletions doc/news/DM-46978.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add darks at the end of the twilight flats.
30 changes: 24 additions & 6 deletions python/lsst/ts/externalscripts/base_parameter_march.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def get_schema(cls) -> dict:
Rotation sequence used for the parameter march. This can either be a single number
to use the same rotation angle throughout or an array specifying custom rotation angles.
If not provided, the script will determine the increments automatically.
default: 0.0
anyOf:
- type: number
description: >
Expand Down Expand Up @@ -275,6 +274,8 @@ async def configure(self, config: types.SimpleNamespace) -> None:
f"rotation_sequence length {len(self.rotation_sequence)} "
f"does not match n_steps {self.n_steps}."
)
else:
self.rotation_sequence = None

self.config = config
if hasattr(config, "dofs"):
Expand Down Expand Up @@ -351,14 +352,16 @@ async def format_values(offset_values: np.ndarray) -> np.ndarray:
return cam_hex_values, m2_hex_values, m1m3_bend_values, m2_bend_values

async def track_target_with_rotation(self, rotation_angle) -> None:
await self.tcs.offset_rot(0.0)
await self.tcs.point_azel(
az=self.config.az,
el=self.config.el,
rot_tel=rotation_angle,
)
await self.tcs.stop_tracking()
await asyncio.sleep(1.0)
await asyncio.sleep(5.0)
await self.tcs.start_tracking()
await self.tcs.check_tracking(track_duration=1.0)

async def parameter_march(self) -> None:
"""Perform the parameter_march operation."""
Expand Down Expand Up @@ -387,10 +390,15 @@ async def parameter_march(self) -> None:
self.iterations_started = True

# Move rotator
await self.track_target_with_rotation(self.rotation_sequence[0])
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
]

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

# Move rotator
await self.track_target_with_rotation(
self.rotation_sequence[self.iterations_executed]
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)

# Take images at the current dof position
await self.take_images()

Expand Down Expand Up @@ -464,6 +480,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)

except Exception:
self.log.exception(
"Error while trying to return telescope to its original position."
Expand Down
8 changes: 8 additions & 0 deletions python/lsst/ts/externalscripts/base_take_twilight_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,14 @@ async def take_twilight_flats(self):

self.assert_sun_location()

await self.camera.take_darks(
exptime=30,
ndarks=2,
group_id=self.group_id,
program=self.program,
reason=self.reason,
)

async def assert_feasibility(self) -> None:
"""Verify that camera is in a feasible state to
execute the script.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def take_images(
"""
self.log.debug("Moving to intra-focal position")

await self.mtcs.offset_camera_hexapod(x=0, y=0, z=self.dz, u=0, v=0)
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=-self.dz, u=0, v=0)

supplemented_group_id = self.next_supplemented_group_id()

Expand All @@ -105,7 +105,7 @@ async def take_images(

# Hexapod offsets are relative, so need to move 2x the offset
# to get from the intra- to the extra-focal position.
z_offset = -(self.dz * 2.0)
z_offset = self.dz * 2.0
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=z_offset, u=0, v=0)

self.log.info("Taking extra-focal image")
Expand All @@ -121,7 +121,7 @@ async def take_images(

self.log.info("Send processing request to RA OCPS.")
config = {
"LSSTComCamSim-FROM-OCS_DONUTPAIR": f"{intra_visit_id[0]},{extra_visit_id[0]}"
"LSSTComCam-FROM-OCS_DONUTPAIR": f"{intra_visit_id[0]},{extra_visit_id[0]}"
}
ocps_execute_task = asyncio.create_task(
self.ocps.cmd_execute.set_start(
Expand All @@ -133,7 +133,7 @@ async def take_images(
self.log.debug("Moving to in-focus position")

# Move the hexapod back to in focus position
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=self.dz, u=0, v=0)
await self.mtcs.offset_camera_hexapod(x=0, y=0, z=-self.dz, u=0, v=0)

self.log.info("Taking in-focus image")

Expand Down

0 comments on commit a6bd1cc

Please sign in to comment.