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

fix: moc from zone should accept lon_max = 360 deg #182

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Fixed

* in space MOCs: upper right corner of a zone can now have a longitude of 360° [#180]

## [0.17.0]

### Added
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ bench = true
crate-type = ["cdylib"]

[dependencies]
moc = { version = "0.17", features = ["storage"] }
#moc = { git = 'https://github.com/cds-astro/cds-moc-rust', rev = '361eb278fe782bfc053433495c33e3f16e20cdbd', features = ["storage"] }
#moc = { version = "0.17", features = ["storage"] }
moc = { git = 'https://github.com/cds-astro/cds-moc-rust', rev = 'f252c2ea3f66cef60e501c2beca2977c439236f8', features = ["storage"] }
healpix = { package = "cdshealpix", version = "0.7" }
# healpix = { package = "cdshealpix", git = 'https://github.com/cds-astro/cds-healpix-rust', branch = 'master' }
rayon = "1.10"
Expand Down
14 changes: 11 additions & 3 deletions python/mocpy/moc/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,10 @@ def from_zone(cls, coordinates, max_depth):
"""
Create a MOC from a zone.

The zone is defined by a range of longitudes and latitudes. Its sides follow great
circles in longitudes and small circles for latitudes.
The zone is defined by a range of longitudes and latitudes. Its sides follow
great circles in longitudes and small circles for latitudes.
The bottom and left sides are included in the MOC, while the top and right sides
are not.

Parameters
----------
Expand All @@ -1508,10 +1510,16 @@ def from_zone(cls, coordinates, max_depth):
... max_depth=5
... )
"""
# workaround astropy.SkyCoord that wraps longitudes between [0:360[
# where we want ]0:360] for lon_max. There is no issue for lon_min that is
# expected in [0:360[.
lon_max = coordinates[1].icrs.ra.deg
if lon_max == 0:
lon_max = 360
index = mocpy.from_zone(
coordinates[0].icrs.ra.deg,
coordinates[0].icrs.dec.deg,
coordinates[1].icrs.ra.deg,
lon_max,
coordinates[1].icrs.dec.deg,
np.uint8(max_depth),
)
Expand Down
4 changes: 3 additions & 1 deletion python/mocpy/tests/test_moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,10 @@ def test_from_ring():
def test_from_zone():
moc = MOC.from_zone(SkyCoord([[-50, -50], [50, 50]], unit="deg"), max_depth=5)
# test the diagonal
for coordinate in range(-50, 60, 10):
for coordinate in range(-50, 40, 10): ## (50,50) not included
assert moc.contains_skycoords(SkyCoord(coordinate, coordinate, unit="deg"))
# regression for #180
MOC.from_zone(SkyCoord([(180, 30), (360, 50)], unit="deg"), max_depth=3)


def test_from_box():
Expand Down
Loading