def set_plot_core_lum_relation(self,symb='o',linestyle='--',sparsity=500,label=''):
'''
Plots the core luminosity relation. Mean core mass
from first TP till last TP in model steps of sparsity
Mean lum derived first TP to last TP in model steps of sparsity
time-weighted averages
'''
m=self.run_historydata
core_mean=[]
lum=[]
for case in m:
peak_lum_model,h1_mass_min_DUP_model=case.find_TP_attributes(t0_model=case.find_first_TP(),fig=3, color='r', marker_type='o')
modelrange=range(int(peak_lum_model[0]),int(peak_lum_model[-1]+sparsity),int(sparsity))
core_mean1=[]
lum1=[]
#weight for mean value
ages=case.get('star_age')
weight_sum=0.
for h in range(len(modelrange)):
mod=modelrange[h]
if h==0:
weight=(ages[modelrange[h+1]] - ages[mod])/2.
elif h == len(modelrange)-1:
weight=(ages[mod]-ages[modelrange[h-1]])/2.
else:
weight=(ages[modelrange[h+1]] - ages[mod])/2. + (ages[mod]-ages[modelrange[h-1]])/2.
weight_sum+=weight
core_mean1.append(case.get('h1_boundary_mass')[mod]*weight)
lum1.append(case.get('log_L')[mod]*weight)
core_mean.append(sum(core_mean1)/weight_sum)
lum.append(sum(lum1)/weight_sum)
plt.plot(core_mean,lum,marker=symb,linestyle=linestyle,label=label)
print core_mean,lum
plt.xlabel("M/M$_{\odot}$")
plt.ylabel('log L/L$_{\odot}$')
评论列表
文章目录