For this run (Aug 29-Sep 3,2013) we are trying to finish the Odyssey and get a good chunk of the Illiad. So we will use catalogs already-generated for the previous hectospec and IMACS runs. Rough night plan (via Marla): Odyssey: 16:32:20. +19:49:36 (NGC 6181) Iliad: 22:51:38 -05:33:26 (NGC 7393) LOTR 02:21:00 -05:31:00 (NCG 895) Hand over @ 12:30am HALF NIGHTS 8-9:30pm odyssey 9:30-11pm iliad 1 11-12:30 iliad 2 WHOLE NIGHT 12:30-2am iliad3 2-3:30 LOTR1 3:30-5am LOTR2 (1hr exp, r = 19.5?) Odyssey 6 pointings Iliad 14 pointing LOTR 4 pointings (2 extra in case)

In [ ]:
# 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

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 [158]:
import wiyn
import mmthecto
import magellan
import targeting
import hosts

from astropy import coordinates as coords
from astropy import units as u
from astropy.io import ascii

In [267]:
reload(targeting)
reload(hosts)
reload(wiyn)
reload(mmthecto)
reload(magellan)


Out[267]:
<module 'magellan' from 'magellan.pyc'>

Odyssey


In [4]:
#collect all the SDSS objids of the targets that were *observed* based on Ben's *_cat files
fns = !ls mmthecto/configs_observed/NSA147100_*_cat
cats = [ascii.read(fn,names='idx,ra,dec,mag,fiber?,code,name'.split(',')) for fn in fns]
#now pick just pull in all the IDs
observedids = []
for i, cat in enumerate(cats):
    for nm in cat['name']:
        nm0 = nm.split('_')[0]
        if nm0 in ('sky', 'parked'):
            pass#observedids.append(-1)
        else:
            observedids.append(int(nm0))

In [5]:
fullcat = hosts.odyssey.get_sdss_catalog()


Could not find file "catalogs/Odysseus_sdss.dat" but did find "catalogs/NSA147100_sdss.dat" so using that.

In [23]:
#load the catalog of all the *targets* for hectospec and determine which are already observed
mmtcat = ascii.read('mmthecto/NSA147100.cat', data_start=2)  # remove the '---' lines
mmttargs = mmtcat[mmtcat['type'] == 'TARGET']
mmtids = np.array([-1 if nm.startswith('NSA') else int(nm.split('_')[0])  for nm in mmttargs['object']])
mmtidsobserved = np.array([False if id_ is '' else id_ in observedids for id_ in mmtids])

In [31]:
#There are more in `mmtidsobserved` than `observedids` because many of the observed things are sky/guide stars
print sum(mmtidsobserved) 
print len(observedids)
print len(np.unique(observedids))


3027
2644
2552

In [26]:
#mmttargs goes up to 22 but fullcat only goes to 21.5
np.max(fullcat['r']), np.max(mmttargs['mag'])


21.499994 22.0

In [30]:
#but there's an ID in fullcat for every mmt object with r<21.5, so this scheme is self-consistent
np.all([(i in fullcat['objID']) for i in mmtids[(mmttargs['mag']<21.5) & mmtidsobserved]])


Out[30]:
True

In [49]:
#get the USNO-B catalog
hosts.odyssey.usnob_environs_query(True)


File catalogs/Odysseus_usnob.dat exists - not downloading anything.

In [56]:
#so we use the *unobserved* mmt objects' rows from fullcat to build a new catalog
catmsk = np.in1d(fullcat['objID'], mmtids[~mmtidsobserved])
unobservedcat = fullcat[catmsk]
print 'Base catalog faintest r:', np.max(unobservedcat['r'])  # it cuts off at 21.5, *not* 22


Base catalog faintest r: 21.499872
617 objects
87 FOPS
Could not find file "catalogs/Odysseus_sdss.dat" but did find "catalogs/NSA147100_sdss.dat" so using that.
USNO/SDSS offsets: 0.0565559999472 0.151200000002
Constucting catalog in tst.out

In [296]:
#and use that catalog to output a WIYN-appropriate master catalog for The Odyssey
mastercat = 'hydra_targets/Odyssey2.cat'
#!rm $mastercat
wiyn.construct_master_catalog(hosts.odyssey, mastercat, unobservedcat, faintlimit=20)


980 objects
87 FOPS
Could not find file "catalogs/Odyssey_sdss.dat" but did find "catalogs/NSA147100_sdss.dat" so using that.
USNO/SDSS offsets: 0.0565559999472 0.151200000002
Constucting catalog in hydra_targets/Odyssey2.cat

In [298]:
#need to go through and identify the FOPS that are actually galaxies/dbl stars/etc.  Then the next cell removes them
wiyn.imagelist_from_master(mastercat, 'fop');

In [297]:
#identified by eye from above cell
invalidfops= ['USNO1099-0254783', 'USNO1094-0250228', 'USNO1094-0250370', 'USNO1101-0267099', 'USNO1098-0253607', 'USNO1102-0276584',
              'USNO1100-0256856', 'USNO1098-0253620', 'USNO1094-0250722', 'USNO1103-0282084', 'USNO1102-0276672', 'USNO1098-0253619', 
              'USNO1096-0252506', 'USNO1100-0256855','USNO1095-0252418', 'USNO1096-0252914', 'USNO1095-0252413', 'USNO1103-0281809',
              'USNO1099-0254637']
wiyn.clean_master_catalog(mastercat, invalidfops)

In [254]:
#this is iterated 3 times to generate new ast files that get sent to the department linux machines for running whydra
#note that for these the do_whydra parameters were relaxed because there's not much left in the core: 
#./do_whydra -R 1.5 -C 2.0 -c 9
wiyn.generate_ast_file(mastercat, 21,texp=1, faintmagcut=19.5, scpname='turtle')


Using existing catalogs ['hydra_targets/Odyssey2_1.hydra', 'hydra_targets/Odyssey2_2.hydra'] for removing from master
Writing to hydra_targets/Odyssey2_3.ast
SCP commands:
scp hydra_targets/Odyssey2_3.ast turtle:/home/ejt26/hydra_simulator/whydra
scp "turtle:/home/ejt26/hydra_simulator/whydra/Odyssey2_3.hydra" hydra_targets

In [258]:
#the remainder should have mostly fainter objects
wiyn.generate_ast_file(mastercat, 21,texp=1, faintmagcut=20, scpname='michigan')


Using existing catalogs ['hydra_targets/Odyssey2_1-bright.hydra', 'hydra_targets/Odyssey2_1.hydra', 'hydra_targets/Odyssey2_2-bright.hydra', 'hydra_targets/Odyssey2_2.hydra', 'hydra_targets/Odyssey2_3-bright.hydra', 'hydra_targets/Odyssey2_3.hydra', 'hydra_targets/Odyssey2_4.hydra', 'hydra_targets/Odyssey2_5.hydra', 'hydra_targets/Odyssey2_6.hydra'] for removing from master
Writing to hydra_targets/Odyssey2_10.ast
SCP commands:
scp hydra_targets/Odyssey2_10.ast michigan:/home/ejt26/hydra_simulator/whydra
scp "michigan:/home/ejt26/hydra_simulator/whydra/Odyssey2_10.hydra" hydra_targets

In [286]:
#look at the AST files and plot the targets to see why there's only 12 fibers in the last one
def plot_inner_ones(fn, circleoffsets=(0,0)):
    ast = ascii.read(fn ,data_start=8)
    ras = ast['col3']
    decs = ast['col4']
    ra = np.array([coords.Angle(rai, 'hr').degrees for rai in ras])
    dec = np.array([coords.Angle(deci, 'deg').degrees for deci in decs])
    cen = coords.ICRSCoordinates('16:32:20.952', '+19:49:35.15', unit=('hr','deg'))
    dra = (ra - cen.ra.degrees) * 60
    ddec = (dec - cen.dec.degrees) * 60
    
    scatter(dra, ddec)
    t = linspace(0,2*pi,100)
    plot(sin(t)*30+circleoffsets[0],cos(t)*30+circleoffsets[1], c='r')
    
    return sum(hypot(dra,ddec) < 60)
res1 = plot_inner_ones('hydra_targets/Odyssey2_1.ast')
title('Odyssey2_1.ast')
figure()
res2 = plot_inner_ones('hydra_targets/Odyssey2_6.ast')
title('Odyssey2_7.ast')
print res1, res2


941 964

Iliad


In [265]:
#download USNOB catalog if necessary
hosts.iliad.usnob_environs_query(True)


Downloading USNO-B to catalogs/Achilles_usnob.dat
Unknown Size
1144 kB downloaded

In [218]:
ilcat = hosts.iliad.get_sdss_catalog()

In [171]:
observedids = []
observedids.extend(magellan.get_smf_entries('imacs_targets/N7393_1.SMF', inclholes=False)[0])
observedids.extend(magellan.get_smf_entries('imacs_targets/N7393_2.SMF', inclholes=False)[0])
observedids = np.array(observedids, dtype=int)
#all are accounted for in the catalog
np.in1d(observedids,ilcat['objID']).all()


Out[171]:
True

In [173]:
ilobsmsk = np.in1d(ilcat['objID'], observedids)
ilunobscat = ilcat[~ilobsmsk]

In [260]:
#explore effects of fiber mag cuts
#this is for the one-degree field - want larger so there's some space later
targs = targeting.select_targets(hosts.iliad, faintlimit=20, outercutrad=-30) 

print len(targs)
#HYDRA-red has 2" fibers, so fiber2mag is the way to go
fibermagcut20 = targs['fiber2mag_r'] < 20
fibermagcut21 = targs['fiber2mag_r'] < 21
fibermagcut22 = targs['fiber2mag_r'] < 22
fibermagcut225 = targs['fiber2mag_r'] < 22.5
fibermagcut23 = targs['fiber2mag_r'] < 23
print fibermagcut20.sum(), fibermagcut21.sum(), fibermagcut22.sum(), fibermagcut225.sum(), fibermagcut23.sum()

figure(figsize=(10,6))
plt.scatter(ilcat['r'], ilcat['fiber2mag_r'], color='k',lw=0,s=2,alpha=.5)
plt.scatter(ilcat['r'][ilcat['phot_sg']=='STAR'], ilcat['fiber2mag_r'][ilcat['phot_sg']=='STAR'], color='r',lw=0,s=2,alpha=.5)
plt.scatter(targs['r'], targs['fiber2mag_r'], color='b',lw=0,s=3,alpha=1)
plt.axhline(20, color='g', lw=1)
plt.axhline(21, color='g', lw=1)
plt.axhline(22, color='g', lw=1)
plt.axhline(22.5, color='g', lw=1)
plt.axhline(23, color='g', lw=1)
plt.xlabel('$r$')
plt.ylabel('$r$ (2 arcsec fiber)')
plt.xlim(12,21.5)
plt.ylim(12,25);


850
122 523 802 818 834

In [300]:
#generate WIYN master catalog, and then based on the above plot, but on fiber2mag < 22.5
!rm hydra_targets/Iliad.cat 
wiyn.construct_master_catalog(hosts.iliad, targetcat=dict(faintlimit=20, outercutrad=-40), fibermaglimit=22.5)


Fiber mag cut removes 52 of 1498 objects
1446 objects
92 FOPS
USNO/SDSS offsets: -0.118259999988 0.268199999999
Constucting catalog in hydra_targets/Iliad.cat

In [302]:
wiyn.imagelist_from_master('hydra_targets/Iliad.cat', 'fop');

In [303]:
#identified by eye from above cell
invalidfops="""USNO0842-0645669              
USNO0848-0637474  
USNO0846-0642169  
USNO0847-0628459  
USNO0840-0646181  
USNO0848-0637640  
USNO0839-0663718  
USNO0845-0640286  
USNO0843-0651469  
USNO0844-0645131  
USNO0841-0655504  
USNO0841-0655559  
USNO0844-0644955  
USNO0848-0637546  
USNO0842-0646243  
USNO0844-0644868  
USNO0848-0637878  
USNO0849-0620415  
USNO0844-0644801  
USNO0847-0628943  
USNO0843-0652186  
USNO0844-0644757  
USNO0839-0663529  
USNO0840-0646113  

""".split()
wiyn.clean_master_catalog('hydra_targets/Iliad.cat', invalidfops)

In [361]:
#first a set of 4 bright masks
wiyn.generate_ast_file('hydra_targets/Iliad.cat', lst=23,texp=1, faintmagcut=19, finame='Iliad_%i-bright')


Using existing catalogs ['hydra_targets/Iliad_1-bright.hydra', 'hydra_targets/Iliad_2-bright.hydra', 'hydra_targets/Iliad_3-bright.hydra'] for removing from master
Writing to hydra_targets/Iliad_4-bright.ast
SCP commands:
scp hydra_targets/Iliad_4-bright.ast turtle:/home/ejt26/hydra_simulator/whydra
scp "turtle:/home/ejt26/hydra_simulator/whydra/Iliad_4-bright.hydra" hydra_targets

In [387]:
#now go fainter
#for the last 4, use more generous do_whydra:
#./do_whydra -R 1.5 -C 2.0 -c 9
wiyn.generate_ast_file('hydra_targets/Iliad.cat', lst=23,texp=1, faintmagcut=20, finame='Iliad_%i')


Using existing catalogs ['hydra_targets/Iliad_1-bright.hydra', 'hydra_targets/Iliad_10.hydra', 'hydra_targets/Iliad_11.hydra', 'hydra_targets/Iliad_12.hydra', 'hydra_targets/Iliad_13.hydra', 'hydra_targets/Iliad_2-bright.hydra', 'hydra_targets/Iliad_3-bright.hydra', 'hydra_targets/Iliad_4-bright.hydra', 'hydra_targets/Iliad_5.hydra', 'hydra_targets/Iliad_6.hydra', 'hydra_targets/Iliad_7.hydra', 'hydra_targets/Iliad_8.hydra', 'hydra_targets/Iliad_9.hydra'] for removing from master
Writing to hydra_targets/Iliad_14.ast
SCP commands:
scp hydra_targets/Iliad_14.ast turtle:/home/ejt26/hydra_simulator/whydra
scp "turtle:/home/ejt26/hydra_simulator/whydra/Iliad_14.hydra" hydra_targets

Lord of the Rings


In [324]:
#download usnob catalog if necessary
hosts.lotr.usnob_environs_query(True)


Downloading USNO-B to catalogs/LordoftheRings_usnob.dat
Unknown Size
843 kB downloaded

In [326]:
lotrcat = hosts.lotr.get_sdss_catalog()

In [360]:
#explore effects of fiber mag cuts
#this is for the one-degree field - want larger so there's some space later
targs = targeting.select_targets(hosts.lotr,faintlimit=20, outercutrad=-30, photflags=True,colorcuts=None)
targscc = targeting.select_targets(hosts.lotr,faintlimit=20, outercutrad=-30, photflags=True,colorcuts=targeting.bossanova_color_cuts)

print len(targs),len(targscc)

#HYDRA-red has 2" fibers, so fiber2mag is the way to go
fibermagcut20 = targscc['fiber2mag_r'] < 20
fibermagcut21 = targscc['fiber2mag_r'] < 21
fibermagcut22 = targscc['fiber2mag_r'] < 22
fibermagcut225 = targscc['fiber2mag_r'] < 22.5
fibermagcut23 = targscc['fiber2mag_r'] < 23
print fibermagcut20.sum(), fibermagcut21.sum(), fibermagcut22.sum(), fibermagcut225.sum(), fibermagcut23.sum()


figure(figsize=(10,6))
plt.scatter(lotrcat['r'][lotrcat['phot_sg']=='STAR'], lotrcat['fiber2mag_r'][lotrcat['phot_sg']=='STAR'], color='r',lw=0,s=2,alpha=.5)
plt.scatter(lotrcat['r'][lotrcat['phot_sg']=='GALAXY'], lotrcat['fiber2mag_r'][lotrcat['phot_sg']=='GALAXY'], color='k',lw=0,s=2,alpha=.5)
plt.scatter(targs['r'], targs['fiber2mag_r'], color='b',lw=0,s=3,alpha=1)
plt.scatter(targscc['r'], targscc['fiber2mag_r'], color='g',lw=0,s=3,alpha=1)
plt.axhline(20, color='g', lw=1)
plt.axhline(21, color='g', lw=1)
plt.axhline(22, color='g', lw=1)
plt.axhline(22.5, color='g', lw=1)
plt.axhline(23, color='g', lw=1)
plt.xlabel('$r$')
plt.ylabel('$r$ (2 arcsec fiber)')
plt.xlim(12,21.5)
plt.ylim(12,25);


1019 565
93 314 546 556 559

In [357]:
#weird ones with rfib ~ 19 and r>17.5 in targs but not targscc:
galmsk = targs['phot_sg'] == 'GALAXY'
magmsk = targs['r'] > 17.5
fmagmsk = targs['fiber2mag_r'] < 19
tmpcat = targs[galmsk&magmsk&fmagmsk]
targeting.sampled_imagelist(tmpcat['ra'],tmpcat['dec'],None);
#turns out they're a satellite track in only r-band

In [370]:
#make master catalog
#!rm hydra_targets/LordoftheRings.cat
wiyn.construct_master_catalog(hosts.lotr, 'hydra_targets/LOTR.cat', targetcat=dict(faintlimit=20.5, outercutrad=-40, colorcuts=targeting.bossanova_color_cuts), fibermaglimit=22.5)


Fiber mag cut removes 39 of 1946 objects
1907 objects
84 FOPS
USNO/SDSS offsets: -0.239219999995 0.0816299999995
Constucting catalog in hydra_targets/LordoftheRings.cat

In [378]:
wiyn.imagelist_from_master('hydra_targets/LOTR.cat', 'fop');

In [380]:
#identified by eye from above cell
invalidfops=""" 
USNO0845-0022221  
USNO0845-0022354  
USNO0840-0022140  
USNO0839-0022512  
USNO0844-0021768  
USNO0841-0022780  
USNO0845-0022087  
USNO0846-0021793  
USNO0845-0022261  
USNO0844-0022117  
USNO0842-0021983  
USNO0840-0022323  
USNO0842-0022135  
USNO0849-0021659  
USNO0843-0022470  
USNO0841-0022840  
USNO0844-0022100  
USNO0845-0022204  
USNO0845-0022624  
USNO0841-0022963  
USNO0844-0022473  
USNO0842-0021863  
USNO0849-0022026  

""".split()
wiyn.clean_master_catalog('hydra_targets/LOTR.cat', invalidfops)

In [394]:
#first a set of 2 bright masks
wiyn.generate_ast_file('hydra_targets/LOTR.cat', lst=0.5,texp=1, faintmagcut=19, finame='LOTR_%i-bright', scpname=None)


Using existing catalogs ['hydra_targets/LOTR_1-bright.hydra'] for removing from master
Writing to hydra_targets/LOTR_2-bright.ast

In [399]:
#now a few fainter ones
wiyn.generate_ast_file('hydra_targets/LOTR.cat', lst=0.5,texp=1, faintmagcut=20, finame='LOTR_%i', scpname=None)


Using existing catalogs ['hydra_targets/LOTR_1-bright.hydra', 'hydra_targets/LOTR_2-bright.hydra', 'hydra_targets/LOTR_3.hydra', 'hydra_targets/LOTR_4.hydra'] for removing from master
Writing to hydra_targets/LOTR_5.ast

In [404]:
#finally, make the cache
wiyn.generate_wiyn_cache('hydra_targets/aug13.cachelist')

In [ ]: