Dark or Flat capture from a script ?

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Dark or Flat capture from a script ?

#1

Post by Jean-Francois »

Hello Robin,

For a more automatic generation of my master darks ... is it possible to start the "Capture Dark" from a script command ?
I think that I do not need to change the parameters ... so only to "start" the tool for the capture of the darks.

My Idea is to place the camera in a cold location and start a script that generates the master darks for several gain, exposure or capture mode of the camera.

I know that I can use the Sequencer or a script to start different captures ... but it saves the individual images, but not generates the master dark.

Regards,
Jean-Francois

One more question ... why SharpCap saves one image more ? ... When I set 21, it saves 22 images ?
User avatar
admin
Site Admin
Posts: 17534
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Dark or Flat capture from a script ?

#2

Post by admin »

Hi,

there's no direct access via scripting, but the sequencer has steps for both capturing the dark and flat, and those can be run from a script via 'SharpCap.Sequencer.RunSequence(sequenceCode)'.

The reason for the extra frame is that in the interactive use of the capture dark tool, SharpCap has no idea when the user covered the telescope and whether that happened before or after the camera started it's current frame. All SharpCap knows is that at the time the user presses 'Start', the telescope should be covered. So, the first frame to arrive after that point is suspect - maybe it is dark, maybe only partially dark. Therefore SharpCap captures an extra frame and ignores the first one when averaging :)

cheers,

Robin
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Dark or Flat capture from a script ?

#3

Post by Jean-Francois »

Hello Robin,

OK, I will try the sequence step via script.

Finally the mystery of the additional image :-) ... in fact I was thinking about it since several years.

Regards,
Jean-Francois
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Dark or Flat capture from a script ?

#4

Post by Jean-Francois »

Hello Robin,

OK, I have a script. I started yesterday evening with the hope that it was finish this morning ... but not.
It was only on the half. It was in a infinite loop during the cooling of the camera.
The script changes the target temperature and the camera cool down to this temperature ... normally.
But if the script think that the target temperature is "-15°C", but SharpCap (or the camera SDK) does not change it (from -20°C) and have the old temperature, then nothing happen ... for hours until I saw it this morning.

Here the script:

Code: Select all

import time

Exposure    = [10, 20, 30, 60, 120]    # seconds => *1000 für exposure in milliseconds
Temperature = [-25, -20, -15, -10]          # °C
# The script takes 31 dark images for generating the master dark

def Set_temperature(Target_Temp):
    print("Target temperature:", Target_Temp)
    SharpCap.SelectedCamera.Controls.TargetTemperature.Value = Target_Temp
    SharpCap.SelectedCamera.Controls.Temperature.Value

    while abs(Target_Temp - SharpCap.SelectedCamera.Controls.Temperature.Value) > 0.1:
        print("Cooling, temperature :", str("%.1f" % round(SharpCap.SelectedCamera.Controls.Temperature.Value,1)), "°C")
        time.sleep(5)
    # Wait to stabilise the temperature, during the last 0.1°C
    time.sleep(20)

for t in Temperature:
    Set_temperature(t)

    for ex in Exposure:
        print("Exposure:", ex, "s")
        SharpCap.SelectedCamera.Controls.Exposure.ExposureMs = ex * 1000    # in milliseconds
        SharpCap.Sequencer.RunSequence("CREATE MASTER DARK FROM 31 FRAMES")
In the past, I had fast all the time problems with the cooling of my QHY cameras (QHY268, QHY600 and QHYminicam8).
Most of the time in Live View with Force Still mode activated. But sometimes in pure Live mode.
I did not remember to have this problem in Still mode. But that is what happen this night.

I will modify my script with at least 3 target temperature commands (with some delay between it, I hope this will help).
I see that a sequence command exist for the cooling of the camera. It need some modification for the use in my script (change the target temperature in the command string).


Regards,
Jean-Francois
User avatar
admin
Site Admin
Posts: 17534
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Dark or Flat capture from a script ?

#5

Post by admin »

Hi Jean-Francois,

that's not nice - my assumption is that something odd is going on at the QHY SDK level or below in this case. SharpCap actually re-sends the target temperature to the camera once per second on QHY cameras (precisely because there have been previous issues like this where the value is ignored, and re-sending seems to avoid those problems).

When you set the target temperature in a script, the UI for the target temperature slider should update accordingly regardless of whether the QHY SDK actually takes any notice of the temperature value - all of that is done with the value that SharpCap thinks is the current value for the target temperature.

What you can do is add this line to the sequence

Code: Select all

SharpCap.SelectedCamera.Controls.TargetTemperature.RawControl.Refresh()
That forces the value of the control to be read back from the SDK and the UI and values that you get from the scripting objects will update according to what is read back. Of course if nothing changes as a result of that command it means that the SDK is holding the correct target value (even if it isn't being properly implemented).

The only other thing I can think of that might kick the cooling back into doing what it should is to switch the cooler power out of 'auto' mode into manual, then back again after a short delay. It's a difficult one as no-one (other than QHY themselves) really understands how the cooling part of the SDK works and why it sometimes misbehaves, so trying to work around that misbehaviour is very much a game of trial-and-error :(

cheers,

Robin
Post Reply