AllskyTeam / allsky

A Raspberry Pi operated Wireless Allsky Camera
MIT License
1.16k stars 180 forks source link

When using darks, TEMP stuck on 20C? #463

Closed SamCrask closed 2 years ago

SamCrask commented 3 years ago

Hello, thanks for all the hard work on v0.8, a great update. Pi4 with ASI178MC here in a fan cooled box, and it's been working well, especially the exposure issue improvements with the 178 cameras.

After having the creating a series of darks at various temps in allsky/darks, from 26 to 40.jpg, I found the night images were not showing the improvements I expected. To debug this I added a line in darkSubtract.sh below the 'convert' line to show which dark file was subtracted, and the TEMP value used. This showed that the default value of 20c was being used every time for TEMP, and the closest JPG file was used for subtraction (26.jpg), which was nowhere near the current sensor temp (38c).

Line added to darkSubtract.sh to test: echo "*** $ME: DEBUG: Dark frame '$DARK' subtracted using temp '$TEMP' "

At the top of darkSubtract.sh there's a clue to where TEMP comes from... (comment) This has to come after executing darkCapture.sh which sets ${TEMP}.

Reviewing the darkCapture.sh file, I found that if dark capture was not enabled (which will be most of the time when not capturing darks), the default of 20 was all that was ever passed to the TEMP value for darkSubtract.sh. So I copied the following lines from that file above the "if dark mode = 1" block, replacing the TEMP=20 line, and this seems to have fully resolved the issue, my debug line now shows the correct dark is being subtracted when I tail the allsky.log file, and the resulting images are much improved at these high summer sensor temps.

Existing code copied and tweaked in darkCapture.sh file, replacing the TEMP=20 line: (comment) If the temperature file doesn't exist, set a default value, (new) otherwise set the TEMP from the temperature file TEMP_FILE="temperature.txt" if [ -s "$TEMP_FILE" ]; then # -s so we don't use an empty file TEMP=$(printf "%.0f" "cat ${TEMP_FILE}") else TEMP=20 fi

Hope this helps others not seeing the dark subtraction improvements they expected.

EricClaeys commented 3 years ago

@SamCrask, Thanks for point out this bug. I'll fix it in a few days when I'm home from vacation. FYI, darkSubtract.sh also has a bug - if there are dark frames below and above $TEMP, it will use the one above $TEMP even if the one below is closer to $TEMP. For example, if $TEMP is 20 and there is 18.jpg and 25.jpg, it will use 25.jpg. I believe I have a fix for it but need to test it before uploading it. Eric