Staff Assigned: Owen Lawrence CCDCamera.GuiderXStarPosition, GuiderYStarPosition no longer updated after CCDCamera.GuiderMoveStar

Discussion in 'Scripting and Programming' started by Jeff Morgenthaler, Jun 15, 2019.

  1. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi,

    I have a script that reads CCDCamera.GuiderXStarPosition and CCDCamera.GuiderYStarPosition, adds a small value to them and then moves the guide star position with CCDCamera.GuiderMoveStar. I do this in a loop, checking for the guider to settle between moves so I can smoothly move the object from one position on the focal plane to another without losing it in the guider.

    This worked great in 6.13 but no longer works in 6.20. It looks like CCDCamera.GuiderXStarPosition and CCDCamera.GuiderYStarPosition don't change when I call CCDCamera.GuiderMoveStar. Is this a bug that crept in? Is there a step I am missing between setting GuiderMoveStar and reading Guider[XY]StarPosition? Or should I be looking somewhere else in MaxIm for the true position of the guide star when I am offset guiding?

    Thanks for any pointers. I can provide the short segment (~20 lines) of Python code I am using for this if it would help.

    jpm
     
  2. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi,

    It has been almost a month since I posted this message and have heard no reply. I do think it is a bug that CCDCamera.GuiderXStarPosition and CCDCamera.GuiderYStarPosition no longer track with changes made by CCDCamera.GuiderMoveStar. Please fix it.

    Thanks!

    jpm
     
  3. Colin Haig

    Colin Haig Staff Member

    Joined:
    Oct 27, 2014
    Messages:
    2,083
    Hi Jeff,
    Many apologies - somehow we missed it.
    This is assigned to @Owen Lawrence and I expect he will follow-up shortly.

    Could you attach your script ? Use the Upload a File button down below to the right.
     
  4. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Hi,

    Please note: GuiderXStarPosition and GuiderYStarPosition are read-only properties. You cannot effect change by adding anything to them. I do expect them to receive updates while guiding is underway, though.

    Can you please upload a zip archive of your Documents\MaxIm DL 6\Settings folder, as well as your script?

    In detail, how do you use your script in this situation?

    - Owen -
     
  5. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi Colin and Owen, thanks for your responses!

    The whole script is over 3000 lines long and interfaces with other multi-thousand line programs and requires a particular Anaconda version, so I will just cut-paste the section that matters and describe in detail what is going on and why. In the code segment below you will see that I have a little loop that reads the CCDCamera.GuiderXStarPosition and CCDCamera.GuiderYStarPosition, adds a little bit to them, updates the guide star position using CCDCamera.GuiderMoveStar, then waits until the guider settles. If you do this in your favorite scripting language, I think it will be fairly easy to reproduce. You won't even need a loop. Just read CCDCamera.Guider[XY]StarPosition, call CCDCamera.GuiderMove to set the guide star position to another value and read CCDCamera.Guider[XY]StarPosition again and you will find they will not have changed. That is the fundamental problem.

    Since you have asked for more detail, I provide it below, however I am sure this is way more detail than you need, so feel free to stop reading here.

    The current version of my software enables I move my object from one place to another on my main camera focal plane. Most of the 1000s of lines of code I am not giving you are used to do the scene analysis of the main camera images, figure out the coordinate transformations from main to guide camera pixels, which I do in detail using WCS, figure out which guiding mode I am in (I use ACP sometimes and MaxIm-only sometimes, which have different standards for which side to flip a GEM while guiding), etc. Ultimately, I would like to offer this package to the community as a way to solve the general problem of relative flexure between main guide scopes in boresite aligned guiding applications and simultaneously do offset guiding on stars so that I can follow non-sidereal objects. I know it works for simultaneously doing a simple case of flexure correction at one DEC and moving my target exactly where it needs to be. The ability to use CCDCamera.Guider[XY]StarPosition as a state variable is important for the long-term success of this project, since several components of the software independently apply offset guiding corrections.

    Some guide to variable names in my code segment

    cp_coords: center pixel coordinates
    step_dp: step delta pixels, calculated with num_steps to gently move the guide box the full distance I want to go
    tp_coords: this/temp pixel coord
    Note, following the astropy lead, I work with arrays in native C-style row-major coordinates for speed and transpose the indices when I need to interface with the Cartesian/column-major world.

    Let me know if you need any more code or explanation.

    for istep in range(num_steps):
    # Just in case someone else is commanding the guide
    # box to move, use its instantaneous position as the
    # starting point of our move !!! TRANSPOSE !!!
    cp_coords = np.asarray((self.CCDCamera.GuiderYStarPosition,
    self.CCDCamera.GuiderXStarPosition))
    tp_coords = cp_coords + step_dp
    log.debug('Setting to: ' + str(tp_coords[::-1]))
    # !!! TRANSPOSE !!!
    self.CCDCamera.GuiderMoveStar(tp_coords[1], tp_coords[0])
    self.guider_settle()

    If you need anything else, please let me know.

    jpm
     

    Attached Files:

  6. Colin Haig

    Colin Haig Staff Member

    Joined:
    Oct 27, 2014
    Messages:
    2,083
    BTW are you using AstroConda ? I was talking to STScI folks about that a couple weeks ago.
     
  7. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Thanks for the descriptions. I'll set up some tests based on your code to see if I can find a problem.

    I do have a question, though. Why are you swapping coordinates like that? There's nothing wrong with what you wrote, but it seems unnecessary.

    - Owen -
     
  8. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi Owen,

    Thanks for the pointer to AstroConda. If I need to expand the capabilities of my data collection suite to do more on-the-fly analysis, I may need that. For my current purposes, I have found that Anaconda has adequate coverage of the AstroPy suite. The problem with Anaconda I had was a recent version had a bug that broke the Python interface with Windows COM. Using an older version (which, fortunately, they keep around) solved the problem.

    As far as coordinate transposition, this is something that the AstroPy & SciPy people recommend:

    http://docs.astropy.org/en/stable/i...use-for-indexing-such-as-of-image-coordinates
    https://docs.scipy.org/doc/numpy/reference/internals.html

    Basically, all of my Python scripts use transpose index order (Y,X) to keep the underlying C code of Python as efficient as possible and I transpose whenever I interface with a system that uses Cartesian order (X,Y).

    Let me know if you have any other questions or have trouble reproducing the bug I have reported.

    jpm
     
  9. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Hi,

    I tested a script containing calls to GuiderXStarPosition, GuiderYStarPosition, and GuiderMoveStar(). They appear sensitive to whether or not the GUI is finished updating after the move, but as long as you wait long enough, the new star positions do reflect the values provided in GuiderMoveStar(). I don't know what you're doing in self.guider_settle(); could it be returning too quickly?

    - Owen -
     
  10. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Ah, the plot thickens! I have cut the guider_cycle code out and pasted it into its own file so as to preserve the leading spaces so you can read it, since it is more complex than the simple code segment I sent. See attached. guider_settle() is designed to wait as long as it needs to, which is easily more than 10s, but it may be tweaking other things like CCDCamera.GuiderNewMeasurement and CCDCamera.Guider[XY]Error that keep the GUI from settling. Of course while this is going on, I might be recording images with the main camera, which also might keep the GUI busy.

    Let me know if you have any trouble reading guider_settle().

    Thanks for digging into this!

    jpm
     

    Attached Files:

  11. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi Owen,

    It just occurred to me that rather than trying to figure out the timing in my code to see if it is causing a problem with the GUI, could it be possible for GuiderXStarPosition and GuiderYStarPosition to be set to the underlying values that the GUI uses, rather than using the GUI as a relay?

    Just a thought.

    jpm
     
  12. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Hi,

    Thanks for the additional info. The problem is exhibited in a loop such as in your script (which originally I didn't have in my own). The offset from the reference position was being calculated with the wrong sign, causing it to correct itself on each iteration.

    I'll prepare a package for you to try after a bit more testing tomorrow.

    - Owen -
     
  13. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Hi,

    Here is a zip containing a version marked "Beta" which contains the fix for the GuiderMoveStar() function. I recommend you first make a backup of your MaxIm DL installation directory (typcially C:\Program Files (x86)\Diffraction Limited\MaxIm DL 6). Then copy the files contained in the zip file into the installation directory and give it a try.

    Please let me know if it works okay.

    Thanks.

    - Owen -
     

    Attached Files:

  14. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi Owen,

    It was a bit cloudy tonight, so it was a little hard to tell by eye if Jupiter was moving, but the center point reported in my logs definitely was and the error graph did the right thing each successive loop iteration. So I think your solution works! I'll check in more detail when the weather gets better.

    Thanks!

    jpm
     
  15. Owen Lawrence

    Owen Lawrence Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    1,380
    Okay, I'll mark this thread as Resolved once you report back with more certainty. Thanks for the good news so far.

    - Owen -
     
  16. Jeff Morgenthaler

    Jeff Morgenthaler Cyanogen Customer

    Joined:
    Apr 6, 2019
    Messages:
    11
    Hi Owen,

    The weather was clearer tonight and I found that when I moved the guide box, Jupiter actually moved the wrong way in both directions on the main camera. And paying closer attention to the sign on the guide error, I see that when I made step of the guide point to negative values (up), the guide error went negative, but should go positive.

    This doesn't happen with the older version of MaxIm I was using. Could it be that the minus sign you introduced is somehow in the wrong place? Or something else is going on?

    Let me know if you need anything from me that could help track this down.

    Thanks!

    jpm
     

Share This Page