Commit 6549003c95f1e9072f61c7e4aba2dde8a9cdbb20

Authored by Jürgen Knödlseder
1 parent e0744861

Fix cslightcrv (#1920)

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