This post may be pretty similar to the recent one posted by mfs4n.
I’ve been very happy with the performance of the focus tool in SharpCap recently, that is, up until about 11:55 pm last night. I was running a sequence script, and it was to do ~3 hours of imaging, with a refocus every hour. It was performing the last refocus of the night, but then “something happened”. I was asleep when this happened, but my alarm got me up an hour later at 1 am so that I could make sure all worked well, shut everything down, and perhaps start WBPP going in PI. I immediately saw that the imaging session stopped abruptly one hour early because the refocus did not work. The attached .jpg file shows the results of the disastrous refocus. I’ve also attached the portion of the SharpCap log file that deals with this refocus attempt.
Here’s what this looks like to me: The refocus was to perform 9 steps. It did that, and it looks to me like that produced a rather good-looking parabola, the kind that should lead to a good focus point. You can see the parabola on the right side of the graph centered on the vertical dashed line. I plotted the FWHM values from the SharpCap log file for the first 9 steps on graph paper, too (not shown), and that showed a parabola. However, after taking these 9 steps, there is then this message in the SharpCap log file:
Notification (Status=Warning): Focus scan did not contain enough data before best focus point. Moving back to position 6739 and continuing scan.
At this point, all was lost, and so I have a number of questions. First, why did the algorithm not think there was “enough data” and start searching for more? The parabola looked rather good to me with the initial 9 points. Second, why did the SharpCap algorithm keep going on and on when it was very clear a good focus was not going to be found? Third, why was SharpCap giving values of ~4 for the FWHM when the system was horribly out of focus? I didn’t make a screen capture of what the stars looked like on the screen after the last calculation was done, but they were gigantic, far out of focus.
Based on what I’ve been seeing, here are my thoughts:
(1) The SharpCap focus tool can produce a parabola and a focus point given the 9 steps I ask for a large percentage of the time.
(2) If the SharpCap focus tool has to extend to the left one or two more steps beyond the 9 I ask for, it will generate a parabola and a good focus point.
(3) If the SharpCap focus tool decides to backtrack to somewhere near the middle of my 9 steps to try to find a focus, all is lost. In my somewhat limited experience, I don’t think I’ve ever seen this succeed. I also don’t know why in some cases, such as this one from last night, it even has to do this. Perhaps some refinement or relaxation is needed in how the data from the initial steps is used to define a parabola. Also, and this is something I saw someone else allude to, is that in cases like this where the algorithm backtracks to refine the solution, until this is remedied, it may be best instead of doing that, to just to have SharpCap immediately stop the refocus algorithm, return to the original focus point, and let the imaging script continue from there. Another option would be to have the algorithm repeat the initial 9 steps that were asked for (instead of trying to refine the original), with the hope that it would succeed this second time. If not, bail out and let the imaging continue.
BTW, I’m still using SharpCap 4.1.10872 (beta).
Rich
Another autofocus fail
Another autofocus fail
- Attachments
-
- Autofocus_What_Happened_080523.JPG (560.66 KiB) Viewed 7178 times
-
- SharpCapRefocusFailLogFile_080523.txt
- (537 KiB) Downloaded 128 times
- admin
- Site Admin
- Posts: 17552
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Another autofocus fail
Hi,
lots of info for me to dig into in the log - I will come back to you once I have dug through it and worked out what is going on.
cheers,
Robin
lots of info for me to dig into in the log - I will come back to you once I have dug through it and worked out what is going on.
cheers,
Robin
- admin
- Site Admin
- Posts: 17552
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Another autofocus fail
Hi,
OK, so having looked into this, there are a few things going on here that unfortunately interacted in a bad way in this case.
Firstly, the focus scan trying to go back and get more points (and then spectacularly failing to do that). I thought I had cut out that functionality, but it turned out that I had only cut out the most common way for it to happen and the less likely case triggered here was still present in the code. I'm going to properly kill it off this time so that it will not try to go back to get more points, but will instead just fail normally. At some point in the future I'll go back and fix this properly but for now we are better off without it.
So, next, why did it think it needed to go back with a pretty decent parabola in the graph?
There are actually 6 points that make a really good parabola, as shown below, but SharpCap requires a minimum of 7 points to allow a focus fit, so using just these 6 points will never make for a successful result right now.
If you look at the rest of the points in the original scan, you can see that the graph on each side flattens out considerably and including those flattening out points gives a worse fit
What happens is that SharpCap has to consider 7, 8 or 9 points from the original scan when looking for a focus fit, but including the extra points aside from the 'good' 6 makes a worse graph and more deviation from the curve. That deviation is seen by SharpCap as noise in the focus signal, and the bigger it gets, the stronger the constraints SharpCap applies to make sure that the points away from the best focus position are significantly worse than the predicted best focus. Essentially in this data set there are no subsets of the data that pass all the criteria at once to let SharpCap select a curve.
Well, actually, there was at least one, but a small bug meant that it was not considered. I have fixed that for the next update.
Even given the bug fix, the underlying issue is that the data points are a little too far apart, meaning that the scan does not always get 7 or 8 points into the 'good' part of the curve where a parabola fits nicely. By reducing the spacing a little you would make the refocus more robust.
I think I will have a look at whether I can allow a fit from 6 points in some circumstances, but not just at the moment.
cheers,
Robin
OK, so having looked into this, there are a few things going on here that unfortunately interacted in a bad way in this case.
Firstly, the focus scan trying to go back and get more points (and then spectacularly failing to do that). I thought I had cut out that functionality, but it turned out that I had only cut out the most common way for it to happen and the less likely case triggered here was still present in the code. I'm going to properly kill it off this time so that it will not try to go back to get more points, but will instead just fail normally. At some point in the future I'll go back and fix this properly but for now we are better off without it.
So, next, why did it think it needed to go back with a pretty decent parabola in the graph?
There are actually 6 points that make a really good parabola, as shown below, but SharpCap requires a minimum of 7 points to allow a focus fit, so using just these 6 points will never make for a successful result right now.
If you look at the rest of the points in the original scan, you can see that the graph on each side flattens out considerably and including those flattening out points gives a worse fit
What happens is that SharpCap has to consider 7, 8 or 9 points from the original scan when looking for a focus fit, but including the extra points aside from the 'good' 6 makes a worse graph and more deviation from the curve. That deviation is seen by SharpCap as noise in the focus signal, and the bigger it gets, the stronger the constraints SharpCap applies to make sure that the points away from the best focus position are significantly worse than the predicted best focus. Essentially in this data set there are no subsets of the data that pass all the criteria at once to let SharpCap select a curve.
Well, actually, there was at least one, but a small bug meant that it was not considered. I have fixed that for the next update.
Even given the bug fix, the underlying issue is that the data points are a little too far apart, meaning that the scan does not always get 7 or 8 points into the 'good' part of the curve where a parabola fits nicely. By reducing the spacing a little you would make the refocus more robust.
I think I will have a look at whether I can allow a fit from 6 points in some circumstances, but not just at the moment.
cheers,
Robin
Re: Another autofocus fail
Robin,
Thanks for looking into this.
In terms of reducing the spacing a bit, I'll do that, although I'm not sure why in some cases, like this one that failed, that the curve flattens out at the edges so much (I give a guess on why it did that below). It did not do that on the previous attempts that night or the previous night, and I ran exactly the same script with exactly the same equipment last night centered on exactly the same object, and I got great looking parabolas (6 times) without any real noticeable flattening. I'll change the values from 250/-250 that I've been using, to 200/-200. I find that these numbers must be tailored to the specific telescope/focuser and EAF that you are using. I guess I'm still in the learning stages on finding what the optimal values are for my equipment.
Concerning those cases when the SharpCap algorithm decides to try to refine the curve, I'd be OK (ecstatic, really) if you dropped that for now. Like I said, I don't think I've ever seen that work for me. However, if the SharpCap algorithm doesn't find a focus point on the first go-around, I still think it might be worth having it repeat the attempt, perhaps with a reduced spacing from the original attempt (20% maybe?). That way, if the user asks for 9 steps from 250 to -250 and a focal point is not found, the SharpCap algorithm could make second attempt using 9 steps from 200 to -200. Such a scenario could've possibly worked for me on the failed attempt 2 nights ago (with the elimination of the "refinement" failure, too). If that works, a statement could be put in the log file recommending that the user strongly consider reducing the spacing in their script. If it doesn't find a focal point on the second attempt, just bail out of the focus algorithm and resume the imaging script. Also, perhaps on the first attempt there could have been a small cirrus cloud or contrail coming by that may have negatively affected the focus, and running the algorithm a second time may result in obtaining a good focus if that cloud has moved away by then. I'm guessing it's possible that something like that may have caused my "flattening" the other night. I ran the focus algorithm at least 15 other times on the past 3 nights without that problem, so I think rerunning the algorithm when it doesn't find a focus point on the first attempt may be a very good thing to consider. I don't think that could hurt anything (except taking a little more time), but it has the possibility of helping by finding the focus point.
Thanks for your help,
Rich
Thanks for looking into this.
In terms of reducing the spacing a bit, I'll do that, although I'm not sure why in some cases, like this one that failed, that the curve flattens out at the edges so much (I give a guess on why it did that below). It did not do that on the previous attempts that night or the previous night, and I ran exactly the same script with exactly the same equipment last night centered on exactly the same object, and I got great looking parabolas (6 times) without any real noticeable flattening. I'll change the values from 250/-250 that I've been using, to 200/-200. I find that these numbers must be tailored to the specific telescope/focuser and EAF that you are using. I guess I'm still in the learning stages on finding what the optimal values are for my equipment.
Concerning those cases when the SharpCap algorithm decides to try to refine the curve, I'd be OK (ecstatic, really) if you dropped that for now. Like I said, I don't think I've ever seen that work for me. However, if the SharpCap algorithm doesn't find a focus point on the first go-around, I still think it might be worth having it repeat the attempt, perhaps with a reduced spacing from the original attempt (20% maybe?). That way, if the user asks for 9 steps from 250 to -250 and a focal point is not found, the SharpCap algorithm could make second attempt using 9 steps from 200 to -200. Such a scenario could've possibly worked for me on the failed attempt 2 nights ago (with the elimination of the "refinement" failure, too). If that works, a statement could be put in the log file recommending that the user strongly consider reducing the spacing in their script. If it doesn't find a focal point on the second attempt, just bail out of the focus algorithm and resume the imaging script. Also, perhaps on the first attempt there could have been a small cirrus cloud or contrail coming by that may have negatively affected the focus, and running the algorithm a second time may result in obtaining a good focus if that cloud has moved away by then. I'm guessing it's possible that something like that may have caused my "flattening" the other night. I ran the focus algorithm at least 15 other times on the past 3 nights without that problem, so I think rerunning the algorithm when it doesn't find a focus point on the first attempt may be a very good thing to consider. I don't think that could hurt anything (except taking a little more time), but it has the possibility of helping by finding the focus point.
Thanks for your help,
Rich
- admin
- Site Admin
- Posts: 17552
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Another autofocus fail
Hi Rich,
the only 'smart' bit left in the current version is to carry on taking more samples beyond the specified count if either of the following seem to be true
* Focus is improving, but not reached best focus yet
* Best focus seems to have been passed, but not enough points yet to be sure that we have passed it
Both of those are pretty reliable in doing what they are supposed to without making a mess of things, but you can turn smart scanning off in the focus scan options if you want.
I just had a look at the data from the scan an hour earlier than the failed one and there is evidence of flattening to the sides of the graph there too
I think that this one has been more successful because there is a data point close to the middle of the dip, meaning that when SharpCap selects 7 points as the smallest possible data set, it picks the minimum poiunt and 3 each side, and those make a fairly decent parabola. An hour later you ended up with two data points each side of the dip and the got issues. Definitely something for me to look into in future to try to remove this sensitivity.
Another weird thing... Why did all the scores come in as roughly 4 when the scan went wrong and the focuser moved way out of focus? Normally I would expect no stars to be picked up and therefore a score of 25.
cheers,
Robin
the only 'smart' bit left in the current version is to carry on taking more samples beyond the specified count if either of the following seem to be true
* Focus is improving, but not reached best focus yet
* Best focus seems to have been passed, but not enough points yet to be sure that we have passed it
Both of those are pretty reliable in doing what they are supposed to without making a mess of things, but you can turn smart scanning off in the focus scan options if you want.
I just had a look at the data from the scan an hour earlier than the failed one and there is evidence of flattening to the sides of the graph there too
I think that this one has been more successful because there is a data point close to the middle of the dip, meaning that when SharpCap selects 7 points as the smallest possible data set, it picks the minimum poiunt and 3 each side, and those make a fairly decent parabola. An hour later you ended up with two data points each side of the dip and the got issues. Definitely something for me to look into in future to try to remove this sensitivity.
Another weird thing... Why did all the scores come in as roughly 4 when the scan went wrong and the focuser moved way out of focus? Normally I would expect no stars to be picked up and therefore a score of 25.
cheers,
Robin
Re: Another autofocus fail
Robin,
Thanks for more info on how the algorithm for focusing works. That helps in knowing how to set things up.
I changed my limits for my current setup to search from offsets of 200 to -200, instead of from 250 to -250. So far this evening, that has worked as I would like - good parabolas on 3 auto focus runs (despite some periods of mega-cirrus). Since the algorithm requires 7 points for the parabola, I would think that adding more steps than my current level of 9 would help. There is a trade-off however, between using more steps and time elapsed to obtain the focal point. For now, I'll stick with 9 steps. As long as my shorter span works, there shouldn't be a need to add any more steps. My success rate with the auto focus is over 95% now and should even be higher after this latest correction.
Yes, I am puzzled by the scores of "4" when the camera was hopelessly out of focus. As I said before, I saw the stars on the screen at the end of this failure, and they were huge.
I take it that you don't like my idea of repeating a focus attempt if the first one fails by shortening the scan on the second attempt. If what I did tonight solves the issue I had the other night, I could see not doing that.
Should I just download the latest version to get all the changes you've made to the auto focus routine?
Rich
Thanks for more info on how the algorithm for focusing works. That helps in knowing how to set things up.
I changed my limits for my current setup to search from offsets of 200 to -200, instead of from 250 to -250. So far this evening, that has worked as I would like - good parabolas on 3 auto focus runs (despite some periods of mega-cirrus). Since the algorithm requires 7 points for the parabola, I would think that adding more steps than my current level of 9 would help. There is a trade-off however, between using more steps and time elapsed to obtain the focal point. For now, I'll stick with 9 steps. As long as my shorter span works, there shouldn't be a need to add any more steps. My success rate with the auto focus is over 95% now and should even be higher after this latest correction.
Yes, I am puzzled by the scores of "4" when the camera was hopelessly out of focus. As I said before, I saw the stars on the screen at the end of this failure, and they were huge.
I take it that you don't like my idea of repeating a focus attempt if the first one fails by shortening the scan on the second attempt. If what I did tonight solves the issue I had the other night, I could see not doing that.
Should I just download the latest version to get all the changes you've made to the auto focus routine?
Rich
- admin
- Site Admin
- Posts: 17552
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Another autofocus fail
Hi Rich,
yes, the latest version will have the updates I was discussing above, so should cope slightly better in poor curve shape cases than the version you are runing.
Right now I am trying to avoid adding anything new at all to SharpCap, and certainly not anything complicated that could have undesireable side effects, so the second scan is off for now. To be honest, I'd prefer to try to fix the underlying problem (not spotting a perfectly good parabola) anyway as that would get the focus working without the need for a second run through.
cheers,
Robin
yes, the latest version will have the updates I was discussing above, so should cope slightly better in poor curve shape cases than the version you are runing.
Right now I am trying to avoid adding anything new at all to SharpCap, and certainly not anything complicated that could have undesireable side effects, so the second scan is off for now. To be honest, I'd prefer to try to fix the underlying problem (not spotting a perfectly good parabola) anyway as that would get the focus working without the need for a second run through.
cheers,
Robin