kwargs_for_spectrum = {'poiss_list_is_log_prior': [False,False,False,False,False], 'poiss_list_prior_range': [[0,2],[0,2],[0,2],[-5,5],[-5,5]], 'make_triangle': True, 'spectrum_run_tag': 'compute_spectrum_example','spectrum_plots_dir':run_tag + '-spect'}
b.initiate_spectrum(over_ride_saved_spectrum = False,**kwargs_for_spectrum)
b.configure_for_scan()

##########################################
#Poissonian likelihood
b.initiate_poissonian() #we are going to do a poissonian LL scan

##########################################
#perform scan and load scan
b.perform_scan(run_tag = run_tag)
b.load_scan(run_tag = run_tag)

##########################################
#the dictionary
a = ar(b.dict_dir,b.run_tag)

##########################################
#mask for plots
a.set_mask_total(band_mask_range = [-30,30],mask_ring = False)

a.make_triangle(plot_name = "triangle_poiss_high_Lat.pdf")

the_spectrum_diff = a.return_spectrum_conf_int(0,quant  = [0.16,0.5,0.84])
the_spectrum_bubs = a.return_spectrum_conf_int(1,quant  = [0.16,0.5,0.84])
the_spectrum_iso = a.return_spectrum_conf_int(2,quant  = [0.16,0.5,0.84])
the_spectrum_ps = a.return_spectrum_conf_int(3,quant  = [0.16,0.5,0.84])
the_spectrum_2mass = a.return_spectrum_conf_int(4,quant  = [0.16,0.5,0.84])
print 'The 68 percent confidence interval for the [diff,bubs,iso,ps,2mass] spectra in this energy range are ', the_spectrum_diff,the_spectrum_bubs,the_spectrum_iso, the_spectrum_ps , the_spectrum_2mass,'with units GeV/cm^2/s/sr'

b.configure_for_scan()

##########################################
#Non-Poissonian likelihood
iso_PS_location = 2
b.initiate_1_ps(ps_location=iso_PS_location)

##########################################
#perform scan and load scan
b.perform_scan(run_tag = run_tag) #if you have already performed the scan and you want to redo an anlysis or do a new analysis, you can comment out perform_scan and only do load_scan.  Or, you can just use the dictionary through the class analyze_results (ar)
b.load_scan(run_tag = run_tag)


##########################################
#the dictionary
a = ar(b.dict_dir,b.run_tag) #load the dictionary for analysis

a.set_mask_total(band_mask_range = [-30,30],mask_ring = False) #the mask for the analysis

a.make_triangle(plot_name = "triangle_nptf_high_Lat.pdf") #make a triangle plot

the_spectrum_diff = a.return_spectrum_conf_int(0,quant  = [0.16,0.5,0.84])
the_spectrum_bubs = a.return_spectrum_conf_int(1,quant  = [0.16,0.5,0.84])
the_spectrum_iso = a.return_spectrum_conf_int(2,quant  = [0.16,0.5,0.84])
the_spectrum_ps = a.return_spectrum_conf_int(3,quant  = [0.16,0.5,0.84])
print 'The 68 percent confidence interval for the [diff,bubs,iso,ps] spectra in this energy range are ', the_spectrum_diff,the_spectrum_bubs,the_spectrum_iso, the_spectrum_ps ,'with units GeV/cm^2/s/sr'

the_spectrum = a.return_non_poiss_spectrum_conf_int(0)
print 'The 68 percent confidence interval for the unresolved PS spectrum in this energy range is ', the_spectrum, 'with units GeV/cm^2/s/sr'