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
60 stars 33 forks source link

Allow for empty path_vertices #129

Closed mcoughlin closed 5 months ago

mcoughlin commented 5 months ago

This PR fixes an error in case the MOC results in empty path_vertices_l (which happens in case of a MOC on the other side of the globe).

Also, the pre-commit did a number on this file.

mcoughlin commented 5 months ago

@ManonMarchand @fxpineau

ManonMarchand commented 5 months ago

This example is very old. There is now a function that allows to draw the border of the MOC directly:

from astropy.coordinates import Latitude, Longitude
import astropy.units as u
import matplotlib.pyplot as plt
lon = Longitude([5, -5, -5, 5], u.deg)
lat = Latitude([5, 5, -5, -5], u.deg)
moc = MOC.from_polygon(lon, lat)
fig = plt.figure(figsize=(10, 10))
wcs = moc.wcs(fig)
ax = fig.add_subplot(projection=wcs)
moc.border(ax, wcs, color='purple')
plt.show()

image

Do you think the example misled you? Should we remove it? Or were you looking for the details of the implementation of the border? In that case we should keep it.

mcoughlin commented 5 months ago

@ManonMarchand This issue comes up when the border is plotted: moc.border(ax=ax, wcs=ax.wcs, alpha=1, color="black") etc. in certain cases.

ManonMarchand commented 5 months ago

Ah got it! Sorry I was out of it. Don't know why but I thought we were in the example on borders that shows the implementation. I'll rebase and merge this, thanks.