Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-20310

Investigate new WCS fitting for final tangent to sky projection

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: meas_astrom
    • Labels:
      None

      Description

      Investigate how to fit a final tweak to the WCS from tangent-plane/IWCS produced by DM-20188 to the Sky allowing for tweaks to on sky positions and affine transform.

        Attachments

          Issue Links

            Activity

            Hide
            cmorrison Chris Morrison [X] (Inactive) added a comment -

            John Parejko and had a few chats about how to fit the final WCS that includes only a shift/rotation and possibly a small stretch. Thankfully most of the functions we need to create everything are exposed in python through ast-shim.

            The plan we came up with is to postpend a fitted 2D matrix transform to the already existing transform between the ast Frame just before the "IWC" frame to take care of any rotation and possible "squish". In addition to this we will fit the crvals on the "Sky" frame. The fitting would be done a total of 6 variables and would minimize the distance between reference positions on the sky to the predicted source locations on sky. This leaves every part of the WCS produced by Parejko's createInitialWcs function intact save for the initial crvals.

            The steps to fit would be:

            get frameDict from inital WCS
            copy all frames from frameDict
            for iteration in number of fit steps:
                create new rotation matrix and post-pend to the mapping of "DOMAIN_BEFORE_IWC" -> "IWC"
                update crval in SkyFrame copy
                create new SkyWcs from copied/updated frames
                predict source sky locations
                compare to matched reference locations
            return final WCS
            

            Parejko was also helpful enough to write a small example of getting the frames and creating a new WCS

            # solution for now (until DM-20315 is fixed)
            frameDict = skyWcs.getFrameDict()
            mapping = frameDict.getMapping("PIXELS", "IWC")
            newMap = mapping.then(astshim.MatrixMap(someMatrix))
            # maybe remapFrame would work, if we could trust it
            pixels = frameDict.getFrame("PIXELS")
            iwc = frameDict.getFrame("IWC")
            sky = frameDict.getFrame("SKY")
            iwcMap = frameDict.getMapping("IWC", "SKY")
            newFrameDict = frameDict(pixels)
            newFrameDict.addFrame("PIXELS", newMap, iwc)
            newFrameDict.addFrame("IWC", iwcMap, sky)
            newSkyWcs = SkyWcs(newFrameDict)
            

            Show
            cmorrison Chris Morrison [X] (Inactive) added a comment - John Parejko and had a few chats about how to fit the final WCS that includes only a shift/rotation and possibly a small stretch. Thankfully most of the functions we need to create everything are exposed in python through ast-shim. The plan we came up with is to postpend a fitted 2D matrix transform to the already existing transform between the ast Frame just before the "IWC" frame to take care of any rotation and possible "squish". In addition to this we will fit the crvals on the "Sky" frame. The fitting would be done a total of 6 variables and would minimize the distance between reference positions on the sky to the predicted source locations on sky. This leaves every part of the WCS produced by Parejko's createInitialWcs function intact save for the initial crvals. The steps to fit would be: get frameDict from inital WCS copy all frames from frameDict for iteration in number of fit steps: create new rotation matrix and post-pend to the mapping of "DOMAIN_BEFORE_IWC" -> "IWC" update crval in SkyFrame copy create new SkyWcs from copied/updated frames predict source sky locations compare to matched reference locations return final WCS Parejko was also helpful enough to write a small example of getting the frames and creating a new WCS # solution for now (until DM-20315 is fixed) frameDict = skyWcs.getFrameDict() mapping = frameDict.getMapping("PIXELS", "IWC") newMap = mapping.then(astshim.MatrixMap(someMatrix)) # maybe remapFrame would work, if we could trust it pixels = frameDict.getFrame("PIXELS") iwc = frameDict.getFrame("IWC") sky = frameDict.getFrame("SKY") iwcMap = frameDict.getMapping("IWC", "SKY") newFrameDict = frameDict(pixels) newFrameDict.addFrame("PIXELS", newMap, iwc) newFrameDict.addFrame("IWC", iwcMap, sky) newSkyWcs = SkyWcs(newFrameDict)
            Hide
            jbosch Jim Bosch added a comment -

            Looks good to me!

            Are you planning to just use a standard (e.g. scipy optimizer) for the fit steps, or did you have some other way of predicting the rotation matrix and new crval from the last iteration?

            Show
            jbosch Jim Bosch added a comment - Looks good to me! Are you planning to just use a standard (e.g. scipy optimizer) for the fit steps, or did you have some other way of predicting the rotation matrix and new crval from the last iteration?
            Hide
            cmorrison Chris Morrison [X] (Inactive) added a comment -

            Yeah, I think that was the plan. The matcher current just uses optimize.least_squares for it's minimizing and I can't imagine this needing anything better really.

            Show
            cmorrison Chris Morrison [X] (Inactive) added a comment - Yeah, I think that was the plan. The matcher current just uses optimize.least_squares for it's minimizing and I can't imagine this needing anything better really.
            Hide
            cmorrison Chris Morrison [X] (Inactive) added a comment -

            So quick question, should we close this ticket and open a new one for the work on me coding this up? If so who watching this ticket wants to say they reviewed it?

            Show
            cmorrison Chris Morrison [X] (Inactive) added a comment - So quick question, should we close this ticket and open a new one for the work on me coding this up? If so who watching this ticket wants to say they reviewed it?
            Hide
            cmorrison Chris Morrison [X] (Inactive) added a comment -

            Giving this to you as you said the overall design looked good.

            Show
            cmorrison Chris Morrison [X] (Inactive) added a comment - Giving this to you as you said the overall design looked good.
            Hide
            jbosch Jim Bosch added a comment -

            Happy to go with a new ticket for the implementation.

             

            Show
            jbosch Jim Bosch added a comment - Happy to go with a new ticket for the implementation.  

              People

              Assignee:
              cmorrison Chris Morrison [X] (Inactive)
              Reporter:
              cmorrison Chris Morrison [X] (Inactive)
              Reviewers:
              Jim Bosch
              Watchers:
              Chris Morrison [X] (Inactive), Jim Bosch, John Parejko, John Swinbank, Lauren MacArthur
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins Builds

                  No builds found.