From 6c27b9e48a5b35705e7b0c8c15498fe3c3f0d5af Mon Sep 17 00:00:00 2001 From: elanaku Date: Wed, 6 Nov 2024 16:32:36 -0300 Subject: [PATCH 01/10] In base_take_twilight_flat.py, add option to give twilight flats a pointing. --- .../base_take_twilight_flats.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index 2591350c..c63819a6 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -238,6 +238,14 @@ def get_schema(cls): minimum: 0.0 maximum: 90.0 default: 45.0 + target_az: + description: Target azimuth for sky flats. + type: number + default: 90 + point_directly: + description: If True, point at target az el. If False, point relative to sun. + type: boolean + default: False tracking: description: If True, track sky. If False, keep az and el constant. type: boolean @@ -355,9 +363,26 @@ def get_target_radec(self): target ra dec """ + min_sun_distance = 60 + az_sun, el_sun = self.tcs.get_sun_azel() - target_az = (az_sun + self.config.distance_from_sun) % 360 + if self.config.point_directly: + if np.abs(az_sun - (self.config.target_az % 360)) < min_sun_distance: + raise RuntimeError( + f"Distance from sun {az_sun - (self.config.target_az % 360)} is \ + less than {min_sun_distance}. Stopping." + ) + + target_az = self.config.target_az + else: + if np.abs(self.config.distance_from_sun) < min_sun_distance: + raise RuntimeError( + f"Distance from sun {self.config.distance_from_sun} is less than {min_sun_distance}. \ + Stopping." + ) + + target_az = (az_sun + self.config.distance_from_sun) % 360 target_radec = self.tcs.radec_from_azel(target_az, self.config.target_el) From 895ad2772cd1af4698156b7c2c3f0b6647ff4211 Mon Sep 17 00:00:00 2001 From: elanaku Date: Thu, 7 Nov 2024 14:50:25 -0300 Subject: [PATCH 02/10] In take_twilight_flats_comcom.py, increase consdb polling timeout. --- .../ts/externalscripts/maintel/take_twilight_flats_comcam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py b/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py index a5fe698f..5ec1188c 100644 --- a/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py +++ b/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py @@ -128,7 +128,7 @@ async def get_sky_counts(self) -> float: float Sky counts in electrons. """ - timeout = 30 + timeout = 60 detector_num = 4 ccd_exp_id = computeCcdExposureId( "LSSTComCam", self.latest_exposure_id, detector_num From 1df4dc25661065b0494e4ad509085ae407eb3bc3 Mon Sep 17 00:00:00 2001 From: elanaku Date: Fri, 8 Nov 2024 16:10:01 -0300 Subject: [PATCH 03/10] In base_take_twilight_flat.py, reduce shortest initial exptime for flats --- python/lsst/ts/externalscripts/base_take_twilight_flats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index c63819a6..e8e2867c 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -217,6 +217,7 @@ def get_schema(cls): min_exp_time: description: Minimum exposure time allowed. type: number + minimum: 0.1 default: 1.0 min_sun_elevation: description: Lowest position of sun in degrees at which twilight flats can be taken. @@ -502,8 +503,10 @@ async def take_twilight_flats(self): await self.slew_azel_and_setup_instrument(az, self.config.target_el) # Take one 1s flat to calibrate the exposure time - self.log.info("Taking 1s flat to calibrate exposure time.") - exp_time = 1 + self.log.info( + "Taking {self.config.min_exp_time}s flat to calibrate exposure time." + ) + exp_time = self.config.min_exp_time # TODO: change from take_acq to take_sflat (DM-46675) flat_image = await self.camera.take_acq( exptime=exp_time, From b542331ba52398846ba1660f333c4ac47cd8c95e Mon Sep 17 00:00:00 2001 From: elanaku Date: Sat, 9 Nov 2024 15:45:24 -0300 Subject: [PATCH 04/10] In base_take_twilight_flats, increase number of darks at end of twilight flats --- python/lsst/ts/externalscripts/base_take_twilight_flats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index e8e2867c..e362181a 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -609,8 +609,8 @@ async def take_twilight_flats(self): self.assert_sun_location() await self.camera.take_darks( - exptime=30, - ndarks=2, + exptime=15, + ndarks=40, group_id=self.group_id, program=self.program, reason=self.reason, From 43fbce5213b76f2cfc25ec8394c7231d5048e5e3 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sat, 9 Nov 2024 21:39:32 -0700 Subject: [PATCH 05/10] In maintel/parameter_march_comcam, wait for extra visit to be ingested before requesting OCPS processing. --- .../externalscripts/maintel/parameter_march_comcam.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/lsst/ts/externalscripts/maintel/parameter_march_comcam.py b/python/lsst/ts/externalscripts/maintel/parameter_march_comcam.py index 47b69a7a..2aa23261 100644 --- a/python/lsst/ts/externalscripts/maintel/parameter_march_comcam.py +++ b/python/lsst/ts/externalscripts/maintel/parameter_march_comcam.py @@ -51,6 +51,8 @@ def __init__(self, index, descr="Perform a parameter march with ComCam.") -> Non self.instrument_name = "LSSTComCam" + self.max_image_in_oods_retries = 9 + @property def camera(self): return self.comcam @@ -110,6 +112,7 @@ async def take_images( self.log.info("Taking extra-focal image") + self.camera.rem.ccoods.evt_imageInOODS.flush() extra_visit_id = await self.camera.take_cwfs( exptime=self.config.exp_time, n=1, @@ -118,6 +121,14 @@ async def take_images( reason="EXTRA" + ("" if self.reason is None else f"_{self.reason}"), program=self.config.program, ) + self.log.info("Waiting for data to be ingested by OODS.") + for _ in range(self.max_image_in_oods_retries): + try: + await self.camera.rem.ccoods.evt_imageInOODS.next( + flush=False, timeout=self.camera.long_timeout + ) + except asyncio.TimeoutError: + break self.log.info("Send processing request to RA OCPS.") config = { From c40070abc31f4bbb09bcd32ce81847c239c55492 Mon Sep 17 00:00:00 2001 From: elanaku Date: Mon, 11 Nov 2024 20:41:22 -0300 Subject: [PATCH 06/10] In base_take_twilight_flat.py, Allow ignore mtdome --- python/lsst/ts/externalscripts/base_take_twilight_flats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index e362181a..bd0ae84a 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -291,6 +291,9 @@ async def configure(self, config: types.SimpleNamespace): if comp in self.camera.components_attr: self.log.debug(f"Ignoring Camera component {comp}.") setattr(self.camera.check, comp, False) + elif comp in ["mtdome", "mtdometrajectory"]: + self.log.debug(f"Ignoring dome component {comp}.") + setattr(self.tcs.check, comp, False) else: self.log.warning( f"Component {comp} not in CSC Group. " From f6c79c087d4763b6e4c7fa0b39342582ece544f3 Mon Sep 17 00:00:00 2001 From: elanaku Date: Wed, 13 Nov 2024 12:11:31 -0300 Subject: [PATCH 07/10] In base_take_twilight_flats.py, Make configurable rotator angle. --- .../base_take_twilight_flats.py | 25 ++++++++++++++----- .../maintel/take_twilight_flats_comcam.py | 14 +++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index bd0ae84a..40344b07 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -251,6 +251,10 @@ def get_schema(cls): description: If True, track sky. If False, keep az and el constant. type: boolean default: True + rotator_angle: + description: Rotator angle in degrees relative to physical sky. + type: number + default: 0 ignore: description: >- CSCs from the camera group to ignore in status check. @@ -507,7 +511,7 @@ async def take_twilight_flats(self): # Take one 1s flat to calibrate the exposure time self.log.info( - "Taking {self.config.min_exp_time}s flat to calibrate exposure time." + f"Taking {self.config.min_exp_time}s flat to calibrate exposure time." ) exp_time = self.config.min_exp_time # TODO: change from take_acq to take_sflat (DM-46675) @@ -544,11 +548,20 @@ async def take_twilight_flats(self): exp_time = self.config.max_exp_time if exp_time < self.config.min_exp_time: - self.log.warning( - f"Calculated exposure time {exp_time} below min exposure time \ - {self.config.min_exp_time}. Stopping." - ) - break + if self.where_sun == "setting": + sleep_time = 30 + self.log.warning( + f"Calculated exposure time {exp_time} below min exposure time \ + {self.config.min_exp_time}. Waiting {sleep_time}s." + ) + await asyncio.sleep(sleep_time) + continue + else: + self.log.warning( + f"Calculated exposure time {exp_time} below min exposure time \ + {self.config.min_exp_time}. Stopping." + ) + break await self.checkpoint( f"Taking flat {i+1} of {self.config.n_flat} with exposure time {exp_time}." diff --git a/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py b/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py index 5ec1188c..3923ee9d 100644 --- a/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py +++ b/python/lsst/ts/externalscripts/maintel/take_twilight_flats_comcam.py @@ -179,9 +179,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() - self.tracking_started = True + await self.mtcs.slew_icrs( + ra=ra, + dec=dec, + rot_type=RotType.Physical, + rot=0, + ) + + current_filter = await self.comcam.get_current_filter() if current_filter != self.config.filter: self.log.debug( @@ -197,8 +203,11 @@ async def track_radec_and_setup_instrument(self, ra, dec): ra=ra, dec=dec, rot_type=RotType.PhysicalSky, + rot=self.config.rotator_angle, ) + self.tracking_started = True + async def slew_azel_and_setup_instrument(self, az, el): """Abstract method to set the instrument. Change the filter and slew and track target. @@ -225,6 +234,7 @@ async def slew_azel_and_setup_instrument(self, az, el): await self.mtcs.point_azel( az=az, el=el, + rot_tel=self.config.rotator_angle, ) async def configure(self, config): From eb35198c1ed71ba89e5c8ba884653fcf26ac2eab Mon Sep 17 00:00:00 2001 From: edennihy Date: Tue, 19 Nov 2024 11:13:24 -0700 Subject: [PATCH 08/10] In base_take_twilight_flats.py, split strings using standard method. --- .../base_take_twilight_flats.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/python/lsst/ts/externalscripts/base_take_twilight_flats.py b/python/lsst/ts/externalscripts/base_take_twilight_flats.py index 40344b07..84be93e9 100644 --- a/python/lsst/ts/externalscripts/base_take_twilight_flats.py +++ b/python/lsst/ts/externalscripts/base_take_twilight_flats.py @@ -378,16 +378,16 @@ def get_target_radec(self): if self.config.point_directly: if np.abs(az_sun - (self.config.target_az % 360)) < min_sun_distance: raise RuntimeError( - f"Distance from sun {az_sun - (self.config.target_az % 360)} is \ - less than {min_sun_distance}. Stopping." + f"Distance from sun {az_sun - (self.config.target_az % 360)} is " + f"less than {min_sun_distance}. Stopping." ) target_az = self.config.target_az else: if np.abs(self.config.distance_from_sun) < min_sun_distance: raise RuntimeError( - f"Distance from sun {self.config.distance_from_sun} is less than {min_sun_distance}. \ - Stopping." + f"Distance from sun {self.config.distance_from_sun} is less than {min_sun_distance}. " + "Stopping." ) target_az = (az_sun + self.config.distance_from_sun) % 360 @@ -485,8 +485,8 @@ def assert_sun_location(self): sun_coordinates[1] > self.config.max_sun_elevation ): raise RuntimeError( - f"Sun elevation {sun_coordinates} is outside appropriate elevation limits. \ - Must be above {self.config.min_sun_elevation} or below {self.config.max_sun_elevation}." + f"Sun elevation {sun_coordinates} is outside appropriate elevation limits. " + f"Must be above {self.config.min_sun_elevation} or below {self.config.max_sun_elevation}." ) async def take_twilight_flats(self): @@ -530,7 +530,6 @@ async def take_twilight_flats(self): i = 0 while i < self.config.n_flat: - # TODO: make consistent with LATISS and comcam sky_counts = await self.get_sky_counts() self.log.info( @@ -541,9 +540,9 @@ async def take_twilight_flats(self): if exp_time > self.config.max_exp_time: self.log.warning( - f"Calculated exposure time {exp_time} above max exposure time \ - {self.config.max_exp_time} s. Taking images with exposure \ - time {self.config.max_exp_time}." + f"Calculated exposure time {exp_time} above max exposure time " + f"{self.config.max_exp_time} s. Taking images with exposure " + f" time {self.config.max_exp_time}." ) exp_time = self.config.max_exp_time @@ -551,15 +550,15 @@ async def take_twilight_flats(self): if self.where_sun == "setting": sleep_time = 30 self.log.warning( - f"Calculated exposure time {exp_time} below min exposure time \ - {self.config.min_exp_time}. Waiting {sleep_time}s." + 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 else: self.log.warning( - f"Calculated exposure time {exp_time} below min exposure time \ - {self.config.min_exp_time}. Stopping." + f"Calculated exposure time {exp_time} below min exposure time " + f"{self.config.min_exp_time}. Stopping." ) break @@ -599,7 +598,6 @@ async def take_twilight_flats(self): nrepeats = 4 for k in range(nrepeats): - if np.abs(self.config.dither) > 0: await self.tcs.offset_azel( az=self.config.dither, From d90d6c939e868c5060a795ae0efc4eddf36eb27e Mon Sep 17 00:00:00 2001 From: edennihy Date: Mon, 18 Nov 2024 12:38:17 -0700 Subject: [PATCH 09/10] Add news fragments. --- doc/news/DM-47381.bugfix.rst | 1 + doc/news/DM-47381.feature.1.rst | 1 + doc/news/DM-47381.feature.rst | 6 ++++++ 3 files changed, 8 insertions(+) create mode 100644 doc/news/DM-47381.bugfix.rst create mode 100644 doc/news/DM-47381.feature.1.rst create mode 100644 doc/news/DM-47381.feature.rst diff --git a/doc/news/DM-47381.bugfix.rst b/doc/news/DM-47381.bugfix.rst new file mode 100644 index 00000000..2ef4cfba --- /dev/null +++ b/doc/news/DM-47381.bugfix.rst @@ -0,0 +1 @@ +In maintel/parameter_march_comcam, wait for extra visit to be ingested before requesting OCSP processing. \ No newline at end of file diff --git a/doc/news/DM-47381.feature.1.rst b/doc/news/DM-47381.feature.1.rst new file mode 100644 index 00000000..6596eeee --- /dev/null +++ b/doc/news/DM-47381.feature.1.rst @@ -0,0 +1 @@ +In maintel/tma/random_walk_and_take_image_gencam.py, add get_instrument_name method. \ No newline at end of file diff --git a/doc/news/DM-47381.feature.rst b/doc/news/DM-47381.feature.rst new file mode 100644 index 00000000..9bff582d --- /dev/null +++ b/doc/news/DM-47381.feature.rst @@ -0,0 +1,6 @@ +In base_take_twilight_flats.py: +- Make rotator angle configurable. +- Allow ignoring mtdome. +- increase number of darks at end of twilight base_take_twilight_flats. +- increase consdb polling timeout. +- add option to give twilight flats a pointing. \ No newline at end of file From 7301807d0fe30b3650b6a406c0a35eb855feca87 Mon Sep 17 00:00:00 2001 From: edennihy Date: Tue, 19 Nov 2024 12:13:40 -0700 Subject: [PATCH 10/10] In maintel/tma/random_walk_and_take_image_gencam.py, add get_instrument_name method. --- .../maintel/tma/random_walk_and_take_image_gencam.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/lsst/ts/externalscripts/maintel/tma/random_walk_and_take_image_gencam.py b/python/lsst/ts/externalscripts/maintel/tma/random_walk_and_take_image_gencam.py index 3027560c..118868b8 100755 --- a/python/lsst/ts/externalscripts/maintel/tma/random_walk_and_take_image_gencam.py +++ b/python/lsst/ts/externalscripts/maintel/tma/random_walk_and_take_image_gencam.py @@ -85,6 +85,8 @@ def __init__(self, index, add_remotes: bool = True): RandomWalk.get_azel_random_walk, ) + self.instrument_name = "GenCam" + async def _take_data(self): """Takes data with all the generic cameras""" for i in range(self.config.num_exp): @@ -118,6 +120,9 @@ async def assert_feasibility(self): self.tcs.assert_all_enabled(), self.tcs.assert_liveliness(), *tasks ) + def get_instrument_name(self): + return self.instrument_name + async def configure(self, config): """Configure the script.