Skip to content

Commit

Permalink
disable autodownload of IERS tables; better stability; preparing v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptorron committed Feb 29, 2024
1 parent 70c05e4 commit 59667e4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
31 changes: 24 additions & 7 deletions src/indi_pylibcamera/CameraControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
from astropy.io import fits
import astropy.coordinates
import astropy.units
import astropy.utils.iers

from picamera2 import Picamera2
from libcamera import controls, Rectangle


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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -783,22 +788,27 @@ 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
self.present_CameraSettings = NewCameraSettings
# 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
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/indi_pylibcamera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
INDI driver for libcamera supported cameras
"""

__version__ = "2.5.0"
__version__ = "2.6.0"
6 changes: 6 additions & 0 deletions src/indi_pylibcamera/indi_pylibcamera.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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!
#
Expand Down
2 changes: 1 addition & 1 deletion src/indi_pylibcamera/indi_pylibcamera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<devGroup group="CCDs">
<device label="INDI pylibcamera">
<driver name="INDI pylibcamera">indi_pylibcamera</driver>
<version>2.5.0</version>
<version>2.6.0</version>
</device>
</devGroup>
</driversList>

0 comments on commit 59667e4

Please sign in to comment.