From d0835fc8f4edd7c075cab13f305cdcd3e7d552fb Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 21 Oct 2017 21:37:54 +0200 Subject: [PATCH] Add "statistic" parameter to ctbutterfly, cterror, cttsmap, and ctulimit (#2237) --- NEWS | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------- configure.ac | 4 ++-- cscripts/csiactobs.py | 2 +- cscripts/csobs2caldb.py | 2 +- cscripts/cstsmapsplit.par | 1 + doc/source/users/reference_manual/cstsmapsplit.rst | 8 ++++++++ doc/source/users/reference_manual/ctbutterfly.rst | 5 +++++ doc/source/users/reference_manual/cterror.rst | 23 ++++++++++++++--------- doc/source/users/reference_manual/cttsmap.rst | 25 +++++++++++++++---------- doc/source/users/reference_manual/ctulimit.rst | 35 ++++++++++++++++++++--------------- src/ctbutterfly/ctbutterfly.cpp | 13 ++++++------- src/ctbutterfly/ctbutterfly.par | 1 + src/cterror/cterror.cpp | 10 ++++++---- src/cterror/cterror.par | 1 + src/cttsmap/cttsmap.cpp | 11 +++++------ src/cttsmap/cttsmap.par | 1 + src/ctulimit/ctulimit.cpp | 8 +++++--- src/ctulimit/ctulimit.par | 1 + 18 files changed, 290 insertions(+), 103 deletions(-) diff --git a/NEWS b/NEWS index 10e810f..cfc9303 100644 --- a/NEWS +++ b/NEWS @@ -24,41 +24,49 @@ Support model None -ctobssim - CTA observation simulation -------------------------------------- -Use t-type parameters for "tmin" and "tmax" to all specifying times in various -formats (#1864). +ctbin - CTA event binning +------------------------- +None -ctselect - CTA event selection ------------------------------- -Use t-type parameters for "tmin" and "tmax" to all specifying times in various -formats (#1864). +ctbkgcube - CTA background cube generation +------------------------------------------ +None -ctbin - CTA event binning -------------------------- +ctbutterfly - Generate butterfly diagrams +----------------------------------------- +Add "statistic" parameter to allow setting of optimizer statistic (#2237). + + +ctcubemask - CTA cube filtering +------------------------------- None -ctlike - Maximum likelihood fitting ------------------------------------ -Rename "stats" parameter to "statistic" (#2238). +ctedispcube - CTA energy dispersion cube generation +--------------------------------------------------- +None -cttsmap - Generation of Test Statistic map ------------------------------------------- +cterror - Likelihood profile error computation +---------------------------------------------- +Add "statistic" parameter to allow setting of optimizer statistic (#2237). + + +ctexpcube - CTA exposure cube generation +---------------------------------------- None -ctskymap - CTA sky mapping --------------------------- -Header keywords informing about the dates and times covered by the observations -used to generate the skymap, as well as the event energy range, are now appended -as header keywords to the FITS file (#2194). +ctlike - Maximum likelihood fitting +----------------------------------- +Rename "stats" parameter to "statistic" (#2237). -Add the RING background method, which is a classical analysis methods for IACT -data analysis, for background subtraction (#2207). + +ctmapcube - CTA map cube generation +----------------------------------- +None ctmodel - CTA counts cube modelling @@ -72,8 +80,19 @@ parallelization of the tool has also been optimised so that diffuse models are not loaded over and over again (#2189). -ctexpcube - CTA exposure cube generation ----------------------------------------- +ctobssim - CTA observation simulation +------------------------------------- +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). + + +ctphase - Event phase computation +--------------------------------- +None + + +ctprob - Event probability computation +-------------------------------------- None @@ -82,62 +101,143 @@ ctpsfcube - CTA point spread function cube generation None -ctedispcube - CTA energy dispersion cube generation ---------------------------------------------------- -None +ctselect - CTA event selection +------------------------------ +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). -ctbkgcube - CTA background cube generation +ctskymap - CTA sky mapping +-------------------------- +Header keywords informing about the dates and times covered by the observations +used to generate the skymap, as well as the event energy range, are now appended +as header keywords to the FITS file (#2194). + +Add the RING background method, which is a classical analysis methods for IACT +data analysis, for background subtraction (#2207). + + +cttsmap - Generation of Test Statistic map ------------------------------------------ +Add "statistic" parameter to allow setting of optimizer statistic (#2237). + + +ctulimit - Compute upper limit +------------------------------ +Add "statistic" parameter to allow setting of optimizer statistic (#2237). + + +cscaldb - Inspect calibration database +-------------------------------------- None -ctmapcube - CTA map cube generation ------------------------------------ +csebins - Generate energy boundaries +------------------------------------ None -ctcubemask - CTA cube filtering -------------------------------- +csfindobs - Find IACT observations +---------------------------------- None -ctbutterfly - Generate butterfly diagrams ------------------------------------------ +csiactcopy - Copy IACT observations +----------------------------------- None -ctulimit - Compute upper limit ------------------------------- +csiactdata - Inspect IACT data store +------------------------------------ None -cterror - Likelihood profile error computation ----------------------------------------------- +csiactobs - Inspect IACT observation definition XML file +-------------------------------------------------------- None -ctprob - Event probability computation +cslightcrv - Generate light curve +--------------------------------- +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). + + +csmodelinfo - Return model information -------------------------------------- None -ctphase - Event phase computation ---------------------------------- +csmodelmerge - Merge models +--------------------------- None -cscripts --------- +csmodelselect - Select models +----------------------------- +None + + +csmodelsois - Puts selected sources in diffuse model cube +--------------------------------------------------------- Add csmodelsois script that replaces selected models in a model container by a diffuse map cube (#2180). -Use t-type parameters for "tmin" and "tmax" to all specifying times in various -formats (#1864). +csobs2caldb - Generate calibration database entry for an IACT observation +------------------------------------------------------------------------- +None + + +csobsdef - Generate observation definition XML file +--------------------------------------------------- +None + + +csobsinfo - Return observation definition information +----------------------------------------------------- +None + + +csobsselect - Select observations +--------------------------------- +None + + +csphagen - Generate On/Off observations +--------------------------------------- The script csphagen was added to allow the generation of PHA, ARF and RMF datasets for classical On/Off IACT analysis (#2208). + +csphasecrv - Generate phase curve +--------------------------------- +None + + +cspull - Generate pull distributions +------------------------------------ +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). + + +csresmap - Generate residual map +-------------------------------- +None + + +csroot2caldb - Generates calibration database from ROOT file +------------------------------------------------------------ +None + + +cssens - Computes sensitivity curve +----------------------------------- +None + + +csspec - Generates Spectral Energy Distribution +----------------------------------------------- The csspec script now can also handle On/Off spectra for SED generation (#2231). The csspec script now can also handle non-CTA data. For that purpose a "method" @@ -148,6 +248,58 @@ will use "SLICE" for observations containing only CTA data and "NODES" for obser containing other data (#1927). +cssrcdetect - Detects sources in sky map +---------------------------------------- +None + + +cstsdist - Computes Test Statistic distribution +----------------------------------------------- +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). + + +cstsmapmerge - Merge Test Statistic maps +---------------------------------------- +None + + +cstsmapsplit - Prepare split Test Statistic computation +------------------------------------------------------- +None + + +csviscube - Generate visibility cube +------------------------------------ +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). + + +csworkflow - Execute workflow +----------------------------- +None + + +calutils - Calibration utilities +-------------------------------- +None + + +ioutils - Input/Output utilities +-------------------------------- +None + + +modutils - Model utilities +-------------------------- +None + + +obsutils - Observation utilities +-------------------------------- +None + + Examples -------- None diff --git a/configure.ac b/configure.ac index ee4482d..8851bd1 100644 --- a/configure.ac +++ b/configure.ac @@ -32,8 +32,8 @@ AC_INIT([ctools], [1.5.0.dev1], [jurgen.knodlseder@irap.omp.eu], [ctools]) AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) AC_CONFIG_MACRO_DIR([m4]) #AM_INIT_AUTOMAKE([gnu no-dependencies foreign]) -AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) -#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) +#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) +AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) AC_CONFIG_HEADER([config.h]) diff --git a/cscripts/csiactobs.py b/cscripts/csiactobs.py index 2ca8437..a6e58d4 100755 --- a/cscripts/csiactobs.py +++ b/cscripts/csiactobs.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # ========================================================================== -# Generates an IACT observation definition XML file. +# Generates an IACT observation definition XML file # # Copyright (C) 2015-2017 Michael Mayer # diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index 2882da5..17c354c 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # ========================================================================== -# Creates a calibration database entry for an IACT observation. +# Creates a calibration database entry for an IACT observation # # Copyright (C) 2015-2017 Michael Mayer # diff --git a/cscripts/cstsmapsplit.par b/cscripts/cstsmapsplit.par index 7869298..5e469f8 100644 --- a/cscripts/cstsmapsplit.par +++ b/cscripts/cstsmapsplit.par @@ -27,6 +27,7 @@ caldb, s, a, prod2,,, "Calibration database" irf, s, a, South_0.5h,,, "Instrument response function" edisp, b, h, no,,, "Apply energy dispersion?" errors, b, h, no,,, "Compute/store parameter errors?" +statistic, s, h, CSTAT,CSTAT|WSTAT|CHI2,, "Optimization statistic" outmap, f, a, tsmap.fits,,, "Output Test Statistic map file" bins_per_job, i, a, 5,,, "Number of TS map bins per task" compute_null, b, a, yes,,,"Compute null hypothesis first?" diff --git a/doc/source/users/reference_manual/cstsmapsplit.rst b/doc/source/users/reference_manual/cstsmapsplit.rst index 023e1d6..93ddd85 100644 --- a/doc/source/users/reference_manual/cstsmapsplit.rst +++ b/doc/source/users/reference_manual/cstsmapsplit.rst @@ -50,6 +50,14 @@ General parameters ``(edisp = no) [boolean]`` Applies energy dispersion to response computation. +``(errors = no) [boolean]`` + Compute and store parameter errors? + +``(statistic = CSTAT) [string]`` + Optimization statistic. ``CSTAT`` applies to all types of observations, + ``WSTAT``applies only to On/Off observations, and ``CHI2`` applies only + to binned or stacked observations. + ``outmap [file]`` Output Test Statistic map file. diff --git a/doc/source/users/reference_manual/ctbutterfly.rst b/doc/source/users/reference_manual/ctbutterfly.rst index a3dc3e7..1bd7603 100644 --- a/doc/source/users/reference_manual/ctbutterfly.rst +++ b/doc/source/users/reference_manual/ctbutterfly.rst @@ -86,6 +86,11 @@ General parameters ``(confidence = 0.68) [real]`` Confidence level for error computation. +``(statistic = CSTAT) [string]`` + Optimization statistic. ``CSTAT`` applies to all types of observations, + ``WSTAT``applies only to On/Off observations, and ``CHI2`` applies only + to binned or stacked observations. + ``(matrix = "NONE") [file]`` Input covariance matrix file (not used) diff --git a/doc/source/users/reference_manual/cterror.rst b/doc/source/users/reference_manual/cterror.rst index 2551282..4d2537c 100644 --- a/doc/source/users/reference_manual/cterror.rst +++ b/doc/source/users/reference_manual/cterror.rst @@ -30,13 +30,13 @@ General parameters ``inobs [file]`` Input event list, counts cube or observation definition XML file. - + ``inmodel [file]`` Input model XML file. - + ``srcname [string]`` Name of source model for which the parameter errors should be computed. - + ``expcube [file]`` Input exposure cube file. @@ -51,22 +51,27 @@ General parameters ``caldb [string]`` Calibration database. - + ``irf [string]`` Instrumental response function. - + ``(edisp = no) [boolean]`` Applies energy dispersion to response computation. - + ``outmodel [file]`` Output model XML file with updated error information. - + ``(confidence = 0.68) [real]`` Confidence level for error computation. - + ``(tol = 1e-3) [real]`` Computation tolerance. - + +``(statistic = CSTAT) [string]`` + Optimization statistic. ``CSTAT`` applies to all types of observations, + ``WSTAT``applies only to On/Off observations, and ``CHI2`` applies only + to binned or stacked observations. + ``(max_iter = 50) [integer]`` Maximum number of iterations before stopping the likelihood profil computations. diff --git a/doc/source/users/reference_manual/cttsmap.rst b/doc/source/users/reference_manual/cttsmap.rst index d0d9858..61f8868 100644 --- a/doc/source/users/reference_manual/cttsmap.rst +++ b/doc/source/users/reference_manual/cttsmap.rst @@ -62,34 +62,39 @@ General parameters ``outmap [file]`` Output Test Statistic map file. - + ``(errors = no) [boolean]`` Compute and store parameter errors? - + +``(statistic = CSTAT) [string]`` + Optimization statistic. ``CSTAT`` applies to all types of observations, + ``WSTAT``applies only to On/Off observations, and ``CHI2`` applies only + to binned or stacked observations. + ``(usepnt = no) [boolean]`` Use CTA pointing direction for map centre instead of xref/yref parameters? - + ``nxpix [integer]`` Number of map pixels in Right Ascension or Galactic longitude. - + ``nypix [integer]`` Number of map pixels in Declination or Galactic latitude. - + ``binsz [real]`` Map pixel size (in degrees/pixel). - + ``coordsys [string]`` Coordinate system (CEL - celestial, GAL - galactic). - + ``proj [string]`` Projection method. ``xref [real]`` Right Ascension / Galactic longitude of map centre (J2000, in degrees). - + ``yref [real]`` Declination / Galactic latitude of map centre (J2000, in degrees). - + ``(binmin = -1) [integer]`` First bin to compute. @@ -98,7 +103,7 @@ General parameters ``(logLO = -1) [real]`` LogLikelihood value of null hypothesis. - + Standard parameters ------------------- diff --git a/doc/source/users/reference_manual/ctulimit.rst b/doc/source/users/reference_manual/ctulimit.rst index 2caab0c..d89b692 100644 --- a/doc/source/users/reference_manual/ctulimit.rst +++ b/doc/source/users/reference_manual/ctulimit.rst @@ -22,19 +22,18 @@ upper flux limit (specified by the hidden parameters ``emin`` and ``emax``) into the log file. - General parameters ------------------ ``inobs [file]`` Input event list, counts cube or observation definition XML file. - + ``inmodel [file]`` Input model XML file. - + ``srcname [string]`` Name of source model for which the upper flux limit should be computed. - + ``expcube [file]`` Input exposure cube file. @@ -49,36 +48,41 @@ General parameters ``caldb [string]`` Calibration database. - + ``irf [string]`` Instrumental response function. - + ``(edisp = no) [boolean]`` Applies energy dispersion to response computation. - + ``(confidence = 0.95) [real]`` Confidence level of upper limit. - + ``(sigma_min = 0.0) [real]`` Minimum boundary to start searching for upper limit value. Number of standard deviations above best fit value - + ``(sigma_max = 10.0) [real]`` Maximum boundary to start searching for upper limit value. Number of standard deviations above best fit value - + ``(eref = 1.0) [real])`` Reference energy for differential limit (in TeV). - + ``(emin = 1.0) [real])`` Minimum energy for integral flux limit (in TeV). - + ``(emax = 100) [real]`` Maximum energy for integral flux limit (in TeV). - + ``(tol = 1e-5) [real]`` Computation tolerance. - + +``(statistic = CSTAT) [string]`` + Optimization statistic. ``CSTAT`` applies to all types of observations, + ``WSTAT``applies only to On/Off observations, and ``CHI2`` applies only + to binned or stacked observations. + ``(max_iter = 50) [integer]`` Maximum number of iterations before stopping the upper limit computations. @@ -103,7 +107,8 @@ Standard parameters Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` - Enables debug mode. In debug mode the executable will dump any log file output to the console. + Enables debug mode. In debug mode the executable will dump any log file + output to the console. ``(mode = ql) [string]`` Mode of automatic parameters (default is "ql", i.e. "query and learn"). diff --git a/src/ctbutterfly/ctbutterfly.cpp b/src/ctbutterfly/ctbutterfly.cpp index 7d6ed26..f8d6261 100644 --- a/src/ctbutterfly/ctbutterfly.cpp +++ b/src/ctbutterfly/ctbutterfly.cpp @@ -451,17 +451,16 @@ void ctbutterfly::free_members(void) * @exception GException::feature_not_implemented * Loading of covariance matrix is not yet implemented. * - * Get all task parameters from parameter file or (if required) by querying - * the user. Most parameters are only required if no observation exists so - * far in the observation container. In this case, a single CTA observation - * will be added to the container, using the definition provided in the - * parameter file. + * Get all task parameters from parameter file. ***************************************************************************/ void ctbutterfly::get_parameters(void) { // Setup observations from "inobs" parameter setup_observations(m_obs); + // Set observation statistic + set_obs_statistic(gammalib::toupper((*this)["statistic"].string())); + // Setup models from "inmodel" parameter setup_models(m_obs, (*this)["srcname"].string()); @@ -475,8 +474,8 @@ void ctbutterfly::get_parameters(void) std::string matrixfilename = (*this)["matrix"].filename(); if (matrixfilename != "NONE") { std::string msg = "Loading of matrix from file not implemented yet. " - "Use filename = \"NONE\" to induce a recomputation of " - "the matrix internally."; + "Use filename = \"NONE\" to induce a recomputation " + "of the matrix internally."; throw GException::feature_not_implemented(G_GET_PARAMETERS, msg); // m_covariance.load(matrixfilename); } diff --git a/src/ctbutterfly/ctbutterfly.par b/src/ctbutterfly/ctbutterfly.par index 93f411a..328ae95 100644 --- a/src/ctbutterfly/ctbutterfly.par +++ b/src/ctbutterfly/ctbutterfly.par @@ -34,6 +34,7 @@ method, s, h, GAUSSIAN, GAUSSIAN|ENVELOPE,,"Butterfly computation method" #===================== fit, b, h, no,,, "Perform maximum likelihood fitting?" confidence, r, h, 0.68,0.0,1.0, "Confidence level" +statistic, s, h, CSTAT,CSTAT|WSTAT|CHI2,, "Optimization statistic" matrix, f, h, "NONE",,, "Input covariance Matrix FITS file" # diff --git a/src/cterror/cterror.cpp b/src/cterror/cterror.cpp index 9e9ef4a..bf00ed5 100644 --- a/src/cterror/cterror.cpp +++ b/src/cterror/cterror.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cterror - Parameter error calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015-2016 by Florent Forest * + * copyright (C) 2015-2017 by Florent Forest * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -443,14 +443,16 @@ void cterror::free_members(void) /***********************************************************************//** * @brief Get application parameters * - * Get all task parameters from parameter file or (if required) by querying - * the user. + * Get all task parameters from parameter file. ***************************************************************************/ void cterror::get_parameters(void) { // Setup observations from "inobs" parameter setup_observations(m_obs); - + + // Set observation statistic + set_obs_statistic(gammalib::toupper((*this)["statistic"].string())); + // Setup models from "inmodel" parameter setup_models(m_obs, (*this)["srcname"].string()); diff --git a/src/cterror/cterror.par b/src/cterror/cterror.par index 8f210c6..1e27b0e 100644 --- a/src/cterror/cterror.par +++ b/src/cterror/cterror.par @@ -34,6 +34,7 @@ outmodel, f, a, "results.xml",,, "Output model definiton XML file" #============================= confidence, r, h, 0.68,0.0,1.0, "Confidence level" tol, r, h, 1e-3,,, "Computation tolerance" +statistic, s, h, CSTAT,CSTAT|WSTAT|CHI2,, "Optimization statistic" max_iter, i, h, 50,1,1000, "Maximum number of iterations" # diff --git a/src/cttsmap/cttsmap.cpp b/src/cttsmap/cttsmap.cpp index e932dca..52c029b 100644 --- a/src/cttsmap/cttsmap.cpp +++ b/src/cttsmap/cttsmap.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cttsmap - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2016 by Michael Mayer * + * copyright (C) 2014-2017 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -525,17 +525,16 @@ void cttsmap::free_members(void) * @exception GException::invalid_value * Test source has no RA/DEC parameters. * - * Get all task parameters from parameter file or (if required) by querying - * the user. Most parameters are only required if no observation exists so - * far in the observation container. In this case, a single CTA observation - * will be added to the container, using the definition provided in the - * parameter file. + * Get all task parameters from parameter file. ***************************************************************************/ void cttsmap::get_parameters(void) { // Setup observations from "inobs" parameter setup_observations(m_obs); + // Set observation statistic + set_obs_statistic(gammalib::toupper((*this)["statistic"].string())); + // Setup models from "inmodel" parameter setup_models(m_obs, (*this)["srcname"].string()); diff --git a/src/cttsmap/cttsmap.par b/src/cttsmap/cttsmap.par index ec7a0aa..bea9f23 100644 --- a/src/cttsmap/cttsmap.par +++ b/src/cttsmap/cttsmap.par @@ -32,6 +32,7 @@ outmap, f, a, "tsmap.fits",,, "Output Test Statistic map file" # TS map computation parameters #============================== errors, b, h, no,,, "Compute and store parameter errors?" +statistic, s, h, CSTAT,CSTAT|WSTAT|CHI2,, "Optimization statistic" # # Spatial binning parameters diff --git a/src/ctulimit/ctulimit.cpp b/src/ctulimit/ctulimit.cpp index ce6f95b..ddf4cfa 100644 --- a/src/ctulimit/ctulimit.cpp +++ b/src/ctulimit/ctulimit.cpp @@ -449,14 +449,16 @@ void ctulimit::free_members(void) /***********************************************************************//** * @brief Get application parameters * - * Get all task parameters from parameter file or (if required) by querying - * the user. + * Get all task parameters from parameter file. ***************************************************************************/ void ctulimit::get_parameters(void) { // Setup observations from "inobs" parameter setup_observations(m_obs); - + + // Set observation statistic + set_obs_statistic(gammalib::toupper((*this)["statistic"].string())); + // Setup models from "inmodel" parameter setup_models(m_obs, (*this)["srcname"].string()); diff --git a/src/ctulimit/ctulimit.par b/src/ctulimit/ctulimit.par index 7fa4a0c..d4a5670 100644 --- a/src/ctulimit/ctulimit.par +++ b/src/ctulimit/ctulimit.par @@ -37,6 +37,7 @@ eref, r, h, 1.0,,, "Reference energy for differential limit (TeV)" emin, r, h, 1.0,,, "Minimum energy for integral flux limit (TeV)" emax, r, h, 100.0,,, "Maximum energy for integral flux limit (TeV)" tol, r, h, 1e-5,,, "Computation tolerance" +statistic, s, h, CSTAT,CSTAT|WSTAT|CHI2,, "Optimization statistic" max_iter, i, h, 50,1,1000, "Maximum number of iterations" # -- libgit2 0.21.4