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

Initialization error in docs/tutorials/multiresolution.ipynb #283

Closed
b-remy opened this issue Apr 26, 2024 · 6 comments
Closed

Initialization error in docs/tutorials/multiresolution.ipynb #283

b-remy opened this issue Apr 26, 2024 · 6 comments

Comments

@b-remy
Copy link

b-remy commented Apr 26, 2024

I was running the multiresolution.ipynb tutorial and encountered an error when initializing the sources as ExtendedSource

# Source initialisation
sources = [
    scarlet.ExtendedSource(model_frame,
                           sky_coord,
                           observations,
                           thresh=0.1,
                          )
    for sky_coord in ra_dec
]

returning

ArithmeticError: Model TabulatedSpectrum, Parameter 'spectrum' is not finite:
[      nan       nan       nan       nan       nan 2.6395272]

Has scarlet initialization procedure changed after this notebook was pushed? Here is a colab notebook to reproduce the error https://colab.research.google.com/drive/1nV-mGIQoCJZbExxPD_usa0evmJIZjOG8?usp=sharing

@pmelchior
Copy link
Owner

Weird. This is the spectrum initialization of the HSC image going wrong. Can you check if the pixel coordinates associated with the source position in RA/Dec is correct?

@b-remy
Copy link
Author

b-remy commented Apr 30, 2024

It seems they are in RA/DEC

array([[150.33104781,   2.07003218],
       [150.33022577,   2.0702573 ],
       [150.33102661,   2.07022809],
       [150.33106896,   2.07029557],
       [150.33096789,   2.07025819],
       [150.33104769,   2.0701253 ],
       [150.33005928,   2.07028169],
       [150.32999003,   2.07030221],
       [150.32993349,   2.07048086],
       [150.32991772,   2.07056598],
       [150.33021891,   2.07083053],
       [150.33059818,   2.07098648]])

And the display function is converting these RA/DEC coordinates to HSC pixels to overlap sources to the morphology
image

I am trying to figure out where the nans come from

@pmelchior
Copy link
Owner

I think I have found part of the problem. If so, it's related to #282. Can you test if spectra = init.get_pixel_spectrum(sky_coord, observations) returns nans, please.

@b-remy
Copy link
Author

b-remy commented Apr 30, 2024

This works for each source

[array([4.375723 , 3.706623 , 2.6916485, 3.2171175, 2.4734876],
      dtype=float32), array([1.4452889], dtype=float32)]
[array([8.453968, 8.744746, 8.078425, 7.21597 , 6.92792 ], dtype=float32), array([6.1424046], dtype=float32)]
[array([10.523911 ,  9.074745 ,  6.5678105,  7.0109396,  4.94793  ],
      dtype=float32), array([4.0687194], dtype=float32)]
[array([9.881581 , 8.826522 , 6.136643 , 6.26985  , 4.0761013],
      dtype=float32), array([13.809645], dtype=float32)]
[array([8.960169, 7.722469, 5.366055, 5.421723, 4.023126], dtype=float32), array([3.0977886], dtype=float32)]
[array([7.3961725, 6.314975 , 4.6239867, 5.7644944, 4.153218 ],
      dtype=float32), array([4.3545218], dtype=float32)]
[array([18.904358, 21.548618, 21.980566, 22.801405, 18.784016],
      dtype=float32), array([23.688356], dtype=float32)]
[array([21.445032, 24.591253, 24.96186 , 25.030066, 20.297144],
      dtype=float32), array([16.399578], dtype=float32)]
[array([5.963582 , 6.2947664, 6.730194 , 7.1471443, 6.6866164],
      dtype=float32), array([3.1061878], dtype=float32)]
[array([4.42793  , 4.904378 , 5.2223344, 5.5198197, 5.395245 ],
      dtype=float32), array([2.4887385], dtype=float32)]
[array([1.1586634, 3.9580977, 8.05664  , 9.940866 , 8.854514 ],
      dtype=float32), array([9.527296], dtype=float32)]
[array([0.48858365, 0.92691386, 0.74116206, 0.7110228 , 0.5247147 ],
      dtype=float32), array([0.9085161], dtype=float32)]

@pmelchior
Copy link
Owner

Check out brach init_fixes. It should work now. I haven't run all tests, but if they work as expected I will create a PR for that branch asap

@b-remy
Copy link
Author

b-remy commented May 1, 2024

Thank you for the fix @pmelchior the tutorial notebook works fine now! I'm closing this issue

@b-remy b-remy closed this as completed May 1, 2024
@pmelchior pmelchior mentioned this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants