from pywwt.jupyter import WWTJupyterWidget
from astropy.coordinates import SkyCoord, concatenate
from astropy import units as u
import requests
wwt = WWTJupyterWidget()
wwt
k2_json = requests.get('https://github.com/KeplerGO/K2FootprintFiles/raw/master/json/k2-footprint.json')
k2_dict = k2_json.json()
channels = k2_dict['c12']['channels']
#wwt.clear_annotations()
for index in channels:
ras = channels[str(index)]['corners_ra']
decs = channels[str(index)]['corners_dec']
corners = SkyCoord(ras, decs, unit=u.deg,)
wwt.add_polygon(corners, line_width=1.5*u.pixel, fill=True,
fill_color='silver', opacity=.1)
wwt.center_on_coordinates(corners[0], fov = 30 * u.deg)
wwt.crosshairs = False
wwt.background = 'Digitized Sky Survey (Color)'
#wwt.background = 'Tycho (Synthetic, Optical)' # for zoom
wwt.foreground = 'Planck Dust & Gas'
wwt.foreground_opacity = .5
k2_138 = SkyCoord('23:15:47.77','-10:50:58.91',unit=(u.hourangle,u.deg))
print(corners[0], k2_138)
#wwt.center_on_coordinates(k2_138, fov=60*u.deg, instant=False)
wwt.center_on_coordinates(k2_138, fov=1*u.deg, instant=False)
wwt.add_circle(k2_138, fill=False, radius = 10*u.arcsec)
#wwt.render('k2_138.png')