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

MOC from zone with upper right corner #180

Closed
camposandro opened this issue Oct 31, 2024 · 1 comment · Fixed by #182
Closed

MOC from zone with upper right corner #180

camposandro opened this issue Oct 31, 2024 · 1 comment · Fixed by #182
Labels

Comments

@camposandro
Copy link

I'm currently migrating the HATS box filtering implementation to use mocpy's zones, hats#401, and I identified an edge case that I cannot get to work. When the upper right corner of the zone is in the 0/360-degree boundary, an error is thrown:

from mocpy import MOC
from astropy.coordinates import SkyCoord

>>> moc = MOC.from_zone(SkyCoord([(180,30),(0,50)], unit="deg"), max_depth=3)
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cdshealpix-0.7.0/src/sph_geom/zone.rs:28:5:
assertion failed: (0.0..TWICE_PI).contains(&lon_min) && 0.0 < lon_max && lon_max <= TWICE_PI
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/scampos/anaconda3/envs/lsdb/lib/python3.10/site-packages/mocpy/moc/moc.py", line 1511, in from_zone
    index = mocpy.from_zone(
pyo3_runtime.PanicException: assertion failed: (0.0..TWICE_PI).contains(&lon_min) && 0.0 < lon_max && lon_max <= TWICE_PI

The SkyCoord object wraps the 360 degree longitudes to 0 degrees, and therefore the maximum longitude constraint that imposes 0.0 < lon_max && lon_max <= TWICE_PI fails. It would be great if we could handle both 360/0.

The region I am trying to achieve is approximately the following (used coordinates [(180,30),(359,50)]).
Figure_1

@ManonMarchand
Copy link
Member

Indeed, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants