Page 3 of 4

Re: Python Library Installation

Posted: Mon Sep 07, 2020 1:25 pm
by admin
Hi,

the forums really shouldn't log you out in a short period of time – for me they remember my login for many weeks. One workaround I can suggest is to use the preview button regularly while you are writing a message.

When you are looking at the two numbers produced by the call to GetStats(), the first is the mean pixel value of the selection area and the second is the standard deviation of the pixel value. You should be able to split out the parts by assigning to a variable and then accessing the .Item1 and .Item2 properties of the assigned variable.

On the subject of IronLab vs IronPython, the Python window inside SharpCap is based on IronLab with a few extra tweaks. I'd be interested to know where you got your download from as I was under the impression that the IronLab project had basically fizzled out.

Cheers, Robin

Re: Python Library Installation

Posted: Mon Sep 07, 2020 8:08 pm
by Jean-Francois
Hello Robin,

OK ...".Item1" and ".Item2" ... that is very simple ... I try it ... but ...

What is wrong now in this script ?

Code: Select all


import time

Mean = 0
Dev = 0

def framehandler(sender, args):
	if (dumpdata):
		cutout = args.Frame.CutROI(SharpCap.Transforms.SelectionRect)
		#print cutout.GetStats()
		Stat = cutout.GetStats()
		Mean = Stat.Item1
		Dev = Stat.Item2
		print Stat.Item1
		print Stat.Item2
		cutout.Release()
		
def evthandler(sender, args):
	if (SharpCap.SelectedCamera != None):
		SharpCap.SelectedCamera.FrameCaptured -= framehandler

def monitorFrames():
	SharpCap.SelectedCamera.FrameCaptured += framehandler


dumpdata = True

SharpCap.CaptureEvent += evthandler
monitorFrames()
time.sleep(1)

dumpdata = False


print Mean
print Dev
I can print the Stat.Item1 and Stat.Item2 values ... nice, but I cannot assign to a global variable (Mean and Dev).
Note that I have a very annoying behavior:
I mean the line with "#print cutout.GetStats()".
Start the script first with the comment, then uncomment the line,
start the script again and then comment the line again and start again.
=> the (value, value) appears all the time after you uncomment it, you can delete the line with the "print cutout.GetStats()", save the file, reopen the file ... the (value, value) appears all the time.
It is annoying because some changes I write are no more taken in account. The only way is to stop the camera, stop SharpCap and restart SharpCap and reopen camera and the script. And if I write some part with error, SharpCap shows an error message and then crash.

It is difficult ... but not impossible (I say to me ... stay positiv ;) "A small step after a small step after a small step, ...")

Additional questions :
Is it possible to save the setting of console ? I change some settings (line numbering, "ConvertTabsToSpaces", ...), but IronPython forget it each time. I try with admin right, but the same thing.
Is it possible to have the file name shown in the console window (line, head) ? I had several time overwrite a script, after changing something without remembering that it was an other name.

Concerning the Ironlab, I download the version 1.1.2.0 (5 Jul. 2012) from this website: https://code.google.com/archive/p/ironlab/downloads
Alternative from here https://github.com/SteveUM/ironlab
This site mentions the "added numy/scipy support files ... commits 4 years ago" and the update of the IronPythonConsole to 1.1.4.
Do you download from the SourceForge website the version IronLab2010.2.01 ?

If you write that you use already the IronPython from Ironlab ... it could be possible to use the "google" or the "SteveUM" version (please say yes).


Regards,
Jean-Francois

Re: Python Library Installation

Posted: Mon Sep 07, 2020 9:49 pm
by procyon12
Hi Jean-Francois,

with your script I made some tests (I'm not a programmer) - surprised that sometimes it seems to work :-)

W7-64, SC 3.2.6421.0 pro, with GPS running, FW upgrade

However, some problems:

a) The rectangle selection sometimes results in things like

Rectangle Selection : {X=0,Y=0,Width=4,Height=4}

Traceback (most recent call last):
File "<string>", line 125, in <module>
File "<string>", line 75, in LED_cal_start_pos
File "<string>", line 63, in rect_average
ValueError: Der Parameter muss positiv und kleiner als die Breite sein.


the reason is unknown for me ...., changing the rectangle can work

b) The results for St and EndPos given in the console from a succesful script run differ to those shown in in the SC GUI

c) If I take a set of settings the autocal routine gives me (with a little luck) the right calibration - I get a lock and in the GPS status window all the values are o.k. If I change the St and EndPos (I have now e.g. "Bad calibration") and I start the script it doesn't find the right values. Sometimes the script doesn't find an end...

d) Several runs can lead to different results.

I attach a profile, the script found result (which is wrong) and the working (auto-) calibration data.

Thanks for your work.

Christian

Re: Python Library Installation

Posted: Mon Sep 07, 2020 11:19 pm
by Jean-Francois
Hello Christian,

Do you move the red rectangle in the region of the LED illumination ?
And do you enlarge the rectangle ?

Here an example with 2x2 binning:
LED_illumination_1.jpg
LED_illumination_1.jpg (521.22 KiB) Viewed 2039 times
Note that the script you use saves the image in PNG format.
That is not so good with the very low level of light.
In your file, you can see that the min/max of the value is between 3 and 15.
In the future, the script will use the data from memory (without passing by PNG file).

For the finding position ... I write today (and night) a new algorithm for finding the region of the light transition.
I first write in Mathcad (ideal for direct and quick visualization), then I implement the function this evening in a new script.
After that I need to write a function that solves the Fermi function for finding precisely the inflection point of the light curve.

The problem is that the actual version of IronPython does not import the numpy library.
I found alternative libraries for solving equation systems.


Regards,
Jean-Francois

Re: Python Library Installation

Posted: Tue Sep 08, 2020 7:13 am
by procyon12
Hi,

believe I was completely wrong with the rectangle ... (I used the ROI function).
Now I understand, will make some new tests later.
I'm curious.

Christian

Re: Python Library Installation

Posted: Tue Sep 08, 2020 12:59 pm
by procyon12
Hi Jean-Francois,

The rectangle (and the whole script in principle) are working now - with both the latest SC 3.2 and 3.3.
Usually the script runs to it's end, however, it needs up to 3min.
The results from your script are sometimes not reproducable. Also I get different results if I start from different points wrt the autocalibration points.
Are you aware of Kai Getrost's presentation http://www.occultations.org/meetings/NA ... trost.pptx especially his so called "Third-transition issue", slide 50 ?

Because of other themes I havn't worked with a QHY174GPS for a longer time. Today I made some tests with the "autocalibration" and found (again) that it works pretty well, seldom one has to reduce the EndPos a little.
So my question is: what would be the advantage of your approach?

Cheers

Christian

Re: Python Library Installation

Posted: Tue Sep 08, 2020 2:14 pm
by admin
Hi,

thanks for the link to the other version of IronLab on github. It looks like the developer of that version has deliberately added support for numpy to be largely built in. In theory I could take those changes into SharpCap, but I would need to check how many megabytes would be added to the installer – this is a pretty unusual use case and adding five or 10 MB to the installer because of it is problem not justified. I'm fairly sure that with the correct combination of dropping the Python files into a folder and setting the Python path, you could achieve the same thing the SharpCap version of iron-pyton.

Cheers, Robin

Re: Python Library Installation

Posted: Tue Sep 08, 2020 7:32 pm
by Jean-Francois
Hello Christian,

Also the script I upload was a "first try" to show what I want to do.
The idea is that SharpCap produce the calibration in the same way as the user will do manually ... also change something to the Start or End Position and compare with the preceding LED illumination.
The script use the PNG image saving on the disc ... it need unnecessary time for saving and reading the images and pixel resolution loss.
The first algorithm is not really effective ... sometimes it changes the values with too small steps.
I write yesterday evening a new algorithm for a quick setting of the Start or End Position.
I need to test it with the camera connected. Later I want to have the transition curve fitted for a precise (stable) solution.

Concerning the presentation from Kai Getrost ... I can say that is an impressive analysis of the camera GPS-LED capabilities.
The text in the note (lower window, not in the presentation mode) is very instructive.
... and no, I was not aware about the "third transition".

What I need is to investigate is the correct setting of the LED "position" ... until now I think that the "half intensity" position was the wanted position.
In the presentation of Kai, he mentions that the Start Pos has to be "dark" (slide 14) and the End Pos has to be "light" (slide 18).
The numbers of 75KHz counter are in both case the same (my method with the middle of the LED pulse centered at the optical exposure start and end, the method of Kai (and QHY ?) is to sync the end of the LED pulse with the optical exposure start and end).
It seems that at the end it is the same.

What will be the advantage of my approach ?
- I do the script for learning a little (sometimes more, sometimes less) Python programming
- if an observation session is only on 1 target for the all night, at only 1 camera setting ... then the user can continue to set the LED calibration manually.
- in the case that the user will have several targets, and maybe at the beginning, it is necessary to adapt the exposure time, then it is a little bit annoying to repeat the LED calibration.
- and what is if the exposure time is 10 s or longer ? ... doing the calibration manually can be frustrating (especially when you click on the wrong side "up" in place of "down" or you do not remember on which digit you click).
- and if one day I finish the script, and if the QHY-174 GPS camera owners use it ... then, Robin can write a tool based on the script (so Robin, any help to me now is less work for you later :D )


Best regards,
Jean-Francois

Re: Python Library Installation

Posted: Tue Sep 08, 2020 7:44 pm
by Jean-Francois
Hello Robin,

Concerning the IronPython/IronLab with numpy. Somebody write an extra NumpyDotNet.dll file for IronPython.
Other people write an full integration of numpy/scipy for IronPython in the IronLab project.

When you say "setting the Python path" ... you mean to copy somewhere the needed files and then to "say" to SharpCap IronPython where he can found (and use) these files. I try that ... but I'm ~ 99% chance that I do at least one error.
It could be ideally to point the needed files directly to the IronLab installation directory. I do not know if it is really possible.

10 MB ? ... what is today 10 MB ? (some software installation files are today above 1 GB)

Regards,
Jean-Francois

OK, I need now to program in place of writing message :-)

Re: Python Library Installation

Posted: Wed Sep 09, 2020 10:39 pm
by Jean-Francois
Hello Christian (and other QHY-174-GPS camera user),

I have a new version of my script for setting the Start/End Pos value ... but I will upload it in the forum section "Camera/QHY".

Regards,
Jean-Francois