Creating a MOC from a set of coordinates
In [1]:
%matplotlib inline
In [2]:
import warnings
warnings.filterwarnings('ignore')
from mocpy import MOC
from astropy import units as u
from astropy.coordinates import SkyCoord, Angle
Let's load a VizieR catalog
In [3]:
from astroquery.vizier import Vizier
viz = Vizier(columns=['*', '_RAJ2000', '_DEJ2000'])
viz.ROW_LIMIT = -1
table = viz.get_catalogs('I/293/npm2cros')[0]
print(table)
Let's create a MOC from the coordinates of this table
In [4]:
moc = MOC.from_lonlat(table['_RAJ2000'].T * u.deg, table['_DEJ2000'].T * u.deg, 6)
# A function creating all the matplotlib context for plotting a MOC with its perimeter
def plot(moc, title=''):
from matplotlib import path, patches
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(15, 10))
from mocpy import WCS
with WCS(fig,
fov=330 * u.deg,
center=SkyCoord(0, 0, unit='deg', frame='galactic'),
coordsys='galactic',
rotation=Angle(0, u.degree),
projection="AIT") as wcs:
ax = fig.add_subplot(1, 1, 1, projection=wcs)
moc.fill(ax=ax, wcs=wcs, edgecolor='r', facecolor='r', linewidth=1.0, fill=True, alpha=0.5)
moc.border(ax=ax, wcs=wcs, color="black", alpha=0.5)
plt.xlabel('ra')
plt.ylabel('dec')
if title:
plt.title(title)
plt.grid(color="black", linestyle="dotted")
plt.show()
plt.close()
plot(moc=moc, title='I/293/npm2cros')
In [ ]:
In [ ]: