Skip to content

Commit

Permalink
Wrap sci PA to the range -30 to 30 degrees.
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Oct 16, 2024
1 parent 0da6448 commit ab2510e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gort/gort.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
run_in_executor,
set_tile_status,
)
from gort.transforms import wrap_pa_hex


if TYPE_CHECKING:
Expand Down Expand Up @@ -851,6 +852,12 @@ async def observe_tile(
if adjust_focus:
await self.guiders.adjust_focus()

# Wrap the PA to the range -30 to 30.
new_pa = wrap_pa_hex(tile.sci_coords.pa)
if new_pa != tile.sci_coords.pa:
self.log.debug(f"Wrapping sci PA from {tile.sci_coords.pa} to {new_pa}.")
tile.sci_coords.pa = new_pa

if tile.tile_id is not None:
dither_positions_str = ", ".join(map(str, dither_positions))
self.log.info(
Expand Down
29 changes: 29 additions & 0 deletions src/gort/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"Siderostat",
"HomTrans",
"Mirror",
"wrap_pa_hex",
]


Expand Down Expand Up @@ -421,6 +422,34 @@ def calculate_field_angle(
return siderostat.field_angle(target, time=obstime)


def wrap_pa_hex(pa: float):
"""Wraps a position angle to the range -30 to 30 degrees.
Parameters
----------
pa
The position angle to wrap. Always in degrees in the range 0 to infinity.
Returns
-------
pa_wrap
The wrapped position angle in the range -30 to 30 degrees.
"""

# First convert to the range 0 to 360 degrees.
pa = pa % 360

# Then wrap to the range 0 to 60 degrees to account for the IFU hexagonal symmetry.
pa = pa % 60

# Finally, wrap to the range -30 to 30 degrees.
if pa > 30:
pa -= 60

return pa


class Siderostat:
"""A siderostat of 2 mirrors.
Expand Down

0 comments on commit ab2510e

Please sign in to comment.