In [8]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
import numpy as np
if 'saga_base_dir' not in locals():
saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
os.chdir(saga_base_dir)
In [9]:
%matplotlib inline
from matplotlib import pyplot as plt
from matplotlib import rcParams
rcParams['figure.figsize'] = (16, 10)
rcParams['image.interpolation'] = 'none'
rcParams['image.origin'] = 'lower'
In [53]:
from __future__ import print_function, division
from astropy import units as u
from astropy import table
from astropy.coordinates import *
import targeting
In [15]:
t = table.Table.read('allgoodspec_apr26_15.fits.gz')
smsk = (t['SATS']==1)&(t['REMOVE']==-1)
tsats = t[smsk]
tsats.colnames
Out[15]:
In [30]:
def get_sats_and_names(hostdct, tsats):
msk = np.array([hn in (hostdct.keys()) for hn in tsats['HOST_NSAID']])
nms = []
cntd = dict([(hn, 0) for hn in hostdct])
for hn in tsats['HOST_NSAID'][msk]:
cntd[hn] += 1
nms.append(hostdct[hn] + str(cntd[hn]))
return msk, np.array(nms)
In [31]:
evehost = {33446:'StarTrek',85746:'MobyDick',140594:'Alice', 165536:'Dune'}
evesats, evenms = get_sats_and_names(evehost, tsats)
evesc = SkyCoord(tsats['ra'][evesats], tsats['dec'][evesats], unit=u.deg)
In [32]:
mornhost = {61945:'AnaK',147100:'odyssey'}
mornsats, mornnms = get_sats_and_names(mornhost, tsats)
mornsc = SkyCoord(tsats['ra'][mornsats], tsats['dec'][mornsats], unit=u.deg)
In [33]:
targeting.sampled_imagelist(mornsc, None, names=mornnms)
Out[33]:
In [34]:
targeting.sampled_imagelist(evesc, None, names=evenms)
Out[34]:
In [85]:
#197+17.1 07 29 09.40 +20 54 45.90 2000.0
def make_starlist(fnout, tab, names):
with open(fnout, 'w') as f:
for e, nm in zip(tab, names):
spaces = 16 - len(nm)
if spaces >= 0:
f.write(nm)
f.write(' '*(spaces+1))
else:
f.write(nm[:16])
f.write(SkyCoord(e['ra'], e['dec'], unit=u.deg).to_string('hmsdms', sep=' '))
f.write(' 2000.0')
f.write('\n')
In [86]:
make_starlist('/Users/erik/Desktop/evestarlist', tsats[evesats], evenms)
make_starlist('/Users/erik/Desktop/mornstarlist', tsats[mornsats], mornnms)
In [46]:
!cat /Users/erik/Desktop/evestarlist
In [47]:
!cat /Users/erik/Desktop/mornstarlist
In [76]:
def offset_info(fromsc, tosc, starlistname=False):
dra = (tosc.ra-fromsc.ra)*np.cos((tosc.dec + fromsc.dec)/2)
ddec = tosc.dec-fromsc.dec
eorw = 'E' if dra>0 else 'W'
nors = 'N' if ddec>0 else 'S'
if starlistname:
return '{0:16} {1} 2000.0 raoffset={2} decoffset={3}'.format(starlistname[:16], fromsc.to_string('hmsdms', sep=' '), dra.arcsec, ddec.arcsec)
else:
return '{0} {1} {2} {3}'.format(dra.arcsec, eorw, ddec.arcsec, nors)
In [77]:
#Target: #Alice1
star = SkyCoord(180.25811*u.deg, -1.33095*u.deg)
targ = SkyCoord(180.29501*u.deg, -1.29751*u.deg)
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',30.98)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'Alice1_star'))
In [81]:
#Target: #Dune1
star = SkyCoord(221.41462*u.deg, -0.16425*u.deg)
targ = SkyCoord(221.31587*u.deg, -0.15953*u.deg)
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',140.2)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'Dune1_star'))
In [80]:
#Target: #ST1
star = SkyCoord(123.63623*u.deg, 36.44702*u.deg)
targ = SkyCoord(123.64988*u.deg, 36.43433*u.deg)
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',122.7)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'StarTrek1_star'))
In [82]:
#Target: #ST2
star = SkyCoord(123.19385*u.deg, 36.19421*u.deg)
targ = SkyCoord(123.24365*u.deg, 36.19831*u.deg)
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',79.8)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'StarTrek2_star'))
In [83]:
#Target: MobyDick1
star = SkyCoord(149.71499*u.deg, 32.73056*u.deg)
targ = SkyCoord(149.68717*u.deg, 32.72027*u.deg)
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',134.8)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'MobyDick1_star'))
In [93]:
#Target: odyssey4
star = SkyCoord(248.17742*u.deg, 19.81614*u.deg)
targ = SkyCoord(248.15208*u.deg, 19.81026*u.deg)
pa = 154.0
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',pa)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'odyssey4_star'))
In [94]:
#Target: AnaK1
star = SkyCoord(354.31458*u.deg, 0.37003*u.deg)
targ = SkyCoord(354.35063*u.deg, 0.39077*u.deg)
pa = 140.7
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',pa)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'AnaK1_star'))
In [95]:
#Target: AnaK2
star = SkyCoord(354.15222*u.deg, 0.65171*u.deg)
targ = SkyCoord(354.19530*u.deg, 0.62340*u.deg)
pa = 129.3
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',pa)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'AnaK2_star'))
In [96]:
#Target: Odyssey8
star = SkyCoord(248.56304*u.deg, 19.73387*u.deg)
targ = SkyCoord(248.58080*u.deg, 19.72003*u.deg)
pa = 122.1
print('Target:', targ)
#print('PA12:', t1.position_angle(t2).deg, 'or', t1.position_angle(t2).deg-360)
#print('PA21:', t2.position_angle(t1).deg, 'or', t2.position_angle(t1).deg-360)
print('PA =',pa)
print('Offsets:', offset_info(star, targ))
print('SLentry:', offset_info(star, targ, 'odyssey8_star'))