cds-astro / mocpy

Python library to easily create and manipulate MOCs (Multi-Order Coverage maps)
https://cds-astro.github.io/mocpy/
BSD 3-Clause "New" or "Revised" License
59 stars 33 forks source link

add from_zone and union in from_cones #169

Closed ManonMarchand closed 2 weeks ago

ManonMarchand commented 2 weeks ago

Fixes #165 (new feature from_zone + documentation zone versus box)

import matplotlib.pyplot as plt
from astropy import units as u
from astropy.coordinates import SkyCoord
from mocpy import MOC

moc = MOC.from_zone(
    SkyCoord([[-50, -50], [50, 50]], unit="deg"),
    max_depth=10,
)

fig = plt.figure()
wcs = moc.wcs(fig)  # automatically creates a wcs for the MOC
ax = fig.add_subplot(projection=wcs)
moc.fill(ax, wcs, color="teal", alpha=0.5)
ax.grid(True)

image

Fixes #164 (small_cones strategy is used in the new option of from_cones

import matplotlib.pyplot as plt
from astropy import units as u
from astropy.coordinates import SkyCoord
from mocpy import MOC

moc = MOC.from_cones(
    [10, 4, 2] * u.arcmin,
    [11, 3, 10] * u.arcmin,
    radius=2 * u.arcmin,
    max_depth=14,
    union_strategy="small_cones",
)

fig = plt.figure()
wcs = moc.wcs(fig)
ax = fig.add_subplot(projection=wcs)
moc.fill(ax, wcs, color="hotpink", alpha=0.5)

image