# moc.write('tess_{}.fits'.format(MAX_DEPTH), format='fits', overwrite=True) # moc.write('hst_{}.fits'.format(MAX_DEPTH), format='fits', overwrite=True) # Read from file moc = MOC.from_fits('tess_s0001_14.fits') moc = MOC.from_fits('tess_9.fits') moc.plot(title='TESS') plt.savefig('full_tess.png') # Plot the MOC using matplotlib fig = plt.figure(111, figsize=(10, 8)) # Define a astropy WCS easily with WCS(fig, fov=360 * 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, alpha=1, linewidth=1.5, fill=True, color="green") moc.border(ax=ax, wcs=wcs, alpha=0.5, color="black") major_ticks = np.arange(0, 101, 20) ax.set_xticks(major_ticks) ax.set_yticks(major_ticks) # plt.xlabel('RA') # plt.ylabel('Dec') # plt.title('Coverage of TESS Sector 1') plt.grid(color="black", linestyle="dotted") plt.savefig('temp_full.png')
lon = [20, -20, -20, 20] * u.deg lat = [20, 20, -20, -20] * u.deg depth = 7 ipix, depth, fully_covered = polygon_search(lon, lat, depth) from mocpy import MOC, WCS from astropy.coordinates import SkyCoord, Angle moc = MOC.from_healpix_cells(ipix, depth, fully_covered) # Plot the MOC using matplotlib import matplotlib.pyplot as plt fig = plt.figure(111, figsize=(10, 10)) # Define a astropy WCS easily with WCS(fig, fov=100 * u.deg, center=SkyCoord(0, 0, unit='deg', frame='icrs'), coordsys="icrs", rotation=Angle(0, u.degree), projection="AIT") as wcs: ax = fig.add_subplot(1, 1, 1, projection=wcs) # Call fill with a matplotlib axe and the `~astropy.wcs.WCS` wcs object. moc.fill(ax=ax, wcs=wcs, alpha=0.5, fill=True, color="green") # Draw the perimeter of the MOC in black moc.border(ax=ax, wcs=wcs, alpha=0.5, color="black") plt.xlabel('ra') plt.ylabel('dec') plt.title('Polygon search') plt.grid(color="black", linestyle="dotted") plt.show()
from matplotlib.path import Path from matplotlib.patches import PathPatch import astropy.units as u moc = MOC.from_fits('polygon_moc.fits') skycoords = moc.get_boundaries() # Plot the MOC using matplotlib import matplotlib.pyplot as plt fig = plt.figure(111, figsize=(10, 10)) # Define a astropy WCS easily with WCS(fig, fov=20 * u.deg, center=SkyCoord(10, 5, unit='deg', frame='icrs'), coordsys="icrs", rotation=Angle(0, u.degree), # The gnomonic projection transforms great circles into straight lines. projection="TAN") as wcs: ax = fig.add_subplot(1, 1, 1, projection=wcs) # Call fill with a matplotlib axe and the `~astropy.wcs.WCS` wcs object. moc.fill(ax=ax, wcs=wcs, alpha=0.5, fill=True, color="red", linewidth=1) moc.border(ax=ax, wcs=wcs, alpha=1, color="red") # Plot the border from astropy.wcs.utils import skycoord_to_pixel x, y = skycoord_to_pixel(skycoords[0], wcs) p = Path(np.vstack((x, y)).T) patch = PathPatch(p, color="black", fill=False, alpha=0.75, lw=2) ax.add_patch(patch)