Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: WCS to Pixels to WCS gives wrong reference data #2724

Closed
pllim opened this issue Feb 22, 2024 · 4 comments · Fixed by #2751
Closed

BUG: WCS to Pixels to WCS gives wrong reference data #2724

pllim opened this issue Feb 22, 2024 · 4 comments · Fixed by #2751
Labels
bug Something isn't working imviz

Comments

@pllim
Copy link
Contributor

pllim commented Feb 22, 2024

This is a follow-up of:

And discovered in:

Workflow to reproduce:

  1. Use the ImvizDitheredExample.ipynb example notebook. Load both data.
  2. Link by WCS on the Orientation plugin.
  3. Click the "N-up E-left" icon so now the images in first viewer is aligned by N-up E-left.
  4. Create a second viewer and load the first image only.
  5. With second viewer (imviz-1) selected in Orientation, click on the "N-up E-right" icon so now the second viewer image is aligned by N-up E-right.
  6. Now select "Pixels" in Orientation. Both viewers will go back to pixel linking and no longer appear rotated.
  7. Now click "WCS" again in Orientation. See that both images do not go back to being aligned by one of the 3 possible WCS layers (see screenshot below). Despite that, when you blink, the stars still aligned (despite the exposures being dithered) as if ENH: Image rotation via WCS-only layers #2179 never happened.

Screenshot 2024-02-22 162201

🐱

@pllim pllim added bug Something isn't working imviz labels Feb 22, 2024
@bmorris3
Copy link
Contributor

That's confusing, especially because I made sure this worked when I last touched this code.

I followed your example, and I see the bug too, and if you do:

for viewer_name, viewer in imviz.viewers.items():
    print(
        viewer_name, 
        viewer._obj.state.reference_data.label, 
        viewer._obj.state.linked_by_wcs
    )

You see

imviz-0 acs_47tuc_1[SCI,1] True
imviz-1 acs_47tuc_1[SCI,1] True

but as you mentioned, the data are linked by the WCS on the data, rather than the WCS in the WCS-only layer.

Did someone change the logic for when to change reference data on link-type change?

@pllim
Copy link
Contributor Author

pllim commented Feb 26, 2024

Did someone change the logic

So many things were merged in around that time, I can't remember what is what. Might be an accidental regression when a rebase happen somewhere too.

@pllim
Copy link
Contributor Author

pllim commented Mar 12, 2024

@bmorris3 , I think I know where the bug is but I don't understand the distinction between default_reference_layer and refdata in link_image_data. I thought about adding a elif link_type == 'wcs' and old_link_type == 'pixels': after this block but not sure how to do it properly. Any advice? Thanks!

if link_type == 'pixels' and old_link_type == 'wcs':

@bmorris3
Copy link
Contributor

default_reference_layer in all cases (without deleting Data) is just the first loaded Data. It's useful here because the WCS-only layers are defined wrt the first loaded Data. refdata comes from get_reference_image_data, which may be None, or the first loaded image, or the data you've set as reference data in the workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working imviz
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants