In [1]:
import sys
import pickle
import numpy
from galpy.util import bovy_plot
from matplotlib import cm
import define_rcsample
In [2]:
with open('../mapfits/tribrokenexpflare.sav','rb') as savefile:
bf= numpy.array(pickle.load(savefile))
samples= numpy.array(pickle.load(savefile))
bf_g15= numpy.array(pickle.load(savefile))
samples_g15= numpy.array(pickle.load(savefile))
bf_zero= numpy.array(pickle.load(savefile))
samples_zero= numpy.array(pickle.load(savefile))
maps= define_rcsample.MAPs()
In [5]:
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthise= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(numpy.exp(samples[ii,3]))
terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
if tmed < 5.:
tmed= 0.
terr= numpy.nan
plotthis[ii]= tmed
plotthise[ii]= terr
maps.plot(plotthis,vmin=5.,vmax=13.,minnstar=15,zlabel=r'$R_{\mathrm{peak}}\,(\mathrm{kpc})$')
bovy_plot.bovy_text(-0.55,0.225,r'$\mathrm{single}$',
size=16.,color='w')
bovy_plot.bovy_text(-0.495,0.19,r'$\mathrm{exponential}$',
size=16.,color='w')
maps.plot(plotthise,vmin=0.,vmax=1.,minnstar=15,zlabel=r'$R_{\mathrm{peak}}\,(\mathrm{kpc})$')
print numpy.nanmedian(plotthise)
In [4]:
plotthisf= numpy.zeros(len(bf))+numpy.nan
plotthisfe= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(samples[ii,4])
terr= 1.4826*numpy.nanmedian(numpy.fabs(samples[ii,4])-tmed)
if terr > 0.6: tmed= numpy.nan
plotthisf[ii]= tmed
plotthisfe[ii]= terr
#plotthisf[plotthis == 0.]= numpy.nan
maps.plot(plotthisf,vmin=-0.3,vmax=0.1,minnstar=15)
maps.plot(plotthisfe,vmin=0.,vmax=.6,minnstar=15)
print numpy.nanmedian(plotthisf[plotthis > 0.]), 1.4826*numpy.nanmedian(numpy.fabs(plotthisf[plotthis > 0.]-numpy.nanmedian(plotthisf[plotthis > 0.])))/numpy.sqrt(numpy.sum(plotthis > 0.))
print numpy.nanmedian(plotthisf[plotthis == 0.]), 1.4826*numpy.nanmedian(numpy.fabs(plotthisf[plotthis == 0.]-numpy.nanmedian(plotthisf[plotthis == 0.])))/numpy.sqrt(numpy.sum(plotthis == 0.))
In [5]:
overplot=False
for ii, map in enumerate(maps.map()):
if plotthis[ii] == 0.: continue
tmed= numpy.nanmedian(samples[ii,4])
terr= 1.4826*numpy.nanmedian(numpy.fabs(samples[ii,4])-tmed)
if terr > 0.6: continue
bovy_plot.bovy_hist(samples[ii,4],bins=51,range=[-0.3,0.1],histtype='step',
color=cm.coolwarm(((numpy.nanmedian(map['ALPHAFE'])+0.0)/0.1)),
overplot=overplot)
overplot=True
In [6]:
overplot=False
for ii, map in enumerate(maps.map()):
if plotthis[ii] > 0.: continue
tmed= numpy.nanmedian(samples[ii,4])
terr= 1.4826*numpy.nanmedian(numpy.fabs(samples[ii,4])-tmed)
if terr > 0.3: continue
bovy_plot.bovy_hist(samples[ii,4],bins=51,range=[-0.3,0.1],histtype='step',
color=cm.coolwarm(((numpy.nanmedian(map['ALPHAFE'])-0.05)/0.2)),
overplot=overplot)
overplot=True
In [7]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
trp= numpy.nanmedian(numpy.exp(samples[ii,3]))
terr= numpy.std(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
if trp < 5. and terr > 0.1:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
if tmed > 1.:
tmed= sorted(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
tmed= tmed[int(round(0.05*len(tmed)))]
elif terr > 0.1:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]+0.1) < 0.03)])
else:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))])
#if numpy.sum((True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]+0.1) < 0.03)) < 1000: tmed= numpy.nan
plotthisz[ii]= tmed
maps.plot(plotthisz*1000.,
vmin=200.,vmax=1000.,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[7]:
In [8]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
trp= numpy.nanmedian(numpy.exp(samples[ii,3]))
terr= numpy.std(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
if trp < 5. and terr > 0.1:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
if tmed > 1.:
tmed= sorted(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]) < 0.03)])
tmed= tmed[int(round(0.05*len(tmed)))]
elif terr > 0.1:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]+0.1) < 0.03)])
else:
tmed= numpy.median(1./samples[ii,1,(True-numpy.isnan(1./samples[ii,1]))])
#if numpy.sum((True-numpy.isnan(1./samples[ii,1]))*(numpy.fabs(samples[ii,4]+0.1) < 0.03)) < 1000: tmed= numpy.nan
plotthisz[ii]= tmed
maps.plot(1./plotthisz,
vmin=1.,vmax=4.,
minnstar=15,
zlabel=r'$1/h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[8]:
In [9]:
plotthisa= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(map['AVG_ALPHAFE'])-(maps.ymin+0.05*(ii%7)+0.05/2.)
plotthisa[ii]= tmed
maps.plot(plotthisa,vmin=-0.01,vmax=0.01,minnstar=15)
Out[9]:
In [10]:
with open('../mapfits/tribrokenexp.sav','rb') as savefile:
bf= numpy.array(pickle.load(savefile))
samplesnf= numpy.array(pickle.load(savefile))
In [11]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samplesnf[ii,1])
plotthisz[ii]= tmed
maps.plot(plotthisz*1000.,
vmin=200.,vmax=1000.,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[11]:
In [12]:
with open('../mapfits/tribrokenexpfixedflare.sav','rb') as savefile:
bf= numpy.array(pickle.load(savefile))
samplesff= numpy.array(pickle.load(savefile))
In [13]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samplesff[ii,1])
plotthisz[ii]= tmed
maps.plot(plotthisz*1000.,
vmin=200.,vmax=1000.,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[13]:
In [14]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samplesff[ii,1])/numpy.nanmedian(1./samples[ii,1])
plotthisz[ii]= tmed
maps.plot(plotthisz,
vmin=0.7,vmax=1.3,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[14]:
In [15]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
plotthisze= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 5.:
tmed= numpy.nanmedian(1./samplesnf[ii,1])
terr= numpy.nanstd(1./samplesnf[ii,1])
else:
tmed= numpy.nanmedian(1./samplesff[ii,1])
terr= numpy.nanstd(1./samplesff[ii,1])
plotthisz[ii]= tmed
plotthisze[ii]= terr
plotthisz[plotthisze/plotthisz > 0.2]= numpy.nan
maps.plot(plotthisz*1000.,
vmin=200.,vmax=1000.,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
maps.plot(plotthisz/plotthisze,
vmin=5.,vmax=20.,
minnstar=15,
zlabel=r'$\sigma h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[15]:
In [15]:
In [35]:
plotthis= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samples[ii,2])
terr= numpy.nanstd(1./samples[ii,2])
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 5.: tmed= numpy.nan
# terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
#if tmed < 5.:
# tmed= 0.
plotthis[ii]= tmed
maps.plot(plotthis,vmin=1.,vmax=5.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}\,(\mathrm{kpc}^{-1})$')
Out[35]:
In [132]:
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthise= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samples[ii,0])
terr= numpy.nanstd(samples[ii,0])
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 6.: tmed= numpy.nan
# terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
#if tmed < 5.:
# tmed= 0.
plotthis[ii]= tmed
plotthise[ii]= terr
#plotthis[plotthise > 0.1]= numpy.nan
maps.plot(plotthis,vmax=5.,vmin=1./.6,minnstar=15,zlabel=r'$h_{R,{\mathrm{in}}}\,(\mathrm{kpc})$')
Out[132]:
In [51]:
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthise= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(samples[ii,0]/samples[ii,2])
terr= numpy.nanstd(samples[ii,0]/samples[ii,2])
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 6.:
tmed= numpy.nan
terr= numpy.nan
# terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
#if tmed < 5.:
# tmed= 0.
plotthis[ii]= tmed
plotthise[ii]= terr
#plotthis[plotthise > 0.1]= numpy.nan
maps.plot(plotthis,vmin=0.,vmax=2.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}/h_{R,{\mathrm{in}}}$')
maps.plot(plotthise,vmin=0.,vmax=2.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}/h_{R,{\mathrm{in}}}$')
maps.plot((1.-plotthis)/plotthise,vmin=-4.,vmax=4.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}/h_{R,{\mathrm{in}}}$')
Out[51]:
In [128]:
figsize(8,8)
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthise= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(samples[ii,2]-samples[ii,0])
terr= numpy.nanstd(samples[ii,2]-samples[ii,0])
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 6.:
tmed= numpy.nan
terr= numpy.nan
# terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
#if tmed < 5.:
# tmed= 0.
plotthis[ii]= tmed
plotthise[ii]= terr
#plotthis[plotthise > 0.1]= numpy.nan
maps.plot(plotthis,vmin=0.,vmax=.6,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}-h_{R,{\mathrm{in}}}$')
maps.plot(plotthis/plotthise,vmin=0.,vmax=5.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}-h_{R,{\mathrm{in}}}$')
Out[128]:
In [151]:
figsize(8,8)
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthise= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
diff= numpy.amin(numpy.array([numpy.log(2.)/samples[ii,0],numpy.exp(samples[ii,3])]),axis=1)
diff+= numpy.amin(numpy.array([numpy.log(2.)/samples[ii,2],14.-numpy.exp(samples[ii,3])]),axis=1)
tmed= numpy.nanmedian(diff)
terr= numpy.nanstd(diff)
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 6.:
tmed= numpy.nan
terr= numpy.nan
# terr= 1.4826*numpy.nanmedian(numpy.fabs(numpy.exp(samples[ii,3])-tmed))
#if tmed < 5.:
# tmed= 0.
plotthis[ii]= tmed
plotthise[ii]= terr
#plotthis[plotthise > 0.1]= numpy.nan
maps.plot(plotthis,vmin=4.,vmax=6.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}+h_{R,{\mathrm{in}}}$')
maps.plot(plotthise,vmin=0.,vmax=5.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}+h_{R,{\mathrm{in}}}$')
print numpy.nanmedian(plotthis)
In [62]:
import densprofiles
import copy
In [90]:
Rs= numpy.linspace(4.,12.,1001)
ldp= []
ldpe= []
tsamples= copy.deepcopy(samples)
tsamples[:,3,:]= numpy.log(8.)
tsamples[:,2,:]-= tsamples[:,0,:]
tsamples[:,0,:]= 0.
for ii, map in enumerate(maps.map()):
print ii
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 6.: continue
if len(map) < 16: continue
tdp= numpy.ones((len(Rs),len(tsamples[ii,0])//10))
for jj in range(len(tsamples[ii,0])//10):
tdp[Rs >= 8.,jj]= numpy.exp(-tsamples[ii,2,jj*10]*(Rs[Rs >= 8.]-8.))
#densprofiles.tribrokenexpflaredisk(Rs,0.*Rs,0.*Rs,params=tsamples[ii,:,jj*10])/(tsamples[ii,1,jj*10]*numpy.exp((Rs-8.0)*tsamples[ii,4,jj]))
ldp.append(numpy.nanmedian(tdp,axis=-1))
ldpe.append(numpy.nanstd(tdp,axis=-1))
In [113]:
figsize(16,30)
subplot(3,1,1)
ii= 0
for jj, map in enumerate(maps.map()):
if numpy.nanmedian(numpy.exp(samples[jj,3])) < 6.: continue
if len(map) < 16: continue
ii+= 1
if jj%7 != 0: continue
if ii >= len(ldp): break
semilogy(Rs,ldp[ii]/ldp[ii][501],lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]+ldpe[ii])/(ldp[ii][501]+ldpe[ii][501]),ls=':',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]-ldpe[ii])/(ldp[ii][501]-ldpe[ii][501]),ls='--',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,numpy.median(numpy.array([l/l[501] for l in ldp]),axis=0),lw=3.,color='k')
ylim(0.05,20.)
subplot(3,1,2)
ii= 0
for jj, map in enumerate(maps.map()):
if numpy.nanmedian(numpy.exp(samples[jj,3])) < 6.: continue
if len(map) < 16: continue
ii+= 1
if jj%7 != 1: continue
if ii >= len(ldp): break
semilogy(Rs,ldp[ii]/ldp[ii][501],lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]+ldpe[ii])/(ldp[ii][501]+ldpe[ii][501]),ls=':',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]-ldpe[ii])/(ldp[ii][501]-ldpe[ii][501]),ls='--',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,numpy.median(numpy.array([l/l[501] for l in ldp]),axis=0),lw=3.,color='k')
ylim(0.05,20.)
subplot(3,1,3)
ii= 0
for jj, map in enumerate(maps.map()):
if numpy.nanmedian(numpy.exp(samples[jj,3])) < 6.: continue
if len(map) < 16: continue
ii+= 1
if jj%7 != 2: continue
if ii >= len(ldp): break
semilogy(Rs,ldp[ii]/ldp[ii][501],lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]+ldpe[ii])/(ldp[ii][501]+ldpe[ii][501]),ls=':',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,(ldp[ii]-ldpe[ii])/(ldp[ii][501]-ldpe[ii][501]),ls='--',lw=3.,color=cm.coolwarm((numpy.median(map['FE_H'])+0.5)/.7))
semilogy(Rs,numpy.median(numpy.array([l/l[501] for l in ldp]),axis=0),lw=3.,color='k')
ylim(0.05,20.)
Out[113]:
In [83]:
plot(densprofiles.tribrokenexpflaredisk(Rs,0.*Rs,0.*Rs,params=[0.,1.,0.5,numpy.log(8.),-0.1]))
Out[83]:
In [96]:
len(ldp)
Out[96]:
In [116]:
-numpy.log(0.3)/4.
Out[116]:
In [12]:
plotthis= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samples[ii,2])
terr= numpy.nanstd(1./samples[ii,2])
if numpy.nanmedian(numpy.exp(samples[ii,3])) >= 5.:
tmed= numpy.nan
if terr/tmed > 0.5:
tmed= numpy.nan
plotthis[ii]= tmed
maps.plot(plotthis,vmin=0.,vmax=4.,minnstar=15,zlabel=r'$h_{R,{\mathrm{out}}}$')
print numpy.nanmedian(plotthis), 1.4826*numpy.nanmedian(numpy.fabs(plotthis-numpy.nanmedian(plotthis)))/numpy.sqrt(numpy.sum(True-numpy.isnan(plotthis)))
In [152]:
with open('../mapfits/tribrokentwoexp.sav','rb') as savefile:
bf_twoexp= numpy.array(pickle.load(savefile))
samples_twoexp= numpy.array(pickle.load(savefile))
In [180]:
figsize(5,5)
plotthis= numpy.zeros(len(bf))+numpy.nan
plotthishz= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
hzindx= (numpy.fabs((1./samples_twoexp[ii,1]-1./samples_twoexp[ii,5])*samples_twoexp[ii,1]) > 0.5)
#hzindx= numpy.ones(len(samples[ii,4]),dtype='bool')
#print numpy.sum(hzindx)
tup= sorted(densprofiles.ilogit(samples_twoexp[ii,4,hzindx]))[int(round(0.95*numpy.sum(hzindx)))]
tmed= numpy.nanmedian(1./samples_twoexp[ii,5,hzindx])
plotthis[ii]= tup
plotthishz[ii]= tmed
#plotthis[plotthise > 0.1]= numpy.nan
maps.plot(plotthis,vmin=0.,vmax=0.5,minnstar=15,zlabel=r'$\beta_2$')
maps.plot(plotthishz*1000.,vmin=0.,vmax=1000.,minnstar=15,zlabel=r'$h_{Z,2}\,(\mathrm{pc})$')
print numpy.nanmedian(plotthis)
In [174]:
plotthisz= numpy.zeros(len(bf))+numpy.nan
plotthisze= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
tmed= numpy.nanmedian(1./samples_twoexp[ii,1])
terr= numpy.nanstd(1./samples_twoexp[ii,1])
plotthisz[ii]= tmed
plotthisze[ii]= terr
plotthisz[plotthisze/plotthisz > 0.2]= numpy.nan
maps.plot(plotthisz*1000.,
vmin=200.,vmax=1000.,
minnstar=15,
zlabel=r'$h_Z\,(\mathrm{pc})$',
shrink=1.)
Out[174]:
In [207]:
figsize(5,5)
plotthisfrac= numpy.zeros(len(bf))+numpy.nan
plotthisfrace= numpy.zeros(len(bf))+numpy.nan
plotthisnhz= numpy.zeros(len(bf))+numpy.nan
plotthisnhze= numpy.zeros(len(bf))+numpy.nan
plotthishz= numpy.zeros(len(bf))+numpy.nan
plotthishze= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
hzindx= densprofiles.ilogit(samples_twoexp[ii,4]) > 0.1
tmed= numpy.nanmedian(samples_twoexp[ii,1,hzindx]/samples_twoexp[ii,5,hzindx])
terr= numpy.nanstd(samples_twoexp[ii,1,hzindx]/samples_twoexp[ii,5,hzindx])
plotthisfrac[ii]= tmed
plotthisfrace[ii]= terr
if numpy.nanmedian(numpy.exp(samples[ii,3])) < 5.:
tmed= numpy.nanmedian(1./samplesnf[ii,1])
terr= numpy.nanstd(1./samplesnf[ii,1])
else:
tmed= numpy.nanmedian(1./samplesff[ii,1])
terr= numpy.nanstd(1./samplesff[ii,1])
plotthishz[ii]= tmed
plotthishze[ii]= terr
plotthisfrac[plotthishze/plotthishz > 0.2]= numpy.nan
#plotthisfrac[plotthisfrace/plotthisfrac > 2.]= numpy.nan
maps.plot(plotthisfrac,vmin=0.,vmax=2.,minnstar=15,zlabel=r'$h_{Z,2}\,(\mathrm{pc})$')
maps.plot(plotthisfrace,vmin=0.,vmax=2.,minnstar=15,zlabel=r'$h_{Z,2}\,(\mathrm{pc})$')
print numpy.nanmedian(plotthisfrac)
In [252]:
figsize(6,6)
plotthisz1= numpy.zeros(len(bf))+numpy.nan
plotthisz1e= numpy.zeros(len(bf))+numpy.nan
plotthisz2= numpy.zeros(len(bf))+numpy.nan
plotthisz2e= numpy.zeros(len(bf))+numpy.nan
for ii, map in enumerate(maps.map()):
hzindx= densprofiles.ilogit(samples_twoexp[ii,4]) > 0.15
tmed= numpy.nanmedian(1./samples_twoexp[ii,1,hzindx])
terr= numpy.nanstd(1./samples_twoexp[ii,1,hzindx])
plotthisz1[ii]= tmed
plotthisz1e[ii]= terr
tmed= numpy.nanmedian(1./samples_twoexp[ii,5,hzindx])
terr= numpy.nanstd(1./samples_twoexp[ii,5,hzindx])
plotthisz2[ii]= tmed
plotthisz2e[ii]= terr
plotthisz1[plotthisz1e/plotthisz1 > 0.5]= numpy.nan
plot(plotthisz2*1000.,plotthisz1*1000.,'ko')
errorbar(plotthisz2*1000.,plotthisz1*1000.,
yerr=plotthisz1e*1000.,
marker='o',color='k',ls='none')
plot((0,2000),(0,2000),'k-')
xlim(0.,1200.)
ylim(0.,1200.)
maps.plot(plotthisz1*1000.,vmin=200.,vmax=1000.,minnstar=15,zlabel=r'$h_{Z,2}\,(\mathrm{pc})$')
Out[252]:
In [1]:
import sys
import pickle
import numpy
from galpy.util import bovy_plot
from matplotlib import cm
import define_rcsample
import os
from matplotlib import cm
import extreme_deconvolution as XD
os.environ['OMP_NUM_THREADS']= '1'
In [2]:
with open('../mapfits/tribrokenexpflare.sav','rb') as savefile:
bf= numpy.array(pickle.load(savefile))
samples= numpy.array(pickle.load(savefile))
maps= define_rcsample.MAPs()
In [4]:
plotmaps= [9,16,23,29,36,43,50,57,64,71]
cmap= cm.coolwarm
xrange= [-0.4,0.2]
overplot= False
plotXDFit= True
ngauss= 2
allxamp= numpy.empty((len(plotmaps),ngauss))
allxmean= numpy.empty((len(plotmaps),ngauss,1))
allxcovar= numpy.empty((len(plotmaps),ngauss,1,1))
cnt= 0
for ii, map in enumerate(maps.map()):
if not ii in plotmaps: continue
tfeh= round(numpy.median(map['FE_H'])*20.)/20.
if tfeh == 0.35: tfeh= 0.4
if tfeh == -0.0: tfeh= 0.0
print tfeh
bovy_plot.bovy_hist(samples[ii,4],range=xrange,bins=51,overplot=overplot,
histtype='step',normed=True,zorder=2,
color=cmap((tfeh+0.5)*0.95/0.9+0.05))
# Fit PDFs with XD
xamp= numpy.array([0.45,0.5])
xmean= numpy.array([numpy.mean(samples[ii,4])+numpy.random.normal()*numpy.std(samples[ii,4]),
numpy.mean(samples[ii,4])+numpy.random.normal()*numpy.std(samples[ii,4])])[:,numpy.newaxis]
xcovar= numpy.reshape(numpy.tile(numpy.var(samples[ii,4]),(2,1)),(2,1,1))
XD.extreme_deconvolution(samples[ii,4][:,numpy.newaxis],numpy.zeros((len(samples[ii,4]),1)),
xamp,xmean,xcovar)
allxamp[cnt]= xamp
allxmean[cnt]= xmean
allxcovar[cnt]= xcovar
if plotXDFit:
txs= numpy.linspace(xrange[0],xrange[1],1001)
plot(txs,1./numpy.sqrt(2.*numpy.pi)*(xamp[0]/numpy.sqrt(xcovar[0,0,0])*numpy.exp(-0.5*(txs-xmean[0,0])**2./xcovar[0,0,0])
+xamp[1]/numpy.sqrt(xcovar[1,0,0])*numpy.exp(-0.5*(txs-xmean[1,0])**2./xcovar[1,0,0])),
color=cmap((tfeh+0.5)*0.95/0.9+0.05),zorder=1)
overplot=True
cnt+= 1
txs= numpy.linspace(xrange[0],xrange[1],1001)
comb= numpy.ones_like(txs)
for ii in range(len(plotmaps)):
comb*= 1./numpy.sqrt(2.*numpy.pi)*(allxamp[ii,0]/numpy.sqrt(allxcovar[ii,0,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,0,0])**2./allxcovar[ii,0,0,0])
+allxamp[ii,1]/numpy.sqrt(allxcovar[ii,1,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,1,0])**2./allxcovar[ii,1,0,0]))
comb/= numpy.sum(comb)*(txs[1]-txs[0])
plot(txs,comb/2.,'k-',lw=2.,zorder=20)
Out[4]:
In [6]:
numpy.sum(comb*txs)/numpy.sum(comb), numpy.sqrt(numpy.sum(comb*txs**2.)/numpy.sum(comb)-(numpy.sum(comb*txs)/numpy.sum(comb))**2.)
Out[6]:
In [8]:
plotmaps= [12,19,26,32,39,45]#,51]
cmap= cm.coolwarm
xrange= [-0.3,0.3]
overplot= False
plotXDFit= True
ngauss= 2
allxamp= numpy.empty((len(plotmaps),ngauss))
allxmean= numpy.empty((len(plotmaps),ngauss,1))
allxcovar= numpy.empty((len(plotmaps),ngauss,1,1))
cnt= 0
for ii, map in enumerate(maps.map()):
if not ii in plotmaps: continue
tfeh= round(numpy.median(map['FE_H'])*20.)/20.
if tfeh == 0.35: tfeh= 0.4
if tfeh == -0.0: tfeh= 0.0
print tfeh
bovy_plot.bovy_hist(samples[ii,4],range=xrange,bins=51,overplot=overplot,
histtype='step',normed=True,zorder=2,
color=cmap((tfeh+0.2)*0.65/0.6+0.05))
# Fit PDFs with XD
xamp= numpy.array([0.45,0.5])
xmean= numpy.array([numpy.mean(samples[ii,4])+numpy.random.normal()*numpy.std(samples[ii,4]),
numpy.mean(samples[ii,4])+numpy.random.normal()*numpy.std(samples[ii,4])])[:,numpy.newaxis]
xcovar= numpy.reshape(numpy.tile(numpy.var(samples[ii,4]),(2,1)),(2,1,1))
XD.extreme_deconvolution(samples[ii,4][:,numpy.newaxis],numpy.zeros((len(samples[ii,4]),1)),
xamp,xmean,xcovar)
allxamp[cnt]= xamp
allxmean[cnt]= xmean
allxcovar[cnt]= xcovar
if plotXDFit:
txs= numpy.linspace(xrange[0],xrange[1],1001)
plot(txs,1./numpy.sqrt(2.*numpy.pi)*(xamp[0]/numpy.sqrt(xcovar[0,0,0])*numpy.exp(-0.5*(txs-xmean[0,0])**2./xcovar[0,0,0])
+xamp[1]/numpy.sqrt(xcovar[1,0,0])*numpy.exp(-0.5*(txs-xmean[1,0])**2./xcovar[1,0,0])),
color=cmap((tfeh+0.5)*0.95/0.9+0.05),zorder=1)
overplot=True
cnt+= 1
txs= numpy.linspace(xrange[0],xrange[1],1001)
comb= numpy.ones_like(txs)
for ii in range(len(plotmaps)):
comb*= 1./numpy.sqrt(2.*numpy.pi)*(allxamp[ii,0]/numpy.sqrt(allxcovar[ii,0,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,0,0])**2./allxcovar[ii,0,0,0])
+allxamp[ii,1]/numpy.sqrt(allxcovar[ii,1,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,1,0])**2./allxcovar[ii,1,0,0]))
comb/= numpy.sum(comb)*(txs[1]-txs[0])
plot(txs,comb/2.,'k-',lw=2.,zorder=20)
Out[8]:
In [9]:
numpy.sum(comb*txs)/numpy.sum(comb), numpy.sqrt(numpy.sum(comb*txs**2.)/numpy.sum(comb)-(numpy.sum(comb*txs)/numpy.sum(comb))**2.)
Out[9]:
In [13]:
txs= numpy.linspace(xrange[0],xrange[1],1001)
comb= numpy.ones_like(txs)
for ii in range(len(plotmaps)-1):
comb*= 1./numpy.sqrt(2.*numpy.pi)*(allxamp[ii,0]/numpy.sqrt(allxcovar[ii,0,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,0,0])**2./allxcovar[ii,0,0,0])
+allxamp[ii,1]/numpy.sqrt(allxcovar[ii,1,0,0])*numpy.exp(-0.5*(txs-allxmean[ii,1,0])**2./allxcovar[ii,1,0,0]))
comb/= numpy.sum(comb)*(txs[1]-txs[0])
plot(txs,comb/2.,'k-',lw=2.,zorder=20)
Out[13]:
In [14]:
numpy.sum(comb*txs)/numpy.sum(comb), numpy.sqrt(numpy.sum(comb*txs**2.)/numpy.sum(comb)-(numpy.sum(comb*txs)/numpy.sum(comb))**2.)
Out[14]:
In [ ]: