Commit 34fcdde89a27e9ed41a0745645c8643605026a39
1 parent
172f60c6
Correct for Python 3.x.
The script was adapted to comply to Python 3.x syntax.
Showing
2 changed files
with
17 additions
and
17 deletions
pyext/ctools/analysisutils.py
| @@ -45,9 +45,9 @@ class base(object): | @@ -45,9 +45,9 @@ class base(object): | ||
| 45 | def info(self,message,newline=True): | 45 | def info(self,message,newline=True): |
| 46 | printstring = self.infocolor+"["+self.classname+"]: "+message+self.endcolor | 46 | printstring = self.infocolor+"["+self.classname+"]: "+message+self.endcolor |
| 47 | if newline: | 47 | if newline: |
| 48 | - print printstring | 48 | + print(printstring) |
| 49 | else: | 49 | else: |
| 50 | - print self.infocolor+message+self.endcolor, | 50 | + print(self.infocolor+message+self.endcolor) |
| 51 | sys.stdout.flush() | 51 | sys.stdout.flush() |
| 52 | 52 | ||
| 53 | def warning(self,message,functionname = ""): | 53 | def warning(self,message,functionname = ""): |
| @@ -56,15 +56,15 @@ class base(object): | @@ -56,15 +56,15 @@ class base(object): | ||
| 56 | printstring = self.warningcolor+"["+self.classname+"] Warning: "+message+self.endcolor | 56 | printstring = self.warningcolor+"["+self.classname+"] Warning: "+message+self.endcolor |
| 57 | else: | 57 | else: |
| 58 | printstring = self.warningcolor+"["+self.classname+"::"+functionname+"] Warning: "+message+self.endcolor | 58 | printstring = self.warningcolor+"["+self.classname+"::"+functionname+"] Warning: "+message+self.endcolor |
| 59 | - print printstring | 59 | + print(printstring) |
| 60 | 60 | ||
| 61 | def success(self,message): | 61 | def success(self,message): |
| 62 | printstring = self.successcolor+"["+self.classname+"]: "+message+self.endcolor | 62 | printstring = self.successcolor+"["+self.classname+"]: "+message+self.endcolor |
| 63 | - print printstring | 63 | + print(printstring) |
| 64 | 64 | ||
| 65 | def progress(self,message="."): | 65 | def progress(self,message="."): |
| 66 | string = self.infocolor+message+self.endcolor | 66 | string = self.infocolor+message+self.endcolor |
| 67 | - print string | 67 | + print(string) |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | class ResultsSorage(dict,base): | 70 | class ResultsSorage(dict,base): |
| @@ -104,10 +104,10 @@ class ResultsSorage(dict,base): | @@ -104,10 +104,10 @@ class ResultsSorage(dict,base): | ||
| 104 | self.info("Key name : "+k) | 104 | self.info("Key name : "+k) |
| 105 | try : | 105 | try : |
| 106 | for ki in self[k].iterkeys(): | 106 | for ki in self[k].iterkeys(): |
| 107 | - print "\t",ki,"\t",self[k][ki] | 107 | + print("\t",ki,"\t",self[k][ki]) |
| 108 | except: | 108 | except: |
| 109 | - print self[k] | ||
| 110 | 109 | + print(self[k]) | |
| 110 | + print() | ||
| 111 | 111 | ||
| 112 | class Analyser(base): | 112 | class Analyser(base): |
| 113 | def __init__(self): | 113 | def __init__(self): |
| @@ -332,8 +332,8 @@ class Analyser(base): | @@ -332,8 +332,8 @@ class Analyser(base): | ||
| 332 | self.info("Results of the Fit") | 332 | self.info("Results of the Fit") |
| 333 | for m in self.like.obs().models(): | 333 | for m in self.like.obs().models(): |
| 334 | if srcname == m.name() or srcname=="": | 334 | if srcname == m.name() or srcname=="": |
| 335 | - print "Model : "+m.name() | ||
| 336 | - print m | 335 | + print("Model : "+m.name()) |
| 336 | + print(m) | ||
| 337 | 337 | ||
| 338 | def GetSrcResuls(self,Res,srcname,E0=None,factor = 1e6,tmin=None,tmax=None): | 338 | def GetSrcResuls(self,Res,srcname,E0=None,factor = 1e6,tmin=None,tmax=None): |
| 339 | """function to get and store the results of a fit""" | 339 | """function to get and store the results of a fit""" |
| @@ -417,7 +417,7 @@ def MakeEbin(analyse,nbins,srcname,binned = False): | @@ -417,7 +417,7 @@ def MakeEbin(analyse,nbins,srcname,binned = False): | ||
| 417 | emin = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*i) | 417 | emin = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*i) |
| 418 | emax = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*(i+1)) | 418 | emax = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*(i+1)) |
| 419 | E0 = pow(10, (log10(emin) + log10(emax)) / 2) | 419 | E0 = pow(10, (log10(emin) + log10(emax)) / 2) |
| 420 | - print "Making energy bin between %2.1e"%(emin)+analyse.m_eunit+" and %2.1e"%(emax)+analyse.m_eunit | 420 | + print("Making energy bin between %2.1e"%(emin)+analyse.m_eunit+" and %2.1e"%(emax)+analyse.m_eunit) |
| 421 | 421 | ||
| 422 | # change the PivotEnergy to E0 | 422 | # change the PivotEnergy to E0 |
| 423 | m = obs_copy.models()[srcname] | 423 | m = obs_copy.models()[srcname] |
| @@ -463,7 +463,7 @@ def MakeLC(analyse,nbins,srcname,binned = False): | @@ -463,7 +463,7 @@ def MakeLC(analyse,nbins,srcname,binned = False): | ||
| 463 | obs_copy = analyse.like.obs().copy() | 463 | obs_copy = analyse.like.obs().copy() |
| 464 | tmin = analyse.m_tmin + (analyse.m_tmax-analyse.m_tmin)/(nbins)*i | 464 | tmin = analyse.m_tmin + (analyse.m_tmax-analyse.m_tmin)/(nbins)*i |
| 465 | tmax = analyse.m_tmin + (analyse.m_tmax-analyse.m_tmin)/(nbins)*(i+1) | 465 | tmax = analyse.m_tmin + (analyse.m_tmax-analyse.m_tmin)/(nbins)*(i+1) |
| 466 | - print "Making time bin between %2.1e"%(tmin)+" and %2.1e"%(tmax) | 466 | + print("Making time bin between %2.1e"%(tmin)+" and %2.1e"%(tmax)) |
| 467 | 467 | ||
| 468 | ana_bin = Analyser() | 468 | ana_bin = Analyser() |
| 469 | 469 |
pyext/ctools/plotutils.py
| @@ -219,11 +219,11 @@ class LightCurvePlotter(analysisutils.base,options): | @@ -219,11 +219,11 @@ class LightCurvePlotter(analysisutils.base,options): | ||
| 219 | unit = self.m_data["Iflux"]["unit"] | 219 | unit = self.m_data["Iflux"]["unit"] |
| 220 | plt.ylabel("E$^{2}$ dN/dE ["+unit+"]",fontsize=15) | 220 | plt.ylabel("E$^{2}$ dN/dE ["+unit+"]",fontsize=15) |
| 221 | 221 | ||
| 222 | - print time | ||
| 223 | - print dtime | ||
| 224 | - print flux | ||
| 225 | - print dflux_ed | ||
| 226 | - print dflux_eu | 222 | + print(time) |
| 223 | + print(dtime) | ||
| 224 | + print(flux) | ||
| 225 | + print(dflux_ed) | ||
| 226 | + print(dflux_eu) | ||
| 227 | plt.errorbar(time,flux,xerr=[dtime,dtime],yerr=[dflux_ed,dflux_eu],fmt=self.fmt,color=self.markercolor,elinewidth=self.elinewidth) | 227 | plt.errorbar(time,flux,xerr=[dtime,dtime],yerr=[dflux_ed,dflux_eu],fmt=self.fmt,color=self.markercolor,elinewidth=self.elinewidth) |
| 228 | plt.show() | 228 | plt.show() |
| 229 | 229 |