Skip to content

Commit

Permalink
fix: moc from zone should accept lon_max = 360 deg
Browse files Browse the repository at this point in the history
  • Loading branch information
ManonMarchand committed Nov 8, 2024
1 parent a76f409 commit 3eebca2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
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
2 changes: 2 additions & 0 deletions python/mocpy/tests/test_moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ def test_from_zone():
# test the diagonal
for coordinate in range(-50, 60, 10):
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

0 comments on commit 3eebca2

Please sign in to comment.