From 59667e47a4582d9b87964aa0212f2380f6e2c17c Mon Sep 17 00:00:00 2001 From: scriptorron <22291722+scriptorron@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:28:34 +0100 Subject: [PATCH] disable autodownload of IERS tables; better stability; preparing v2.6.0 --- CHANGELOG | 5 +++- README.md | 3 ++- src/indi_pylibcamera/CameraControl.py | 31 ++++++++++++++++++----- src/indi_pylibcamera/__init__.py | 2 +- src/indi_pylibcamera/indi_pylibcamera.ini | 6 +++++ src/indi_pylibcamera/indi_pylibcamera.xml | 2 +- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0f86f32..e5b2781 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ +2.6.0 - support for monochrome cameras -- better support for seldom raw and RGB frame formats +- support for new raw and RGB frame formats (including monochrome) +- disable astropy to download the latest IERS-A table from internet to avoid errors during observation session +- better stability of exposure loop 2.5.0 - fixed changed data alignment in Pi 5 raw images diff --git a/README.md b/README.md index f67af4d..e1c2cc1 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,8 @@ every frame exposure can solve this issue. Valid values of this switch are: * `auto`: Automatically choose based on list of known critical cameras. Default (if not otherwise set in INI file) is `auto`. - +- `enable_IERS_autoupdate` (`yes`, `no`): Allows the `astropy` library to update the IERS-A table from internet. +By default this is disabled to avoid errors when the camera is not connected to internet. There are more settings, mostly to support debugging. diff --git a/src/indi_pylibcamera/CameraControl.py b/src/indi_pylibcamera/CameraControl.py index 3155d63..b17ba6d 100644 --- a/src/indi_pylibcamera/CameraControl.py +++ b/src/indi_pylibcamera/CameraControl.py @@ -12,6 +12,7 @@ from astropy.io import fits import astropy.coordinates import astropy.units +import astropy.utils.iers from picamera2 import Picamera2 from libcamera import controls, Rectangle @@ -19,10 +20,6 @@ from .indidevice import * -# From time to time astropy downloads the latest IERS-A table from internet. -# If offline this will raise an error. Here we disable the auto update. -from astropy.utils.iers import conf -conf.auto_max_age = None class CameraSettings: """exposure settings @@ -217,8 +214,14 @@ class CameraControl: def __init__(self, parent, config): self.parent = parent self.config = config - self.do_CameraAdjustments = config.getboolean("driver", "CameraAdjustments", fallback=True) - self.IgnoreRawModes = config.getboolean("driver", "IgnoreRawModes", fallback=False) + # From time to time astropy downloads the latest IERS-A table from internet. + # If offline this will raise an error. Here we disable the auto update. + if self.config.getboolean("driver", "enable_IERS_autoupdate", fallback=True): + astropy.utils.iers.conf.auto_max_age = None + astropy.utils.iers.conf.iers_degraded_accuracy = "ignore" + # + self.do_CameraAdjustments = self.config.getboolean("driver", "CameraAdjustments", fallback=True) + self.IgnoreRawModes = self.config.getboolean("driver", "IgnoreRawModes", fallback=False) # reset states self.picam2 = None self.present_CameraSettings = CameraSettings() @@ -737,6 +740,7 @@ def __ExposureLoop(self): self.Sig_ActionExpose.clear() if self.Sig_ActionExit.is_set(): # exit exposure loop + #logger.error(f'DBG vor stop (line 744): {self.picam2.started=}') # FIXME self.picam2.stop_() self.parent.setVector("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", value=0, state=IVectorState.OK) return @@ -763,6 +767,7 @@ def __ExposureLoop(self): if self.present_CameraSettings.is_ReconfigurationNeeded(NewCameraSettings) or self.needs_Restarts: logger.info(f'reconfiguring camera') # need a new camera configuration + #logger.error(f'DBG vor create_still_configuration: {self.picam2.started=}') # FIXME config = self.picam2.create_still_configuration( queue=NewCameraSettings.DoFastExposure, buffer_count=2 # 2 if NewCameraSettings.DoFastExposure else 1 # need at least 2 buffer for queueing @@ -783,15 +788,19 @@ def __ExposureLoop(self): #self.parent.setVector("CCD_FRAME", "HEIGHT", value=NewCameraSettings.ProcSize[1]) # optimize (align) configuration: small changes to some main stream configurations # (for instance: size) will fit better to hardware + #logger.error(f'DBG vor align_configuration: {self.picam2.started=}') # FIXME self.picam2.align_configuration(config) # set still configuration + #logger.error(f'DBG vor configure: {self.picam2.started=}') # FIXME self.picam2.configure(config) # changing exposure time or analogue gain needs a restart if IsRestartNeeded: # change camera controls + #logger.error(f'DBG vor set_controls: {self.picam2.started=}') # FIXME self.picam2.set_controls(NewCameraSettings.get_controls()) # start camera if not already running in Fast Exposure mode if not self.picam2.started: + #logger.error(f'DBG vor start (line 802): {self.picam2.started=}') # FIXME self.picam2.start() logger.debug(f'camera started') # camera runs now with new parameter @@ -799,6 +808,7 @@ def __ExposureLoop(self): # last chance to exit or abort before doing exposure if self.Sig_ActionExit.is_set(): # exit exposure loop + #logger.error(f'DBG vor stop (line 811): {self.picam2.started=}') # FIXME self.picam2.stop_() self.parent.setVector("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", value=0, state=IVectorState.OK) return @@ -808,6 +818,7 @@ def __ExposureLoop(self): # get (non-blocking!) frame and meta data self.Sig_CaptureDone.clear() ExpectedEndOfExposure = time.time() + self.present_CameraSettings.ExposureTime + #logger.error(f'DBG vor capture_arrays: {self.picam2.started=}') # FIXME job = self.picam2.capture_arrays( ["raw" if self.present_CameraSettings.DoRaw else "main"], wait=False, signal_function=self.on_CaptureFinished, @@ -824,12 +835,15 @@ def __ExposureLoop(self): # allow to close camera if self.Sig_ActionExit.is_set(): # exit exposure loop + #logger.error(f'DBG vor stop (line 838): {self.picam2.started=}') # FIXME self.picam2.stop_() self.parent.setVector("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", value=0, state=IVectorState.OK) return # allow to abort exposure Abort = self.Sig_ActionAbort.is_set() if Abort: + #logger.error(f'DBG vor stop (line 846): {self.picam2.started=}') # FIXME + self.picam2.stop_() # stop exposure immediately self.Sig_ActionAbort.clear() break # allow exposure to finish earlier than expected (for instance when in fast exposure mode) @@ -838,6 +852,7 @@ def __ExposureLoop(self): time.sleep(PollingPeriod_s) # get frame and its metadata if not Abort: + #logger.error(f'DBG vor wait: {self.picam2.started=}') # FIXME (array, ), metadata = self.picam2.wait(job) logger.info('got exposed frame') # at least HQ camera reports CCD temperature in meta data @@ -848,6 +863,7 @@ def __ExposureLoop(self): # last chance to exit or abort before sending blob if self.Sig_ActionExit.is_set(): # exit exposure loop + #logger.error(f'DBG vor stop (line 864): {self.picam2.started=}') # FIXME self.picam2.stop_() self.parent.setVector("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", value=0, state=IVectorState.OK) return @@ -859,7 +875,8 @@ def __ExposureLoop(self): FastCount_Frames = self.parent.knownVectors["CCD_FAST_COUNT"]["FRAMES"].value if not DoFastExposure: # in normal exposure mode the camera needs to be started with exposure command - self.picam2.stop_() + #logger.error(f'DBG vor stop (line 876): {self.picam2.started=}') # FIXME + self.picam2.stop() if not Abort: if DoFastExposure: FastCount_Frames -= 1 diff --git a/src/indi_pylibcamera/__init__.py b/src/indi_pylibcamera/__init__.py index 9c7cd44..3137068 100644 --- a/src/indi_pylibcamera/__init__.py +++ b/src/indi_pylibcamera/__init__.py @@ -2,4 +2,4 @@ INDI driver for libcamera supported cameras """ -__version__ = "2.5.0" +__version__ = "2.6.0" diff --git a/src/indi_pylibcamera/indi_pylibcamera.ini b/src/indi_pylibcamera/indi_pylibcamera.ini index d20811d..2f9da9f 100644 --- a/src/indi_pylibcamera/indi_pylibcamera.ini +++ b/src/indi_pylibcamera/indi_pylibcamera.ini @@ -36,6 +36,12 @@ DoSnooping=yes #force_Restart=no #force_Restart=yes +# From time to time astropy downloads the latest IERS-A table from internet. This will raise an error when the +# the camera is not connected to internet. Therefore the auto update is disabled by default. That can lead to +# small errors in the object coordinates stored in the FITS header. If your camera is internet connected you can +# enable the autoupdate here: +#enable_IERS_autoupdate=yes + ##################################### # The following settings are to help debugging. Don't change them unasked! # diff --git a/src/indi_pylibcamera/indi_pylibcamera.xml b/src/indi_pylibcamera/indi_pylibcamera.xml index a43ab15..e0ffefb 100644 --- a/src/indi_pylibcamera/indi_pylibcamera.xml +++ b/src/indi_pylibcamera/indi_pylibcamera.xml @@ -2,7 +2,7 @@ indi_pylibcamera - 2.5.0 + 2.6.0