Skip to content

Commit

Permalink
fix the Npred problem
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsanchez committed Mar 31, 2017
1 parent fee0997 commit 9d1fffd
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions enrico/lightcurve.py
Expand Up @@ -239,12 +239,8 @@ def _PlotLC(self,folded=False):
# Find name used for index parameter
if (self.config['target']['spectrum'] == 'PowerLaw' or
self.config['target']['spectrum'] == 'PowerLaw2'):
if float(self.config['target']['redshift'])==0:
IndexName = 'Index'
CutoffName = None
else:
IndexName = 'alpha'
CutoffName = None
elif (self.config['target']['spectrum'] == 'PLExpCutoff' or
self.config['target']['spectrum'] == 'PLSuperExpCutoff'):
IndexName = 'Index1'
Expand Down Expand Up @@ -315,16 +311,18 @@ def _PlotLC(self,folded=False):
CanvNpred = _GetCanvas()
gTHNpred.Draw()
TgrNpred.Draw('zP')

_,TgrNpred_detected = plotting.PlotNpred(Npred_detected,Flux[Npred_detected_indices],FluxErrForNpred[Npred_detected_indices])
TgrNpred_detected.SetLineColor(2)
TgrNpred_detected.SetMarkerColor(2)
TgrNpred_detected.Draw('zP')
fittedFunc.Draw("SAME")

CanvNpred.Print(LcOutPath+"_Npred.png")
CanvNpred.Print(LcOutPath+"_Npred.eps")
CanvNpred.Print(LcOutPath+"_Npred.C")
if len(Npred_detected)>0:
TgrNpred_detected = plotting.PlotNpred(Npred_detected,Flux[Npred_detected_indices],FluxErrForNpred[Npred_detected_indices])
TgrNpred_detected.SetLineColor(2)
TgrNpred_detected.SetMarkerColor(2)
TgrNpred_detected.Draw('zP')
fittedFunc.Draw("SAME")

CanvNpred.Print(LcOutPath+"_Npred.png")
CanvNpred.Print(LcOutPath+"_Npred.eps")
CanvNpred.Print(LcOutPath+"_Npred.C")
else :
print "No Npred Plot produced"

gTHTS,TgrTS = plotting.PlotTS(Time,TimeErr,TS)
CanvTS = _GetCanvas()
Expand Down Expand Up @@ -415,15 +413,18 @@ def _PlotLC(self,folded=False):
def CheckNpred(self,Npred,Flux,FluxErr,detected_indices):
"""check if the errors are well computed using the Npred/sqrt(Npred) vs Flux/FluxErr relation
and print corresponding point which failled"""
_,TgrNpred = plotting.PlotNpred(Npred[detected_indices],Flux[detected_indices],FluxErr[detected_indices])
func = ROOT.TF1("func","pol1",np.min(np.sqrt(Npred)),np.max(np.sqrt(Npred)))
TgrNpred.Fit(func,"Q")
for i in xrange(len(Flux)):
if Flux[i]/FluxErr[i]>2*func.Eval(sqrt(Npred[i])):
self._errorReading("problem in errors calculation for",i)
print "Flux +/- error = ",Flux[i]," +/- ",FluxErr[i]
print "V(Npred) = ",sqrt(Npred[i])
print

if len(detected_indices) > 0 :
_,TgrNpred = plotting.PlotNpred(Npred[detected_indices],Flux[detected_indices],FluxErr[detected_indices])

TgrNpred.Fit(func,"Q")
for i in xrange(len(Flux)):
if Flux[i]/FluxErr[i]>2*func.Eval(sqrt(Npred[i])):
self._errorReading("problem in errors calculation for",i)
print "Flux +/- error = ",Flux[i]," +/- ",FluxErr[i]
print "V(Npred) = ",sqrt(Npred[i])
print
func.SetLineColor(15)
func.SetLineStyle(2)
return func
Expand Down

0 comments on commit 9d1fffd

Please sign in to comment.