Skip to content

Commit 0f91068

Browse files
fix: moc from zone should accept lon_max = 360 deg (#182)
* fix: moc from zone should accept lon_max = 360 deg * fix: upper right corner is not expected in the MOC
1 parent a76f409 commit 0f91068

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
## [unreleased]
1818

19+
### Fixed
20+
21+
* in space MOCs: upper right corner of a zone can now have a longitude of 360° [#180]
22+
1923
## [0.17.0]
2024

2125
### Added

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ bench = true
2828
crate-type = ["cdylib"]
2929

3030
[dependencies]
31-
moc = { version = "0.17", features = ["storage"] }
32-
#moc = { git = 'https://github.com/cds-astro/cds-moc-rust', rev = '361eb278fe782bfc053433495c33e3f16e20cdbd', features = ["storage"] }
31+
#moc = { version = "0.17", features = ["storage"] }
32+
moc = { git = 'https://github.com/cds-astro/cds-moc-rust', rev = 'f252c2ea3f66cef60e501c2beca2977c439236f8', features = ["storage"] }
3333
healpix = { package = "cdshealpix", version = "0.7" }
3434
# healpix = { package = "cdshealpix", git = 'https://github.com/cds-astro/cds-healpix-rust', branch = 'master' }
3535
rayon = "1.10"

python/mocpy/moc/moc.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,10 @@ def from_zone(cls, coordinates, max_depth):
14831483
"""
14841484
Create a MOC from a zone.
14851485
1486-
The zone is defined by a range of longitudes and latitudes. Its sides follow great
1487-
circles in longitudes and small circles for latitudes.
1486+
The zone is defined by a range of longitudes and latitudes. Its sides follow
1487+
great circles in longitudes and small circles for latitudes.
1488+
The bottom and left sides are included in the MOC, while the top and right sides
1489+
are not.
14881490
14891491
Parameters
14901492
----------
@@ -1508,10 +1510,16 @@ def from_zone(cls, coordinates, max_depth):
15081510
... max_depth=5
15091511
... )
15101512
"""
1513+
# workaround astropy.SkyCoord that wraps longitudes between [0:360[
1514+
# where we want ]0:360] for lon_max. There is no issue for lon_min that is
1515+
# expected in [0:360[.
1516+
lon_max = coordinates[1].icrs.ra.deg
1517+
if lon_max == 0:
1518+
lon_max = 360
15111519
index = mocpy.from_zone(
15121520
coordinates[0].icrs.ra.deg,
15131521
coordinates[0].icrs.dec.deg,
1514-
coordinates[1].icrs.ra.deg,
1522+
lon_max,
15151523
coordinates[1].icrs.dec.deg,
15161524
np.uint8(max_depth),
15171525
)

python/mocpy/tests/test_moc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,10 @@ def test_from_ring():
600600
def test_from_zone():
601601
moc = MOC.from_zone(SkyCoord([[-50, -50], [50, 50]], unit="deg"), max_depth=5)
602602
# test the diagonal
603-
for coordinate in range(-50, 60, 10):
603+
for coordinate in range(-50, 40, 10): ## (50,50) not included
604604
assert moc.contains_skycoords(SkyCoord(coordinate, coordinate, unit="deg"))
605+
# regression for #180
606+
MOC.from_zone(SkyCoord([(180, 30), (360, 50)], unit="deg"), max_depth=3)
605607

606608

607609
def test_from_box():

0 commit comments

Comments
 (0)