diff --git a/src/lvmguider/guider.py b/src/lvmguider/guider.py index 9eb2660..903d43b 100644 --- a/src/lvmguider/guider.py +++ b/src/lvmguider/guider.py @@ -158,6 +158,7 @@ def set_pixel(self, pixel_x: float | None = None, pixel_z: float | None = None): # In auto mode, if we change the current pixel, we start drifting # towards a new target position. self.command.actor.status |= GuiderStatus.DRIFTING + self.pixel = new_pixel return self.pixel @@ -235,7 +236,10 @@ async def guide_one( guide_tolerance = guide_tolerance or self.config.get("guide_tolerance", 5) if mode == "auto": - is_acquisition = not self.use_reference_frames + is_acquisition = bool( + not self.use_reference_frames + or self.command.actor.status & GuiderStatus.DRIFTING + ) elif mode == "guide": is_acquisition = False elif mode == "acquire": @@ -279,7 +283,10 @@ async def guide_one( ra_p = numpy.round(ra_ref - offset_radec[0] / 3600 * cos_dec, 6) dec_p = numpy.round(dec_ref - offset_radec[1] / 3600.0, 6) - if sep > guide_tolerance and apply_correction is True and mode == "auto": + if self.command.actor.status & GuiderStatus.DRIFTING: + raise ValueError("Guider is drifting. Reverting to acquisition.") + + if (sep > guide_tolerance) and apply_correction is True and mode == "auto": self.set_reference_frames() self.command.actor._status &= ~GuiderStatus.GUIDING self.command.actor._status |= GuiderStatus.ACQUIRING