cds-astro / ipyaladin

An IPython Widget for Aladin Lite, the sky viewer.
https://cds-astro.github.io/ipyaladin/
BSD 3-Clause "New" or "Revised" License
126 stars 26 forks source link

Bounding box measured in pixel sizes (vs RA/DEC) #64

Closed SultanOrazbayev closed 2 months ago

SultanOrazbayev commented 1 year ago

It's possible to add a bounding box/shape using add_overlay_from_stcs method on ipyaladin. However this requires specifying the coordinates using RA/DEC. Is it possible to specify the bounding box coordinates using pixels?

from ipyaladin import Aladin
a = Aladin(target="M 51", fov=1.2)
a.add_overlay_from_stcs(
    "Polygon ICRS 202.63748 47.24951 202.46382 47.32391 202.46379 47.32391 202.45459 47.32391 202.34527 47.20597 202.34527 47.20596 202.34529 47.19710 202.51870 47.12286 202.52789 47.12286 202.52791 47.12286 202.63746 47.24063 202.63749 47.24949\nPolygon J2000 202.74977 47.36958 202.57592 47.44415 202.57585 47.44416 202.56666 47.44416 202.45683 47.32632 202.45683 47.31746 202.63051 47.24302 202.63970 47.24302 202.74978 47.36069 202.74982 47.36955\nPolygon J2000 202.52540 47.12904 202.35192 47.20325 202.34273 47.20325 202.23391 47.08518 202.23395 47.07633 202.23398 47.07630 202.40715 47.00227 202.40721 47.00226 202.41640 47.00226 202.52539 47.12018",
    {"color": "red"},
)
a
ManonMarchand commented 1 year ago

Hello and thanks for opening the ticket :slightly_smiling_face:

This is not possible yet, but it is a good idea for a feature! We'll have a look at this.

Notes for implementation:

SultanOrazbayev commented 1 year ago

Thank you for the quick response!

From reading more about this, I see that astropy has some utils for converting degree to pixel (and back). However, they require WCS info, which can be loaded from FITS. In case of ipyaladin can you tell me which WCS is used?

ManonMarchand commented 1 year ago

Hello,

There is an experimental branch feature-export-wcs if you want to try it (clone the repo, switch to branch and pip install .)

The use is documented in 2_Base_commands.ipynb

(looks like this)

from ipyaladin import Aladin
aladin = Aladin()
aladin
aladin.update_WCS()
aladin.wcs # returns a dictionnary with the WCS information

Won't merge yet due to two limitations:

SultanOrazbayev commented 1 year ago

This is very useful, thank you very much, @ManonMarchand !

ManonMarchand commented 1 year ago

No worries Some projections are still buggy but we're approaching a merge upstream :muscle:

SultanOrazbayev commented 2 months ago

Thank you, @ManonMarchand !

ManonMarchand commented 2 months ago

Was done by @Xen0Xys ;) You now have access to the WCS, see example 11. This should allow you to retrieve what you need, but don't hesitate to open a new issue if it does not work.