Skip to content

Commit

Permalink
Merge pull request #165 from lsst-ts/tickets/DM-47641
Browse files Browse the repository at this point in the history
  • Loading branch information
edennihy authored Dec 2, 2024
2 parents 4b23aac + 35385a0 commit 8016c89
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In base_take_twilight_flats.py, change logic for high counts at sunset.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In love_manager_client and moke_love_stress_tests, make sure LoveManagerClient uses a child logging from the script.
3 changes: 3 additions & 0 deletions doc/news/DM-47641.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In maintel/take_twilight_flats_comcam.py:
- Add nounwrap az wrap strategy.
- Fix table name in ConsDB for sky counts.
35 changes: 28 additions & 7 deletions python/lsst/ts/externalscripts/base_take_twilight_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,34 @@ async def take_twilight_flats(self):

if exp_time < self.config.min_exp_time:
if self.where_sun == "setting":
sleep_time = 30
self.log.warning(
f"Calculated exposure time {exp_time} below min exposure time "
f"{self.config.min_exp_time}. Waiting {sleep_time}s."
)
await asyncio.sleep(sleep_time)
continue
while exp_time < self.config.min_exp_time:
sleep_time = 30
self.log.warning(
f"Calculated exposure time {exp_time} below min exposure time "
f"{self.config.min_exp_time}. Waiting {sleep_time}s."
)
await asyncio.sleep(sleep_time)

# TODO: change from take_acq to take_sflat (DM-46675)
flat_image = await self.camera.take_acq(
exptime=self.config.min_exp_time,
n=1,
group_id=self.group_id,
program=self.program,
reason=self.reason,
)

self.latest_exposure_id = int(flat_image[0])

sky_counts = await self.get_sky_counts()
self.log.info(
f"Flat just taken with exposure time {self.config.min_exp_time} \
had counts of {sky_counts}"
)

exp_time = self.get_new_exptime(
sky_counts, self.config.min_exp_time
)
else:
self.log.warning(
f"Calculated exposure time {exp_time} below min exposure time "
Expand Down
10 changes: 8 additions & 2 deletions python/lsst/ts/externalscripts/love_manager_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ def __init__(
password,
event_streams,
telemetry_streams,
log=None,
msg_tracing=False,
):
self.log = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
self.log = (
log.getChild(type(self).__name__)
if log is not None
else logging.getLogger(type(self).__name__)
)

self.username = username
self.event_streams = event_streams
Expand Down Expand Up @@ -129,7 +134,7 @@ async def __handle_message_reception(self):
async for message in self.__websocket:
if message.type == aiohttp.WSMsgType.TEXT:
msg = json.loads(message.data)
self.log.debug("Received message: ", msg)
self.log.debug(f"Received message: {msg}")
if "category" not in msg or (
"option" in msg and msg["option"] == "subscribe"
):
Expand Down Expand Up @@ -162,6 +167,7 @@ async def __subscribe_to(self, csc, salindex, topic, topic_type):
"salindex": salindex,
"stream": topic,
}
self.log.debug(f"send_str={subscribe_msg}")
await self.__websocket.send_str(json.dumps(subscribe_msg))

async def start_ws_client(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from lsst.ts.observatory.control.maintel.comcam import ComCam, ComCamUsages
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages
from lsst.ts.observatory.control.utils import RotType
from lsst.ts.xml.enums.MTPtg import WrapStrategy

try:
from lsst.summit.utils import ConsDbClient
Expand Down Expand Up @@ -134,8 +135,10 @@ async def get_sky_counts(self) -> float:
"LSSTComCam", self.latest_exposure_id, detector_num
)

query = f"SELECT * from cdb_lsstcomcam.ccdvisit1_quicklook \
where ccdvisit_id={ccd_exp_id}"
query = (
"SELECT * from cdb_lsstcomcam.ccdexposure_quicklook "
f"where ccdexposure_id={ccd_exp_id}"
)
item = "postisr_pixel_median"
get_counts = functools.partial(
self.client.wait_for_item_in_row,
Expand Down Expand Up @@ -185,6 +188,7 @@ async def track_radec_and_setup_instrument(self, ra, dec):
dec=dec,
rot_type=RotType.Physical,
rot=0,
az_wrap_strategy=WrapStrategy.NOUNWRAP,
)

current_filter = await self.comcam.get_current_filter()
Expand All @@ -204,6 +208,7 @@ async def track_radec_and_setup_instrument(self, ra, dec):
dec=dec,
rot_type=RotType.PhysicalSky,
rot=self.config.rotator_angle,
az_wrap_strategy=WrapStrategy.NOUNWRAP,
)

self.tracking_started = True
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ts/externalscripts/make_love_stress_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ async def run(self):
self.password,
event_streams,
telemetry_streams,
log=self.log,
msg_tracing=True,
)
self.clients.append(client)
Expand Down

0 comments on commit 8016c89

Please sign in to comment.