In the K2 Mission the Kepler Spacecraft observes different fields along the ecliptic. The "selected", "wanted", and "proposed" K2 fields are shown in the below figure.
Campaign 5 will start on 2015.04.27 and last until 2015.07.13 and will a section of the sky between RAs of 120 - 140 degrees, and declinations between 9 and 24 degrees.
In [1]:
import K2fov
import hipparchos2io as hip2
from hipparchos2io.hip2 import reader as hipreader
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
In [5]:
#http://matplotlib.org/users/customizing.html
font = {'family' : 'Helvetica',
'weight' : 'bold',
'size' : 12.}
plt.rc('font', **font) # pass in the font dict as kwargs
axes = {'labelsize' : 12.,
'linewidth' : 2.,
'labelweight' : 'bold'}
plt.rc('axes', **axes) # pass in the font dict as kwargs
plt.rc('text', usetex=False)
In [7]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
%reload_ext autoreload
In [8]:
myfigsize = (12.0, 8.0)
myfontsize = 10.
plt.rcParams['figure.figsize'] = myfigsize
In [9]:
#determine the hip library directory:
hip2dir = '/'.join(hip2.__file__.split('/')[:-1])+'/'
In [10]:
#read in all the hipparcos data to a list of star objects:
stars = hipreader.get_stars_list(hip2dir+'hip2_data/hip2.dat')
In [11]:
#now cycle through the hip data, adding it to the DataFrame
stararr = [{'hipid': star.hipparcos_id,
'ra': star.ra_radians,
'dec': star.dec_radians,
'plx': star.parallax_mas,
'pmra': star.proper_motion_ra_mas_per_year,
'pmdec': star.proper_motion_dec_mas_per_year,
'era': star.ra_error_mas,
'edec': star.dec_error_mas,
'eplx': star.parallax_error_mas,
'epmra': star.proper_motion_ra_error_mas_per_year,
'epmdec': star.proper_motion_dec_error_mas_per_year,
'mag': star.magnitude,
'emag': star.magnitude_error,
'bv': star.color_index,
'ebv': star.color_index_error,
'vi': star.VI_color_index} for star in stars]
In [12]:
#create a pandas DataFrame for the hip data:
hip_df = pd.DataFrame(stararr)
In [13]:
hip_df.head(3)
Out[13]:
In [14]:
hip_df['absmag'] = hip_df['mag'] - 5. * np.log10(100./hip_df['plx'])
In [15]:
len(hip_df)
Out[15]:
In [16]:
hip_close = hip_df[((hip_df['plx'] >= 10) & (hip_df['bv'] != 0))]
In [17]:
len(hip_close)
Out[17]:
In [19]:
plt.plot(hip_close['bv'], hip_close['absmag'], '.')
plt.xlabel('B-V')
plt.ylabel('$M_{V}$')
plt.ylim([20, -5])
Out[19]:
A few requirements on our target selection:
In [21]:
#convert the ras to radians
ralorad = 120 / 180. * np.pi
rahirad = 140 / 180. * np.pi
dechirad = 20 / 180. * np.pi
declorad = 9 / 180. * np.pi
hip_camp = hip_close[((hip_close['mag'] < 8.) &
(hip_close['ra'] > ralorad) &
(hip_close['ra'] < rahirad) &
(hip_close['dec'] < dechirad) &
(hip_close['dec'] > declorad) &
(hip_close['bv'] > 0.63) &
(hip_close['absmag'] > 1.1))].copy()
len(hip_camp)
Out[21]:
In [23]:
plt.plot(hip_close['bv'], hip_close['absmag'], '.', color='#46959E')
plt.plot(hip_camp['bv'], hip_camp['absmag'], 'o', color='#BA4C37')
plt.xlabel('B-V')
plt.ylabel('$M_{V}$')
plt.ylim([20, -5])
Out[23]:
In [24]:
hip_camp
Out[24]:
In [25]:
hip_camp['radeg'] = hip_camp['ra'] * 180. / np.pi
hip_camp['decdeg'] = hip_camp['dec'] * 180. / np.pi
In [26]:
hip_camp[['radeg', 'decdeg', 'mag']]
Out[26]:
In [134]:
#Method 1
fname = 'targsToCheck.csv'
hip_camp.to_csv(fname, columns = ['radeg', 'decdeg', 'mag'], index=False, header=False)
fieldnum = 5
K2fov.K2onSilicon(fname,fieldnum)
In [29]:
#Method 2
fieldnum = 5
ra_sources_deg, dec_sources_deg, mag = (hip_camp['radeg'].values,
hip_camp['decdeg'].values,
hip_camp['mag'].values)
from K2fov.K2onSilicon import getRaDecRollFromFieldnum
from K2fov.K2onSilicon import onSiliconCheck
from K2fov.K2onSilicon import nearSiliconCheck
import K2fov.fov as fov
import K2fov.projection as proj
ra_deg, dec_deg, scRoll_deg = getRaDecRollFromFieldnum(fieldnum)
fovRoll_deg = fov.getFovAngleFromSpacecraftRoll(scRoll_deg)
k = fov.KeplerFov(ra_deg, dec_deg, fovRoll_deg)
raDec = k.getCoordsOfChannelCorners()
onSilicon = map(onSiliconCheck,
ra_sources_deg,dec_sources_deg,np.repeat(k,len(ra_sources_deg)))
nearSilicon = map(nearSiliconCheck,
ra_sources_deg,dec_sources_deg,np.repeat(k,len(ra_sources_deg)))
onSilicon = np.array(onSilicon,dtype=bool)
nearSilicon = np.array(nearSilicon, dtype=bool)
#the plotting bit:
almost_black = '#262626'
light_grey = np.array([float(248)/float(255)]*3)
#ph = proj.Gnomic(ra_deg, dec_deg)
ph = proj.PlateCaree()
k.plotPointing(ph,showOuts=False,plot_degrees=False)
targets = ph.skyToPix(ra_sources_deg, dec_sources_deg)
targets = np.array(targets ) #* 180 / np.pi
fig = plt.gcf()
ax = fig.gca()
ax = fig.add_subplot(111)
#ax.scatter(*targets,s=2,label='not on silicon')
ax.scatter(*targets,color='#fc8d62',s=7,label='not on silicon')
ax.scatter(targets[0][onSilicon],
targets[1][onSilicon],color='#66c2a5',s=8,label='on silicon')
ax.set_xlabel('R.A. [degrees]',fontsize=16)
ax.set_ylabel('Declination [degrees]',fontsize=16)
ax.invert_xaxis()
ax.minorticks_on()
legend = ax.legend(loc=0,
frameon=True, scatterpoints=1)
rect = legend.get_frame()
rect.set_alpha(0.3)
rect.set_facecolor(light_grey)
rect.set_linewidth(0.0)
texts = legend.texts
for t in texts:
t.set_color(almost_black)
siliconFlag = np.zeros_like(ra_sources_deg)
#prints zero if target is not on silicon
siliconFlag = np.where(nearSilicon,0,siliconFlag)
#prints a 2 if target is on silicon
siliconFlag = np.where(onSilicon,2,siliconFlag)
hip_camp['onSilicon'] = siliconFlag
hip_camp_good = hip_camp[hip_camp['onSilicon'] == 2]
hip_camp_good[['hipid', 'radeg', 'decdeg', 'bv', 'mag', 'absmag', 'onSilicon']]
Out[29]:
In [ ]: