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
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 [2]:
%matplotlib inline
from matplotlib import pyplot as plt
from matplotlib import rcParams
from matplotlib import style

In [3]:
from __future__ import division, print_function

import os
import numpy as np

from astropy import units as u
from astropy import constants as cnst
from astropy.coordinates import SkyCoord, Distance
from astropy.wcs import WCS
from astropy.io import fits, ascii
from astropy.table import Table

In [58]:
# changes values into steps that can be passed into plt.plot
def vals_to_steps(vals, lower, upper, reverse=False):
    svals = np.sort(vals)[::-1] if reverse else np.sort(vals)
    vsr = np.repeat(svals, 2)
    ns = np.repeat(np.arange(len(vals) + 1), 2)[1:-1]
    vsr = np.insert(vsr, 0, lower if reverse else upper)
    vsr = np.append(vsr, upper if reverse else lower)
    ns = np.insert(ns, [0, -1], [0, ns[-1]])
    return vsr, ns

LG


In [4]:
#special import magic w/ cding
pwd = os.path.abspath(os.curdir)
os.chdir(os.environ['HOME']+'/astrodata/mcconn12_nearbydwarfs/')
import nearbygals
ngtab = nearbygals.get_table()
os.chdir(pwd)

In [5]:
ng_MV = ngtab['Vmag'] - ngtab['distmod']#-3.1*ngtab['EBmV']

#fix LMC/SMC manually
#ng_MV[ngtab['name']=='LMC'] =  
#ng_MV[ngtab['name']=='LMC'] = 

#MV -> Mr: assuming "typcial" B-V=1 and Jester for Stars with Rc-Ic < 1.15 and U-B < 0
BmV = 1
ng_Mr = ng_MV - 0.46*(BmV) + 0.11

Mr_MW_sats = ng_Mr[(20 < ngtab['distance'])&(ngtab['distance'] < 300)]

Anddist = ngtab[ngtab['and_number']==0]['center'][0].separation_3d(SkyCoord(ra=[row.ra for row in ngtab['center']], 
         dec=[row.dec for row in ngtab['center']], 
         distance=[row.distance for row in ngtab['center']]))
Mr_And_sats = ng_Mr[Anddist < 300*u.kpc][1:]  #First one is actually M31

Full data set


In [65]:
allspec = Table.read(os.environ['HOME']+'/Dropbox/SAGA/data/allspectaken_v4.fits')
allsats = allspec[(allspec['SATS']==1)&(allspec['REMOVE']==-1)]
allsats


Out[65]:
<Table masked=True length=121>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDPCLASS_1SATSREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEAT
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string384float64float64int64int64int64int64string32string384float64string384
1237648702984683605225.005401226-1.0913022673431161121054724696103817046451974348816.025115.327415.008714.900314.78380.007903070.002745120.003204070.004456610.009042040.3277120.2411280.1748860.1326110.094022617.932218.7455-99.0-99.06.3540215.5154-99.020.98090153516.0790.214.2869999.014.0229999.012.57170.0040470613.4520.0310.006297655.12096e-0600.0524630.042043224.594-1.0910228.40381922.07.693145729024.6830184051203.93750357835574-11-1NSAsdss4.0SDSS
1237650372092690464180.29544216-1.297683831931319448581640280014.718913.868913.523313.364313.31120.006161120.002182750.002218780.002977850.005712360.187590.1380270.1001090.07590930.053820718.121518.8384-99.0-99.016.260736.7104-99.021.392664250716.4810.20314.6879999.014.3539999.013.570.03213.4150.0420.00496344-1.000.039220.037245180.098-1.1000823.24871465.07.3211405940Alice16.7329983482113.161017531171514-11-1NSAsixdf4.0
1237662524159557759195.10391847613.67025281173263951778713872199399133369338470416.294115.390915.071114.953214.93470.02273120.006675440.01175050.01818980.02993570.1823220.1341510.09729740.07377770.052309319.502920.3731-99.0-99.011.788731.5461-99.022.14881316299999.09999.09999.09999.09999.09999.014.9310.0414.6620.0710.006701541.43393e-0500.029640.021994194.86314.171230.0271988.07.907142722033.1822246225289.82564855875784-11-1NSAsdss4.0SDSS
1237662525233037420194.57210413614.557151882331161189774200920199402266977477632015.079413.905713.342213.064612.84580.008764890.002582330.002530720.002780830.007909940.1384850.1018960.07390360.05603890.039732318.035618.8593-99.0-99.022.410763.5675-99.021.839335819415.6880.13815.0750.16614.5430.12510.9780.0016625613.4650.0620.006742941.85704e-0500.0449880.01468194.86314.171230.0271988.07.907142722028.678557215250.4899595169964-11-1NSAsdss4.0SDSS
1237662196143947955206.06203055641.6773969113335253360136464155047609820095488017.570316.362615.722915.442215.40750.03577360.005511780.004911730.00561550.01569720.03721170.027380.01985830.01505790.010676318.742519.4958-99.0-99.06.8654123.2344-99.021.81763763416.6260.12915.8180.13115.6830.18913.87420.0075292214.7490.050.008695959.33515e-0600.0555040.026538206.3341.712537.22852549.018.434163956012.1863238779131.969466856424-11-1NSAsdss4.0SDSS
1237662307796910232206.1906667341.55671773475058011246640155048654356141875218.25517.093816.544216.292416.10360.03688740.006376970.005904590.008112270.02740150.04391430.03231180.02343520.01777020.012599319.29820.0954-99.0-99.05.5703913.9169-99.022.195783279999.09999.09999.09999.09999.09999.014.22030.01095615.0780.0610.008945332.04436e-0500.0485050.029693206.3341.712537.22852549.018.434163956011.2416329592121.73915493356427-11-1NSAsdss4.0SDSS
1237662300829384713228.77161386842.209456892631178711093284952188934421391765708816.705214.232513.189512.607912.06450.01794650.002381260.001940240.001803910.002342640.1306450.0961270.06971930.0528660.037482716.682917.459716.748521.624577111213.253935.588413.325220.932335877212.2569999.011.6440.0610.7219999.010.2090.0001287569.450.020.008326389.01325e-0600.0765110.029508228.76442.049936.91722562.08.573166035544Hamlet9.57904047243102.86705766869290--1-1NSAsdss4.0SDSS
1237655369832267945217.9453357558.0087096127319361739427439288958081253247590416.907115.857615.394415.186115.0470.02229660.004480640.004447440.005790070.01810760.05459570.0401710.02913540.02209250.015663819.116519.9402-99.0-99.015.784153.7135-99.022.21076086689999.09999.09999.09999.09999.09999.013.43550.006239514.8550.0550.00611507-1.000.0324180.014835218.02357.921531.00851898.398.27716515305.7811975526552.146417920928287-11-1NSAsdss4.0
1237664871897039021141.02204138234.64656417533105624251797848143442154545482342418.000716.334515.69215.379715.15780.04866390.007944830.007020560.008336430.02079710.08810580.06482740.04701830.03565250.025278119.544920.382710.225922.73590061858.7856717.843415.749522.46386046289999.09999.09999.09999.09999.09999.014.8830.0414.8640.0850.006234495.27589e-0500.0612310.029378141.07734.513527.67141687.08.03213587908.4335440226967.8839226826-1-11-1SDSSSDSS4.0SDSS
1237664871897170083141.50622822734.65340218543263988285935704179364958636817817615.662314.506813.968713.699513.53530.01212580.004680730.004141630.005070040.01333350.111620.08212890.05956670.04516770.032024418.541519.3918-99.0-99.017.297645.7608-99.021.97921385159999.09999.09999.09999.09999.09999.011.57330.0029440713.6210.0390.005394661.66289e-0500.0346370.029037141.07734.513527.67141687.08.032135879022.813830591183.63365315564909-11-1NSAsdss4.0SDSS
..........................................................................................................................................................................................
1237664669514662021171.1162007939.8140845353105622104313872224742821309975142417.896417.04316.630816.445416.40850.03463910.009764110.01049250.01793960.03463720.1215410.08942910.06486140.04918240.03487119.871220.702-99.0-99.010.043336.8172-99.022.68643522689999.09999.09999.09999.09999.09999.014.63530.019245415.690.1180.006255871.99016e-0500.0506680.047781170.63139.876931.56291948.09.453139281022.6523061801207.97555740788021-11-1NSAsdss4.0SDSS
1237662226210160806170.45777186840.0018120793176027355713880224739412823929036818.859718.030417.525317.336317.4390.0892170.0222890.01609510.01829160.06915650.1091120.08028340.05822820.04415270.031304820.453521.2731-99.0-99.07.1237822.3917-99.023.11265464589999.09999.09999.09999.09999.09999.015.45060.03604116.3250.2420.00664252.15579e-0500.1564020.061138170.63139.876931.56291948.09.453139281010.9454692896100.49319859488016-11-1NSAsdss4.0SDSS
1237664670051336378170.40248254540.15599467113193583034535952222945697037132800017.317216.161515.675315.425715.360.0334210.006798190.005608480.01017120.03223790.09348880.06878810.04989090.03783080.026822519.308920.1369-99.0-99.09.3767523.2929-99.022.35209714229999.09999.09999.09999.09999.09999.013.50910.010027114.9180.0880.006446683.40538e-0500.0334670.020791170.63139.876931.56291948.09.453139281019.7806207768181.61032562486968-11-1NSAsdss4.0SDSS
1237664669514596560170.77894501839.95672810333105624251797520224740512335556812818.079517.185616.809916.642716.51050.02714950.01098250.01236720.02198880.1117340.09874890.07265850.0526980.03995930.028331619.655620.4609-99.0-99.06.4640517.0031-99.022.51435906889999.09999.09999.09999.09999.09999.014.61990.01849915.3270.0950.006491397.35389e-0600.0403960.033603170.63139.876931.56291948.09.45313928108.3295964067176.476244094988018-11-1NSAsdss4.0SDSS
1237660765378248765137.96215550634.9637406847335253361184784143339954936325120016.232415.461315.080314.873714.70510.02894380.006739930.007166490.007870710.02563490.1135950.08358190.06062060.04596670.03259119.798520.6367-99.0-99.017.464343.3808-99.023.03198096379999.09999.09999.09999.09999.09999.015.3580.04815.1040.1060.006909491.26599e-0500.0421440.037786138.10235.027532.33742049.09.50613573907.8686013137974.0164715186157086-11-1NSAsdss4.0SDSS
1237660765378314404138.18497416634.925549611431161153266978832143340339765394841615.293214.005613.348513.021712.8090.006612280.002194610.002017640.00208950.003141180.1223390.09001580.06528690.04950510.035099717.654418.4177-99.0-99.012.772124.1065-99.020.889550121115.0160.08314.3010.08813.9610.08210.41280.00092850712.20.0250.006519129.36948e-0600.0922290.036795138.10235.027532.33742049.09.50613573907.3478491069469.117992287850569-11-1NSAsdss4.0SDSS
1237660765915316352138.04093028335.53761471623105624251797848136459348122117120018.376917.141116.904116.92718.41680.07024250.01008810.01303620.02064290.29220.11150.08204040.05950250.0451190.031989920.264120.949515.876524.90330402528.7289115.552917.167423.86767072689999.09999.09999.09999.09999.09999.09999.09999.09999.09999.00.006364233.27313e-0600.0750010.115918138.10235.027532.33742049.09.506135739030.7536074138289.28205192-1-11-1SDSSSDSS4.0SDSS
1237667255616143515158.0432463428.4830569538335253360136208265039070955466956816.97715.7915.267215.029514.89580.01560950.003085090.003230440.003623450.00773560.1267240.0932420.06762690.05127940.036357717.864718.619-99.0-99.05.7980715.8747-99.021.050925563215.7580.0915.3220.1215.0770.12712.85760.0050885313.7880.0440.005276561.02568e-0500.0512280.027819158.23128.511824.41171408.08.917137625010.047496908271.3479343973107759-11-1NSAsdss4.0SDSS
1237667287812735027157.77827429828.7966447953335253360136208265040170467094732814.709913.63812.997312.777512.49020.004155980.001790260.001726870.001747060.002232480.1236420.09097450.06598230.05003240.035473615.541216.2389-99.0-99.06.0696816.2422-99.019.090724709612.7890.04712.1360.04811.9530.0499.987360.0003462710.4910.0210.00474537.54079e-0600.1115930.043889158.23128.511824.41171408.08.917137625029.360597066208.489287227107764-11-1NSAsdss4.0SDSS
1237665367429677221158.71239779828.66385332883263953926197264265271260301652172817.087115.986915.574815.370715.31780.04032340.005897110.007747270.0103460.05432780.1541840.1134470.08228150.06239160.044236419.386220.2372-99.0-99.09.9859929.4525-99.022.13534598949999.09999.09999.09999.09999.09999.014.8230.03914.6350.0740.004413112.32353e-0500.0416550.02169158.23128.511824.41171408.08.917137625026.9982990593191.714994189107942-11-1NSAsdss4.0SDSS

In [66]:
#double-check that there's no very close pairs/repeats
allsatcoords = SkyCoord(allsats['ra'], allsats['dec'], unit=u.deg)
idx, d2d, d3d = allsatcoords.match_to_catalog_sky(allsatcoords, nthneighbor=2)
plt.hist(d2d.arcsec,range=(0,30))


Out[66]:
(array([ 0.,  0.,  0.,  2.,  0.,  0.,  0.,  0.,  0.,  0.]),
 array([  0.,   3.,   6.,   9.,  12.,  15.,  18.,  21.,  24.,  27.,  30.]),
 <a list of 10 Patch objects>)

In [57]:
nametoids = dict(zip(allsats['HOST_SAGA_NAME'], allsats['HOST_NSAID']))
del nametoids['']
nametoids


Out[57]:
{'Aeneid': 148734,
 'Alice': 140594,
 'AnaK': 61945,
 'Beowulf': 135667,
 'Catch22': 150887,
 'Dune': 165536,
 'Gilgamesh': 166313,
 'Hamlet': 166035,
 'Iliad': 150238,
 'MobyDick': 85746,
 'OBrother': 149781,
 'Odyssey': 147100,
 'StarTrek': 33446,
 'Ulysses': 150340}

In [59]:
#minus sign means low enough not to put on the plot below
completeness = {'Odyssey':.82, 
                'Gilgamesh':.78,
                'AnaK':.76,
                'StarTrek':.84,
                'MobyDick':.58,
                'Narnia':.52,
                'Dune':.74,
                'OBrother':.69,
                'Alice':-.14,
                'Sopranos':-.08,
                'Aeneid':.78,
                'Beowulf':-.14,
                'Hamlet':.35}

In [12]:
plt.figure(figsize=(12,10))
lower, upper = -10, -20

plot_styles = []
color_cycle = style.library['ggplot']['axes.color_cycle']
for line_style in ['--', ':']:
    for c in color_cycle:
        plot_styles.append(dict(color=c, ls=line_style))
    

for i, (nm, nsaid) in enumerate(nametoids.items()):
    msk = allsats['HOST_NSAID'] == nsaid
    satsofhost = allsats[msk]
    dm = Distance(satsofhost['HOST_DIST'], u.Mpc).distmod.value
    Mr = satsofhost['r'] + satsofhost['Ar'] - dm
    
    compl = completeness.get(nm, 1)
    if compl<0:
        continue
    vals, ns = vals_to_steps(Mr, lower, upper)
    plt.plot(vals, ns/compl, lw=2, label=nm, **plot_styles[i])
    
    
plt.plot(*vals_to_steps(Mr_MW_sats, lower, upper), label='MW', ls='-', lw=3)
plt.plot(*vals_to_steps(Mr_And_sats, lower, upper), label='M31', ls='-', lw=3)


incomplmag = 20.5*u.mag - Distance(42*u.Mpc).distmod
plt.axvspan(lower, incomplmag.value, alpha=.2,color='k')

plt.xlim(upper, lower)
plt.ylim(0, 10.)
plt.legend(loc=0, fontsize=18)

plt.xlabel(r'$M_r$', fontsize=48)
plt.ylabel(r'$N(<M_r)/C$', fontsize=48)
plt.xticks(fontsize=22)
plt.yticks(fontsize=22)
plt.tight_layout()
plt.savefig('SAGA_LF.png')
plt.savefig('SAGA_LF.pdf')


slightly modified version for AAT proposal


In [30]:
plt.figure(figsize=(12,10))
lower, upper = -10, -20

plot_styles = []
color_cycle = style.library['ggplot']['axes.color_cycle']
for line_style in ['--', ':']:
    for c in color_cycle:
        plot_styles.append(dict(color=c, ls=line_style))


sorti = np.argsort(np.array(nametoids.values()))
sortednametoids = zip(np.array(nametoids.keys())[sorti], np.array(nametoids.values())[sorti])
        
i = -1
for nm, nsaid in sortednametoids:
    if nm in ('Ulysses', 'Iliad', 'Hamlet'):
        continue
    else:
        i += 1
    msk = allsats['HOST_NSAID'] == nsaid
    satsofhost = allsats[msk]
    dm = Distance(satsofhost['HOST_DIST'], u.Mpc).distmod.value
    Mr = satsofhost['r'] + satsofhost['Ar'] - dm
    
    compl = completeness.get(nm, 1)
    if compl<0:
        continue
    vals, ns = vals_to_steps(Mr, lower, upper)
    plt.plot(vals, ns/compl, lw=2, label='NSA {}'.format(nsaid), **plot_styles[i])
    
    
plt.plot(*vals_to_steps(Mr_MW_sats, lower, upper), label='MW', ls='-', lw=3)
plt.plot(*vals_to_steps(Mr_And_sats, lower, upper), label='M31', ls='-', lw=3)


incomplmag = 20.5*u.mag - Distance(42*u.Mpc).distmod
plt.axvspan(lower, incomplmag.value, alpha=.2,color='k')

plt.xlim(upper, lower)
plt.ylim(0, 10.)
plt.legend(loc=0, fontsize=18)

plt.xlabel(r'$M_r$', fontsize=48)
plt.ylabel(r'$N(<M_r)/C$', fontsize=48)
plt.xticks(fontsize=22)
plt.yticks(fontsize=22)
plt.tight_layout()
plt.savefig('SAGA_LF.png')
plt.savefig('SAGA_LF.pdf')


update for AAT proposal table


In [119]:
allspec = Table.read(os.environ['HOME']+'/Dropbox/SAGA/data/allspectaken_v5.fits.gz')
allsats = allspec[(allspec['SATS']==1)&(allspec['REMOVE']==-1)]

In [120]:
#double-check that there's no very close pairs/repeats
allsatcoords = SkyCoord(allsats['ra'], allsats['dec'], unit=u.deg)
idx, d2d, d3d = allsatcoords.match_to_catalog_sky(allsatcoords, nthneighbor=2)
plt.hist(d2d.arcsec,range=(0,30))


Out[120]:
(array([ 16.,   0.,   3.,   0.,   0.,   0.,   0.,   0.,   0.,   0.]),
 array([  0.,   3.,   6.,   9.,  12.,  15.,  18.,  21.,  24.,  27.,  30.]),
 <a list of 10 Patch objects>)

In [121]:
idx1, idx2, d2d, _ = allsatcoords.search_around_sky(allsatcoords, 1*u.arcsec)
uniquepairs = set([tuple(sorted(pair)) for pair in zip(idx1[idx1!=idx2], idx2[idx1!=idx2])])
msk = np.ones(len(allsats), dtype=bool)
msk[np.array(list(uniquepairs))[:,1]] = False
allsats = allsats[msk]

allsatcoords = SkyCoord(allsats['ra'], allsats['dec'], unit=u.deg)
idx, d2d, d3d = allsatcoords.match_to_catalog_sky(allsatcoords, nthneighbor=2)
plt.hist(d2d.arcsec,range=(0,30))


Out[121]:
(array([ 0.,  0.,  3.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]),
 array([  0.,   3.,   6.,   9.,  12.,  15.,  18.,  21.,  24.,  27.,  30.]),
 <a list of 10 Patch objects>)

In [122]:
nsaids = [147100,150887,61945,148734,166313,165536,149781,33446,140594,85746]
p01_compl = [.34,.12,.57,.15,.54,.39,.27,.43,.19,.36]
p1_compl = [1,.66,.66,.5,.92,.73,1,1,.7,.7]
gri_compl = [.21,.4,.47,.8,.34,.27,.21,.36,.8,.2]

In [123]:
plt.figure(figsize=(12,10))
lower, upper = -10, -20

plot_styles = []
color_cycle = style.library['ggplot']['axes.color_cycle']
for line_style in ['--', ':']:
    for c in color_cycle:
        plot_styles.append(dict(color=c, ls=line_style))
    
i = - 1
for nsaid, compl in zip(nsaids, p1_compl):
    msk = allsats['HOST_NSAID'] == nsaid
    satsofhost = allsats[msk]
    dm = Distance(satsofhost['HOST_DIST'], u.Mpc).distmod.value
    Mr = satsofhost['r'] + satsofhost['Ar'] - dm
    
    if len(Mr) < 1:
        print('skipping', nsaid)
        continue
    else:
        print('NSA', nsaid, 'has', len(Mr), 'sats')
        i+=1
    
    vals, ns = vals_to_steps(Mr, lower, upper)
    plt.plot(vals, ns/compl, lw=2, label='NSA {}'.format(nsaid), **plot_styles[i])
    
    
plt.plot(*vals_to_steps(Mr_MW_sats, lower, upper), label='MW', ls='-', lw=3)
plt.plot(*vals_to_steps(Mr_And_sats, lower, upper), label='M31', ls='-', lw=3)


incomplmag = 20.5*u.mag - Distance(42*u.Mpc).distmod
plt.axvspan(lower, incomplmag.value, alpha=.2,color='k')

plt.xlim(upper, lower)
plt.ylim(0, 10.)
plt.legend(loc=0, fontsize=18)

plt.xlabel(r'$M_r$', fontsize=48)
plt.ylabel(r'$N(<M_r)/C$', fontsize=48)
plt.xticks(fontsize=22)
plt.yticks(fontsize=22)
plt.tight_layout()
plt.savefig('SAGA_LF_2.png')
plt.savefig('SAGA_LF_2.pdf')


NSA 147100 has 8 sats
NSA 150887 has 4 sats
NSA 61945 has 3 sats
NSA 148734 has 2 sats
NSA 166313 has 3 sats
NSA 165536 has 2 sats
NSA 149781 has 2 sats
NSA 33446 has 2 sats
NSA 140594 has 1 sats
NSA 85746 has 1 sats

Odyssey/Gilgamesh only


In [3]:
sattab = fits.getdata('/Users/erik/Dropbox/SAGA/satellite-learning/galaxies_around_SAGAhosts_allspectra_v2.3.fits.gz')

In [21]:
issat = sattab['SATS']==1
inody = sattab['HOSTNAME']=='Odyssey'
ingilg = sattab['HOSTNAME']=='Gilgamesh'
odysats = sattab[issat&inody]
gilgsats = sattab[issat&ingilg]
len(odysats), len(gilgsats)


Out[21]:
(8, 2)

In [206]:
odysats[-2][1]


Out[206]:
(1237662224092299404, 247.84002994962782, 20.184075813520494, 3, 105553418387472, 0, 14.96636, 13.900308, 13.309114, 13.030106, 12.79305, 0.14956565, 0.0, 0.0, 0.0, 0.20462532, 0.32571051, 0.23965468, 0.17381756, 0.13180059, 0.093448266, 18.629335, 19.469557, 26.837091, 22.448240280151367, 16.462582, 40.518742, 14.738416, 22.816354751586914, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 9999.0, 0.0085534714, -1.0, 0, 0.097627997, 0.099662997, 68560, '147100', '      248.087', 19.826429, 2375.0, 34.0, 25.598127615297667, 253.16823706977448, 1, 'Odyssey', 'NSA', '', 4.0, 'NSA')

In [199]:
Mr_ody_sats = odysats['R'] - odysats['AR'] - Distance(odysats['HOST_DIST']*u.Mpc).distmod.value
Mr_gilg_sats = gilgsats['R'] - gilgsats['AR'] - Distance(gilgsats['HOST_DIST']*u.Mpc).distmod.value

In [207]:
rcParams['xtick.labelsize'] = rcParams['ytick.labelsize'] = 16*2
rcParams['axes.labelsize'] = 24*2
rcParams['legend.fontsize'] = 24

def lumfunc(mag, startat=-20, extend_to=-12, **kwargs):
    kwargs.setdefault('where', 'pre')
    kwargs.setdefault('lw', 2)
    
    mags = np.sort(mag)
    Mr, n =  np.r_[mags, mags[-1]], np.arange(len(mags)+1)
    if extend_to and mags[-1] < extend_to:
        Mr = np.r_[Mr, extend_to]
        n = np.r_[n, n[-1]]
    if startat and mags[0] > startat:
        Mr = np.r_[startat, Mr]
        n = np.r_[0, n]
    return plt.step(Mr, n, **kwargs)

plt.figure(figsize=(10,10))
lumfunc(Mr_gilg_sats, label='NGC 5962', lw=4) 
lumfunc(Mr_ody_sats, label='NGC 6181', ls='-', lw=4)
lumfunc(Mr_MW_sats, label='MW', ls='--', lw=2)
lumfunc(Mr_And_sats, label='M31', ls='--', lw=2)

plt.axvline(-12, color='k', ls=':')

plt.xlim(-20,-9.5)
plt.ylim(-.1,9.1)
plt.yticks(np.arange(10))

magstr = 'M_r'
plt.xlabel('${magstr}$'.format(**locals()))
plt.ylabel('$N(<{magstr})$'.format(**locals()))

plt.legend(loc=0)


plt.tight_layout()

plt.savefig('/Users/erik/Desktop/aatprop_lumfunc.pdf')
plt.savefig('/Users/erik/Desktop/aatprop_lumfunc.eps')
plt.savefig('/Users/erik/Desktop/aatprop_lumfunc.png')



In [ ]: