From 5a2aa22f064fc9d3c902fd8460598564faa42307 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Mon, 10 Feb 2020 11:19:39 +0100 Subject: [PATCH] Merge in code --- cscripts/csspec.par | 26 +++++++++++++------------- cscripts/csspec.py | 8 ++++---- doc/source/users/reference_manual/csspec.rst | 6 +++--- examples/show_spectrum.py | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cscripts/csspec.par b/cscripts/csspec.par index df85946..fa4f2f4 100755 --- a/cscripts/csspec.par +++ b/cscripts/csspec.par @@ -31,19 +31,19 @@ outfile, f, a, spectrum.fits,,, "Output spectrum file" # # Script parameters #================== -method, s, a, AUTO,SLICE|NODES|AUTO,, "Spectrum generation method" -ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" -emin, r, a, 0.1,,, "Start value for first energy bin in TeV" -emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" -enumbins, i, a, 20,1,200, "Number of energy bins" -ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" -calc_ts, b, h, yes,,, "Compute TS value in each bin" -calc_ulim, b, h, yes,,, "Compute upper limit in each bin" -fix_srcs, b, h, yes,,, "Fix other skymodel parameters" -fix_bkg, b, h, no,,, "Fix background parameters" -dll_sigstep, r, h, 0,0,100, "Step size in standard deviations for log-like profiles" -dll_sigmax, r, h, 5,1,100, "Maximum number of standard deviations for log-like profiles" +method, s, a, AUTO,SLICE|NODES|AUTO,, "Spectrum generation method" +ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" +emin, r, a, 0.1,,, "Start value for first energy bin in TeV" +emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" +enumbins, i, a, 20,1,200, "Number of energy bins" +ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" +calc_ts, b, h, yes,,, "Compute TS value in each bin" +calc_ulim, b, h, yes,,, "Compute upper limit in each bin" +fix_srcs, b, h, yes,,, "Fix other skymodel parameters" +fix_bkg, b, h, no,,, "Fix background parameters" +dll_sigstep, r, h, 0.0,0.0,100.0, "Step size in standard deviations for log-like profiles" +dll_sigmax, r, h, 5.0,1.0,100.0, "Maximum number of standard deviations for log-like profiles" dll_freenodes, b, h, no,,, "Free nodes not being fit when computing log-like profiles" # diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 42014b5..3a9bc48 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -2,7 +2,7 @@ # ========================================================================== # Generates a spectrum. # -# Copyright (C) 2014-2019 Michael Mayer +# Copyright (C) 2014-2020 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1031,7 +1031,6 @@ class csspec(ctools.csobservation): # from [10^-24, 10^-14] or [norm, 10^-14] whichever is broader log_start = -24 if (log_norm > -24) else log_norm log_step = (-14 - log_start) / (sigsteps-1) - norm_vals = [10 ** (log_start + i*log_step) for i in range(sigsteps)] # Loop through normalizations @@ -1042,14 +1041,15 @@ class csspec(ctools.csobservation): # Re-run the fit like.run() - + # Store dlikelihood & norm dloglike.append(loglike - like.obs().logL()) if self._method == 'SLICE': norm_scan.append(spectral.eval(elogmean)) else: norm_scan.append(new_norm) - + + # Return return (norm_scan, dloglike, -loglike) def _create_fits(self, results): diff --git a/doc/source/users/reference_manual/csspec.rst b/doc/source/users/reference_manual/csspec.rst index dab3910..7beebbb 100755 --- a/doc/source/users/reference_manual/csspec.rst +++ b/doc/source/users/reference_manual/csspec.rst @@ -145,17 +145,17 @@ General parameters ``(fix_bkg = no) [boolean]`` Fix background model parameters? -``(dll_sigstep) [real]`` +``(dll_sigstep = 0) [real]`` Step size in standard deviations for log-like profiles. Note this value determines the number of steps to use. -``(dll_sigmax) [real]`` +``(dll_sigmax = 5.0) [real]`` Maximum number of standard deviations for log-like profiles. The final number of bins generated in the likelihood profile will be: 2*(dll_sigmax/dll_sigstep) + 1 ensuring that the central flux will always be evaluated. -``(dll_freenodes) [boolean]`` +``(dll_freenodes = no) [boolean]`` Free nodes not being fit when computing log-like profiles. This parameter only has an effect if 'method=NODES' is set. diff --git a/examples/show_spectrum.py b/examples/show_spectrum.py index 8236e30..529556d 100755 --- a/examples/show_spectrum.py +++ b/examples/show_spectrum.py @@ -2,7 +2,7 @@ # ========================================================================== # Display spectrum generated by csspec # -# Copyright (C) 2015-2019 Juergen Knoedlseder +# Copyright (C) 2015-2020 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -107,13 +107,13 @@ def get_spectrum_fits(fits): # Determine if we can load the delta-log-likelihood profiles has_sedtype = table.has_card('SED_TYPE') - load_dll = False + load_dll = False if has_sedtype: seds = table.card('SED_TYPE').string().split(',') # Load likelhood columns if present if seds[0] == 'likelihood': - load_dll = True + load_dll = True c_loglike = table['loglike'] c_norm_scan = table['norm_scan'] c_dll_scan = table['dloglike_scan'] @@ -150,7 +150,7 @@ def get_spectrum_fits(fits): spec['dll_scan'] = np.zeros((nrows, c_norm_scan.elements(0))) for row in range(nrows): - loglike = c_loglike.real(row) + loglike = c_loglike.real(row) spec['loglike'].append(loglike) spec['engs_scan'].append(c_energy.real(row) - c_ed.real(row)) for col in range(c_norm_scan.elements(row)): -- libgit2 0.21.4