Skip to content

Commit

Permalink
* Adding a pocs run alignment command that will take polar alignmen…
Browse files Browse the repository at this point in the history
…t pictures.
  • Loading branch information
wtgee committed Aug 26, 2023
1 parent 29a4476 commit d432fe0
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/panoptes/pocs/utils/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import typer
from panoptes.utils.time import current_time
from panoptes.utils.utils import altaz_to_radec
from rich import print
from typing_extensions import Annotated

from panoptes.pocs.core import POCS
from panoptes.pocs.scheduler.field import Field
from panoptes.pocs.scheduler.observation.base import Observation

app = typer.Typer()

Expand All @@ -24,3 +28,57 @@ def run_auto(confirm: Annotated[bool, typer.Option(prompt='Are you sure you want
pocs.power_down()
except Exception:
print('[bold red]POCS encountered an error.[/bold red]')


@app.command(name='alignment')
def run_alignment(confirm: Annotated[
bool, typer.Option(prompt='Are you sure you want to run the polar alignment script?')],
exptime: float = 30,
num_exposures: int = 10,
field_name: str = 'PolarAlignment',
move_mount=True
) -> None:
"""Runs POCS in alignment mode."""
if confirm is False:
print('Exit.')
raise typer.Abort()

altaz_coords = [
# (alt, az)
(40, 90),
(55, 60),
(55, 120),
(70, 210),
(70, 330),
]

# Helper function to make an observation from altaz coordinates.
def get_altaz_observation(coords) -> Observation:
alt, az = coords
coord = altaz_to_radec(alt, az, pocs.observatory.earth_location, current_time())
alignment_observation = Observation(Field(field_name, coord),
exptime=exptime,
min_nexp=num_exposures,
exp_set_size=num_exposures)

return alignment_observation

print('[green]Running POCS in alignment mode!\tPress Ctrl-c to quit.[/green]')
pocs = POCS.from_config()
pocs.initialize()

# Start the polar alignment sequence.
mount = pocs.observatory.mount
for i, altaz_coord in enumerate(altaz_coords):
print(f'Starting coord #{i:02d} {altaz_coord=}...', end='')
observation = get_altaz_observation(altaz_coord)
pocs.observatory.current_observation = observation

if move_mount:
print(f'Slewing to {observation.field.coord=} for {altaz_coord=}')
mount.set_target_coordinates(observation.field.coord)
mount.slew_to_target(blocking=True)

# Take the observation.
pocs.observatory.take_observation(blocking=True)
print(f'done.')

0 comments on commit d432fe0

Please sign in to comment.