Commit 6549003c95f1e9072f61c7e4aba2dde8a9cdbb20

Authored by Jürgen Knödlseder
1 parent e0744861

Fix cslightcrv (#1920)

ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.2.0 released 3 * Version 1.2.0 released
4 ======================== 4 ========================
5 5
  6 + cslightcrv no longer accepts counts cubes on input (#1920)
6 Set ctbin reference time to CTA reference time (#1922) 7 Set ctbin reference time to CTA reference time (#1922)
7 Change ds9file parameter to outds9file 8 Change ds9file parameter to outds9file
8 Add cssrcdetect script (#1617) 9 Add cssrcdetect script (#1617)
@@ -244,6 +244,9 @@ Improve the upper limit computation in the cslightcrv script. Now all source @@ -244,6 +244,9 @@ Improve the upper limit computation in the cslightcrv script. Now all source
244 parameters, except the source intensity, are set to the initial values given 244 parameters, except the source intensity, are set to the initial values given
245 in the model definition file for upper limit computation. 245 in the model definition file for upper limit computation.
246 246
  247 +The cslightcrv script no longer accepts counts cubes on input as no light
  248 +curves can be derived from counts cubes (#1920).
  249 +
247 250
248 Examples 251 Examples
249 -------- 252 --------
cscripts/cslightcrv.par
@@ -16,13 +16,9 @@ @@ -16,13 +16,9 @@
16 # 16 #
17 # Input and output parameters 17 # Input and output parameters
18 #============================ 18 #============================
19 -inobs, f, a, events.fits,,, "Input event list, counts cube, or observation definition XML file" 19 +inobs, f, a, events.fits,,, "Input event list or observation definition XML file"
20 inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file" 20 inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file"
21 srcname, s, a, Crab,,, "Source name" 21 srcname, s, a, Crab,,, "Source name"
22 -expcube, f, a, NONE,,, "Input exposure cube file (only needed for stacked analysis)"  
23 -psfcube, f, a, NONE,,, "Input PSF cube file (only needed for stacked analysis)"  
24 -edispcube, f, a, NONE,,, "Input energy dispersion cube file (only needed for stacked analysis)"  
25 -bkgcube, f, a, NONE,,, "Input background cube file (only needed for stacked analysis)"  
26 caldb, s, a, prod2,,, "Calibration database" 22 caldb, s, a, prod2,,, "Calibration database"
27 irf, s, a, South_0.5h,,, "Instrument response function" 23 irf, s, a, South_0.5h,,, "Instrument response function"
28 edisp, b, h, no,,, "Apply energy dispersion?" 24 edisp, b, h, no,,, "Apply energy dispersion?"
cscripts/cslightcrv.py
@@ -41,7 +41,7 @@ class cslightcrv(ctools.cscript): @@ -41,7 +41,7 @@ class cslightcrv(ctools.cscript):
41 The format of the ASCII file is one row per time bin, each specifying 41 The format of the ASCII file is one row per time bin, each specifying
42 the start of stop value of the bin, separated by a whitespace. The 42 the start of stop value of the bin, separated by a whitespace. The
43 times are given in Modified Julian Days (MJD). 43 times are given in Modified Julian Days (MJD).
44 - 44 +
45 Examples: 45 Examples:
46 >>> lcrv = cslightcrv() 46 >>> lcrv = cslightcrv()
47 >>> lcrv.run() 47 >>> lcrv.run()
@@ -92,17 +92,18 @@ class cslightcrv(ctools.cscript): @@ -92,17 +92,18 @@ class cslightcrv(ctools.cscript):
92 """ 92 """
93 Get parameters from parfile 93 Get parameters from parfile
94 """ 94 """
95 - # Setup observations  
96 - self._setup_observations(self._obs) 95 + # Setup observations (require response and allow event list, don't
  96 + # allow counts cube)
  97 + self._setup_observations(self._obs, True, True, False)
97 98
98 # Set models if there are none in the container 99 # Set models if there are none in the container
99 if self._obs.models().size() == 0: 100 if self._obs.models().size() == 0:
100 self._obs.models(self['inmodel'].filename()) 101 self._obs.models(self['inmodel'].filename())
101 102
102 - # Get source name 103 + # Get source name
103 self._srcname = self['srcname'].string() 104 self._srcname = self['srcname'].string()
104 105
105 - # Get time boundaries 106 + # Get time boundaries
106 self._tbins = self._create_tbounds() 107 self._tbins = self._create_tbounds()
107 108
108 # Set stacked analysis flag to True if the requested number of 109 # Set stacked analysis flag to True if the requested number of
@@ -127,7 +128,7 @@ class cslightcrv(ctools.cscript): @@ -127,7 +128,7 @@ class cslightcrv(ctools.cscript):
127 self['nxpix'].integer() 128 self['nxpix'].integer()
128 self['nypix'].integer() 129 self['nypix'].integer()
129 self['binsz'].real() 130 self['binsz'].real()
130 - 131 +
131 # Do the same for the hidden parameters, just in case 132 # Do the same for the hidden parameters, just in case
132 self['edisp'].boolean() 133 self['edisp'].boolean()
133 self['calc_ulim'].boolean() 134 self['calc_ulim'].boolean()
@@ -161,14 +162,14 @@ class cslightcrv(ctools.cscript): @@ -161,14 +162,14 @@ class cslightcrv(ctools.cscript):
161 # values are "FILE", "LIN" and "GTI". This is enforced at 162 # values are "FILE", "LIN" and "GTI". This is enforced at
162 # parameter file level, hence no checking is needed. 163 # parameter file level, hence no checking is needed.
163 algorithm = self['tbinalg'].string() 164 algorithm = self['tbinalg'].string()
164 - 165 +
165 # If the algorithm is "FILE" then handle a FITS or an ASCII file for 166 # If the algorithm is "FILE" then handle a FITS or an ASCII file for
166 # the time bin definition 167 # the time bin definition
167 if algorithm == 'FILE': 168 if algorithm == 'FILE':
168 169
169 # Get the filename 170 # Get the filename
170 filename = self['tbinfile'].filename() 171 filename = self['tbinfile'].filename()
171 - 172 +
172 # If the file a FITS file then load GTIs directly 173 # If the file a FITS file then load GTIs directly
173 if filename.is_fits(): 174 if filename.is_fits():
174 gti.load(filename) 175 gti.load(filename)
@@ -212,14 +213,14 @@ class cslightcrv(ctools.cscript): @@ -212,14 +213,14 @@ class cslightcrv(ctools.cscript):
212 for i in range(obs.events().gti().size()): 213 for i in range(obs.events().gti().size()):
213 gti.append(obs.events().gti().tstart(i), 214 gti.append(obs.events().gti().tstart(i),
214 obs.events().gti().tstop(i)) 215 obs.events().gti().tstop(i))
215 - 216 +
216 # Return Good Time Intervals 217 # Return Good Time Intervals
217 return gti 218 return gti
218 219
219 def _get_free_par_names(self): 220 def _get_free_par_names(self):
220 """ 221 """
221 Return list of free parameter names 222 Return list of free parameter names
222 - 223 +
223 Returns 224 Returns
224 ------- 225 -------
225 names : list of str 226 names : list of str
@@ -469,7 +470,7 @@ class cslightcrv(ctools.cscript): @@ -469,7 +470,7 @@ class cslightcrv(ctools.cscript):
469 470
470 # Retrieve a new oberservation container 471 # Retrieve a new oberservation container
471 new_obs = cntcube.obs().copy() 472 new_obs = cntcube.obs().copy()
472 - 473 +
473 # Set stacked response 474 # Set stacked response
474 if self['edisp'].boolean(): 475 if self['edisp'].boolean():
475 new_obs[0].response(response['expcube'], response['psfcube'], 476 new_obs[0].response(response['expcube'], response['psfcube'],
@@ -480,7 +481,7 @@ class cslightcrv(ctools.cscript): @@ -480,7 +481,7 @@ class cslightcrv(ctools.cscript):
480 481
481 # Get new models 482 # Get new models
482 models = response['models'] 483 models = response['models']
483 - 484 +
484 # Fix background models if required 485 # Fix background models if required
485 if self['fix_bkg'].boolean(): 486 if self['fix_bkg'].boolean():
486 for model in models: 487 for model in models:
@@ -688,7 +689,7 @@ class cslightcrv(ctools.cscript): @@ -688,7 +689,7 @@ class cslightcrv(ctools.cscript):
688 689
689 # Get light curve filename 690 # Get light curve filename
690 outfile = self['outfile'].filename() 691 outfile = self['outfile'].filename()
691 - 692 +
692 # Continue only filename and residual map are valid 693 # Continue only filename and residual map are valid
693 if self._fits != None: 694 if self._fits != None:
694 695
doc/source/users/reference_manual/cslightcrv.rst
@@ -26,8 +26,8 @@ upper flux limit. @@ -26,8 +26,8 @@ upper flux limit.
26 General parameters 26 General parameters
27 ------------------ 27 ------------------
28 28
29 -``(inobs = NONE) [file]``  
30 - Input event list, counts cube or observation definition XML file. 29 +``inobs [file]``
  30 + Input event list or observation definition XML file.
31 31
32 ``inmodel [file]`` 32 ``inmodel [file]``
33 Input model XML file. 33 Input model XML file.
@@ -36,24 +36,21 @@ General parameters @@ -36,24 +36,21 @@ General parameters
36 Name of the source in the source model XML file which should be used 36 Name of the source in the source model XML file which should be used
37 for sensitivity computation. 37 for sensitivity computation.
38 38
39 -``outfile [file]``  
40 - Name of the source spectrum output file.  
41 -  
42 -``expcube [file]``  
43 - Exposure cube file (only needed for stacked analysis).  
44 -  
45 -``psfcube [file]``  
46 - PSF cube file (only needed for stacked analysis).  
47 -  
48 -``bkgcube [file]``  
49 - Background cube file (only needed for stacked analysis).  
50 -  
51 ``caldb [string]`` 39 ``caldb [string]``
52 Calibration database. 40 Calibration database.
53 41
54 ``irf [string]`` 42 ``irf [string]``
55 Instrumental response function. 43 Instrumental response function.
56 44
  45 +``(edisp = no) [boolean]``
  46 + Applies energy dispersion to response computation.
  47 +
  48 +``outfile [file]``
  49 + Name of the source spectrum output file.
  50 +
  51 +``(tbinalg = GTI) <FILE|LIN|GTI> [string]``
  52 + Algorithm for defining time bins.
  53 +
57 ``tmin [real]`` 54 ``tmin [real]``
58 Lightcurve start time (in MJD). 55 Lightcurve start time (in MJD).
59 56
@@ -63,24 +60,18 @@ General parameters @@ -63,24 +60,18 @@ General parameters
63 ``tbins [integer]`` 60 ``tbins [integer]``
64 Number of time bins. 61 Number of time bins.
65 62
66 -``(tbinalg = GTI) <FILE|LIN|GTI> [string]``  
67 - Algorithm for defining time bins.  
68 -  
69 ``tbinfile [file]`` 63 ``tbinfile [file]``
70 File defining the time binning. 64 File defining the time binning.
71 65
72 -``binned [boolean]``  
73 - Use binned analysis in each time bin.  
74 -  
75 -``enumbins [integer]``  
76 - Number of energy bins per light curve bin (0=unbinned).  
77 -  
78 ``emin [real]`` 66 ``emin [real]``
79 Lower energy limit of events (in TeV). 67 Lower energy limit of events (in TeV).
80 68
81 ``emax [real]`` 69 ``emax [real]``
82 Upper energy limit of events (in TeV). 70 Upper energy limit of events (in TeV).
83 71
  72 +``enumbins [integer]``
  73 + Number of energy bins per light curve bin (0=unbinned).
  74 +
84 ``coordsys <CEL|GAL> [string]`` 75 ``coordsys <CEL|GAL> [string]``
85 Coordinate system (CEL - celestial, GAL - galactic). 76 Coordinate system (CEL - celestial, GAL - galactic).
86 77