def run(basename, prof): read_scale() # read in half light radius, Nu0[munit/Rscale^2], Nu0[munit/pc^2], munit print(gp.files.get_scale_file(0)) A = np.loadtxt(gp.files.get_scale_file(0), unpack=False, skiprows=1) gp.rstarhalf = A[0] # halflight radius (all tracer part.s), stored first ("0") # read in radial bins radii, binmin, binmax, nudat1, nuerr1 = gh.readcol5(gp.files.nufiles[0]) gp.xipol = radii*gp.rstarhalf # [pc] maxr = max(radii) radii = np.hstack([radii, 2*maxr, 4*maxr, 8*maxr]) gp.xepol = radii*gp.rstarhalf models = read_models() # use physical representation for profiles profs = [] for i in range(len(models)): M = models[i] tmp_rho = M[0:gp.nepol] off = gp.nipol tmp_nu = M[off:off+gp.nepol] off += gp.nipol tmp_beta = M[off:off+gp.nbeta] # TODO: include handling of N populations try: tmp_prof = physical(gp.xepol, prof, pop, tmp_rho, tmp_nu, tmp_beta) profs.append(tmp_prof) except Exception as detail: print('handling error in profile', detail) continue sortedprofs = gh.sort_profiles_binwise(np.array(profs).transpose()) Mmin, M95lo, M68lo, Mmedi, \ M68hi, M95hi, Mmax = gh.get_median_1_2_sig(sortedprofs) # plot ranges if prof=='rho' or prof=='nu': gpl.startlog(); gpl.xscale('log') else: gpl.start() plot_labels(prof, pop) if prof=='nr': gpl.xscale('log') # gpl.xlim([0.,2.*gp.xipol[-1]]) gp.xipol = np.hstack([gp.xipol[0]/2., gp.xipol, gp.rinfty*gp.xipol[-1]]) if prof=='nu' or prof=='sig': plot_data(gp.xipol, prof, pop) plot_analytic(gp.xepol, prof, pop) radfill = gp.xepol if prof == 'sig': radfill = gp.xipol fill_nice(radfill, M95lo, M68lo, Mmedi, M68hi, M95hi) gpl.savefig(basename+'/prof_'+prof+'_'+str(pop)+'.png') gpl.ion(); gpl.show(); gpl.ioff() return
# sigma_r^2 # gpl.plot(r0, sig_r_2_anf(r0, ascale, Mscale), color='green', lw=1) siglosself, kappaself = ant_sigkaplos2surf(r0, betaanf, intbetaanf, rhoanf, nuanf) gpl.plot(r0, siglosself, ".", color="orange", label=r"$\sigma_p*\Sigma$") siganf = Sigma_sig_los_2_anf(r0, ascale, Mscale) gpl.plot(r0, siganf, color="orange", lw=1) # sigma_LOS^2 siglosanf = sig_los_anf(r0, ascale, Mscale) gpl.plot(r0, siglosanf, color="black", lw=1) gpl.plot(r0, np.sqrt(siglosself / Rhoself), ".", color="black", label=r"$\sigma_p$") # Now add the legend with some customizations. legend = gpl.legend(loc="lower left", shadow=True) # The frame is matplotlib.patches.Rectangle instance surrounding the legend. frame = legend.get_frame() frame.set_facecolor("0.90") print("error fraction determined/true = ", (siglosself / Rhoself) / siglosanf) # gpl.plot(r0, kappa_anf(r0)) # gpl.plot(r0, (kappaself/Rhoself)/(np.sqrt(siglosself/Rhoself)**4)) gpl.savefig("integration_siglos_disturbed.png") gpl.ioff() gpl.show()