Commit 1cf7b40b22290616b297e3692abb4bfa02f55b49
1 parent
16f5fca0
Integrate code
Showing
3 changed files
with
17 additions
and
17 deletions
examples/show_butterfly.py
100644 → 100755
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This script shows how to plot a butterfly created with ctbutterfly |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014 Michael Mayer | |
| 5 | +# Copyright (C) 2014-2015 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -65,9 +65,8 @@ if __name__ == "__main__": |
| 65 | 65 | butterfly_x.append(csv.real(index,0)) |
| 66 | 66 | low_error = csv.real(index,1)-csv.real(index,2) |
| 67 | 67 | if low_error < 1e-26: |
| 68 | - low_error=1e-26 | |
| 68 | + low_error = 1e-26 | |
| 69 | 69 | butterfly_y.append(low_error) |
| 70 | - | |
| 71 | 70 | |
| 72 | 71 | # plot the butterfly and spectral line |
| 73 | 72 | plt.figure() | ... | ... |
src/ctbutterfly/ctbutterfly.cpp
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 37 | #define G_GET_PARAMETERS "ctbutterfly::get_parameters()" |
| 38 | 38 | #define G_SAVE "ctbutterfly::save()" |
| 39 | -#define G_GET_MODEL_PARAMETER "ctbutterfly::get_model_parameter()" | |
| 39 | +#define G_GET_MODEL_PARAMETER "ctbutterfly::get_model_parameter()" | |
| 40 | 40 | |
| 41 | 41 | /* __ Debug definitions __________________________________________________ */ |
| 42 | 42 | |
| ... | ... | @@ -286,20 +286,21 @@ void ctbutterfly::run(void) |
| 286 | 286 | // Loop over models |
| 287 | 287 | for (int j = 0; j < models.size(); ++j) { |
| 288 | 288 | |
| 289 | + // If source name is found, retrieve the nominal flux | |
| 289 | 290 | if (models[j]->name() == m_srcname) { |
| 290 | 291 | |
| 291 | - // If source name is found retrieve the nominal flux | |
| 292 | - // Note that we have to compute the gradients here repetively to update the | |
| 293 | - // gradients in the vector | |
| 294 | - // No check for valid pointers necessary here as this was covered by get_model_parameter() | |
| 295 | - GModelSky* skymodel = dynamic_cast<GModelSky*>(models[j]); | |
| 292 | + // Note that we have to compute the gradients here | |
| 293 | + // repetively to update the gradients in the vector | |
| 294 | + // No check for valid pointers necessary here as this | |
| 295 | + // was covered by get_model_parameter() | |
| 296 | + GModelSky* skymodel = dynamic_cast<GModelSky*>(models[j]); | |
| 296 | 297 | GModelSpectral* spectral = skymodel->spectral(); |
| 297 | 298 | model_flux = spectral->eval_gradients(energy, time); |
| 298 | 299 | |
| 299 | - } | |
| 300 | + } | |
| 300 | 301 | |
| 301 | 302 | // Loop over model parameters |
| 302 | - for(int i = 0; i < models[j]->size(); ++i) { | |
| 303 | + for (int i = 0; i < models[j]->size(); ++i) { | |
| 303 | 304 | |
| 304 | 305 | // Get model parameter |
| 305 | 306 | GModelPar parameter = models[j]->at(i); |
| ... | ... | @@ -398,8 +399,8 @@ void ctbutterfly::init_members(void) |
| 398 | 399 | m_ebounds.clear(); |
| 399 | 400 | |
| 400 | 401 | // Initialise protected members |
| 401 | - m_skymodel = NULL; | |
| 402 | - m_par_scale = 0.0; | |
| 402 | + m_skymodel = NULL; | |
| 403 | + m_par_scale = 0.0; | |
| 403 | 404 | m_obs.clear(); |
| 404 | 405 | m_covariance.clear(); |
| 405 | 406 | m_energies.clear(); |
| ... | ... | @@ -494,7 +495,7 @@ void ctbutterfly::get_parameters(void) |
| 494 | 495 | std::string msg = "Source \""+m_srcname+"\" not found in model " |
| 495 | 496 | "container. Please add a source with that name " |
| 496 | 497 | "or check for possible typos."; |
| 497 | - throw GException::invalid_value(G_GET_PARAMETERS, msg); | |
| 498 | + throw GException::invalid_value(G_GET_PARAMETERS, msg); | |
| 498 | 499 | } |
| 499 | 500 | |
| 500 | 501 | // Get relevant model and parameter for model computation | ... | ... |
src/ctbutterfly/ctbutterfly.hpp
| ... | ... | @@ -78,7 +78,7 @@ protected: |
| 78 | 78 | void copy_members(const ctbutterfly& app); |
| 79 | 79 | void free_members(void); |
| 80 | 80 | void get_parameters(void); |
| 81 | - void get_model_parameter(void); | |
| 81 | + void get_model_parameter(void); | |
| 82 | 82 | |
| 83 | 83 | // User parameters |
| 84 | 84 | std::string m_srcname; //!< Name of source to compute butterfly |
| ... | ... | @@ -88,8 +88,8 @@ protected: |
| 88 | 88 | // Protected members |
| 89 | 89 | GObservations m_obs; //!< Observation container |
| 90 | 90 | GMatrixSparse m_covariance; //!< Covariance matrix |
| 91 | - GModelSky* m_skymodel; //!< Pointer to sky model | |
| 92 | - double m_par_scale; //!< Scale of normalising parameter | |
| 91 | + GModelSky* m_skymodel; //!< Pointer to sky model | |
| 92 | + double m_par_scale; //!< Scale of normalising parameter | |
| 93 | 93 | std::vector<double> m_energies; //!< Energy values for storage |
| 94 | 94 | std::vector<double> m_fluxes; //!< Flux values per energy bin |
| 95 | 95 | std::vector<double> m_errors; //!< Flux errors per energy bin | ... | ... |