Commit d9d22559bd7909fa72860fdd9c2d8bdbdd4c9d30
1 parent
9872a7d1
Allow for CSV or FITS file to store covariance matrix (#1863)
Showing
3 changed files
with
22 additions
and
17 deletions
doc/source/users/reference_manual/ctlike.rst
| ... | ... | @@ -48,13 +48,13 @@ the spatial model parameters can be kept fixed during that computation |
| 48 | 48 | ctlike generates an output model XML file that contains the values of the |
| 49 | 49 | best fitting model parameters. For all free parameters, an ``error`` attribute |
| 50 | 50 | is added that provides the statistical uncertainty in the parameter estimate. |
| 51 | -In addition, the entire output of the covariance matrix to a separate file in CSV | |
| 52 | -format can be queried (parameter ``outcovmat``). The parameter order given in the | |
| 53 | -file header corresponds to the arrangement of the covariance matrix entries. | |
| 54 | 51 | If computation of the Test Statistics has been requested for a model component, |
| 55 | 52 | a ``ts`` attribute providing the Test Statistics value is added. The output model |
| 56 | 53 | can be used as an input model for other ctools. |
| 57 | 54 | |
| 55 | +In addition, the covariance matrix can be saved into a file by specifying a | |
| 56 | +file name for the ``outcovmat`` parameter. If the file name ends with ``.fits`` | |
| 57 | +or ``.fit`` a FITS file is written, otherwise a CSV file is written. | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | General parameters |
| ... | ... | @@ -89,7 +89,7 @@ General parameters |
| 89 | 89 | the maximum likelihood fit. |
| 90 | 90 | |
| 91 | 91 | ``(outcovmat = NONE) [string]`` |
| 92 | - Output CSV file to store covariance matrix. | |
| 92 | + Output FITS or CSV file to store covariance matrix. | |
| 93 | 93 | |
| 94 | 94 | ``(stat = POISSON) [string]`` |
| 95 | 95 | Fitting statistics (POISSON or GAUSSIAN; only affects binned analysis). | ... | ... |
src/ctlike/ctlike.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctlike - Maximum likelihood fitting tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -321,8 +321,13 @@ void ctlike::run(void) |
| 321 | 321 | /***********************************************************************//** |
| 322 | 322 | * @brief Save results |
| 323 | 323 | * |
| 324 | - * This method saves the fit results into a XML file and a CSV file. If | |
| 325 | - * the filename parameters are "NONE", the files are not saved. | |
| 324 | + * This method saves the fit results and the covariance matrix. The fit | |
| 325 | + * results are written into a XML file while the covariance matrix is written | |
| 326 | + * into either a FITS or a CSV file, depending on the file type extension | |
| 327 | + * (an extension of `.fits` or `.fit` produce a FITS file, any other | |
| 328 | + * extension produces a CSV file). | |
| 329 | + * | |
| 330 | + * If the filenames are `NONE` no information is saved. | |
| 326 | 331 | ***************************************************************************/ |
| 327 | 332 | void ctlike::save(void) |
| 328 | 333 | { | ... | ... |
src/ctlike/ctlike.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctlike - Maximum likelihood fitting tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -68,17 +68,17 @@ protected: |
| 68 | 68 | double reoptimize_lm(void); |
| 69 | 69 | |
| 70 | 70 | // User parameters |
| 71 | - bool m_refit; //!< Refitting | |
| 72 | - GFilename m_outmodel; //!< Source model output XML file name | |
| 73 | - GFilename m_outcovmat; //!< Covariance matrix output CSV file name | |
| 74 | - bool m_apply_edisp; //!< Apply energy dispersion? | |
| 75 | - bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? | |
| 76 | - GChatter m_chatter; //!< Chattiness | |
| 71 | + bool m_refit; //!< Refitting | |
| 72 | + GFilename m_outmodel; //!< Source model output XML file name | |
| 73 | + GFilename m_outcovmat; //!< Covariance matrix output file name | |
| 74 | + bool m_apply_edisp; //!< Apply energy dispersion? | |
| 75 | + bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? | |
| 76 | + GChatter m_chatter; //!< Chattiness | |
| 77 | 77 | |
| 78 | 78 | // Members |
| 79 | - int m_max_iter; //!< Maximum number of iterations | |
| 80 | - int m_max_stall; //!< Maximum number of stalls | |
| 81 | - double m_logL; //!< Maximum log likelihood | |
| 79 | + int m_max_iter; //!< Maximum number of iterations | |
| 80 | + int m_max_stall; //!< Maximum number of stalls | |
| 81 | + double m_logL; //!< Maximum log likelihood | |
| 82 | 82 | }; |
| 83 | 83 | |
| 84 | 84 | #endif /* CTLIKE_HPP */ | ... | ... |