Commit e47a5b502ae350bdb41c74e16502eda9a1cda257
1 parent
4677209a
cterror now applies to all model types, not only sky models.
Showing
1 changed file
with
11 additions
and
13 deletions
src/cterror/cterror.cpp
| ... | ... | @@ -37,7 +37,6 @@ |
| 37 | 37 | #define G_GET_PARAMETERS "cterror::get_parameters()" |
| 38 | 38 | #define G_ERR_BISECTION "cterror::error_bisection(double&, double&)" |
| 39 | 39 | #define G_EVALUATE "cterror::evaluate(double&)" |
| 40 | -#define G_RUN "cterror::run()" | |
| 41 | 40 | |
| 42 | 41 | /* __ Debug definitions __________________________________________________ */ |
| 43 | 42 | |
| ... | ... | @@ -241,6 +240,9 @@ void cterror::run(void) |
| 241 | 240 | m_obs.errors(*m_opt); |
| 242 | 241 | m_best_logL = m_obs.logL(); |
| 243 | 242 | |
| 243 | + // Store optimizer for later recovery | |
| 244 | + GOptimizerLM best_opt = *m_opt; | |
| 245 | + | |
| 244 | 246 | // Write optimised model into logger |
| 245 | 247 | if (logTerse()) { |
| 246 | 248 | log << *m_opt << std::endl; |
| ... | ... | @@ -255,14 +257,8 @@ void cterror::run(void) |
| 255 | 257 | // Save best fitting models |
| 256 | 258 | GModels models_best = m_obs.models(); |
| 257 | 259 | |
| 258 | - // Get pointer on sky model | |
| 259 | - GModelSky* model = dynamic_cast<GModelSky*>(models_best[m_srcname]); | |
| 260 | - if (model == NULL) { | |
| 261 | - std::string msg = "Source \""+m_srcname+"\" is not a sky model. " | |
| 262 | - "Please specify the name of a sky model for " | |
| 263 | - "parameter error computation."; | |
| 264 | - throw GException::invalid_value(G_RUN, msg); | |
| 265 | - } | |
| 260 | + // Get pointer on model | |
| 261 | + GModel* model = models_best[m_srcname]; | |
| 266 | 262 | |
| 267 | 263 | // Get number of parameters |
| 268 | 264 | int npars = model->size(); |
| ... | ... | @@ -278,10 +274,9 @@ void cterror::run(void) |
| 278 | 274 | // Initialise with best fitting models |
| 279 | 275 | m_obs.models(models_best); |
| 280 | 276 | |
| 281 | - // Get pointer on sky model parameter | |
| 282 | - GModels& current_models = const_cast<GModels&>(m_obs.models()); | |
| 283 | - GModelSky* current_model = dynamic_cast<GModelSky*>(current_models[m_srcname]); | |
| 284 | - m_model_par = &(current_model->at(i)); | |
| 277 | + // Get pointer on model parameter | |
| 278 | + GModels& current_models = const_cast<GModels&>(m_obs.models()); | |
| 279 | + m_model_par = &(current_models[m_srcname]->at(i)); | |
| 285 | 280 | |
| 286 | 281 | // Extract current value |
| 287 | 282 | m_value = m_model_par->factor_value(); |
| ... | ... | @@ -360,6 +355,9 @@ void cterror::run(void) |
| 360 | 355 | |
| 361 | 356 | } // endif: source model exists |
| 362 | 357 | |
| 358 | + // Recover optimizer | |
| 359 | + *m_opt = best_opt; | |
| 360 | + | |
| 363 | 361 | // Return |
| 364 | 362 | return; |
| 365 | 363 | } | ... | ... |