if poiss: spect_dir = work_dir + 'data/spect/' if not os.path.exists(spect_dir): os.mkdir(spect_dir) cs = fa.compute_spectra(b,run_tag_energy,f.CTB_en_bins[0],f.CTB_en_bins[-1],band_mask_range = [-mask_b_plot,mask_b_plot],mask_ring = True,outer=outer_plot) #spectra over whole energy range cs.mask_total_dict['bubs']=np.logical_not(b.templates_dict_nested['bubs']['summed_templates_not_compressed']) cs.make_spectra_dict() cs.make_norm_dict() if save_spect_label != 'False' or save_spect_label != 'false': cs.save_spectra_dict(spect_dir + save_spect_label,emin,emax,over_write= False) if save_norm_label != 'False' or save_norm_label != 'false': cs.save_norm_dict(spect_dir + save_norm_label,emin,emax,over_write= False) ##plot flux fraction plt.figure(figsize=(8,6)) pflux = fa.plot_flux_fraction(b,band_mask_range = [-mask_b_plot,mask_b_plot], mask_ring = True, outer = outer_plot) pflux.plot_flux_fraction_poiss('nfw',color_vert = 'Red',drawstyle='steps-mid',label = 'NFW DM',color='Red') plt.legend(fontsize=18) plt.xlabel('fraction of flux [%]', fontsize=18) plt.ylabel('posterior probability', fontsize=18) plt.tick_params(axis='x', length=5,width=2,labelsize=18) plt.tick_params(axis='y', length=5,width=2,labelsize=18) plt.ylabel('posterior probability', fontsize=18) plt.ylim(0, 0.25) plt.xlim(0, 20.3) plt.savefig(b.plots_dir_for_run + 'flux_fraction_plot.pdf') plt.close() else: ###plot dn/ds p3FGL = fa.plot_3FGL(f,band_mask_range = [-mask_b_plot,mask_b_plot], mask_ring = True, outer = outer_plot) p3FGL.configure_3FGL(flux_min=10**-12,flux_max=10**-9,n_flux_bins = 25,only_gal = True,error_range = 0.68) #flux_min=10**-11,flux_max=10**-8,
def plot_flux_fractions(): kwargs_spectrum={ 'band_mask_range': [-pmval,pmval],'mask_ring': mask_ring, 'outer': outer_plot} bins=250 if just_disk: #####Disk Only print 'Computing flux fractions for NFW-DM and Disk PS only' plt.figure(figsize=(8,6)) pff=fa.plot_flux_fraction(b_disk,**kwargs_spectrum) pff.plot_flux_fraction_non_poiss('disk',bins=bins,nsteps=2000,label='Disk-PS',color_vert='green',color='green',drawstyle='steps') print 'Disk: ', pff.qvalues_comp pff.plot_flux_fraction_poiss('nfw-0',bins=bins,color_vert='red',color='red',label='NFW-DM',drawstyle='steps') print 'NFW-DM: ', pff.qvalues_comp plt.xlim([0,20]) plt.ylim([0,0.25]) plt.legend(fontsize=16) plt.tick_params(axis='x', length=5,width=2,labelsize=18) plt.tick_params(axis='y',length=5,width=2,labelsize=18) plt.xlabel('fraction of flux [%]', fontsize=18) plt.ylabel('posterior probability', fontsize=18) plt.title('3FGL masked') plt.savefig(b_disk.plots_dir_for_run + 'flux_fraction.pdf',bbox_inches='tight') plt.close() if poiss: ####No PSs print 'Computing flux fractions for Poiss only' plt.figure(figsize=(8,6)) pff=fa.plot_flux_fraction(b_poiss,**kwargs_spectrum) pff.plot_flux_fraction_poiss('nfw-0',bins=bins,color_vert='red',color='red',label='NFW-DM',drawstyle='steps') print 'NFW-DM: ', pff.qvalues_comp plt.xlim([0,15]) plt.ylim([0,0.25]) plt.legend(fontsize=16) plt.tick_params(axis='x', length=5,width=2,labelsize=18) plt.tick_params(axis='y',length=5,width=2,labelsize=18) plt.xlabel('fraction of flux [%]', fontsize=18) plt.ylabel('posterior probability', fontsize=18) plt.title('3FGL masked') plt.savefig(b_poiss.plots_dir_for_run + 'flux_fraction.pdf',bbox_inches='tight') plt.close() if plus_IPS: print 'Computing flux fractions for Disk, NFW, iso PSs and NFW DM' plt.figure(figsize=(8,6)) pff=fa.plot_flux_fraction(b_plus_IPS,**kwargs_spectrum) pff.plot_flux_fraction_non_poiss('disk',bins=bins,nsteps=2000,label='Disk-PS',color_vert='green',color='green',drawstyle='steps') print 'Disk: ', pff.qvalues_comp pff.plot_flux_fraction_non_poiss('nfw',bins=bins,nsteps=2000,label='NFW-PS',color='blue',color_vert='blue',drawstyle='steps') print 'NFW-PS: ', pff.qvalues_comp pff.plot_flux_fraction_poiss('nfw-0',bins=bins,color_vert='red',color='red',label='NFW-DM',drawstyle='steps') print 'NFW-DM: ', pff.qvalues_comp plt.xlim([0,20]) plt.ylim([0,0.25]) plt.legend(fontsize=16) plt.tick_params(axis='x', length=5,width=2,labelsize=18) plt.tick_params(axis='y',length=5,width=2,labelsize=18) plt.xlabel('fraction of flux [%]', fontsize=18) plt.ylabel('posterior probability', fontsize=18) plt.title('3FGL masked') plt.savefig(b_plus_IPS.plots_dir_for_run + 'flux_fraction.pdf',bbox_inches='tight') plt.close()
def plot_flux_fractions(): kwargs_spectrum = {"band_mask_range": band_mask_range, "mask_ring": mask_ring, "outer": outer_plot} bins = 250 if just_disk: #####Disk Only print "Computing flux fractions for NFW-DM and Disk PS only" plt.figure(figsize=(8, 6)) pff = fa.plot_flux_fraction(b_disk, **kwargs_spectrum) pff.plot_flux_fraction_non_poiss( "disk", bins=bins, nsteps=2000, label="Disk-PS", color_vert="green", color="green", drawstyle="steps" ) print "Disk: ", pff.qvalues_comp pff.plot_flux_fraction_non_poiss( "iso", bins=bins, nsteps=2000, label="Iso-PS", color_vert="orange", color="orange", drawstyle="steps" ) print "iso-ps: ", pff.qvalues_comp pff.plot_flux_fraction_poiss( "nfw-0", bins=bins, color_vert="red", color="red", label="NFW-DM", drawstyle="steps" ) print "NFW-DM: ", pff.qvalues_comp plt.xlim([0, 20]) plt.ylim([0, 0.25]) plt.legend(fontsize=16) plt.tick_params(axis="x", length=5, width=2, labelsize=18) plt.tick_params(axis="y", length=5, width=2, labelsize=18) plt.xlabel("fraction of flux [%]", fontsize=18) plt.ylabel("posterior probability", fontsize=18) plt.title("3FGL masked") plt.savefig(b_disk.plots_dir_for_run + "flux_fraction.pdf", bbox_inches="tight") plt.close() if poiss: ####No PSs print "Computing flux fractions for Poiss only" plt.figure(figsize=(8, 6)) pff = fa.plot_flux_fraction(b_poiss, **kwargs_spectrum) pff.plot_flux_fraction_poiss( "nfw-0", bins=bins, color_vert="red", color="red", label="NFW-DM", drawstyle="steps" ) print "NFW-DM: ", pff.qvalues_comp plt.xlim([0, 15]) plt.ylim([0, 0.25]) plt.legend(fontsize=16) plt.tick_params(axis="x", length=5, width=2, labelsize=18) plt.tick_params(axis="y", length=5, width=2, labelsize=18) plt.xlabel("fraction of flux [%]", fontsize=18) plt.ylabel("posterior probability", fontsize=18) plt.title("3FGL masked") plt.savefig(b_poiss.plots_dir_for_run + "flux_fraction.pdf", bbox_inches="tight") plt.close() if plus_IPS: print "Computing flux fractions for Disk, NFW, iso PSs and NFW DM" plt.figure(figsize=(8, 6)) pff = fa.plot_flux_fraction(b_plus_IPS, **kwargs_spectrum) pff.plot_flux_fraction_non_poiss( "disk", bins=bins, nsteps=2000, label="Disk-PS", color_vert="green", color="green", drawstyle="steps" ) print "Disk: ", pff.qvalues_comp pff.plot_flux_fraction_non_poiss( "nfw", bins=bins, nsteps=2000, label="NFW-PS", color="blue", color_vert="blue", drawstyle="steps" ) print "NFW-PS: ", pff.qvalues_comp pff.plot_flux_fraction_non_poiss( "iso", bins=bins, nsteps=2000, label="iso-PS", color="orange", color_vert="orange", drawstyle="steps" ) print "iso-PS: ", pff.qvalues_comp pff.plot_flux_fraction_poiss( "nfw-0", bins=bins, color_vert="red", color="red", label="NFW-DM", drawstyle="steps" ) print "NFW-DM: ", pff.qvalues_comp plt.xlim([0, 20]) plt.ylim([0, 0.25]) plt.legend(fontsize=16) plt.tick_params(axis="x", length=5, width=2, labelsize=18) plt.tick_params(axis="y", length=5, width=2, labelsize=18) plt.xlabel("fraction of flux [%]", fontsize=18) plt.ylabel("posterior probability", fontsize=18) plt.title("3FGL masked") plt.savefig(b_plus_IPS.plots_dir_for_run + "flux_fraction.pdf", bbox_inches="tight") plt.close()