Skip to content

Commit

Permalink
Add CBP image sequence ComCam
Browse files Browse the repository at this point in the history
  • Loading branch information
elanaku committed Dec 3, 2024
1 parent e376500 commit a6ca801
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 0 deletions.
46 changes: 46 additions & 0 deletions python/lsst/ts/externalscripts/base_take_cbp_image_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,54 @@ async def configure_calsys(self):
def camera(self):
raise NotImplementedError()

@property
@abc.abstractmethod
def tcs(self):
raise NotImplementedError()

@abc.abstractmethod
async def configure_camera(self):
"""Abstract method to configure the camera, to be implemented
in subclasses.
"""
raise NotImplementedError()

@abc.abstractmethod
async def configure_tcs(self):
"""Abstract method to configure the tcs, to be implemented
in subclasses.
"""
raise NotImplementedError()

@abc.abstractmethod
def get_instrument_name(self):
"""Abstract method to be defined in subclasses to provide the
instrument name.
"""
raise NotImplementedError()

@abc.abstractmethod
def get_instrument_configuration(self) -> dict:
"""Abstract method to get the instrument configuration.
Returns
-------
dict
Dictionary with instrument configuration.
"""
raise NotImplementedError()

@abc.abstractmethod
def get_instrument_filter(self) -> str:
"""Abstract method to get the instrument filter configuration.
Returns
-------
str
Instrument filter configuration.
"""
raise NotImplementedError()

@abc.abstractmethod
async def slew_azel_and_setup_instrument(self, azimuth, elevation):
"""Abstract method to configure the TMA, to be implemented
Expand Down Expand Up @@ -139,6 +180,10 @@ def get_schema(cls):
description: Elevation of TMA.
type: number
default: 45
tma_rotator_angle:
description: Rotator angle of TMA.
type: number
default: 0
exp_time:
description: Exposure times for camera.
type: number
Expand Down Expand Up @@ -263,6 +308,7 @@ async def configure(self, config: types.SimpleNamespace):
"""

await self.configure_camera()
await self.configure_tcs()
self.config = config

await super().configure(config)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# This file is part of ts_externalscripts
#
# 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

__all__ = ["TakeCBPImageSequenceComCam"]

import yaml
from lsst.ts.observatory.control.maintel.comcam import ComCam, ComCamUsages
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages

from ..base_take_cbp_image_sequence import BaseTakeCBPImageSequence


class TakeCBPImageSequenceComCam(BaseTakeCBPImageSequence):
"""Specialized script for taking CBP images with ComCam."""

def __init__(self, index):
super().__init__(index=index, descr="Take CBP images with ComCam.")

self.mtcs = None
self.comcam = None

@property
def tcs(self):
return self.mtcs

@property
def camera(self):
return self.comcam

async def configure_tcs(self) -> None:
"""Handle creating the MTCS object and waiting remote to start."""
if self.mtcs is None:
self.log.debug("Creating MTCS.")
self.mtcs = MTCS(
domain=self.domain,
intended_usage=MTCSUsages.StateTransition | MTCSUsages.Slew,
log=self.log,
)
await self.mtcs.start_task
else:
self.log.debug("MTCS already defined, skipping.")

async def configure_camera(self) -> None:
"""Handle creating the camera object and waiting remote to start."""
if self.comcam is None:
self.log.debug("Creating Camera.")
self.comcam = ComCam(
self.domain,
intended_usage=ComCamUsages.TakeImageFull
| ComCamUsages.StateTransition,
log=self.log,
tcs_ready_to_take_data=self.mtcs.ready_to_take_data,
)
await self.comcam.start_task
else:
self.log.debug("Camera already defined, skipping.")

@classmethod
def get_schema(cls):
schema_yaml = """
$schema: http://json-schema.org/draft-07/schema#
$id: https://github.com/lsst-ts/ts_externalscripts/take_cbp_image_sequence_comcam.yaml
title: TakeCBPImageSequenceComCam v1
description: Configuration for TakeCBPImageSequenceComCam.
type: object
properties:
filter:
description: Filter name or ID.
anyOf:
- type: string
- type: integer
minimum: 1
- type: "null"
additionalProperties: false
"""
schema_dict = yaml.safe_load(schema_yaml)

base_schema_dict = super(TakeCBPImageSequenceComCam, cls).get_schema()

for prop in base_schema_dict["properties"]:
schema_dict["properties"][prop] = base_schema_dict["properties"][prop]

return schema_dict

def get_instrument_name(self) -> str:
"""Get instrument name.
Returns
-------
instrument_name: `string`
"""
return "LSSTComCam"

def get_instrument_configuration(self) -> dict:
return dict(
filter=self.config.filter,
)

def get_instrument_filter(self) -> str:
"""Get instrument filter configuration.
Returns
-------
instrument_filter: `string`
"""
return f"{self.config.filter}"

async def slew_azel_and_setup_instrument(self, az, el):
"""Abstract method to set the instrument. Change the filter
and slew and track target.
Parameters
----------
az : float
Azimuth of target field.
el : float
Elevation of target field.
"""
current_filter = await self.comcam.get_current_filter()

if current_filter != self.config.filter:
self.log.debug(
f"Filter change required: {current_filter} -> {self.config.filter}"
)
await self.comcam.setup_filter(filter=self.config.filter)
else:
self.log.debug(
f"Already in the desired filter ({current_filter}), slewing."
)

await self.mtcs.point_azel(
az=az,
el=el,
rot_tel=self.tma_rotator_angle,
)

async def configure(self, config):
"""Take the sequence of twilight flats twilight flats."""
self.configure_client()
await super().configure(config)

0 comments on commit a6ca801

Please sign in to comment.