Commit 2a8224a6c4aaa366e0e2f0faf9e9e358f6bbde6e

Authored by Jürgen Knödlseder
1 parent 53d9a3d7

Integrate script.

Showing 1 changed file with 15 additions and 16 deletions
scripts/cslightcrv.py
@@ -133,8 +133,7 @@ class cslightcrv(ctools.cscript): @@ -133,8 +133,7 @@ class cslightcrv(ctools.cscript):
133 133
134 # Return 134 # Return
135 return 135 return
136 -  
137 - 136 +
138 def create_tbounds(self): 137 def create_tbounds(self):
139 138
140 # Create time bin container 139 # Create time bin container
@@ -156,8 +155,8 @@ class cslightcrv(ctools.cscript): @@ -156,8 +155,8 @@ class cslightcrv(ctools.cscript):
156 # Use linear time binning 155 # Use linear time binning
157 time_min = self["tmin"].real() 156 time_min = self["tmin"].real()
158 time_max = self["tmax"].real() 157 time_max = self["tmax"].real()
159 - nbins = self["tbins"].integer()  
160 - step = (time_max - time_min) / float(nbins) 158 + nbins = self["tbins"].integer()
  159 + step = (time_max - time_min) / float(nbins)
161 for i in range(nbins): 160 for i in range(nbins):
162 tmin = gammalib.GTime() 161 tmin = gammalib.GTime()
163 tmin.mjd(time_min + i*step)# ref) 162 tmin.mjd(time_min + i*step)# ref)
@@ -171,8 +170,10 @@ class cslightcrv(ctools.cscript): @@ -171,8 +170,10 @@ class cslightcrv(ctools.cscript):
171 self.m_tbins.append(obs.events().gti().tstart(i),obs.events().gti().tstop(i)) 170 self.m_tbins.append(obs.events().gti().tstart(i),obs.events().gti().tstop(i))
172 else: 171 else:
173 raise AttributeError("tbinalg=\""+self["tbinalg"].string()+"\" unkown. Must be one of \"FILE\", \"LIN\" or \"GTI\"") 172 raise AttributeError("tbinalg=\""+self["tbinalg"].string()+"\" unkown. Must be one of \"FILE\", \"LIN\" or \"GTI\"")
  173 +
  174 + # Return
  175 + return
174 176
175 -  
176 def get_parameters(self): 177 def get_parameters(self):
177 """ 178 """
178 Get parameters from parfile and setup the observation. 179 Get parameters from parfile and setup the observation.
@@ -205,7 +206,6 @@ class cslightcrv(ctools.cscript): @@ -205,7 +206,6 @@ class cslightcrv(ctools.cscript):
205 self.m_ebins = self["nebins"].integer() 206 self.m_ebins = self["nebins"].integer()
206 self.m_emin = self["emin"].real() 207 self.m_emin = self["emin"].real()
207 self.m_emax = self["emax"].real() 208 self.m_emax = self["emax"].real()
208 -  
209 209
210 # Read other parameters 210 # Read other parameters
211 self.m_outfile = self["outfile"].filename() 211 self.m_outfile = self["outfile"].filename()
@@ -309,7 +309,7 @@ class cslightcrv(ctools.cscript): @@ -309,7 +309,7 @@ class cslightcrv(ctools.cscript):
309 self.log("\n") 309 self.log("\n")
310 self.log.header1("Generate lightcurve") 310 self.log.header1("Generate lightcurve")
311 311
312 - # Initialise FITS Table with extension "SPECTRUM" 312 + # Initialise FITS Table with extension "LIGHTCURVE"
313 table = gammalib.GFitsBinTable(self.m_tbins.size()) 313 table = gammalib.GFitsBinTable(self.m_tbins.size())
314 table.extname("LIGHTCURVE") 314 table.extname("LIGHTCURVE")
315 315
@@ -348,14 +348,14 @@ class cslightcrv(ctools.cscript): @@ -348,14 +348,14 @@ class cslightcrv(ctools.cscript):
348 self.log.header2("Time bin "+str(i)) 348 self.log.header2("Time bin "+str(i))
349 349
350 # Get time boundaries 350 # Get time boundaries
351 - tmin = self.m_tbins.tstart(i)  
352 - tmax = self.m_tbins.tstop(i) 351 + tmin = self.m_tbins.tstart(i)
  352 + tmax = self.m_tbins.tstop(i)
353 353
354 - # compute time bin center and time width  
355 - tmean = (tmin + tmax)  
356 - tmean*=0.5  
357 - twidth = (tmax - tmin)  
358 - twidth*=0.5 354 + # Compute time bin center and time width
  355 + tmean = (tmin + tmax)
  356 + tmean *= 0.5
  357 + twidth = (tmax - tmin)
  358 + twidth *= 0.5
359 359
360 # Store time as MJD 360 # Store time as MJD
361 MJD[i] = tmean.mjd() 361 MJD[i] = tmean.mjd()
@@ -501,7 +501,7 @@ class cslightcrv(ctools.cscript): @@ -501,7 +501,7 @@ class cslightcrv(ctools.cscript):
501 501
502 # Set all values to 0 502 # Set all values to 0
503 for col in columns: 503 for col in columns:
504 - col[i] = 0.0 504 + col[i] = 0.0
505 TSvalues[i] = 0.0 505 TSvalues[i] = 0.0
506 ulim_values[i] = 0.0 506 ulim_values[i] = 0.0
507 continue 507 continue
@@ -598,4 +598,3 @@ if __name__ == '__main__': @@ -598,4 +598,3 @@ if __name__ == '__main__':
598 598
599 # Execute application 599 # Execute application
600 app.execute() 600 app.execute()
601 -  
602 \ No newline at end of file 601 \ No newline at end of file