Skip to content

Commit

Permalink
Merge pull request #1132 from aaronwmorris/dev
Browse files Browse the repository at this point in the history
indiclient shutdown causing problems with temp calibrated darks
  • Loading branch information
aaronwmorris committed Feb 14, 2024
2 parents 4d73dd1 + 296305b commit 5f1e8b0
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 221 deletions.
46 changes: 30 additions & 16 deletions indi_allsky/darks.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ def average(self):
self._average()


# shutdown
self.indiclient.disableCcdCooler()
self.indiclient.disconnectServer()


def _average(self):
self._initialize()
self._pre_run_tasks()
Expand All @@ -511,6 +516,11 @@ def tempaverage(self):
self._tempaverage()


# shutdown
self.indiclient.disableCcdCooler()
self.indiclient.disconnectServer()


def _tempaverage(self):
# disable daytime darks processing when doing temperature calibrated frames
self.daytime = False
Expand All @@ -519,34 +529,38 @@ def _tempaverage(self):

self._pre_run_tasks()

current_temp = self.getSensorTemperature()
next_temp_thold = current_temp - self.temp_delta
self.getSensorTemperature()
next_temp_thold = self.sensortemp_v.value - self.temp_delta

# get first set of images
self._run(IndiAllSkyDarksAverage)

while True:
# This loop will run forever, it is up to the user to cancel
current_temp = self.getSensorTemperature()
self.getSensorTemperature()

logger.info('Next temperature threshold: %0.1f', next_temp_thold)

if current_temp > next_temp_thold:
if self.sensortemp_v.value > next_temp_thold:
time.sleep(20.0)
continue

logger.warning('Acheived next temperature threshold')
next_temp_thold = next_temp_thold - self.temp_delta
next_temp_thold -= self.temp_delta

self._run(IndiAllSkyDarksAverage)



def sigmaclip(self):
with app.app_context():
self._sigmaclip()


# shutdown
self.indiclient.disableCcdCooler()
self.indiclient.disconnectServer()


def _sigmaclip(self):
self._initialize()
self._pre_run_tasks()
Expand All @@ -559,6 +573,11 @@ def tempsigmaclip(self):
self._tempsigmaclip()


# shutdown
self.indiclient.disableCcdCooler()
self.indiclient.disconnectServer()


def _tempsigmaclip(self):
# disable daytime darks processing when doing temperature calibrated frames
self.daytime = False
Expand All @@ -567,24 +586,24 @@ def _tempsigmaclip(self):

self._pre_run_tasks()

current_temp = self.getSensorTemperature()
next_temp_thold = current_temp - self.temp_delta
self.getSensorTemperature()
next_temp_thold = self.sensortemp_v.value - self.temp_delta

# get first set of images
self._run(IndiAllSkyDarksSigmaClip)

while True:
# This loop will run forever, it is up to the user to cancel
current_temp = self.getSensorTemperature()
self.getSensorTemperature()

logger.info('Next temperature threshold: %0.1f', next_temp_thold)

if current_temp > next_temp_thold:
if self.sensortemp_v.value > next_temp_thold:
time.sleep(20.0)
continue

logger.warning('Acheived next temperature threshold')
next_temp_thold = next_temp_thold - self.temp_delta
next_temp_thold -= self.temp_delta

self._run(IndiAllSkyDarksSigmaClip)

Expand Down Expand Up @@ -806,11 +825,6 @@ def _run(self, stacking_class):

remaining_configs -= 1

# shutdown
self.indiclient.disableCcdCooler()
self.indiclient.disconnectServer()



def _take_exposures(self, exposure, dark_filename_t, bpm_filename_t, ccd_bits, stacking_class):
exposure_f = float(exposure)
Expand Down
118 changes: 118 additions & 0 deletions misc/libcamera_disable_dpc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash

#set -x # command tracing
set -o errexit
set -o nounset


PATH=/bin:/usr/bin
export PATH


DPC_STRENGTH="0"

### libcamera Defective Pixel Correction (DPC) Strength
# https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf
#
# 0 = Off
# 1 = Normal correction (default)
# 2 = Strong correction
###


LIBCAMERA_PREFIX="/usr"


echo
echo "#########################################################"
echo "### Welcome to the indi-allsky script to disable ###"
echo "### Defective Pixel Correction (DPC) ###"
echo "#########################################################"
echo
echo
echo


if [[ -f "/usr/local/bin/libcamera-still" || -f "/usr/local/bin/rpicam-still" ]]; then
LIBCAMERA_PREFIX="/usr/local"

echo "Detected a custom installation of libcamera in /usr/local"
echo
echo
sleep 3
fi


if [[ "$(id -u)" == "0" ]]; then
echo
echo "Please do not run $(basename "$0") as root"
echo "Re-run this script as the user which will execute the indi-allsky software"
echo
echo
exit 1
fi


echo "Setup proceeding in 10 seconds... (control-c to cancel)"
echo
sleep 10


# Run sudo to ask for initial password
sudo true


LIBCAMERA_CAMERAS="
imx290
imx378
imx477
imx477_noir
imx477_af
imx219
imx219_noir
imx519
imx708
imx708_noir
imx708_wide
imx708_wide_noir
arducam_64mp
"

for LIBCAMERA_JSON in $LIBCAMERA_CAMERAS; do
### PI4 and older
JSON_FILE_VC4="${LIBCAMERA_PREFIX}/share/libcamera/ipa/rpi/vc4/${LIBCAMERA_JSON}.json"

### PI5
JSON_FILE_PISP="${LIBCAMERA_PREFIX}/share/libcamera/ipa/rpi/pisp/${LIBCAMERA_JSON}.json"


if [ -f "$JSON_FILE_VC4" ]; then
echo "Disabling dpc in $JSON_FILE_VC4"

TMP_DPC_JSON_VC4=$(mktemp --suffix=.json)
jq --argjson rpidpc_strength "$DPC_STRENGTH" '."rpi.dpc".strength = $rpidpc_strength' "$JSON_FILE_VC4" > "$TMP_DPC_JSON_VC4"
sudo cp -f "$TMP_DPC_JSON_VC4" "$JSON_FILE_VC4"
sudo chown root:root "$JSON_FILE_VC4"
sudo chmod 644 "$JSON_FILE_VC4"
[[ -f "$TMP_DPC_JSON_VC4" ]] && rm -f "$TMP_DPC_JSON_VC4"
else
echo "File not found: $JSON_FILE_VC4"
fi


if [ -f "$JSON_FILE_PISP" ]; then
echo "Disabling dpc in $JSON_FILE_PISP"

TMP_DPC_JSON_PISP=$(mktemp --suffix=.json)
jq --argjson rpidpc_strength "$DPC_STRENGTH" '."rpi.dpc".strength = $rpidpc_strength' "$JSON_FILE_PISP" > "$TMP_DPC_JSON_PISP"
sudo cp -f "$TMP_DPC_JSON_PISP" "$JSON_FILE_PISP"
sudo chown root:root "$JSON_FILE_PISP"
sudo chmod 644 "$JSON_FILE_PISP"
[[ -f "$TMP_DPC_JSON_PISP" ]] && rm -f "$TMP_DPC_JSON_PISP"
else
echo "File not found: $JSON_FILE_PISP"
fi


done

89 changes: 0 additions & 89 deletions misc/libcamera_enable_dpc.sh

This file was deleted.

0 comments on commit 5f1e8b0

Please sign in to comment.