In [1]:
# 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 [2]:
import hosts
import targeting
import mmthecto

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table

In [3]:
%matplotlib inline
from matplotlib import pyplot as plt
from matplotlib import rcParams

rcParams['image.interpolation'] = 'none'
rcParams['figure.figsize'] = (16, 10)

Use catalogs already-generated by marla for clean-up on Gilgamesh and new observations of NSA33446/85746


In [4]:
n33446 = hosts.NSAHost(33446)
n33446.sdss_environs_query(True)
n33446incat = ascii.read('catalogs/mmt2015a_nsa33446.dat', format='basic', names='ra,dec,objID,r,fibermag_r,rank'.split(','))
len(n33446incat)


File catalogs/NSA33446_sdss.dat exists - not downloading anything.
Out[4]:
819

In [5]:
gilg = hosts.gilgamesh
gilgincat = ascii.read('catalogs/mmt2015a_nsa166313.dat', format='basic', names='ra,dec,objID,r,fibermag_r,rank'.split(','))
len(gilgincat)


Out[5]:
351

In [6]:
ody = hosts.odyssey
odyincat = ascii.read('catalogs/mmt2015a_nsa147100.dat', format='basic', names='ra,dec,objID,r,fibermag_r,rank'.split(','))
len(odyincat)


Out[6]:
283

In [7]:
n85746 = hosts.NSAHost(85746)
n85746.environsarcmin = 50
n85746.sdss_environs_query(True)
n85746incat = ascii.read('catalogs/mmt2015a_nsa85746.dat', format='basic', names='ra,dec,objID,r,fibermag_r,rank'.split(','))
len(n85746incat)


File catalogs/NSA85746_sdss.dat exists - not downloading anything.
Out[7]:
2233

In [8]:
for nm in 'gilg,ody,n33446,n85746'.split(','):
    print nm, SkyCoord(locals()[nm].coords).galactic


gilg <SkyCoord (Galactic): (l, b) in deg
    (26.25163171, 50.47278087)>
ody <SkyCoord (Galactic): (l, b) in deg
    (37.1668326, 39.20844638)>
n33446 <SkyCoord (Galactic): (l, b) in deg
    (185.14923474, 31.30602444)>
n85746 <SkyCoord (Galactic): (l, b) in deg
    (194.22246573, 52.3204934)>

Checks for Gilgamesh


In [9]:
plt.hist(gilgincat['fibermag_r'],bins=100)
None



In [10]:
msk = gilgincat['fibermag_r'] < 20
targeting.sampled_imagelist(gilgincat['ra'][msk],gilgincat['dec'][msk],None,
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in gilgincat[msk]])


Out[10]:
'name ra dec\nfm_r=19.55-rank=4 233.64039611 16.1446637\nfm_r=17.34-rank=3 234.00594371 17.09853327'

In [ ]:
msk = gilgincat['fibermag_r'] > 23
targeting.sampled_imagelist(gilgincat['ra'][msk],gilgincat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in gilgincat[msk]])

In [11]:
print np.sum((17<gilgincat['fibermag_r'])&(gilgincat['fibermag_r'] < 22.5)&(gilgincat['rank'] < 4))
print np.sum((17<gilgincat['fibermag_r'])&(gilgincat['fibermag_r'] < 23)&(gilgincat['rank'] < 4))


109
164

Catalog for Gilgamesh


In [39]:
#note the rank+1 - that's because *flux* stars should be rank 1, but the catalog starts at rank=1
gilgrank = gilgincat['rank']+1
gilgrank[gilgincat['fibermag_r'] > 23] = 6
mskgilg = (17<gilgincat['fibermag_r'])

In [38]:
targeting.sampled_imagelist(gilgincat['ra'][mskgilg],gilgincat['dec'][mskgilg], 
                            names=['rank={0}'.format(r) for r in gilgrank[mskgilg]])


Out[38]:
'name ra dec\nrank=6 234.40955062 17.25887361\nrank=6 234.28824501 17.27400126\nrank=6 234.29767634 16.87114371\nrank=6 234.52654658 17.08070454\nrank=6 234.64347405 16.87531092\nrank=6 234.48767497 16.29280719\nrank=6 233.58135674 16.98083693\nrank=6 234.43881315 17.23958248\nrank=6 233.96896999 16.88151922\nrank=6 234.38375592 16.49930013\nrank=6 234.07420217 15.97219865\nrank=6 234.50136652 17.21812208\nrank=6 234.46255056 15.98721718\nrank=6 234.46991416 17.07805236\nrank=6 234.27087676 16.76153968\nrank=6 234.72218357 17.03879287\nrank=6 234.29000823 17.26043752\nrank=6 234.28839602 16.73544345\nrank=6 234.46452474 17.09115691\nrank=6 234.14031771 16.47539986\nrank=6 234.43329453 17.25771909\nrank=6 233.7677316 16.85905633\nrank=6 234.32801377 16.25410254\nrank=6 234.37996456 17.16445859\nrank=6 234.62081088 16.40716092'

In [40]:
gilgoutcat = mmthecto.generate_catalog(gilg, gilgincat[mskgilg], gilgrank, 
                                       repeatflux=1, removefluxdistance=1*u.arcmin,
                                       fnout='mmthecto/{0}_feb2015.cat'.format(gilg.name),
                                       fluxfnout='mmthecto/{0}_feb2015.fluxstars'.format(gilg.name))


Including 351 targets
Found 220 Flux stars
Removing 19 Flux stars too close to program stars
Found 403 guide stars

Checks for NSA33446


In [14]:
plt.hist(n33446incat['fibermag_r'],bins=100)
None



In [ ]:
msk = n33446incat['fibermag_r'] < 18
targeting.sampled_imagelist(n33446incat['ra'][msk],n33446incat['dec'][msk],None,
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n33446incat[msk]])

In [ ]:
msk = n33446incat['fibermag_r'] > 23
targeting.sampled_imagelist(n33446incat['ra'][msk],n33446incat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n33446incat[msk]])

Catalog for NSA33446


In [15]:
msk33446 = (17<n33446incat['fibermag_r'])&(n33446incat['fibermag_r'] < 23)

In [16]:
targeting.sampled_imagelist(n33446incat['ra'][msk33446],n33446incat['dec'][msk33446], 
                            names=['rank={0}'.format(icat['rank']) for icat in n33446incat[msk33446]])


Out[16]:
'name ra dec\nrank=2 123.13008218 36.30440163\nrank=3 123.02241181 36.37523669\nrank=2 122.75180732 36.33997274\nrank=2 123.4252783 35.90993888\nrank=3 123.65406639 36.1008058\nrank=2 122.86976944 36.10222443\nrank=3 122.89964956 36.09249568\nrank=2 122.81960632 35.95706373\nrank=3 123.65884623 36.41563598\nrank=3 123.37310786 36.09746933\nrank=3 122.83395379 36.4675287\nrank=2 123.4775504 36.64620481\nrank=2 123.61999502 36.05888755\nrank=2 123.68469654 36.3290004\nrank=2 123.06865091 36.11939912\nrank=3 122.91807538 36.34551847\nrank=2 123.43318663 36.44395321\nrank=2 123.47087624 36.37839751\nrank=3 122.85056705 36.47227275\nrank=3 123.15121807 36.43396259\nrank=3 123.11548769 36.50591239\nrank=3 123.54621474 36.53329582\nrank=3 123.20034213 36.49011678\nrank=2 122.7103985 36.35297215\nrank=2 123.41980634 36.12805611'

In [17]:
#note the rank+1 - that's because *flux* stars should be rank 1, but the catalog starts at rank=1
n33446outcat = mmthecto.generate_catalog(n33446, n33446incat[msk33446], n33446incat['rank'][msk33446]+1,
                                         repeatflux=2, removefluxdistance=1*u.arcmin,
                                         fnout='mmthecto/{0}_feb2015.cat'.format(n33446.name),
                                         fluxfnout='mmthecto/{0}_feb2015.fluxstars'.format(n33446.name))


Including 791 targets
Found 145 Flux stars
Removing 7 Flux stars too close to program stars
Found 1241 guide stars

Checks for Odyssey


In [15]:
plt.hist(odyincat['fibermag_r'],bins=100)
print np.sum(odyincat['fibermag_r'] < 22.5), np.sum(odyincat['fibermag_r'] < 23)


210 247

In [19]:
plt.hist(odyincat['rank'],bins=100)
None



In [ ]:
msk = odyincat['rank'] < 3
targeting.sampled_imagelist(odyincat['ra'][msk],odyincat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in odyincat[msk]])

Catalog for Odyssey


In [30]:
#note the rank+1 - that's because *flux* stars should be rank 1, but the catalog starts at rank=1
odyrank = odyincat['rank']+1
odyrank[odyincat['fibermag_r'] > 23] = 6
mskody = (17<odyincat['fibermag_r'])

In [23]:
targeting.sampled_imagelist(odyincat['ra'][mskody],odyincat['dec'][mskody], 
                            names=['rank={0}'.format(r) for r in odyrank[mskody]])


Out[23]:
'name ra dec\nrank=6 247.95218562 19.39605527\nrank=6 248.43372349 19.39331344\nrank=6 248.68178347 19.79363164\nrank=6 248.12967087 19.65397523\nrank=6 248.55044406 19.63829079\nrank=6 248.11462078 19.81623549\nrank=6 248.08046693 19.78292921\nrank=6 248.13597534 19.88599774\nrank=6 247.59118126 19.47266258\nrank=6 248.11434751 19.83603494\nrank=6 248.43528091 19.47291366\nrank=6 248.36724532 20.22582622\nrank=6 248.38484461 19.57235799\nrank=6 247.57156183 19.56922669\nrank=6 248.36901766 20.09476918\nrank=6 248.36216151 20.27356401\nrank=6 247.95681285 20.42286142\nrank=6 248.37801426 19.59255874\nrank=6 248.53929383 19.53290478\nrank=6 247.69249978 19.95780741\nrank=6 247.75722619 19.29108004\nrank=6 247.89897014 19.30479661\nrank=6 247.75335777 19.61505766\nrank=6 248.08514715 19.75976016\nrank=6 247.44750544 19.86910194'

In [31]:
odyoutcat = mmthecto.generate_catalog(ody, odyincat[mskody], odyrank[mskody],
                                         repeatflux=2, removefluxdistance=1*u.arcmin,
                                         fnout='mmthecto/{0}_feb2015.cat'.format(ody.name),
                                         fluxfnout='mmthecto/{0}_feb2015.fluxstars'.format(ody.name))


Including 283 targets
Found 109 Flux stars
Removing 18 Flux stars too close to program stars
Found 172 guide stars

Checks for NSA85746


In [22]:
n85746catsc = SkyCoord(n85746incat['ra']*u.deg, n85746incat['dec']*u.deg)

plt.hist(n85746.coords.separation(n85746catsc).arcmin, bins=100,histtype='step')
plt.xlabel('distance from host [arcmin]')

plt.figure()
plt.scatter((n85746catsc.ra - n85746.coords.ra).to(u.rad)*n85746.dist.to(u.kpc), 
            (n85746catsc.dec - n85746.coords.dec).to(u.rad)*n85746.dist.to(u.kpc), 
            c=n85746incat['rank'])
plt.colorbar()
plt.xlabel(r'$\Delta \alpha$ [kpc]')
plt.ylabel(r'$\Delta \delta$ [kpc]')
None



In [23]:
plt.hist(n85746incat['fibermag_r'],bins=100)
None



In [ ]:
msk = n85746incat['fibermag_r'] < 18
targeting.sampled_imagelist(n85746incat['ra'][msk],n85746incat['dec'][msk],None,
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n85746incat[msk]])

In [ ]:
msk = (22.5 < n85746incat['fibermag_r']) & (n85746incat['fibermag_r'] < 23)
targeting.sampled_imagelist(n85746incat['ra'][msk],n85746incat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n85746incat[msk]])
None

In [ ]:
msk = n85746incat['fibermag_r'] > 23
targeting.sampled_imagelist(n85746incat['ra'][msk],n85746incat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n85746incat[msk]])
None

In [ ]:
msk = n85746incat['fibermag_r'] < 23
targeting.sampled_imagelist(n85746incat['ra'][msk],n85746incat['dec'][msk],None, 
                            names=['fm_r={0}-rank={1}'.format(icat['fibermag_r'],icat['rank']) for icat in n85746incat[msk]])
None

Catalog for NSA85746


In [24]:
#for 85746 we're trying to focus on low-SB galaxies
#note that rank=1 is unpopulated because that gets flux stars
marlarank = n85746incat['rank']  #2/3 w/i Rvir, 4 beyond
fm_r = n85746incat['fibermag_r']
n85746ranks = np.zeros_like(marlarank)
n85746ranks[(22<=fm_r)&(fm_r <= 23)] = 2
n85746ranks[fm_r < 22] = 4
n85746ranks[fm_r > 23] = 7
n85746ranks[marlarank==3] += 1
n85746ranks[marlarank==4] = 6

cnts = np.bincount(n85746ranks)
plt.bar(np.arange(len(cnts))-.4, cnts, .8)
plt.xlim(-.1,8.9)


Out[24]:
(-0.1, 8.9)

In [25]:
msk = n85746ranks ==2
targeting.sampled_imagelist(n85746incat['ra'][msk],n85746incat['dec'][msk], 
                            names=['rmag={0}_fm_r={1}'.format(cati['r'], cati['fibermag_r']) for cati in n85746incat[msk]])


Out[25]:
'name ra dec\nrmag=19.65_fm_r=22.93 149.40384232 32.68124501\nrmag=20.95_fm_r=22.11 149.89691595 32.7408798\nrmag=18.36_fm_r=22.25 149.70048147 32.08545544\nrmag=20.62_fm_r=22.4 149.03245682 32.2377849\nrmag=20.74_fm_r=22.68 149.29384585 32.99678623\nrmag=20.6_fm_r=22.13 149.71019637 32.6188984\nrmag=17.95_fm_r=22.38 149.84529922 31.77332309\nrmag=18.82_fm_r=22.54 149.7192081 32.08319324\nrmag=20.32_fm_r=22.78 149.65525066 32.37535926\nrmag=20.69_fm_r=22.28 149.68716887 32.72026546\nrmag=20.99_fm_r=22.39 149.26849679 32.02805002\nrmag=20.38_fm_r=22.69 149.44383906 32.01556355\nrmag=20.49_fm_r=22.21 148.95588437 32.59073428\nrmag=20.82_fm_r=22.32 149.85519526 31.9433211\nrmag=20.94_fm_r=22.56 149.70893555 32.59781307\nrmag=20.35_fm_r=22.02 149.33048492 32.74678652\nrmag=20.94_fm_r=22.49 149.94644487 31.91402779\nrmag=17.79_fm_r=22.83 149.00950851 32.38040037\nrmag=20.95_fm_r=22.28 149.93203864 32.70718488\nrmag=19.25_fm_r=22.75 149.02434046 32.22732084\nrmag=20.84_fm_r=22.8 149.00363265 32.73762131\nrmag=20.7_fm_r=22.04 148.94010252 32.36744388\nrmag=20.45_fm_r=22.51 150.12469698 32.56168699\nrmag=16.94_fm_r=22.32 149.05167014 32.23358381\nrmag=20.97_fm_r=22.4 149.01816227 32.0639234'

In [26]:
plt.scatter((n85746catsc.ra - n85746.coords.ra).to(u.rad)*n85746.dist.to(u.kpc), 
            (n85746catsc.dec - n85746.coords.dec).to(u.rad)*n85746.dist.to(u.kpc), 
            c=n85746ranks)
plt.colorbar()
plt.xlabel(r'$\Delta \alpha$ [kpc]')
plt.ylabel(r'$\Delta \delta$ [kpc]')
None



In [27]:
msk85746 = (17<n85746incat['fibermag_r'])&(n85746ranks < 6)

In [ ]:
targeting.sampled_imagelist(n85746incat['ra'][msk85746],n85746incat['dec'][msk85746], 
                            names=['rank={0}'.format(r) for r in n85746ranks[msk85746]])

In [28]:
n85746outcat = mmthecto.generate_catalog(n85746, n85746incat[msk85746], n85746ranks[msk85746],
                                         repeatflux=5, removefluxdistance=30*u.arcsec,
                                         fnout='mmthecto/{0}_feb2015.cat'.format(n85746.name),
                                         fluxfnout='mmthecto/{0}_feb2015.fluxstars'.format(n85746.name))


Including 1857 targets
Found 33 Flux stars
Removing 7 Flux stars too close to program stars
Found 186 guide stars

In [ ]: