nugrid_set.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:NuGridPy 作者: NuGrid 项目源码 文件源码
def set_plot_profile_decay(self,cycles=20*[-1],mass_range=20*[[0,0]],ylim=20*[[0,0]],isotopes=[],linestyle=[],save_dir=''): 
        '''
            Plots HRDs


            end_model - array, control how far in models a run is plottet, if -1 till end
            symbs_1  - set symbols of runs
        '''
        if len(linestyle)==0:
            linestyle=200*['-']
        import nugridse as mp
        import utils as u
        #print self.runs_H5_restart
                for i in range(len(self.runs_H5_restart)):
                sefiles=mp.se(self.runs_H5_restart[i])
            cycle=cycles[i]
                        if cycle==-1:
                                cycle=int(sefiles.se.cycles[-1])            
            if mass_range[i][0] ==0 and mass_range[i][1]==0:
                mass_range[i][1]=sefiles.get(cycle,'mass')[-1]              
            sefiles.read_iso_abund_marco(mass_range[i],cycle)
                u.stable_specie()
                sefiles.decay(sefiles.mass_frac)
            idx_species=[]
            for k in range(len(isotopes)):
                other_name_scheme=isotopes[k].split("-")[0].upper()+(5-len(isotopes[k])+1)*" "+isotopes[k].split("-")[1]
                #other_name_scheme=other_name_scheme.capitalize()

                idx_specie=u.back_ind[other_name_scheme]
                idx_species.append(idx_specie)
            mass_abu_array=[]
            for idx_specie in idx_species:
                mass_abu_array.append([])
                for idx_mass in range(len(mp.decayed_multi_d)):
                    mass_abu_array[-1].append(mp.decayed_multi_d[idx_mass][idx_specie])

            #plotting
            plt.figure(self.run_dirs_name[i])
            #print len(mp.used_masses),len(mass_abu_array[0])
            #print mass_abu_array[0]
            for k in range(len(isotopes)):
                plt.plot(mp.used_masses,mass_abu_array[k],linestyle=linestyle[k],label=isotopes[k])
            plt.legend()
            plt.yscale('log')
            #print sefiles.get(cycle,'mass')[-1]
            plt.xlabel('M/Msun')
            plt.ylabel('$X_i$')
            plt.xlim(mass_range[i][0],mass_range[i][1])
            if (ylim[i][0]>0 or ylim[i][1]>0) or (ylim[i][0]>0 and ylim[i][1]>0):
                plt.ylim(ylim[i][0],ylim[i][1])
            if len(save_dir)>0:
                star_mass=sefiles.get("mini")
                star_z=sefiles.get("zini")
                plt.savefig(save_dir+'/'+self.run_dirs_name[i]+'_decay_profiles.png')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号