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 | 45 | def info(self,message,newline=True): |
| 46 | 46 | printstring = self.infocolor+"["+self.classname+"]: "+message+self.endcolor |
| 47 | 47 | if newline: |
| 48 | - print printstring | |
| 48 | + print(printstring) | |
| 49 | 49 | else: |
| 50 | - print self.infocolor+message+self.endcolor, | |
| 50 | + print(self.infocolor+message+self.endcolor) | |
| 51 | 51 | sys.stdout.flush() |
| 52 | 52 | |
| 53 | 53 | def warning(self,message,functionname = ""): |
| ... | ... | @@ -56,15 +56,15 @@ class base(object): |
| 56 | 56 | printstring = self.warningcolor+"["+self.classname+"] Warning: "+message+self.endcolor |
| 57 | 57 | else: |
| 58 | 58 | printstring = self.warningcolor+"["+self.classname+"::"+functionname+"] Warning: "+message+self.endcolor |
| 59 | - print printstring | |
| 59 | + print(printstring) | |
| 60 | 60 | |
| 61 | 61 | def success(self,message): |
| 62 | 62 | printstring = self.successcolor+"["+self.classname+"]: "+message+self.endcolor |
| 63 | - print printstring | |
| 63 | + print(printstring) | |
| 64 | 64 | |
| 65 | 65 | def progress(self,message="."): |
| 66 | 66 | string = self.infocolor+message+self.endcolor |
| 67 | - print string | |
| 67 | + print(string) | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | class ResultsSorage(dict,base): |
| ... | ... | @@ -104,10 +104,10 @@ class ResultsSorage(dict,base): |
| 104 | 104 | self.info("Key name : "+k) |
| 105 | 105 | try : |
| 106 | 106 | for ki in self[k].iterkeys(): |
| 107 | - print "\t",ki,"\t",self[k][ki] | |
| 107 | + print("\t",ki,"\t",self[k][ki]) | |
| 108 | 108 | except: |
| 109 | - print self[k] | |
| 110 | ||
| 109 | + print(self[k]) | |
| 110 | + print() | |
| 111 | 111 | |
| 112 | 112 | class Analyser(base): |
| 113 | 113 | def __init__(self): |
| ... | ... | @@ -332,8 +332,8 @@ class Analyser(base): |
| 332 | 332 | self.info("Results of the Fit") |
| 333 | 333 | for m in self.like.obs().models(): |
| 334 | 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 | 338 | def GetSrcResuls(self,Res,srcname,E0=None,factor = 1e6,tmin=None,tmax=None): |
| 339 | 339 | """function to get and store the results of a fit""" |
| ... | ... | @@ -417,7 +417,7 @@ def MakeEbin(analyse,nbins,srcname,binned = False): |
| 417 | 417 | emin = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*i) |
| 418 | 418 | emax = pow(10,log10(analyse.m_emin) + (log10(analyse.m_emax)-log10(analyse.m_emin))/(nbins)*(i+1)) |
| 419 | 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 | 422 | # change the PivotEnergy to E0 |
| 423 | 423 | m = obs_copy.models()[srcname] |
| ... | ... | @@ -463,7 +463,7 @@ def MakeLC(analyse,nbins,srcname,binned = False): |
| 463 | 463 | obs_copy = analyse.like.obs().copy() |
| 464 | 464 | tmin = analyse.m_tmin + (analyse.m_tmax-analyse.m_tmin)/(nbins)*i |
| 465 | 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 | 468 | ana_bin = Analyser() |
| 469 | 469 | ... | ... |
pyext/ctools/plotutils.py
| ... | ... | @@ -219,11 +219,11 @@ class LightCurvePlotter(analysisutils.base,options): |
| 219 | 219 | unit = self.m_data["Iflux"]["unit"] |
| 220 | 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 | 227 | plt.errorbar(time,flux,xerr=[dtime,dtime],yerr=[dflux_ed,dflux_eu],fmt=self.fmt,color=self.markercolor,elinewidth=self.elinewidth) |
| 228 | 228 | plt.show() |
| 229 | 229 | ... | ... |