Commit b536a10865d9d1ae99739dc0ea4d2936c87dcfcf

Authored by Josh Cardenzana
1 parent 77d33993

(#2925) Add 'fits' parameter to 'plot_residuals()'

Allows generating residuals plots without having to save csresspec output
Showing 1 changed file with 6 additions and 3 deletions
examples/show_residuals.py
@@ -135,7 +135,7 @@ def fill_cmr(row, counts, model, resid, e_counts, e_resid, c_counts, c_model, @@ -135,7 +135,7 @@ def fill_cmr(row, counts, model, resid, e_counts, e_resid, c_counts, c_model,
135 # ====================== # 135 # ====================== #
136 # Plot residual spectrum # 136 # Plot residual spectrum #
137 # ====================== # 137 # ====================== #
138 -def plot_residuals(filename, plotfile, hdu): 138 +def plot_residuals(filename, plotfile, hdu, fits=None):
139 """ 139 """
140 Plot spectrum 140 Plot spectrum
141 141
@@ -147,9 +147,12 @@ def plot_residuals(filename, plotfile, hdu): @@ -147,9 +147,12 @@ def plot_residuals(filename, plotfile, hdu):
147 Plot file name 147 Plot file name
148 hdu : int 148 hdu : int
149 Number of observation to plot 149 Number of observation to plot
  150 + fits : `~gammalib.GFits`
  151 + GFits object containing csresspec results
150 """ 152 """
151 - # Read spectrum file  
152 - fits = gammalib.GFits(filename) 153 + # Read spectrum file
  154 + if fits is None:
  155 + fits = gammalib.GFits(filename)
153 table = fits.table(1 + hdu) 156 table = fits.table(1 + hdu)
154 c_emin = table['Emin'] 157 c_emin = table['Emin']
155 c_emax = table['Emax'] 158 c_emax = table['Emax']