Example #1
0
def main():
    wantPlot = True
    zoom = False

    ra_deg = 98.15766666666666
    dec_deg = 21.594944444444444
    scRoll_deg = 157.6053108

    fovRoll_deg = fov.getFovAngleFromSpacecraftRoll(scRoll_deg)
    k = fov.KeplerFov(ra_deg, dec_deg, fovRoll_deg)

    #Position of example star, WASP-67
    ra_deg, dec_deg = 103.67845833333334, 24.245555555555555


    #Get coordinates of channel corners.
    raDec = k.getCoordsOfChannelCorners()

    #Is a given ra/dec on silicon?
    try:
        ch = k.pickAChannel(ra_deg, dec_deg)
        print "Star is on channel %i Mod-out %s" %(ch, fov.modOutFromChannel(ch))
    except ValueError:
        print "Star is not on silicon"
        print "Caution: Stars within 5 pix of channel edges are not found by this algorithm"


    ch, col, row = k.getChannelColRow(ra_deg, dec_deg)
    print "Star is on channel %i Col %.1f Row %.1f" %(ch, col, row)


    if wantPlot:
        mp.clf()
        #ph is a projection class, in this case HammerAitoff. Pass this
        #class to all FOV plotting commands so it knows how to do the
        #plotting. ph also implements matplotlib's plot, scatter and text
        #commands
        #ph = proj.HammerAitoff(0,0)
        ph = proj.Cylindrical()
        ph.plotGrid()

        k.plotPointing(ph)

        #scenery.plotEcliptic(ph)
        plotWithLabel(ph, ra_deg, dec_deg, "HD 50554")

        if zoom:
            mp.axis([.88, 1.36, -0.60, -0.20])
            k.plotChIds(ph, modout=True)
        mp.show()
Example #2
0
def main():
    wantPlot = True
    zoom = False

    ra_deg = 98.15766666666666
    dec_deg = 21.594944444444444
    scRoll_deg = 157.6053108

    fovRoll_deg = fov.getFovAngleFromSpacecraftRoll(scRoll_deg)
    k = fov.KeplerFov(ra_deg, dec_deg, fovRoll_deg)

    #Position of example star, WASP-67
    ra_deg, dec_deg = 103.67845833333334, 24.245555555555555

    #Get coordinates of channel corners.
    raDec = k.getCoordsOfChannelCorners()

    #Is a given ra/dec on silicon?
    try:
        ch = k.pickAChannel(ra_deg, dec_deg)
        print "Star is on channel %i Mod-out %s" % (ch,
                                                    fov.modOutFromChannel(ch))
    except ValueError:
        print "Star is not on silicon"
        print "Caution: Stars within 5 pix of channel edges are not found by this algorithm"

    ch, col, row = k.getChannelColRow(ra_deg, dec_deg)
    print "Star is on channel %i Col %.1f Row %.1f" % (ch, col, row)

    if wantPlot:
        mp.clf()
        #ph is a projection class, in this case HammerAitoff. Pass this
        #class to all FOV plotting commands so it knows how to do the
        #plotting. ph also implements matplotlib's plot, scatter and text
        #commands
        #ph = proj.HammerAitoff(0,0)
        ph = proj.Cylindrical()
        ph.plotGrid()

        k.plotPointing(ph)

        #scenery.plotEcliptic(ph)
        plotWithLabel(ph, ra_deg, dec_deg, "HD 50554")

        if zoom:
            mp.axis([.88, 1.36, -0.60, -0.20])
            k.plotChIds(ph, modout=True)
        mp.show()
Example #3
0
def K2onSilicon(infile,fieldnum,epicfile):
    ra_sources_deg, dec_sources_deg, mag = parse_file(infile)

    if np.shape(ra_sources_deg)[0] > 500:
        print('There are {} sources in your target list, this could take some time'.format(np.shape(ra_sources_deg)[0]))

    ra_deg, dec_deg, scRoll_deg = getRaDecRollFromFieldnum(fieldnum)

    ## convert from SC roll to FOV coordinates
    ## do not use the fovRoll coords anywhere else
    ## they are internal to this script only
    fovRoll_deg = fov.getFovAngleFromSpacecraftRoll(scRoll_deg)

    ## initialize class
    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)
    
    #hack by DH to overplot EPIC catalog
    ra=np.zeros(100000)
    dec=np.zeros(100000)
    f = open(epicfile, 'r')
    n=0
    n2=0
    
    # only take every 100th EPIC source to speed things up
    for line in f:
        if (n % 100 != 0):
            n=n+1
            continue
    		
        line = line.strip()
        columns = line.split("|")
        ra[n2]=columns[9]
        dec[n2]=columns[10]
        n=n+1
        n2=n2+1

    use=np.where(ra > 0)[0]
    print(n)
    print(np.size(use))
    ra=ra[use]
    dec=dec[use]
	
    
    
    if got_mpl:
        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)
        
        #hack by DH to overplot EPIC catalog
        ax.scatter(ra,dec,s=1)
        
        ax.scatter(*targets,s=2,label='not on silicon')
        ax.scatter(targets[0][nearSilicon],
            targets[1][nearSilicon],color='#fc8d62',s=8,label='near 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)
        fig.savefig('targets_fov.png',dpi=300)
        plt.close('all')

    siliconFlag = np.zeros_like(ra_sources_deg)
    siliconFlag = np.where(nearSilicon,1,siliconFlag)
    siliconFlag = np.where(onSilicon,2,siliconFlag)

    outarr = np.array([ra_sources_deg, dec_sources_deg, mag, siliconFlag])
    np.savetxt('targets_siliconFlag.csv', outarr.T, delimiter=', ',
        fmt=['%10.10f','%10.10f','%10.2f','%i'])

    if got_mpl:
        print('I made two files: targets_siliconFlag.csv and targets_fov.png')
    else:
        print('I made one file: targets_siliconFlag.csv')
Example #4
0
def K2onSilicon(infile, fieldnum, epicfile):
    ra_sources_deg, dec_sources_deg, mag = parse_file(infile)

    if np.shape(ra_sources_deg)[0] > 500:
        print(
            'There are {} sources in your target list, this could take some time'
            .format(np.shape(ra_sources_deg)[0]))

    ra_deg, dec_deg, scRoll_deg = getRaDecRollFromFieldnum(fieldnum)

    ## convert from SC roll to FOV coordinates
    ## do not use the fovRoll coords anywhere else
    ## they are internal to this script only
    fovRoll_deg = fov.getFovAngleFromSpacecraftRoll(scRoll_deg)

    ## initialize class
    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)

    #hack by DH to overplot EPIC catalog
    ra = np.zeros(100000)
    dec = np.zeros(100000)
    f = open(epicfile, 'r')
    n = 0
    n2 = 0

    # only take every 100th EPIC source to speed things up
    for line in f:
        if (n % 100 != 0):
            n = n + 1
            continue

        line = line.strip()
        columns = line.split("|")
        ra[n2] = columns[9]
        dec[n2] = columns[10]
        n = n + 1
        n2 = n2 + 1

    use = np.where(ra > 0)[0]
    print(n)
    print(np.size(use))
    ra = ra[use]
    dec = dec[use]

    if got_mpl:
        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)

        #hack by DH to overplot EPIC catalog
        ax.scatter(ra, dec, s=1)

        ax.scatter(*targets, s=2, label='not on silicon')
        ax.scatter(targets[0][nearSilicon],
                   targets[1][nearSilicon],
                   color='#fc8d62',
                   s=8,
                   label='near 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)
        fig.savefig('targets_fov.png', dpi=300)
        plt.close('all')

    siliconFlag = np.zeros_like(ra_sources_deg)
    siliconFlag = np.where(nearSilicon, 1, siliconFlag)
    siliconFlag = np.where(onSilicon, 2, siliconFlag)

    outarr = np.array([ra_sources_deg, dec_sources_deg, mag, siliconFlag])
    np.savetxt('targets_siliconFlag.csv',
               outarr.T,
               delimiter=', ',
               fmt=['%10.10f', '%10.10f', '%10.2f', '%i'])

    if got_mpl:
        print('I made two files: targets_siliconFlag.csv and targets_fov.png')
    else:
        print('I made one file: targets_siliconFlag.csv')