Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit f23136f

Browse files
authored
Add files via upload
1 parent bd993c7 commit f23136f

14 files changed

+5925
-0
lines changed

mk_table1.ipynb

+490
Large diffs are not rendered by default.

plot_Fig1.ipynb

+647
Large diffs are not rendered by default.

plot_Fig10_vdiff.ipynb

+456
Large diffs are not rendered by default.

plot_Fig11_sb.ipynb

+386
Large diffs are not rendered by default.

plot_Fig12_nsat.ipynb

+362
Large diffs are not rendered by default.

plot_Fig16_images.ipynb

+287
Large diffs are not rendered by default.

plot_Fig3.ipynb

+251
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
#! /usr/bin/python
2+
##################################################
3+
# COMPILE SPECTRA FROM ALL SOURCES FOR ALL FLAG 0 HOSTS
4+
# 1. SDSS
5+
# 2. GAMA
6+
# 3. MMT, AAT, IMACS, WIYN
7+
#
8+
#
9+
#
10+
##################################################
11+
12+
import numpy as np
13+
import os
14+
15+
import matplotlib.pyplot as plt
16+
from scipy import integrate
17+
18+
19+
from astropy import table
20+
from astropy.table import Table
21+
from astropy import units as u
22+
from astropy.io import ascii
23+
24+
25+
26+
from astroML.plotting import setup_text_plots
27+
setup_text_plots(fontsize=9, usetex=True)
28+
29+
30+
from utils import get_mcconn_table
31+
from palettable.colorbrewer.qualitative import Dark2_8
32+
33+
34+
SAGA_DIR = os.environ['SAGA_DIR']
35+
36+
############################################################################
37+
def plot_mwsats():
38+
39+
if 'plt' in locals() and hasattr(plt, 'rcParams'):
40+
plt.rcParams['lines.linewidth'] = 2.5
41+
plt.rcParams['font.size'] = 18.0
42+
plt.rcParams['font.family'] = 'serif'
43+
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=Dark2_8.mpl_colors)
44+
plt.rcParams['legend.fontsize'] = 'medium'
45+
plt.rcParams['legend.frameon'] = False
46+
plt.rcParams['figure.dpi'] = 100
47+
plt.rcParams['figure.figsize'] = 7, 6
48+
plt.rcParams['xtick.major.size'] = 6
49+
plt.rcParams['xtick.minor.size'] = 4
50+
plt.rcParams['ytick.major.size'] = 6
51+
plt.rcParams['ytick.minor.size'] = 4
52+
53+
54+
# READ SPECTRA
55+
file = SAGA_DIR +'/data/saga_spectra_clean.fits.gz'
56+
allspec = Table.read(file)
57+
58+
59+
60+
m1 = allspec['SATS'] == 1
61+
m2 = allspec['TELNAME'] != 'SDSS'
62+
m3 = allspec['TELNAME'] != 'NSA'
63+
m4 = allspec['TELNAME'] != 'GAMA'
64+
m5 = allspec['HOST_SAGA_NAME'] != ''
65+
sdss_sats = allspec[m1&m5]
66+
67+
68+
69+
# MCCONNACHIE DATA
70+
mcconndat = get_mcconn_table()
71+
72+
# CALCULATE NUMBER OF MW SATS
73+
mcconndat.columns
74+
mw = mcconndat['distance']<300
75+
MV = mcconndat['Vmag'] - mcconndat['distmod'] - 0.3
76+
msk = MV < -12.3
77+
msk = MV < -7
78+
print "brighter than -12"
79+
print mcconndat['name'][msk&mw],MV[msk&mw]
80+
81+
print "brighter than -10"
82+
msk = MV < -10.5
83+
print mcconndat['name'][msk&mw],MV[msk&mw]
84+
85+
86+
for obj in mcconndat[msk&mw]:#
87+
MV = obj['Vmag'] - obj['distmod'] - 0.3
88+
print obj['name'],MV,obj['muV0']-0.3
89+
90+
sample = mcconndat['distance']<0
91+
sample[mcconndat['name']=='LMC'] = True
92+
sample[mcconndat['name']=='SMC'] = True
93+
sample[mcconndat['name']=='Sagittarius'] = True
94+
sample[mcconndat['name']=='Fornax'] = True
95+
sample[mcconndat['name']=='Leo I'] = True
96+
sample[mcconndat['name']=='Sculptor'] = True
97+
sample[mcconndat['name']=='M32'] = True
98+
99+
100+
ldat = mcconndat[sample]
101+
102+
103+
104+
105+
106+
sagadists = [5, 20, 30, 40] * u.Mpc
107+
distmods = 5*np.log10(sagadists/(10*u.pc))
108+
109+
data = ldat[ldat['Vabs']<-10]
110+
data = data[np.argsort(data['Vabs'])]
111+
112+
113+
114+
# UPDATE LMC/SMC
115+
m = data['name'] == 'LMC'
116+
data['rh_phys'][m] = 2.2 # Bothun & thompson 1988
117+
m = data['name'] == 'SMC'
118+
data['rh_phys'][m] = 1.0
119+
120+
121+
fig = plt.figure(figsize=(7, 3))
122+
plt.rcParams['font.size'] = 18.0
123+
124+
fig.subplots_adjust(bottom=0.15, top=0.9,left=0.12, right=0.95, wspace=0.3)
125+
126+
cc = ['red','orange','brown','yellow','green','blue']
127+
128+
129+
# PLOT SIZES
130+
plt.subplot(1,2,1)
131+
plt.plot(sdss_sats['HOST_DIST'],sdss_sats['PETRORAD_R'],'.',color='grey',label='SAGA sats')
132+
for i,gal in enumerate(data):
133+
plt.plot(sagadists.value, ((gal['rh_phys']/sagadists.to(u.kpc).value)*u.rad).to(u.arcsec).value,'-o',c=cc[i],label=gal['name'])
134+
print ((gal['rh_phys']/sagadists.to(u.kpc).value)*u.rad).to(u.arcsec).value
135+
136+
plt.ylim(0,25)
137+
plt.xlim(18,42)
138+
plt.xlabel('Dist [Mpc]')
139+
plt.ylabel('$r_{\mathrm{eff}}$ [arcsec]')
140+
141+
plt.axhline(1., c='k', ls='--')
142+
143+
# PLOT SAGA DATA
144+
145+
######################
146+
plt.subplot(1,2,2)
147+
148+
149+
Vmr=0.3
150+
rad = 3*u.arcsec/2. #3" diam = fibermag
151+
152+
for n in data:
153+
print n['name'],n['Vabs']-Vmr
154+
155+
156+
# PLOT SAGA DATA
157+
plt.plot(sdss_sats['FIBERMAG_R'],sdss_sats['r'] - sdss_sats['EXTINCTION_R'],'.',color='grey',label='SAGA sats')
158+
159+
160+
161+
#first do plummer
162+
for i, gal in enumerate(data):
163+
fracs = np.array([frac_inside(gal, rad, dist, 'plummer') for dist in sagadists])
164+
fibmags = gal_mag_frac(gal, fracs, sagadists) - Vmr
165+
totmags = gal_mag_frac(gal, np.ones_like(fracs), sagadists) - Vmr
166+
167+
# plt.plot(fibmags, totmags,'-o',color=cc[i],label=gal['name'])
168+
169+
# plt.text(fibmags[fi], totmags[ti], gal['name'],color=cc[i])
170+
#plt.legend(loc=0)
171+
172+
173+
174+
175+
176+
for i, gal in enumerate(data):
177+
fracs = np.array([frac_inside(gal, rad, dist, 'exp') for dist in sagadists])
178+
fibmags = gal_mag_frac(gal, fracs, sagadists) - Vmr
179+
totmags = gal_mag_frac(gal, np.ones_like(fracs), sagadists) - Vmr
180+
181+
plt.plot(fibmags, totmags,'-o',color=cc[i],label=gal['name'])
182+
183+
plt.legend(loc=2,fontsize=7)
184+
185+
# x1t1 = [min(fiblim[0], totlim[0]), max(fiblim[1], totlim[1])]
186+
# plt.fill_between(x1t1,x1t1, totlim[1],facecolor=[0.6]*3)
187+
plt.axhline(20.75, c='k', ls=':')
188+
plt.axvline(23, c='k', ls=':')
189+
190+
191+
192+
plt.xlabel('Fibermag\_r')
193+
plt.ylabel('$r_o$')
194+
# plt.title('Solid=Plummer, Dashed=Exponential')
195+
plt.xlim(14.5,23.5) #tweak for text
196+
plt.ylim(12,22.)
197+
198+
199+
200+
201+
202+
203+
plt.show()
204+
plt.savefig('fig_mwsats.pdf')
205+
206+
def plummer_prof(r, totflux=1, Reff=1):
207+
a = Reff*(2.**(2./3)-1.)**(-0.5)
208+
return 2*a*(3 * totflux / (4*np.pi*a**3))*(1+(r/a)**2)**-2.5
209+
210+
211+
def exp_prof(r, totflux=1, Reff=1):
212+
from scipy.special import lambertw
213+
#the parenthetical below is non-trivial, but it's ~1.67835
214+
rs = Reff / -(lambertw(-1/2/np.exp(1),-1).real+1.)
215+
rs = Reff/1.67835
216+
# print rs
217+
return totflux*np.exp(-r/rs)/np.pi/2./rs/rs
218+
219+
220+
def frac_inside(gal, radius, dist, prof):
221+
"""
222+
Compute the magnitude inside the given angular `radius` for the
223+
table entry `gal` at a distance of `dist`, assuming a profile
224+
`prof` ('plummer' or 'exp')
225+
"""
226+
if prof == 'plummer':
227+
prof_func = plummer_prof
228+
elif prof == 'exp':
229+
prof_func = exp_prof
230+
else:
231+
raise ValueError('invalid profile type '+ str(prof))
232+
233+
rh_at_distance = (u.arcmin*gal['rh'] * (gal['distance']*u.kpc)/dist).to(u.arcmin)
234+
return integrate.quad(lambda x:prof_func(x, 1, rh_at_distance.value)*x*np.pi*2, 0, radius.to(u.arcmin).value)[0]
235+
236+
def gal_mag_frac(gal, frac, dist):
237+
"""
238+
determine the V magnitude for `frac` of the flux from `gal` at distance `dist`
239+
"""
240+
flux = 10**((gal['Vabs'])/-2.5)
241+
fluxd = flux * ((10*u.pc/dist)**2).decompose().value
242+
return -2.5*np.log10(frac*fluxd)
243+
244+
245+
246+
if __name__ == '__main__':
247+
create_saga_spectra()
248+
249+
250+
251+

0 commit comments

Comments
 (0)