Skip to content

Commit

Permalink
Modify twilight flat scripts to pass pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
elanaku committed Oct 6, 2024
1 parent 723c66c commit 817390f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def configure_camera(self) -> None:
self.domain,
intended_usage=LATISSUsages.TakeImage,
log=self.log,
tcs_ready_to_take_data=self.tcs.ready_to_take_data,
tcs_ready_to_take_data=self.atcs.ready_to_take_data,
)
await self.latiss.start_task
else:
Expand Down Expand Up @@ -119,7 +119,7 @@ async def get_sky_counts(self) -> float:
Sky counts in electrons.
"""
timeout = 30
query = f"SELECT * from cbd_latiss.visit1_quicklook where exposure_id = {self.latest_exposure_id}"
query = f"SELECT * from cbd_latiss.exposure_quicklook where exposure_id = {self.latest_exposure_id}"
item = "post_isr_pixel_median"
get_counts = functools.partial(
self.client.wait_for_item_in_row,
Expand Down Expand Up @@ -166,7 +166,7 @@ async def track_radec_and_setup_instrument(self, ra, dec):
Dec of target field.
"""
# slew to desired field
await self.atcs.slew_icrs(
await self.tcs.slew_icrs(
ra,
dec,
rot_type=RotType.PhysicalSky,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ async def get_sky_counts(self) -> float:
Sky counts in electrons.
"""
timeout = 30
query = f"SELECT * from cbd_lsstcomcam.visit1_quicklook where exposure_id = {self.latest_exposure_id}"
query = f"SELECT * from cbd_lsstcomcam.exposure_quicklook \
where exposure_id = {self.latest_exposure_id}"
item = "post_isr_pixel_median_median"
get_counts = functools.partial(
self.client.wait_for_item_in_row,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
__all__ = ["TakeTwilightFlatsLSSTCam"]

import asyncio
import functools

import yaml
from lsst.ts.observatory.control.maintel.lsstcam import LSSTCam, LSSTCamUsages
Expand Down Expand Up @@ -109,8 +110,16 @@ async def get_sky_counts(self) -> float:
float
Sky counts in electrons.
"""
# TODO: query consDB with util once such the LSSTCam schema exists
sky_counts = 0
timeout = 30
query = f"SELECT * from cbd_lsstcam.exposure_quicklook where exposure_id = {self.latest_exposure_id}"
item = "post_isr_pixel_median_median"
get_counts = functools.partial(
self.client.wait_for_item_in_row,
query=query,
item=item,
timeout=timeout,
)
sky_counts = await asyncio.get_running_loop().run_in_executor(None, get_counts)
return sky_counts

def get_instrument_name(self) -> str:
Expand Down Expand Up @@ -146,15 +155,15 @@ async def track_radec_and_setup_instrument(self, ra, dec):
dec : float
Dec of target field.
"""
current_filter = await self.comcam.get_current_filter()
current_filter = await self.lsstcam.get_current_filter()

self.tracking_started = True

if current_filter != self.config.filter:
self.log.debug(
f"Filter change required: {current_filter} -> {self.config.filter}"
)
await self._handle_slew_and_change_filter()
await self._handle_slew_and_change_filter(ra, dec)
else:
self.log.debug(
f"Already in the desired filter ({current_filter}), slewing and tracking."
Expand All @@ -166,7 +175,7 @@ async def track_radec_and_setup_instrument(self, ra, dec):
rot_type=RotType.PhysicalSky,
)

async def _handle_slew_and_change_filter(self):
async def _handle_slew_and_change_filter(self, ra, dec):
"""Handle slewing and changing filter at the same time.
For ComCam (and MainCam) we need to send the rotator to zero and keep
Expand All @@ -176,8 +185,8 @@ async def _handle_slew_and_change_filter(self):
tasks_slew_with_fixed_rot = [
asyncio.create_task(
self.mtcs.slew_icrs(
ra=self.config.ra,
dec=self.config.dec,
ra=ra,
dec=dec,
rot_type=RotType.Physical,
)
),
Expand Down

0 comments on commit 817390f

Please sign in to comment.