[ACP-675]  AutoFlat inconsistency between ACP selected filter and actual used
Type Bug
Priority Medium
Severity Major
Component AcquireSupport library
Fixed In Version [8.08.0
Versions Affected [7.1c7.1c
Severity Closed
Resolution Complete
Reported By Bob Denny
Resources Bob Denny
Start Date 3/22/2015

Description
There have been claims (e.g. Ben Davies) that the wrong filter is being used for flats: the FILTER keyword in the flat has a different filter than the one ACP uses in the file name, and showing in the log. In at least one case, it is certain that the wrong filter was actually used.

Add additional logging that can be conditionally enabled which will trace the filter usage. This should help isolate these problems.

NOTE MANY CHANGES IN ACP-1119 (linked)!

Comments
8/14/2016 10:58:56 AM   Bob Denny
Change for initializing filter in ACP-8 and we haven't heard on this issue for a year. Closing.
5/17/2015 11:37:36 AM   Bob Denny
REOPENED AGAIN!

See this comm center post by Mel Helm. He had the problem after a night's run, so the problem cannot be filter initialization!! Somehow the filter is getting into the state where it is not reporting the correct selected filter.
3/22/2015 12:31:59 PM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 803
Affected files /trunk/ACP Help/relnotes.htm (Modified)
/trunk/AcquireSupport.wsc (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Always restore previous filter, no matter what. GEM:675
10/24/2014 10:29:06 AM   Bob Denny
Posted a question in the MaxIm forum

10/24/2014 10:03:45 AM   Bob Denny
I finally think I know what's happening. MaxIm remembers the last filter used. However, some filter wheels home to their slot #1 when they start up. If I ask what filter is set right after MaxIm starts, MaxIm tells me the last used filter. However, it is actually not that filter, it is the first filter (or the home filter). If images are taken, the home filter name is correctly recorded in the FITS, yet MaxIm continues to say the previously used filter unless the filter is specifically changed via the API. Only then is it in sync.

Therefore, this if statement in AcquireSupport prevents the filter from syncing:

            If Util.ScriptCamera.Filter <> prevFilt Then        ' If MaxIm's filter changed since the last run
                Util.Console.PrintLine "Restoring filter " & FilterName(prevFilt) & " from previous ACP run at " & _
                    Util.FormatVar(CDate(buf), "yyyymmdd@HhNnSs") & " UTC"
                Util.ScriptCamera.Filter = prevFilt             ' Tell MaxIm to use THIS filter now
            End If

10/24/2014 9:59:31 AM   Bob Denny
DAMN IT! REOPENED AGAIN!
7/26/2014 7:59:38 AM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 697
Affected files /trunk/ACP Help/relnotes.htm (Modified)
/trunk/AcquireSupport.wsc (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Remove focus restoration logic. This is hopefully it for this annoying and long running issue. GEM:675
7/26/2014 7:10:56 AM   Bob Denny
OK, see the filter selection part of the comments from 10/29/2013 3:07:35 PM below.
7/25/2014 9:23:53 AM   Bob Denny
Reopened again. I made a mess with the focus restoration. 

See the thread Focuser Starting Point. Fiddling with the focus position on startup is a waste. The original problem may no longer even be there. Research needed. This whole thing may go away.
2/15/2014 10:02:00 AM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 633
Affected files /trunk/AcquireSupport.wsc (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Handle larger numbers for focuser ticks. GEM:675
2/15/2014 9:56:42 AM   Bob Denny
Reopened from this Comm Center thread by Larry Van Vleet. Need a CLng() on thje focuser tick count.
12/1/2013 12:34:56 PM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 587
Affected files /trunk/AcquireSupport.wsc (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Post-close of issue, cosmetic logging of saved filter state. GEM:675
11/7/2013 7:57:08 AM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 582
Affected files /trunk/AcquireSupport.wsc (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Oops, error in AutoFocus section call to MoveFocus() it MoveFocuser() and takes 2 args. GEM:675
10/30/2013 9:35:44 AM   Bob Denny
Finally! Tracking every change to the filter and focus is the right way to do it! And yes, this is part of the configuration/profile.
10/30/2013 9:34:25 AM   Bob Denny
SVN Comment
Author rbdenny
Repository svn+ssh://rbdenny@a2_svn_dc3/home/rbdenny/svn/astro/acp
SVN Revision 575
Affected files /trunk/ACP Help/relnotes.htm (Modified)
/trunk/AcquireSupport.wsc (Modified)
/trunk/ConfigFiles.txt (Modified)
/trunk/Script Components Master/AcquireSupport.wsc (Modified)
Check-in comment Track filter and focuser changes in FilterState.txt, restore at AcquireSupport.Initialize(). This becomes part of the configuration for save/restore. GEM:675
10/29/2013 3:07:35 PM   Bob Denny
The strategy below (or anything like it) is not going to work. MaxIm saves its camera settings upon creation of the CCDCamera scripting object, and then restores them when the object is released. This really does make sense. The only way this is going to be bulletproof is to permanently save the filter selection every time the filter is changed by script. Then on the next startup, it will set the last filter that was used and take a 1 sec image with that filter, forcing it to rotate into position.

Now, what about focus when focus offsets are in effect? Save the actual focus count on each filter change as well. Next start, restore that focus count and you have the focus that was in effect when the system was last used by ACP. No crystal ball so that's the best we can do. What about when there is an autofocus? No problem, you record the focus filter and focus count again! 

One last (important) detail: Should the file containing the last filter and focus offset should be saved and restored with ACP profile changes? Why not?
10/28/2013 3:52:10 PM   Bob Denny
Amazing. Clear = 3. I manually set the filter to Red and manually expose in MaxIm. Then with script I set the filter in MaxIm (Camera.Filter = 3) then I call Camera.Expose(1, 1, 3), disconnect the camera. Then reconnect the camer and the Filter droplist still shows Red!

Ticket submitted. (edit: Ticket revealed this is all flawed!)

The process works. I added this code to Shutdown()
    If c_haveFilters Then
        Util.Console.PrintLine "Resetting filter and focuser"
        '
        ' The following works whether FilterInfo.txt is present or not. 
        ' Select reference filter and adjust focus appropriately,
        ' or select the configured "clear" filter (ACP Prefs/Imaging)
        '
        SetFilterForTask(FO_FORPOINTING)                        ' Set reference filter 
        '
        Util.ScriptCamera.AutoDownload = True                   ' Force instant download of image
        Call Util.ScriptCamera.Expose(1, 1, Util.ScriptCamera.Filter) ' This should force it to the desired filter for sure
        Util.Console.PrintLine "Filter now set to " & FilterName(Util.ScriptCamera.Filter)
    End If

Not yet in the master tree. 

10/28/2013 2:37:33 PM   Bob Denny
This has been sitting out there for too long. I am at least going to add the shutdown code suggested by Dick B.
10/23/2012 5:51:30 PM   Bob Denny
Looking like we're understand this. See this message in that Comm Center thread.
8/23/2012 12:22:04 PM   Bob Denny
Bumped in the Comm Center thread. Hopefully I can get a handle on this!!
4/12/2012 6:20:57 PM   Bob Denny
Sent some tracing versions of AcquireSupport and AutoFlat (attached here)  to Rob Capon, and dang it, his next set of flats, same flat plan. went fine. Leave this "Wait Customer".
4/9/2012 1:57:44 PM   Bob Denny
A new report came in today, from Rob Capon. The interesting this, in his report is:

The plan was for “Luminance.” In the names of the 8 flat files, they were correctly shown as “Luminance.” When I opened Maxim, the last filter used was also “Luminance”, so MaximDL was set to the correct filter.

However, when I ran a master calibration set in MaximDL, the 8 Luminance flats became a Red flat master. So I opened the file to see the “.fits” information, and indeed the filter was recorded as “Red”.

10/16/2011 4:37:20 PM   Bob Denny
Now Simon Davies reports similar in this Comm Center thread. I bumped the ticked at Diffraction (it is 3 weeks old now).
9/19/2011 9:24:41 AM   Bob Denny
Received email with (among other things) a screen shot showing the problem. Support ticket dispatched to Diffraction.

8/31/2011 7:31:37 PM   Bob Denny
Reminder email sent today
8/22/2011 10:41:13 AM   Bob Denny
Reminder email sent to ben@davies.net
7/28/2011 12:04:09 PM   Bob Denny
Tracing added. Attached AutoFlat.vbs 6.1.5