From 29bbc390ffb2cc94e8931e741400c9d70d5625e5 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 29 Jul 2016 15:44:17 +0200 Subject: [PATCH] Review cslightcrv script (#1828) --- cscripts/cslightcrv.py | 454 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 230 insertions(+), 224 deletions(-) diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 689e055..562dc9f 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -28,7 +28,7 @@ import ctools # ================ # class cslightcrv(ctools.cscript): """ - Generates a lightcurve. + Generates a lightcurve The cslightcrv class generates a light curve for Imaging Air Cherenkov Telescope event data by performing a maximum likelihood fit using @@ -64,14 +64,14 @@ class cslightcrv(ctools.cscript): # Constructor def __init__(self, *argv): """ - Constructor. + Constructor """ # Set name - self._name = "cslightcrv" - self._version = "1.1.0" + self._name = 'cslightcrv' + self._version = '1.1.0' # Initialise some members - self._srcname = "" + self._srcname = '' self._tbins = gammalib.GGti() self._stacked = False self._fits = gammalib.GFits() @@ -93,17 +93,17 @@ class cslightcrv(ctools.cscript): # Private methods def _get_parameters(self): """ - Get parameters from parfile. + Get parameters from parfile """ # Setup observations self._setup_observations(self._obs) # Set models if there are none in the container if self._obs.models().size() == 0: - self._obs.models(self["inmodel"].filename()) + self._obs.models(self['inmodel'].filename()) # Get source name - self._srcname = self["srcname"].string() + self._srcname = self['srcname'].string() # Get time boundaries self._tbins = self._create_tbounds() @@ -111,7 +111,7 @@ class cslightcrv(ctools.cscript): # Set stacked analysis flag to True if the requested number of # energy bins is positive. Otherwise an unbinned analysis will # be done and the stacked analysis flag will be set to False. - if self["enumbins"].integer() > 0: + if self['enumbins'].integer() > 0: self._stacked = True else: self._stacked = False @@ -120,61 +120,56 @@ class cslightcrv(ctools.cscript): # do not store the actual parameter values as we do not want # too many instance attributes with enhances the maintenance # costs. - self["emin"].real() - self["emax"].real() + self['emin'].real() + self['emax'].real() if self._stacked: - self["coordsys"].string() - self["proj"].string() - self["xref"].real() - self["yref"].real() - self["nxpix"].integer() - self["nypix"].integer() - self["binsz"].real() + self['coordsys'].string() + self['proj'].string() + self['xref'].real() + self['yref'].real() + 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() - self["calc_ts"].boolean() - self["fix_bkg"].boolean() - self["fix_srcs"].boolean() + self['edisp'].boolean() + self['calc_ulim'].boolean() + self['calc_ts'].boolean() + self['fix_bkg'].boolean() + self['fix_srcs'].boolean() # Read ahead output parameters if self._read_ahead(): - self["outfile"].filename() + self['outfile'].filename() # Write input parameters into logger if self._logTerse(): self._log_parameters() - self._log("\n") + self._log('\n') # Return return def _create_tbounds(self): """ - Creates light curve time bins. - - The method reads the following user parameters: - tbinalg: Time binning algorithm - tbinfile: Time binning file (FITS or ASCII) - tmin: Start time (MJD) - tmax: Stop time (MJD) - tbins: Number of time bins + Creates light curve time bins - Returns: - Light curve bins in form of a GTI. + Returns + ------- + gti : `~gammalib.GGti` + Light curve bins in form of Good Time Intervals """ # Initialise Good Time Intervals gti = gammalib.GGti() # Get algorithm to use for defining the time intervals - algorithm = self["tbinalg"].string() + algorithm = self['tbinalg'].string() # Handle a FITS or a ASCII file for time bin definition - if algorithm == "FILE": + if algorithm == 'FILE': # Get the filename - filename = self["tbinfile"].filename() + filename = self['tbinfile'].filename() # If the file a FITS file then load GTIs if filename.is_fits(): @@ -190,12 +185,12 @@ class cslightcrv(ctools.cscript): gti.append(tmin,tmax) # Handle linear time binning - elif algorithm == "LIN": + elif algorithm == 'LIN': # Get start and stop time and number of time bins - time_min = self["tmin"].real() - time_max = self["tmax"].real() - nbins = self["tbins"].integer() + time_min = self['tmin'].real() + time_max = self['tmax'].real() + nbins = self['tbins'].integer() # Compute time step and setup time intervals time_step = (time_max - time_min) / float(nbins) @@ -207,7 +202,7 @@ class cslightcrv(ctools.cscript): gti.append(tmin,tmax) # Handle usage of observation GTIs - elif algorithm == "GTI": + elif algorithm == 'GTI': # Append the GTIs of all observations for obs in self._obs: @@ -225,9 +220,11 @@ class cslightcrv(ctools.cscript): def _get_free_par_names(self): """ - Return list of free parameter names. + Return list of free parameter names - Returns: + Returns + ------- + names : list of str List of free parameter names. """ # Initialise list of free parameter names @@ -243,75 +240,78 @@ class cslightcrv(ctools.cscript): def _adjust_model_pars(self): """ - Adjust model parameters dependent on user parameters. + Adjust model parameters dependent on user parameters """ # Write header if self._logTerse(): - self._log("\n") - self._log.header1("Adjust model parameters") + self._log('\n') + self._log.header1('Adjust model parameters') # Adjust model parameters dependent on input user parameters for model in self._obs.models(): - # Set TS flag for all models to false. The source of interest - # will be set to true later + # Set TS flag for all models to false. The source of interest will + # be set to true later model.tscalc(False) + # Get the model classname to distinguish later sky from background + # models + classname = model.classname() + # Log model name if self._logNormal(): self._log.header3(model.name()) - # Deal with the source of interest + # If the model is the source of interest and the 'calc_ts' parameter + # is true then enable the TS computation for the source if model.name() == self._srcname: - if self["calc_ts"].boolean(): + if self['calc_ts'].boolean(): model.tscalc(True) - elif (self["fix_bkg"].boolean() and - model.classname() != "GModelSky"): - for par in model: - if par.is_free(): - par.fix() - if self._logNormal(): - self._log(gammalib.parformat(par.name())) - self._log("fixed\n") - - elif (self["fix_srcs"].boolean() and - model.classname() == "GModelSky"): + # ... otherwise, if the model is not a sky model and the 'fix_bkg' + # parameter is true or if the model is a sky model and the + # 'fix_srcs' parameter is true then fix all parameters of the model + elif ((self['fix_bkg'].boolean() and classname != 'GModelSky') or + (self['fix_srcs'].boolean() and classname == 'GModelSky')): for par in model: if par.is_free(): par.fix() if self._logNormal(): self._log(gammalib.parformat(par.name())) - self._log("fixed\n") + self._log('fixed\n') # Return return def _create_fits_table(self, results): """ - Creates FITS binary table containing light curve results. + Creates FITS binary table containing light curve results - Args: - results: List of result dictionaries. + Parameters + ---------- + results : list of dict + List of result dictionaries - Returns: - FITS binary table containing light curve. + Returns + ------- + table : `~gammalib.GFitsBinTable` + FITS binary table containing light curve """ # Determine number of rows in FITS table nrows = len(results) # Create FITS Table with extension "LIGHTCURVE" table = gammalib.GFitsBinTable(nrows) - table.extname("LIGHTCURVE") + table.extname('LIGHTCURVE') # Append time columns - mjd = gammalib.GFitsTableDoubleCol("MJD", nrows) - e_mjd = gammalib.GFitsTableDoubleCol("e_MJD", nrows) - mjd.unit("days") - e_mjd.unit("days") + mjd = gammalib.GFitsTableDoubleCol('MJD', nrows) + e_mjd = gammalib.GFitsTableDoubleCol('e_MJD', nrows) + mjd.unit('days') + e_mjd.unit('days') for i, result in enumerate(results): - mjd[i] = result["mjd"] - e_mjd[i] = result["e_mjd"] + mjd[i] = result['mjd'] + e_mjd[i] = result['e_mjd'] table.append(mjd) table.append(e_mjd) @@ -319,7 +319,7 @@ class cslightcrv(ctools.cscript): for par in self._obs.models()[self._srcname]: if par.is_free(): name = par.name() - e_name = "e_"+par.name() + e_name = 'e_'+par.name() col = gammalib.GFitsTableDoubleCol(name, nrows) e_col = gammalib.GFitsTableDoubleCol(e_name, nrows) col.unit(par.unit()) @@ -331,14 +331,14 @@ class cslightcrv(ctools.cscript): table.append(e_col) # Append Test Statistic column - ts = gammalib.GFitsTableDoubleCol("TS", nrows) + ts = gammalib.GFitsTableDoubleCol('TS', nrows) for i, result in enumerate(results): - ts[i] = result["ts"] + ts[i] = result['ts'] table.append(ts) # Append upper limit column - ulimit = gammalib.GFitsTableDoubleCol("UpperLimit", nrows) - ulimit.unit("ph/cm2/s") + ulimit = gammalib.GFitsTableDoubleCol('UpperLimit', nrows) + ulimit.unit('ph/cm2/s') for i, result in enumerate(results): ulimit[i] = result['ulimit'] table.append(ulimit) @@ -348,28 +348,32 @@ class cslightcrv(ctools.cscript): def _compute_ulimit(self, obs): """ - Computes upper flux limit. + Computes upper flux limit - Args: - obs: Observation container. + Parameters + ---------- + obs : `~gammalib.GObservations` + Observation container - Returns: - Upper flux limit (-1 of not computed). + Returns + ------- + ulimit : float + Upper flux limit (-1.0 of not computed) """ # Initialise upper flux limit ulimit_value = -1.0 # Perform computation only if requested - if self["calc_ulim"].boolean(): + if self['calc_ulim'].boolean(): # Write header in logger if self._logExplicit(): - self._log.header3("Computing upper flux limit") + self._log.header3('Computing upper flux limit') # Create upper limit object ulimit = ctools.ctulimit(obs) - ulimit["srcname"] = self._srcname - ulimit["eref"] = 1.0 + ulimit['srcname'] = self._srcname + ulimit['eref'] = 1.0 # Try to run upper limit and catch exceptions try: @@ -377,7 +381,7 @@ class cslightcrv(ctools.cscript): ulimit_value = ulimit.flux_ulimit() except: if self._logTerse(): - self._log("Upper limit flux calculation failed.s\n") + self._log('Upper limit flux calculation failed.\n') ulimit_value = -1.0 # Return upper limit @@ -385,129 +389,129 @@ class cslightcrv(ctools.cscript): def _bin_observation(self, obs): """ - Bin an observation is a binned analysis was requested. + Bin an observation if a binned analysis was requested - Args: - obs: Observation container. + Parameters + ---------- + obs : `~gammalib.GObservations` + Observation container - Returns: - Observation container with a binned. + Returns + ------- + obs : `~gammalib.GObservations` + Observation container where the first observation is a binned observation """ # Header if self._logExplicit(): - self._log.header3("Binning events") + self._log.header3('Binning events') # Bin events cntcube = ctools.ctbin(obs) - cntcube["usepnt"] = False - cntcube["ebinalg"] = "LOG" - cntcube["xref"] = self["xref"].real() - cntcube["yref"] = self["yref"].real() - cntcube["binsz"] = self["binsz"].real() - cntcube["nxpix"] = self["nxpix"].integer() - cntcube["nypix"] = self["nypix"].integer() - cntcube["enumbins"] = self["enumbins"].integer() - cntcube["emin"] = self["emin"].real() - cntcube["emax"] = self["emax"].real() - cntcube["coordsys"] = self["coordsys"].string() - cntcube["proj"] = self["proj"].string() + cntcube['usepnt'] = False + cntcube['ebinalg'] = 'LOG' + cntcube['xref'] = self['xref'].real() + cntcube['yref'] = self['yref'].real() + cntcube['binsz'] = self['binsz'].real() + cntcube['nxpix'] = self['nxpix'].integer() + cntcube['nypix'] = self['nypix'].integer() + cntcube['enumbins'] = self['enumbins'].integer() + cntcube['emin'] = self['emin'].real() + cntcube['emax'] = self['emax'].real() + cntcube['coordsys'] = self['coordsys'].string() + cntcube['proj'] = self['proj'].string() cntcube.run() # Header if self._logExplicit(): - self._log.header3("Creating exposure cube") + self._log.header3('Creating exposure cube') # Create exposure cube expcube = ctools.ctexpcube(obs) - expcube["incube"] = "NONE" - expcube["usepnt"] = False - expcube["ebinalg"] = "LOG" - expcube["xref"] = self["xref"].real() - expcube["yref"] = self["yref"].real() - expcube["binsz"] = self["binsz"].real() - expcube["nxpix"] = self["nxpix"].integer() - expcube["nypix"] = self["nypix"].integer() - expcube["enumbins"] = self["enumbins"].integer() - expcube["emin"] = self["emin"].real() - expcube["emax"] = self["emax"].real() - expcube["coordsys"] = self["coordsys"].string() - expcube["proj"] = self["proj"].string() + expcube['incube'] = 'NONE' + expcube['usepnt'] = False + expcube['ebinalg'] = 'LOG' + expcube['xref'] = self['xref'].real() + expcube['yref'] = self['yref'].real() + expcube['binsz'] = self['binsz'].real() + expcube['nxpix'] = self['nxpix'].integer() + expcube['nypix'] = self['nypix'].integer() + expcube['enumbins'] = self['enumbins'].integer() + expcube['emin'] = self['emin'].real() + expcube['emax'] = self['emax'].real() + expcube['coordsys'] = self['coordsys'].string() + expcube['proj'] = self['proj'].string() expcube.run() # Header if self._logExplicit(): - self._log.header3("Creating point spread function cube") + self._log.header3('Creating point spread function cube') # Compute spatial binning for point spread function and # energy dispersion cubes - binsz = 10.0 * self["binsz"].real() - nxpix = self["nxpix"].integer() // 10 # Make sure result is int - nypix = self["nypix"].integer() // 10 # Make sure result is int - if nxpix < 2: - nxpix = 2 - if nypix < 2: - nypix = 2 + binsz = 10.0 * self['binsz'].real() + nxpix = min(self['nxpix'].integer() // 10, 2) # Make sure result is int + nypix = min(self['nypix'].integer() // 10, 2) # Make sure result is int # Create point spread function cube psfcube = ctools.ctpsfcube(obs) - psfcube["incube"] = "NONE" - psfcube["usepnt"] = False - psfcube["ebinalg"] = "LOG" - psfcube["xref"] = self["xref"].real() - psfcube["yref"] = self["yref"].real() - psfcube["binsz"] = binsz - psfcube["nxpix"] = nxpix - psfcube["nypix"] = nypix - psfcube["enumbins"] = self["enumbins"].integer() - psfcube["emin"] = self["emin"].real() - psfcube["emax"] = self["emax"].real() - psfcube["coordsys"] = self["coordsys"].string() - psfcube["proj"] = self["proj"].string() + psfcube['incube'] = 'NONE' + psfcube['usepnt'] = False + psfcube['ebinalg'] = 'LOG' + psfcube['xref'] = self['xref'].real() + psfcube['yref'] = self['yref'].real() + psfcube['binsz'] = binsz + psfcube['nxpix'] = nxpix + psfcube['nypix'] = nypix + psfcube['enumbins'] = self['enumbins'].integer() + psfcube['emin'] = self['emin'].real() + psfcube['emax'] = self['emax'].real() + psfcube['coordsys'] = self['coordsys'].string() + psfcube['proj'] = self['proj'].string() psfcube.run() # Check if we need to include energy dispersion - if self["edisp"].boolean(): + if self['edisp'].boolean(): # Header if self._logExplicit(): - self._log.header3("Creating energy dispersion cube") + self._log.header3('Creating energy dispersion cube') # Create energy dispersion cube edispcube = ctools.ctedispcube(obs) - edispcube["incube"] = "NONE" - edispcube["usepnt"] = False - edispcube["ebinalg"] = "LOG" - edispcube["xref"] = self["xref"].real() - edispcube["yref"] = self["yref"].real() - edispcube["binsz"] = binsz - edispcube["nxpix"] = nxpix - edispcube["nypix"] = nypix - edispcube["enumbins"] = self["enumbins"].integer() - edispcube["emin"] = self["emin"].real() - edispcube["emax"] = self["emax"].real() - edispcube["coordsys"] = self["coordsys"].string() - edispcube["proj"] = self["proj"].string() + edispcube['incube'] = 'NONE' + edispcube['usepnt'] = False + edispcube['ebinalg'] = 'LOG' + edispcube['xref'] = self['xref'].real() + edispcube['yref'] = self['yref'].real() + edispcube['binsz'] = binsz + edispcube['nxpix'] = nxpix + edispcube['nypix'] = nypix + edispcube['enumbins'] = self['enumbins'].integer() + edispcube['emin'] = self['emin'].real() + edispcube['emax'] = self['emax'].real() + edispcube['coordsys'] = self['coordsys'].string() + edispcube['proj'] = self['proj'].string() edispcube.run() # Header if self._logExplicit(): - self._log.header3("Creating background cube") + self._log.header3('Creating background cube') # Create background cube bkgcube = ctools.ctbkgcube(obs) - bkgcube["incube"] = "NONE" - bkgcube["usepnt"] = False - bkgcube["ebinalg"] = "LOG" - bkgcube["xref"] = self["xref"].real() - bkgcube["yref"] = self["yref"].real() - bkgcube["binsz"] = self["binsz"].real() - bkgcube["nxpix"] = self["nxpix"].integer() - bkgcube["nypix"] = self["nypix"].integer() - bkgcube["enumbins"] = self["enumbins"].integer() - bkgcube["emin"] = self["emin"].real() - bkgcube["emax"] = self["emax"].real() - bkgcube["coordsys"] = self["coordsys"].string() - bkgcube["proj"] = self["proj"].string() + bkgcube['incube'] = 'NONE' + bkgcube['usepnt'] = False + bkgcube['ebinalg'] = 'LOG' + bkgcube['xref'] = self['xref'].real() + bkgcube['yref'] = self['yref'].real() + bkgcube['binsz'] = self['binsz'].real() + bkgcube['nxpix'] = self['nxpix'].integer() + bkgcube['nypix'] = self['nypix'].integer() + bkgcube['enumbins'] = self['enumbins'].integer() + bkgcube['emin'] = self['emin'].real() + bkgcube['emax'] = self['emax'].real() + bkgcube['coordsys'] = self['coordsys'].string() + bkgcube['proj'] = self['proj'].string() bkgcube.run() # Retrieve a new oberservation container @@ -517,20 +521,17 @@ class cslightcrv(ctools.cscript): models = bkgcube.models() # Set stacked response - if self["edisp"].boolean(): - new_obs[0].response(expcube.expcube(), - psfcube.psfcube(), - edispcube.edispcube(), - bkgcube.bkgcube()) + if self['edisp'].boolean(): + new_obs[0].response(expcube.expcube(), psfcube.psfcube(), + edispcube.edispcube(), bkgcube.bkgcube()) else: - new_obs[0].response(expcube.expcube(), - psfcube.psfcube(), + new_obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube()) # Fix background models if required - if self["fix_bkg"].boolean(): + if self['fix_bkg'].boolean(): for model in models: - if model.classname() != "GModelSky": + if model.classname() != 'GModelSky': for par in model: par.fix() @@ -544,7 +545,7 @@ class cslightcrv(ctools.cscript): # Public methods def run(self): """ - Run the script. + Run the script """ # Switch screen logging on in debug mode if self._logDebug(): @@ -555,18 +556,18 @@ class cslightcrv(ctools.cscript): # Write observation into logger if self._logTerse(): - self._log("\n") - self._log.header1("Observation") + self._log('\n') + self._log.header1(gammalib.number('Observation',len(self._obs))) self._log(str(self._obs)) - self._log("\n") + self._log('\n') # Adjust model parameters dependent on user parameters self._adjust_model_pars() # Write header if self._logTerse(): - self._log("\n") - self._log.header1("Generate lightcurve") + self._log('\n') + self._log.header1('Generate lightcurve') # Initialise list of result dictionaries results = [] @@ -583,9 +584,7 @@ class cslightcrv(ctools.cscript): # Write time bin into header if self._logTerse(): - self._log.header2("MJD "+ - str(tmin.mjd())+"-"+ - str(tmax.mjd())) + self._log.header2('MJD '+str(tmin.mjd())+'-'+str(tmax.mjd())) # Compute time bin center and time width twidth = 0.5 * (tmax - tmin) # in seconds @@ -601,17 +600,17 @@ class cslightcrv(ctools.cscript): # Log information if self._logExplicit(): - self._log.header3("Selecting events") + self._log.header3('Selecting events') # Select events select = ctools.ctselect(self._obs) - select["emin"] = self["emin"].real() - select["emax"] = self["emax"].real() - select["tmin"] = tmin.convert(self._time_reference()) - select["tmax"] = tmax.convert(self._time_reference()) - select["rad"] = "UNDEFINED" - select["ra"] = "UNDEFINED" - select["dec"] = "UNDEFINED" + select['emin'] = self['emin'].real() + select['emax'] = self['emax'].real() + select['tmin'] = tmin.convert(self._time_reference()) + select['tmax'] = tmax.convert(self._time_reference()) + select['rad'] = 'UNDEFINED' + select['ra'] = 'UNDEFINED' + select['dec'] = 'UNDEFINED' select.run() # Retrieve observation @@ -625,11 +624,11 @@ class cslightcrv(ctools.cscript): # Header if self._logExplicit(): - self._log.header3("Fitting the data") + self._log.header3('Fitting the data') # Do maximum likelihood model fitting like = ctools.ctlike(obs) - like["edisp"] = self["edisp"].boolean() + like['edisp'] = self['edisp'].boolean() like.run() # Skip bin if no event was present @@ -637,13 +636,13 @@ class cslightcrv(ctools.cscript): # Signal skipping of bin if self._logTerse(): - self._log(gammalib.parformat("Warning")) - self._log("No event in this time bin, skip bin.\n") + self._log(gammalib.parformat('Warning')) + self._log('No event in this time bin, skip bin.\n') # Set all results to 0 for par in pars: result['values'][par] = 0.0 - result['values']["e_"+par] = 0.0 + result['values']['e_'+par] = 0.0 # Append result results.append(result) @@ -657,7 +656,7 @@ class cslightcrv(ctools.cscript): # Extract parameter values for par in pars: result['values'][par] = source.spectral()[par].value() - result['values']["e_"+par] = source.spectral()[par].error() + result['values']['e_'+par] = source.spectral()[par].error() # Calculate upper limit (-1 if not computed) ulimit_value = self._compute_ulimit(like.obs()) @@ -665,7 +664,7 @@ class cslightcrv(ctools.cscript): result['ulimit'] = ulimit_value # Extract Test Statistic value - if self["calc_ts"].boolean(): + if self['calc_ts'].boolean(): result['ts'] = source.ts() # Append result to list of dictionaries @@ -673,7 +672,7 @@ class cslightcrv(ctools.cscript): # Log results for this time bin if self._logNormal(): - self._log.header3("Results") + self._log.header3('Results') pars = self._get_free_par_names() for par in pars: value = source.spectral()[par].value() @@ -681,17 +680,17 @@ class cslightcrv(ctools.cscript): unit = source.spectral()[par].unit() self._log(gammalib.parformat(par)) self._log(str(value)) - self._log(" +/- ") + self._log(' +/- ') self._log(str(error)) - self._log(" ") + self._log(' ') self._log(unit) - self._log("\n") + self._log('\n') if result['ulimit'] > 0.0: - self._log(gammalib.parformat("Upper flux limit")) - self._log(str(result['ulimit'])+" ph/cm2/s\n") - if self["calc_ts"].boolean(): - self._log(gammalib.parformat("Test Statistic")) - self._log(str(result['ts'])+"\n") + self._log(gammalib.parformat('Upper flux limit')) + self._log(str(result['ulimit'])+' ph/cm2/s\n') + if self['calc_ts'].boolean(): + self._log(gammalib.parformat('Test Statistic')) + self._log(str(result['ts'])+'\n') # Create FITS table from results table = self._create_fits_table(results) @@ -705,7 +704,7 @@ class cslightcrv(ctools.cscript): def execute(self): """ - Execute the script. + Execute the script """ # Open logfile self.logFileOpen() @@ -724,7 +723,7 @@ class cslightcrv(ctools.cscript): def save(self): """ - Save light curve. + Save light curve """ # Write header if self._logTerse(): @@ -732,16 +731,16 @@ class cslightcrv(ctools.cscript): self._log.header1('Save light curve') # Get light curve filename - outfile = self["outfile"].filename() + outfile = self['outfile'].filename() # Continue only filename and residual map are valid if self._fits != None: # Log file name if self._logTerse(): - self._log(gammalib.parformat("Light curve file")) + self._log(gammalib.parformat('Light curve file')) self._log(outfile.url()) - self._log("\n") + self._log('\n') # Save spectrum self._fits.saveto(outfile, self._clobber()) @@ -753,18 +752,25 @@ class cslightcrv(ctools.cscript): """ Return light curve FITS file. - Returns: - FITS file containing light curve. + Returns + ------- + fits : `~gammalib.GFits()` + FITS file containing light curve """ # Return return self._fits def models(self, models): """ - Set model. + Set model + + Parameters + ---------- + models : `~gammalib.GModels()` + Set model container """ # Copy models - self._obs.models(models.clone()) + self._obs.models(models) # Return return -- libgit2 0.21.4