From 6549003c95f1e9072f61c7e4aba2dde8a9cdbb20 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 3 Feb 2017 15:49:42 +0100 Subject: [PATCH] Fix cslightcrv (#1920) --- ChangeLog | 1 + NEWS | 3 +++ cscripts/cslightcrv.par | 6 +----- cscripts/cslightcrv.py | 27 ++++++++++++++------------- doc/source/users/reference_manual/cslightcrv.rst | 37 ++++++++++++++----------------------- 5 files changed, 33 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index a00cabb..6d910ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Version 1.2.0 released ======================== + cslightcrv no longer accepts counts cubes on input (#1920) Set ctbin reference time to CTA reference time (#1922) Change ds9file parameter to outds9file Add cssrcdetect script (#1617) diff --git a/NEWS b/NEWS index 496e468..2f7b2dd 100644 --- a/NEWS +++ b/NEWS @@ -244,6 +244,9 @@ Improve the upper limit computation in the cslightcrv script. Now all source parameters, except the source intensity, are set to the initial values given in the model definition file for upper limit computation. +The cslightcrv script no longer accepts counts cubes on input as no light +curves can be derived from counts cubes (#1920). + Examples -------- diff --git a/cscripts/cslightcrv.par b/cscripts/cslightcrv.par index f9e4210..597d5f3 100644 --- a/cscripts/cslightcrv.par +++ b/cscripts/cslightcrv.par @@ -16,13 +16,9 @@ # # Input and output parameters #============================ -inobs, f, a, events.fits,,, "Input event list, counts cube, or observation definition XML file" +inobs, f, a, events.fits,,, "Input event list or observation definition XML file" inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file" srcname, s, a, Crab,,, "Source name" -expcube, f, a, NONE,,, "Input exposure cube file (only needed for stacked analysis)" -psfcube, f, a, NONE,,, "Input PSF cube file (only needed for stacked analysis)" -edispcube, f, a, NONE,,, "Input energy dispersion cube file (only needed for stacked analysis)" -bkgcube, f, a, NONE,,, "Input background cube file (only needed for stacked analysis)" caldb, s, a, prod2,,, "Calibration database" irf, s, a, South_0.5h,,, "Instrument response function" edisp, b, h, no,,, "Apply energy dispersion?" diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index a583f38..7a4a4f4 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -41,7 +41,7 @@ class cslightcrv(ctools.cscript): The format of the ASCII file is one row per time bin, each specifying the start of stop value of the bin, separated by a whitespace. The times are given in Modified Julian Days (MJD). - + Examples: >>> lcrv = cslightcrv() >>> lcrv.run() @@ -92,17 +92,18 @@ class cslightcrv(ctools.cscript): """ Get parameters from parfile """ - # Setup observations - self._setup_observations(self._obs) + # Setup observations (require response and allow event list, don't + # allow counts cube) + self._setup_observations(self._obs, True, True, False) # Set models if there are none in the container if self._obs.models().size() == 0: self._obs.models(self['inmodel'].filename()) - # Get source name + # Get source name self._srcname = self['srcname'].string() - # Get time boundaries + # Get time boundaries self._tbins = self._create_tbounds() # Set stacked analysis flag to True if the requested number of @@ -127,7 +128,7 @@ class cslightcrv(ctools.cscript): self['nxpix'].integer() self['nypix'].integer() self['binsz'].real() - + # Do the same for the hidden parameters, just in case self['edisp'].boolean() self['calc_ulim'].boolean() @@ -161,14 +162,14 @@ class cslightcrv(ctools.cscript): # values are "FILE", "LIN" and "GTI". This is enforced at # parameter file level, hence no checking is needed. algorithm = self['tbinalg'].string() - + # If the algorithm is "FILE" then handle a FITS or an ASCII file for # the time bin definition if algorithm == 'FILE': # Get the filename filename = self['tbinfile'].filename() - + # If the file a FITS file then load GTIs directly if filename.is_fits(): gti.load(filename) @@ -212,14 +213,14 @@ class cslightcrv(ctools.cscript): for i in range(obs.events().gti().size()): gti.append(obs.events().gti().tstart(i), obs.events().gti().tstop(i)) - + # Return Good Time Intervals return gti def _get_free_par_names(self): """ Return list of free parameter names - + Returns ------- names : list of str @@ -469,7 +470,7 @@ class cslightcrv(ctools.cscript): # Retrieve a new oberservation container new_obs = cntcube.obs().copy() - + # Set stacked response if self['edisp'].boolean(): new_obs[0].response(response['expcube'], response['psfcube'], @@ -480,7 +481,7 @@ class cslightcrv(ctools.cscript): # Get new models models = response['models'] - + # Fix background models if required if self['fix_bkg'].boolean(): for model in models: @@ -688,7 +689,7 @@ class cslightcrv(ctools.cscript): # Get light curve filename outfile = self['outfile'].filename() - + # Continue only filename and residual map are valid if self._fits != None: diff --git a/doc/source/users/reference_manual/cslightcrv.rst b/doc/source/users/reference_manual/cslightcrv.rst index 8a91dd0..6ed5d78 100644 --- a/doc/source/users/reference_manual/cslightcrv.rst +++ b/doc/source/users/reference_manual/cslightcrv.rst @@ -26,8 +26,8 @@ upper flux limit. General parameters ------------------ -``(inobs = NONE) [file]`` - Input event list, counts cube or observation definition XML file. +``inobs [file]`` + Input event list or observation definition XML file. ``inmodel [file]`` Input model XML file. @@ -36,24 +36,21 @@ General parameters Name of the source in the source model XML file which should be used for sensitivity computation. -``outfile [file]`` - Name of the source spectrum output file. - -``expcube [file]`` - Exposure cube file (only needed for stacked analysis). - -``psfcube [file]`` - PSF cube file (only needed for stacked analysis). - -``bkgcube [file]`` - Background cube file (only needed for stacked analysis). - ``caldb [string]`` Calibration database. ``irf [string]`` Instrumental response function. +``(edisp = no) [boolean]`` + Applies energy dispersion to response computation. + +``outfile [file]`` + Name of the source spectrum output file. + +``(tbinalg = GTI) [string]`` + Algorithm for defining time bins. + ``tmin [real]`` Lightcurve start time (in MJD). @@ -63,24 +60,18 @@ General parameters ``tbins [integer]`` Number of time bins. -``(tbinalg = GTI) [string]`` - Algorithm for defining time bins. - ``tbinfile [file]`` File defining the time binning. -``binned [boolean]`` - Use binned analysis in each time bin. - -``enumbins [integer]`` - Number of energy bins per light curve bin (0=unbinned). - ``emin [real]`` Lower energy limit of events (in TeV). ``emax [real]`` Upper energy limit of events (in TeV). +``enumbins [integer]`` + Number of energy bins per light curve bin (0=unbinned). + ``coordsys [string]`` Coordinate system (CEL - celestial, GAL - galactic). -- libgit2 0.21.4