Commit 60fca9e5d0e10cc6c4c3c7deb40c5926b32c85e2

Authored by Jürgen Knödlseder
1 parent 581a934b

Add ctool::setup_models() method and use ctool::setup_observations() method (#1828)

pyext/ctool.i
@@ -113,8 +113,12 @@ public: @@ -113,8 +113,12 @@ public:
113 // Protected methods 113 // Protected methods
114 const bool& read_ahead(void) const; 114 const bool& read_ahead(void) const;
115 const GTimeReference& time_reference(void) const; 115 const GTimeReference& time_reference(void) const;
116 - GObservations get_observations(const bool& get_response = true);  
117 - void setup_observations(GObservations& obs); 116 +
  117 + // Protected high-level setup methods
  118 + void setup_observations(GObservations& obs, const bool& response = true,
  119 + const bool& list = true,
  120 + const bool& cube = true);
  121 + void setup_models(GObservations& obs, const std::string& name = "");
118 122
119 // Protected methods that create objects from user parameters 123 // Protected methods that create objects from user parameters
120 GEbounds create_ebounds(void); 124 GEbounds create_ebounds(void);
@@ -142,6 +146,7 @@ public: @@ -142,6 +146,7 @@ public:
142 const std::vector<bool>& edisp) const; 146 const std::vector<bool>& edisp) const;
143 void set_obs_response(GCTAObservation* obs); 147 void set_obs_response(GCTAObservation* obs);
144 void set_obs_bounds(GObservations& obs); 148 void set_obs_bounds(GObservations& obs);
  149 + GObservations get_observations(const bool& get_response = true);
145 GSkyDir get_mean_pointing(const GObservations& obs); 150 GSkyDir get_mean_pointing(const GObservations& obs);
146 size_t get_current_rss(void); 151 size_t get_current_rss(void);
147 std::string get_obs_header(const GObservation* obs); 152 std::string get_obs_header(const GObservation* obs);
src/ctbin/ctbin.cpp
@@ -437,20 +437,9 @@ void ctbin::free_members(void) @@ -437,20 +437,9 @@ void ctbin::free_members(void)
437 ***************************************************************************/ 437 ***************************************************************************/
438 void ctbin::get_parameters(void) 438 void ctbin::get_parameters(void)
439 { 439 {
440 - // If there are no observations in container then load them via user  
441 - // parameters  
442 - if (m_obs.size() == 0) {  
443 -  
444 - // Throw exception if no input observation file is given  
445 - require_inobs(G_GET_PARAMETERS);  
446 -  
447 - // Throw exception if counts cube is given  
448 - require_inobs_nocube(G_GET_PARAMETERS);  
449 -  
450 - // Get observation container without response (not needed)  
451 - m_obs = get_observations(false);  
452 -  
453 - } // endif: there was no observation in the container 440 + // Setup observations from "inobs" parameter. Do not request response
  441 + // information and do not accept counts cubes.
  442 + setup_observations(m_obs, false, true, false);
454 443
455 // Create an event cube based on task parameters 444 // Create an event cube based on task parameters
456 GCTAEventCube cube = create_cube(m_obs); 445 GCTAEventCube cube = create_cube(m_obs);
src/ctbkgcube/ctbkgcube.cpp
@@ -473,26 +473,8 @@ void ctbkgcube::free_members(void) @@ -473,26 +473,8 @@ void ctbkgcube::free_members(void)
473 ***************************************************************************/ 473 ***************************************************************************/
474 void ctbkgcube::get_parameters(void) 474 void ctbkgcube::get_parameters(void)
475 { 475 {
476 - // If there are no observations in container then load them via user  
477 - // parameters  
478 - if (m_obs.size() == 0) {  
479 -  
480 - // Throw exception if no input observation file is given  
481 - require_inobs(G_GET_PARAMETERS);  
482 -  
483 - // Throw exception if counts cube is given  
484 - require_inobs_nocube(G_GET_PARAMETERS);  
485 -  
486 - // Build observation container  
487 - m_obs = get_observations();  
488 -  
489 - } // endif: there was no observation in the container  
490 -  
491 - // ... otherwise add response information and energy boundaries in case  
492 - // that they are missing  
493 - else {  
494 - setup_observations(m_obs);  
495 - } 476 + // Setup observations from "inobs" parameter. Do not accept counts cubes.
  477 + setup_observations(m_obs, true, true, false);
496 478
497 // Get the incube filename 479 // Get the incube filename
498 std::string incube = (*this)["incube"].filename(); 480 std::string incube = (*this)["incube"].filename();
src/ctbutterfly/ctbutterfly.cpp
@@ -584,37 +584,13 @@ void ctbutterfly::free_members(void) @@ -584,37 +584,13 @@ void ctbutterfly::free_members(void)
584 ***************************************************************************/ 584 ***************************************************************************/
585 void ctbutterfly::get_parameters(void) 585 void ctbutterfly::get_parameters(void)
586 { 586 {
587 - // If there are no observations in container then load them via user  
588 - // parameters  
589 - if (m_obs.size() == 0) {  
590 -  
591 - // Throw exception if no input observation file is given  
592 - require_inobs(G_GET_PARAMETERS);  
593 -  
594 - // Build observation container  
595 - m_obs = get_observations();  
596 -  
597 - } // endif: there was no observation in the container  
598 -  
599 - // ... otherwise add response information and energy boundaries in case  
600 - // that they are missing  
601 - else {  
602 - setup_observations(m_obs);  
603 - }  
604 -  
605 - // If there is are no models associated with the observations then  
606 - // load now the model definition  
607 - if (m_obs.models().size() == 0) {  
608 -  
609 - // Get models XML filename  
610 - std::string filename = (*this)["inmodel"].filename();  
611 -  
612 - // Setup models for optimizing.  
613 - m_obs.models(GModels(filename));  
614 -  
615 - } // endif: no models were associated with observations 587 + // Setup observations from "inobs" parameter
  588 + setup_observations(m_obs);
  589 +
  590 + // Setup models from "inmodel" parameter
  591 + setup_models(m_obs, (*this)["srcname"].string());
616 592
617 - // Get name of test source and check container for this name 593 + // Get name of test source
618 m_srcname = (*this)["srcname"].string(); 594 m_srcname = (*this)["srcname"].string();
619 595
620 // Check model name and type 596 // Check model name and type
src/ctcubemask/ctcubemask.cpp
@@ -36,7 +36,6 @@ @@ -36,7 +36,6 @@
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 #define G_RUN "ctcubemask::run()" 37 #define G_RUN "ctcubemask::run()"
38 #define G_APPLY_MASK "ctcubemask::apply_mask(GCTAObservation*)" 38 #define G_APPLY_MASK "ctcubemask::apply_mask(GCTAObservation*)"
39 -#define G_GET_PARAMETERS "ctcubemask::get_parameters()"  
40 39
41 /* __ Debug definitions __________________________________________________ */ 40 /* __ Debug definitions __________________________________________________ */
42 41
@@ -439,9 +438,6 @@ void ctcubemask::free_members(void) @@ -439,9 +438,6 @@ void ctcubemask::free_members(void)
439 /***********************************************************************//** 438 /***********************************************************************//**
440 * @brief Get application parameters 439 * @brief Get application parameters
441 * 440 *
442 - * @exception GException::invalid_value  
443 - * Parameter "inobs" is required for ctcubemask.  
444 - *  
445 * Get all task parameters from parameter file or (if required) by querying 441 * Get all task parameters from parameter file or (if required) by querying
446 * the user. 442 * the user.
447 * 443 *
@@ -455,20 +451,9 @@ void ctcubemask::get_parameters(void) @@ -455,20 +451,9 @@ void ctcubemask::get_parameters(void)
455 m_select_energy = true; 451 m_select_energy = true;
456 m_select_roi = true; 452 m_select_roi = true;
457 453
458 - // If there are no observations in container then load them via user  
459 - // parameters  
460 - if (m_obs.size() == 0) {  
461 -  
462 - // Throw exception if no input observation file is given  
463 - require_inobs(G_GET_PARAMETERS);  
464 -  
465 - // Throw exception if event list is given  
466 - require_inobs_nolist(G_GET_PARAMETERS);  
467 -  
468 - // Build observation container without response (not needed)  
469 - m_obs = get_observations(false);  
470 -  
471 - } // endif: there was no observation in the container 454 + // Setup observations from "inobs" parameter. Do not request response
  455 + // information and do not accept event lists.
  456 + setup_observations(m_obs, false, false, true);
472 457
473 // Get parameters 458 // Get parameters
474 m_regfile = (*this)["regfile"].filename(); 459 m_regfile = (*this)["regfile"].filename();
src/ctedispcube/ctedispcube.cpp
@@ -346,26 +346,8 @@ void ctedispcube::free_members(void) @@ -346,26 +346,8 @@ void ctedispcube::free_members(void)
346 ***************************************************************************/ 346 ***************************************************************************/
347 void ctedispcube::get_parameters(void) 347 void ctedispcube::get_parameters(void)
348 { 348 {
349 - // If there are no observations in container then load them via user  
350 - // parameters  
351 - if (m_obs.size() == 0) {  
352 -  
353 - // Throw exception if no input observation file is given  
354 - require_inobs(G_GET_PARAMETERS);  
355 -  
356 - // Throw exception if counts cube is given  
357 - require_inobs_nocube(G_GET_PARAMETERS);  
358 -  
359 - // Build observation container  
360 - m_obs = get_observations();  
361 -  
362 - } // endif: there was no observation in the container  
363 -  
364 - // ... otherwise add response information and energy boundaries in case  
365 - // that they are missing  
366 - else {  
367 - setup_observations(m_obs);  
368 - } 349 + // Setup observations from "inobs" parameter. Do not accept counts cubes.
  350 + setup_observations(m_obs, true, true, false);
369 351
370 // Get the incube filename 352 // Get the incube filename
371 std::string incube = (*this)["incube"].filename(); 353 std::string incube = (*this)["incube"].filename();
src/cterror/cterror.cpp
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 #include "GOptimizer.hpp" 34 #include "GOptimizer.hpp"
35 35
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 -#define G_GET_PARAMETERS "cterror::get_parameters()"  
38 #define G_ERR_BISECTION "cterror::error_bisection(double&, double&)" 37 #define G_ERR_BISECTION "cterror::error_bisection(double&, double&)"
39 #define G_EVALUATE "cterror::evaluate(double&)" 38 #define G_EVALUATE "cterror::evaluate(double&)"
40 39
@@ -455,52 +454,19 @@ void cterror::free_members(void) @@ -455,52 +454,19 @@ void cterror::free_members(void)
455 /***********************************************************************//** 454 /***********************************************************************//**
456 * @brief Get application parameters 455 * @brief Get application parameters
457 * 456 *
458 - * @exception GException::invalid_value  
459 - * Test source not found.  
460 - *  
461 * Get all task parameters from parameter file or (if required) by querying 457 * Get all task parameters from parameter file or (if required) by querying
462 * the user. 458 * the user.
463 ***************************************************************************/ 459 ***************************************************************************/
464 void cterror::get_parameters(void) 460 void cterror::get_parameters(void)
465 { 461 {
466 - // If there are no observations in container then load them via user  
467 - // parameters  
468 - if (m_obs.size() == 0) {  
469 -  
470 - // Throw exception if no input observation file is given  
471 - require_inobs(G_GET_PARAMETERS);  
472 -  
473 - // Build observation container  
474 - m_obs = get_observations();  
475 -  
476 - } // endif: there was no observation in the container  
477 -  
478 - // ... otherwise add response information and energy boundaries in case  
479 - // that they are missing  
480 - else {  
481 - setup_observations(m_obs);  
482 - }  
483 -  
484 - // If there are no models associated with the observations then  
485 - // load now the model definition  
486 - if (m_obs.models().size() == 0) {  
487 -  
488 - // Get models XML filename  
489 - std::string filename = (*this)["inmodel"].filename(); 462 + // Setup observations from "inobs" parameter
  463 + setup_observations(m_obs);
  464 +
  465 + // Setup models from "inmodel" parameter
  466 + setup_models(m_obs, (*this)["srcname"].string());
490 467
491 - // Setup models for optimizing.  
492 - m_obs.models(GModels(filename));  
493 -  
494 - } // endif: no models were associated with observations  
495 -  
496 - // Get name of test source and check container for this name 468 + // Get name of test source
497 m_srcname = (*this)["srcname"].string(); 469 m_srcname = (*this)["srcname"].string();
498 - if (!m_obs.models().contains(m_srcname)) {  
499 - std::string msg = "Source \""+m_srcname+"\" not found in model "  
500 - "container. Please add a source with that name "  
501 - "or check for possible typos.";  
502 - throw GException::invalid_value(G_GET_PARAMETERS, msg);  
503 - }  
504 470
505 // Read energy dispersion flag 471 // Read energy dispersion flag
506 m_apply_edisp = (*this)["edisp"].boolean(); 472 m_apply_edisp = (*this)["edisp"].boolean();
src/ctexpcube/ctexpcube.cpp
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 #include "GWcs.hpp" 34 #include "GWcs.hpp"
35 35
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 -#define G_GET_PARAMETERS "ctexpcube::get_parameters()"  
38 #define G_SET_FROM_CNTMAP "ctexpcube::set_from_cntmap(std::string&)" 37 #define G_SET_FROM_CNTMAP "ctexpcube::set_from_cntmap(std::string&)"
39 38
40 /* __ Debug definitions __________________________________________________ */ 39 /* __ Debug definitions __________________________________________________ */
@@ -371,26 +370,8 @@ void ctexpcube::free_members(void) @@ -371,26 +370,8 @@ void ctexpcube::free_members(void)
371 ***************************************************************************/ 370 ***************************************************************************/
372 void ctexpcube::get_parameters(void) 371 void ctexpcube::get_parameters(void)
373 { 372 {
374 - // If there are no observations in container then load them via user  
375 - // parameters  
376 - if (m_obs.size() == 0) {  
377 -  
378 - // Throw exception if no input observation file is given  
379 - require_inobs(G_GET_PARAMETERS);  
380 -  
381 - // Throw exception if counts cube is given  
382 - require_inobs_nocube(G_GET_PARAMETERS);  
383 -  
384 - // Build observation container  
385 - m_obs = get_observations();  
386 -  
387 - } // endif: there was no observation in the container  
388 -  
389 - // ... otherwise add response information and energy boundaries in case  
390 - // that they are missing  
391 - else {  
392 - setup_observations(m_obs);  
393 - } 373 + // Setup observations from "inobs" parameter. Do not accept counts cubes.
  374 + setup_observations(m_obs, true, true, false);
394 375
395 // Get the incube filename 376 // Get the incube filename
396 std::string incube = (*this)["incube"].filename(); 377 std::string incube = (*this)["incube"].filename();
src/ctlike/ctlike.cpp
@@ -33,7 +33,6 @@ @@ -33,7 +33,6 @@
33 #include "GTools.hpp" 33 #include "GTools.hpp"
34 34
35 /* __ Method name definitions ____________________________________________ */ 35 /* __ Method name definitions ____________________________________________ */
36 -#define G_GET_PARAMETERS "ctlike::get_parameters()"  
37 36
38 /* __ Debug definitions __________________________________________________ */ 37 /* __ Debug definitions __________________________________________________ */
39 38
@@ -361,23 +360,8 @@ void ctlike::save(void) @@ -361,23 +360,8 @@ void ctlike::save(void)
361 ***************************************************************************/ 360 ***************************************************************************/
362 void ctlike::get_parameters(void) 361 void ctlike::get_parameters(void)
363 { 362 {
364 - // If there are no observations in container then load them via user  
365 - // parameters  
366 - if (m_obs.size() == 0) {  
367 -  
368 - // Throw exception if no input observation file is given  
369 - require_inobs(G_GET_PARAMETERS);  
370 -  
371 - // Get observation container  
372 - m_obs = get_observations();  
373 -  
374 - } // endif: there was no observation in the container  
375 -  
376 - // ... otherwise add response information and energy boundaries in case  
377 - // that they are missing  
378 - else {  
379 - setup_observations(m_obs);  
380 - } 363 + // Setup observations from "inobs" parameter
  364 + setup_observations(m_obs);
381 365
382 // If only single observation is used, read statistics parameter 366 // If only single observation is used, read statistics parameter
383 if (!m_use_xml) { 367 if (!m_use_xml) {
src/ctpsfcube/ctpsfcube.cpp
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 #include "GWcs.hpp" 34 #include "GWcs.hpp"
35 35
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 -#define G_GET_PARAMETERS "ctpsfcube::get_parameters()"  
38 37
39 /* __ Debug definitions __________________________________________________ */ 38 /* __ Debug definitions __________________________________________________ */
40 39
@@ -331,26 +330,8 @@ void ctpsfcube::free_members(void) @@ -331,26 +330,8 @@ void ctpsfcube::free_members(void)
331 ***************************************************************************/ 330 ***************************************************************************/
332 void ctpsfcube::get_parameters(void) 331 void ctpsfcube::get_parameters(void)
333 { 332 {
334 - // If there are no observations in container then load them via user  
335 - // parameters  
336 - if (m_obs.size() == 0) {  
337 -  
338 - // Throw exception if no input observation file is given  
339 - require_inobs(G_GET_PARAMETERS);  
340 -  
341 - // Throw exception if counts cube is given  
342 - require_inobs_nocube(G_GET_PARAMETERS);  
343 -  
344 - // Build observation container  
345 - m_obs = get_observations();  
346 -  
347 - } // endif: there was no observation in the container  
348 -  
349 - // ... otherwise add response information and energy boundaries in case  
350 - // that they are missing  
351 - else {  
352 - setup_observations(m_obs);  
353 - } 333 + // Setup observations from "inobs" parameter. Do not accept counts cubes.
  334 + setup_observations(m_obs, true, true, false);
354 335
355 // Get the incube filename 336 // Get the incube filename
356 std::string incube = (*this)["incube"].filename(); 337 std::string incube = (*this)["incube"].filename();
src/ctselect/ctselect.cpp
@@ -37,7 +37,6 @@ @@ -37,7 +37,6 @@
37 #define G_SELECT_EVENTS "ctselect::select_events(GCTAObservation*, "\ 37 #define G_SELECT_EVENTS "ctselect::select_events(GCTAObservation*, "\
38 "std::string&, std::string&, std::string&)" 38 "std::string&, std::string&, std::string&)"
39 #define G_SET_EBOUNDS "ctselect::set_ebounds(GCTAObservation*, GEbounds&)" 39 #define G_SET_EBOUNDS "ctselect::set_ebounds(GCTAObservation*, GEbounds&)"
40 -#define G_GET_PARAMETERS "ctselect::get_parameters()"  
41 40
42 /* __ Debug definitions __________________________________________________ */ 41 /* __ Debug definitions __________________________________________________ */
43 42
@@ -502,20 +501,9 @@ void ctselect::get_parameters(void) @@ -502,20 +501,9 @@ void ctselect::get_parameters(void)
502 m_select_roi = true; 501 m_select_roi = true;
503 m_select_time = true; 502 m_select_time = true;
504 503
505 - // If there are no observations in container then load them via user  
506 - // parameters  
507 - if (m_obs.size() == 0) {  
508 -  
509 - // Throw exception if no input observation file is given  
510 - require_inobs(G_GET_PARAMETERS);  
511 -  
512 - // Throw exception if counts cube is given  
513 - require_inobs_nocube(G_GET_PARAMETERS);  
514 -  
515 - // Get observation container without response (not needed)  
516 - m_obs = get_observations(false);  
517 -  
518 - } // endif: there was no observation in the container 504 + // Setup observations from "inobs" parameter. Do not request response
  505 + // information and do not accept counts cubes.
  506 + setup_observations(m_obs, false, true, false);
519 507
520 // Get parameters 508 // Get parameters
521 m_usepnt = (*this)["usepnt"].boolean(); 509 m_usepnt = (*this)["usepnt"].boolean();
src/ctskymap/ctskymap.cpp
@@ -35,7 +35,6 @@ @@ -35,7 +35,6 @@
35 /* __ Method name definitions ____________________________________________ */ 35 /* __ Method name definitions ____________________________________________ */
36 #define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)" 36 #define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)"
37 #define G_BIN_EVENTS "ctskymap::bin_events(GCTAObservation*)" 37 #define G_BIN_EVENTS "ctskymap::bin_events(GCTAObservation*)"
38 -#define G_GET_PARAMETERS "ctskymap::get_parameters()"  
39 38
40 /* __ Debug definitions __________________________________________________ */ 39 /* __ Debug definitions __________________________________________________ */
41 40
@@ -402,20 +401,9 @@ void ctskymap::free_members(void) @@ -402,20 +401,9 @@ void ctskymap::free_members(void)
402 ***************************************************************************/ 401 ***************************************************************************/
403 void ctskymap::get_parameters(void) 402 void ctskymap::get_parameters(void)
404 { 403 {
405 - // If there are no observations in container then load them via user  
406 - // parameters  
407 - if (m_obs.size() == 0) {  
408 -  
409 - // Throw exception if no input observation file is given  
410 - require_inobs(G_GET_PARAMETERS);  
411 -  
412 - // Throw exception if counts cube is given  
413 - require_inobs_nocube(G_GET_PARAMETERS);  
414 -  
415 - // Get observation container without response (not needed)  
416 - m_obs = get_observations(false);  
417 -  
418 - } // endif: there was no observation in the container 404 + // Setup observations from "inobs" parameter. Do not request response
  405 + // information and do not accept counts cubes.
  406 + setup_observations(m_obs, false, true, false);
419 407
420 // Create sky map based on task parameters 408 // Create sky map based on task parameters
421 m_skymap = create_map(m_obs); 409 m_skymap = create_map(m_obs);
src/cttsmap/cttsmap.cpp
@@ -500,8 +500,7 @@ void cttsmap::free_members(void) @@ -500,8 +500,7 @@ void cttsmap::free_members(void)
500 * @brief Get application parameters 500 * @brief Get application parameters
501 * 501 *
502 * @exception GException::invalid_value 502 * @exception GException::invalid_value
503 - * Test source not found or no RA/DEC parameters found for test  
504 - * source. 503 + * Test source has no RA/DEC parameters.
505 * 504 *
506 * Get all task parameters from parameter file or (if required) by querying 505 * Get all task parameters from parameter file or (if required) by querying
507 * the user. Most parameters are only required if no observation exists so 506 * the user. Most parameters are only required if no observation exists so
@@ -511,44 +510,14 @@ void cttsmap::free_members(void) @@ -511,44 +510,14 @@ void cttsmap::free_members(void)
511 ***************************************************************************/ 510 ***************************************************************************/
512 void cttsmap::get_parameters(void) 511 void cttsmap::get_parameters(void)
513 { 512 {
514 - // If there are no observations in container then load them via user  
515 - // parameters  
516 - if (m_obs.size() == 0) { 513 + // Setup observations from "inobs" parameter
  514 + setup_observations(m_obs);
  515 +
  516 + // Setup models from "inmodel" parameter
  517 + setup_models(m_obs, (*this)["srcname"].string());
517 518
518 - // Throw exception if no input observation file is given  
519 - require_inobs(G_GET_PARAMETERS);  
520 -  
521 - // Get observation container  
522 - m_obs = get_observations();  
523 -  
524 - } // endif: there was no observation in the container  
525 -  
526 - // ... otherwise add response information and energy boundaries in case  
527 - // that they are missing  
528 - else {  
529 - setup_observations(m_obs);  
530 - }  
531 -  
532 - // If there is are no models associated with the observations then  
533 - // load now the model definition  
534 - if (m_obs.models().size() == 0) {  
535 -  
536 - // Get models XML filename  
537 - std::string filename = (*this)["inmodel"].filename();  
538 -  
539 - // Setup models for optimizing.  
540 - m_obs.models(GModels(filename));  
541 -  
542 - } // endif: no models were associated with observations  
543 -  
544 - // Get name of test source and check container for this name 519 + // Get name of test source
545 m_srcname = (*this)["srcname"].string(); 520 m_srcname = (*this)["srcname"].string();
546 - if (!m_obs.models().contains(m_srcname)) {  
547 - std::string msg = "Source \""+m_srcname+"\" not found in model "  
548 - "container. Please add a source with that name "  
549 - "or check for a possible typos.";  
550 - throw GException::invalid_value(G_GET_PARAMETERS, msg);  
551 - }  
552 521
553 // Get Model and store it as protected member 522 // Get Model and store it as protected member
554 m_testsource = m_obs.models()[m_srcname]->clone(); 523 m_testsource = m_obs.models()[m_srcname]->clone();
src/ctulimit/ctulimit.cpp
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 #include "GOptimizer.hpp" 34 #include "GOptimizer.hpp"
35 35
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 -#define G_GET_PARAMETERS "ctulimit::get_parameters()"  
38 #define G_GET_MODEL_PARAMETER "ctulimit::get_model_parameter()" 37 #define G_GET_MODEL_PARAMETER "ctulimit::get_model_parameter()"
39 #define G_UL_BISECTION "ctulimit::ul_bisection(double&, double&)" 38 #define G_UL_BISECTION "ctulimit::ul_bisection(double&, double&)"
40 #define G_EVALUATE "ctulimit::evaluate(double&)" 39 #define G_EVALUATE "ctulimit::evaluate(double&)"
@@ -461,46 +460,18 @@ void ctulimit::free_members(void) @@ -461,46 +460,18 @@ void ctulimit::free_members(void)
461 /***********************************************************************//** 460 /***********************************************************************//**
462 * @brief Get application parameters 461 * @brief Get application parameters
463 * 462 *
464 - * @exception GException::invalid_value  
465 - * Test source not found.  
466 - *  
467 * Get all task parameters from parameter file or (if required) by querying 463 * Get all task parameters from parameter file or (if required) by querying
468 * the user. 464 * the user.
469 ***************************************************************************/ 465 ***************************************************************************/
470 void ctulimit::get_parameters(void) 466 void ctulimit::get_parameters(void)
471 { 467 {
472 - // If there are no observations in container then load them via user  
473 - // parameters  
474 - if (m_obs.size() == 0) {  
475 -  
476 - // Throw exception if no input observation file is given  
477 - require_inobs(G_GET_PARAMETERS);  
478 -  
479 - // Build observation container  
480 - m_obs = get_observations();  
481 -  
482 - } // endif: there was no observation in the container  
483 -  
484 - // ... otherwise add response information and energy boundaries in case  
485 - // that they are missing  
486 - else {  
487 - setup_observations(m_obs);  
488 - }  
489 -  
490 - // If there is are no models associated with the observations then  
491 - // load now the model definition  
492 - if (m_obs.models().size() == 0) {  
493 -  
494 - // Get models XML filename  
495 - std::string filename = (*this)["inmodel"].filename();  
496 -  
497 - // Setup models for optimizing.  
498 - m_obs.models(GModels(filename));  
499 -  
500 - } // endif: no models were associated with observations 468 + // Setup observations from "inobs" parameter
  469 + setup_observations(m_obs);
  470 +
  471 + // Setup models from "inmodel" parameter
  472 + setup_models(m_obs, (*this)["srcname"].string());
501 473
502 - // Get name of test source. The get_model_parameter() method will check  
503 - // where a source with the given name exists in the model container. 474 + // Get name of test source
504 m_srcname = (*this)["srcname"].string(); 475 m_srcname = (*this)["srcname"].string();
505 476
506 // Get relevant model and parameter for upper limit computation 477 // Get relevant model and parameter for upper limit computation
src/support/ctool.cpp
@@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
50 50
51 /* __ Method name definitions ____________________________________________ */ 51 /* __ Method name definitions ____________________________________________ */
52 #define G_SETUP_OBSERVATION "ctool::setup_observations(GObservations&)" 52 #define G_SETUP_OBSERVATION "ctool::setup_observations(GObservations&)"
  53 +#define SETUP_MODELS "ctool::setup_models(GObservations&, std::string&)"
53 #define G_GET_MEAN_POINTING "ctool::get_mean_pointing(GObservations&)" 54 #define G_GET_MEAN_POINTING "ctool::get_mean_pointing(GObservations&)"
54 #define G_CREATE_EBOUNDS "ctool::create_ebounds()" 55 #define G_CREATE_EBOUNDS "ctool::create_ebounds()"
55 #define G_RESTORE_EDISP "ctool::restore_edisp(GObservations&, "\ 56 #define G_RESTORE_EDISP "ctool::restore_edisp(GObservations&, "\
@@ -304,189 +305,194 @@ void ctool::free_members(void) @@ -304,189 +305,194 @@ void ctool::free_members(void)
304 305
305 306
306 /***********************************************************************//** 307 /***********************************************************************//**
307 - * @brief Get observation container 308 + * @brief Setup observation container
308 * 309 *
309 - * @param[in] get_response Indicates whether response information should  
310 - * be loaded (default: true) 310 + * @param[in] obs Observation container
  311 + * @param[in] response Require response
  312 + * @param[in] list Accept event list as "inobs" parameter
  313 + * @param[in] cube Accept counts cube as "inobs" parameter
311 * 314 *
312 - * Get an observation container according to the user parameters. The method  
313 - * supports loading of a individual FITS file or an observation definition  
314 - * file in XML format. If the input filename is empty, parameters are read  
315 - * to build a CTA observation from scratch. 315 + * @exception GException::invalid_value
  316 + * Invalid "inobs" parameter encountered.
  317 + *
  318 + * Setup an observation container by extracting all required missing
  319 + * information from user parameters.
  320 + *
  321 + * If the observation container @p obs is empty, the method will extract the
  322 + * filename from the "inobs" parameter, and if the filename is neither empty
  323 + * nor "NONE", it will load the observation container from the specified file.
  324 + * Otherwise, the method will throw an exception.
  325 + *
  326 + * If the "inobs" file is a FITS file, and depending on the information that
  327 + * is found in the FITS file, the method will append a single CTA observation
  328 + * to the observation container, containing either an event list or a counts
  329 + * cube. It will set the m_use_xml member to false to signal that no
  330 + * observation XML file should be used for saving. The @p list and @p cube
  331 + * parameters can be used to specify whether the method actually should accept
  332 + * event lists or counts cube. If it shouldn't the method will throw an
  333 + * exception.
  334 + *
  335 + * If the "inobs" file is not a FITS file, the method assumes that an
  336 + * observation definition XML file has been specified, and will load that
  337 + * file into the observation container. It will set the m_use_xml member to
  338 + * true to signal that an observation XML file should be used for saving. No
  339 + * checking on event list or counts cubes will be done on the observation
  340 + * container.
  341 + *
  342 + * By default, the method will also setup the response for all CTA
  343 + * observations in the container. In case that no response information is
  344 + * required, the @p response argument should be set to @p false. See the
  345 + * set_response() method for details.
  346 + *
  347 + *
  348 + * The method will also setup the observation boundaries for all CTA
  349 + * observations in the container that contain event lists. For details, see
  350 + * the set_obs_bounds() method.
316 ***************************************************************************/ 351 ***************************************************************************/
317 -GObservations ctool::get_observations(const bool& get_response) 352 +void ctool::setup_observations(GObservations& obs,
  353 + const bool& response,
  354 + const bool& list,
  355 + const bool& cube)
318 { 356 {
319 - // Initialise empty observation container  
320 - GObservations obs;  
321 -  
322 - // Get the filename from the input parameters  
323 - std::string filename = (*this)["inobs"].filename();  
324 -  
325 - // If no observation definition file has been specified then read all  
326 - // parameters that are necessary to create an observation from scratch  
327 - if ((filename == "NONE") || (gammalib::strip_whitespace(filename) == "")) {  
328 -  
329 - // Setup a new CTA observation  
330 - GCTAObservation cta_obs = create_cta_obs();  
331 -  
332 - // Get response if required  
333 - if (get_response) {  
334 -  
335 - // Set response  
336 - set_obs_response(&cta_obs);  
337 -  
338 - } // endif: response was required  
339 -  
340 - // Append observation to container  
341 - obs.append(cta_obs);  
342 -  
343 - } // endif: filename was "NONE" or "" 357 + // Load observations if there are none in the container
  358 + if (obs.size() == 0) {
344 359
345 - // ... otherwise we have a file name  
346 - else { 360 + // Get the filename from the "inobs" parameter
  361 + GFilename filename = (*this)["inobs"].filename();
347 362
348 - // If file is a FITS file then create an empty CTA observation  
349 - // and load file into observation  
350 - if (GFilename(filename).is_fits()) { 363 + // Throw an exception if the "inobs" parameter is not a valid
  364 + // filename
  365 + if ((gammalib::toupper(filename.url()) == "NONE") ||
  366 + filename.is_empty()) {
  367 + std::string msg = "The \"inobs\" parameter \""+filename.url()+
  368 + "\" is not a valid filename. Please specify "
  369 + "a valid event list, counts cube or "
  370 + "observation definition XML file.";
  371 + throw GException::invalid_value(G_SETUP_OBSERVATION, msg);
  372 + }
351 373
352 - // Allocate empty CTA observation  
353 - GCTAObservation cta_obs; 374 + // If file does not exist then throw an exceptions
  375 + if (!filename.exists()) {
  376 + std::string msg = "The \"inobs\" parameter \""+filename.url()+
  377 + "\" specifies a file that does not "
  378 + "exist. Please specify a valid event "
  379 + "list, counts cube or observation "
  380 + "definition XML file.";
  381 + throw GException::invalid_value(G_SETUP_OBSERVATION, msg);
  382 + }
354 383
355 - // Load data  
356 - cta_obs.load(filename); 384 + // If the file is a FITS file then load it into a CTA
  385 + // observation and append that observation to the container ...
  386 + else if (filename.is_fits()) {
357 387
358 - // Get response if required  
359 - if (get_response) { 388 + // Load CTA observation
  389 + GCTAObservation cta(filename);
360 390
361 - // Set response  
362 - set_obs_response(&cta_obs); 391 + // If no event list is accepted but an event list has been
  392 + // loaded then throw an exception
  393 + if (!list && cta.eventtype() == "EventList") {
  394 + std::string msg = "The \"inobs\" parameter \""+filename.url()+
  395 + "\" specifies an event list, but this "
  396 + "tool does not accept event lists.";
  397 + throw GException::invalid_value(G_SETUP_OBSERVATION, msg);
  398 + }
363 399
364 - } // endif: response was required 400 + // If no counts cube is accepted but a conts cube has been
  401 + // loaded then throw an exception
  402 + if (!cube && cta.eventtype() == "CountsCube") {
  403 + std::string msg = "The \"inobs\" parameter \""+filename.url()+
  404 + "\" specifies a counts cube, but this "
  405 + "tool does not accept counts cubes.";
  406 + throw GException::invalid_value(G_SETUP_OBSERVATION, msg);
  407 + }
365 408
366 - // Append observation to container  
367 - obs.append(cta_obs); 409 + // Append CTA observation to observation container
  410 + obs.append(cta);
368 411
369 // Signal that no XML file should be used for storage 412 // Signal that no XML file should be used for storage
370 m_use_xml = false; 413 m_use_xml = false;
371 414
372 - } 415 + } // endelse: file was a FITS file
373 416
374 - // ... otherwise load file into observation container 417 + // ... otherwise it is assumed that the file is an observation
  418 + // definition XML file and the file is loaded into the
  419 + // observation container
375 else { 420 else {
376 421
377 - // Load observations from XML file 422 + // Load observation definition file
378 obs.load(filename); 423 obs.load(filename);
379 424
380 - // Get response if required  
381 - if (get_response) {  
382 -  
383 - // For all observations that have no response, set the response  
384 - // from the task parameters  
385 - set_response(obs);  
386 -  
387 - } // endif: response was required  
388 -  
389 - // Set observation boundary parameters (emin, emax, rad)  
390 - set_obs_bounds(obs);  
391 -  
392 // Signal that XML file should be used for storage 425 // Signal that XML file should be used for storage
393 m_use_xml = true; 426 m_use_xml = true;
394 427
395 } // endelse: file was an XML file 428 } // endelse: file was an XML file
396 429
  430 + } // endif: there were no observations in the container
  431 +
  432 + // Setup the response for all CTA observations in the observation
  433 + // container if response information is required
  434 + if (response) {
  435 + set_response(obs);
397 } 436 }
398 437
399 - // Return observation container  
400 - return obs; 438 + // Setup boundaries for all CTA observations containing event lists
  439 + set_obs_bounds(obs);
  440 +
  441 + // Return
  442 + return;
401 } 443 }
402 444
403 445
404 /***********************************************************************//** 446 /***********************************************************************//**
405 - * @brief Setup observation container 447 + * @brief Setup model container
406 * 448 *
407 * @param[in] obs Observation container 449 * @param[in] obs Observation container
  450 + * @param[in] name Mandatory model name
408 * 451 *
409 * @exception GException::invalid_value 452 * @exception GException::invalid_value
410 - * Invalid "inobs" parameter encountered. 453 + * Mandatory model name not found in observation container.
411 * 454 *
412 - * Setup an observation container by appending all required information that  
413 - * is missing using user parameters. 455 + * Setup a model container by loading the models from the "inmodel"
  456 + * parameter.
414 * 457 *
415 - * If the observation container @p obs is empty, the method will extract the  
416 - * filename from the "inobs" parameter, and if the filename is neither empty  
417 - * nor "NONE", will load the observation container from the specified file.  
418 - * If the file is a FITS file, and dependent on the information that is found  
419 - * in the FITS file, the method will append a single CTA observation to the  
420 - * observation container, containing either an event list or a counts cube.  
421 - * Otherwise, the method assumes that the file is an observation definition  
422 - * XML file and will load that file into the observation container.  
423 - *  
424 - * If the filename is empty or "NONE", the method will throw an exception.  
425 - *  
426 - * The method will then setup the response for all CTA observations in the  
427 - * container (see the set_response() method for more information).  
428 - *  
429 - * The method will furthermore setup the observation boundaries for all CTA  
430 - * observations in the container that contain event lists (see the  
431 - * set_obs_bounds() method for more information). 458 + * If the model container in the observation container @p obs is empty, the
  459 + * method will extract the model container filename from the "inmodel"
  460 + * parameter, load the model container and assign it to the observations
  461 + * container.
  462 + *
  463 + * If a mandatory model name is specified, the method will further check
  464 + * whether a model with the name exists in the model container.
432 ***************************************************************************/ 465 ***************************************************************************/
433 -void ctool::setup_observations(GObservations& obs) 466 +void ctool::setup_models(GObservations& obs,
  467 + const std::string& name)
434 { 468 {
435 - // Load observations if there are none in the container  
436 - if (obs.size() == 0) { 469 + // If there are no models in the observation container then load model
  470 + // container from the "inmodel" parameter and attach it to the
  471 + // observation container
  472 + if (obs.models().size() == 0) {
437 473
438 - // Get the filename from the "inobs" parameter  
439 - GFilename filename((*this)["inobs"].filename());  
440 -  
441 - // Load observation container from file if the filename is neither  
442 - // "NONE" nor empty ...  
443 - if ((gammalib::toupper(filename.url()) != "NONE") &&  
444 - !filename.is_empty()) {  
445 -  
446 - // If file does not exist then throw an exceptions  
447 - if (!filename.exists()) {  
448 - std::string msg = "The \"inobs\" parameter \""+filename+  
449 - "\" specifies a file that does not "  
450 - "exist. Please specify a valid event "  
451 - "list, counts cube or observation "  
452 - "definition XML file.";  
453 - throw GException::invalid_value(G_SETUP_OBSERVATION, msg);  
454 - } 474 + // Get models XML filename
  475 + GFilename filename = (*this)["inmodel"].filename();
455 476
456 - // If the file is a FITS file then load it into a CTA  
457 - // observation and append that observation to the container ...  
458 - else if (filename.is_fits()) {  
459 - GCTAObservation cta(filename);  
460 - obs.append(cta);  
461 - } 477 + // Load model container and assign it to observations container
  478 + obs.models(GModels(filename.url()));
462 479
463 - // ... otherwise it is assumed that the file is an observation  
464 - // definition XML file and the file is loaded into the  
465 - // observation container  
466 - else {  
467 - obs.load(filename);  
468 - } 480 + } // endif: no models were in observations container
469 481
470 - } 482 + // If a mandatory model name exists then check whether this model is
  483 + // part of the observation container. Throw an exception if the model
  484 + // does not exist
  485 + if (!name.empty()) {
471 486
472 - // ... otherwise, if the filename is "NONE" or empty then throw  
473 - // an exception.  
474 - else {  
475 - std::string msg = "The \"inobs\" parameter \""+filename+  
476 - "\" is not a valid filename. Please specify "  
477 - "a valid event list, counts cube or "  
478 - "observation definition XML file.";  
479 - throw GException::invalid_value(G_SETUP_OBSERVATION, msg); 487 + // Throw an exception if the model name does not exist
  488 + if (!obs.models().contains(name)) {
  489 + std::string msg = "Model \""+name+"\" not found in model "
  490 + "container. Please add a model with that name "
  491 + "or check for possible typos.";
  492 + throw GException::invalid_value(SETUP_MODELS, msg);
480 } 493 }
481 494
482 - } // endif: there were no observations in the container  
483 -  
484 - // Setup the response for all CTA observations in the observation  
485 - // container  
486 - set_response(obs);  
487 -  
488 - // Setup boundaries for all CTA observations containing event lists  
489 - set_obs_bounds(obs); 495 + } // endif: mandatory model name existed
490 496
491 // Return 497 // Return
492 return; 498 return;
@@ -1329,6 +1335,104 @@ void ctool::set_obs_bounds(GObservations&amp; obs) @@ -1329,6 +1335,104 @@ void ctool::set_obs_bounds(GObservations&amp; obs)
1329 1335
1330 1336
1331 /***********************************************************************//** 1337 /***********************************************************************//**
  1338 + * @brief Get observation container
  1339 + *
  1340 + * @param[in] get_response Indicates whether response information should
  1341 + * be loaded (default: true)
  1342 + *
  1343 + * Get an observation container according to the user parameters. The method
  1344 + * supports loading of a individual FITS file or an observation definition
  1345 + * file in XML format. If the input filename is empty, parameters are read
  1346 + * to build a CTA observation from scratch.
  1347 + ***************************************************************************/
  1348 +GObservations ctool::get_observations(const bool& get_response)
  1349 +{
  1350 + // Initialise empty observation container
  1351 + GObservations obs;
  1352 +
  1353 + // Get the filename from the input parameters
  1354 + std::string filename = (*this)["inobs"].filename();
  1355 +
  1356 + // If no observation definition file has been specified then read all
  1357 + // parameters that are necessary to create an observation from scratch
  1358 + if ((filename == "NONE") || (gammalib::strip_whitespace(filename) == "")) {
  1359 +
  1360 + // Setup a new CTA observation
  1361 + GCTAObservation cta_obs = create_cta_obs();
  1362 +
  1363 + // Get response if required
  1364 + if (get_response) {
  1365 +
  1366 + // Set response
  1367 + set_obs_response(&cta_obs);
  1368 +
  1369 + } // endif: response was required
  1370 +
  1371 + // Append observation to container
  1372 + obs.append(cta_obs);
  1373 +
  1374 + } // endif: filename was "NONE" or ""
  1375 +
  1376 + // ... otherwise we have a file name
  1377 + else {
  1378 +
  1379 + // If file is a FITS file then create an empty CTA observation
  1380 + // and load file into observation
  1381 + if (GFilename(filename).is_fits()) {
  1382 +
  1383 + // Allocate empty CTA observation
  1384 + GCTAObservation cta_obs;
  1385 +
  1386 + // Load data
  1387 + cta_obs.load(filename);
  1388 +
  1389 + // Get response if required
  1390 + if (get_response) {
  1391 +
  1392 + // Set response
  1393 + set_obs_response(&cta_obs);
  1394 +
  1395 + } // endif: response was required
  1396 +
  1397 + // Append observation to container
  1398 + obs.append(cta_obs);
  1399 +
  1400 + // Signal that no XML file should be used for storage
  1401 + m_use_xml = false;
  1402 +
  1403 + }
  1404 +
  1405 + // ... otherwise load file into observation container
  1406 + else {
  1407 +
  1408 + // Load observations from XML file
  1409 + obs.load(filename);
  1410 +
  1411 + // Get response if required
  1412 + if (get_response) {
  1413 +
  1414 + // For all observations that have no response, set the response
  1415 + // from the task parameters
  1416 + set_response(obs);
  1417 +
  1418 + } // endif: response was required
  1419 +
  1420 + // Set observation boundary parameters (emin, emax, rad)
  1421 + set_obs_bounds(obs);
  1422 +
  1423 + // Signal that XML file should be used for storage
  1424 + m_use_xml = true;
  1425 +
  1426 + } // endelse: file was an XML file
  1427 +
  1428 + }
  1429 +
  1430 + // Return observation container
  1431 + return obs;
  1432 +}
  1433 +
  1434 +
  1435 +/***********************************************************************//**
1332 * @brief Derives mean pointing from CTA observations 1436 * @brief Derives mean pointing from CTA observations
1333 * 1437 *
1334 * @param[in] obs Observation container. 1438 * @param[in] obs Observation container.
src/support/ctool.hpp
@@ -71,8 +71,12 @@ protected: @@ -71,8 +71,12 @@ protected:
71 void free_members(void); 71 void free_members(void);
72 const bool& read_ahead(void) const; 72 const bool& read_ahead(void) const;
73 const GTimeReference& time_reference(void) const; 73 const GTimeReference& time_reference(void) const;
74 - GObservations get_observations(const bool& get_response = true);  
75 - void setup_observations(GObservations& obs); 74 +
  75 + // Protected high-level setup methods
  76 + void setup_observations(GObservations& obs, const bool& response = true,
  77 + const bool& list = true,
  78 + const bool& cube = true);
  79 + void setup_models(GObservations& obs, const std::string& name = "");
76 80
77 // Protected methods that create objects from user parameters 81 // Protected methods that create objects from user parameters
78 GEbounds create_ebounds(void); 82 GEbounds create_ebounds(void);
@@ -100,6 +104,7 @@ protected: @@ -100,6 +104,7 @@ protected:
100 const std::vector<bool>& edisp) const; 104 const std::vector<bool>& edisp) const;
101 void set_obs_response(GCTAObservation* obs); 105 void set_obs_response(GCTAObservation* obs);
102 void set_obs_bounds(GObservations& obs); 106 void set_obs_bounds(GObservations& obs);
  107 + GObservations get_observations(const bool& get_response = true);
103 GSkyDir get_mean_pointing(const GObservations& obs); 108 GSkyDir get_mean_pointing(const GObservations& obs);
104 size_t get_current_rss(void); 109 size_t get_current_rss(void);
105 std::string get_obs_header(const GObservation* obs); 110 std::string get_obs_header(const GObservation* obs);
test/test_ctobssim.py
@@ -74,7 +74,8 @@ class Test(test): @@ -74,7 +74,8 @@ class Test(test):
74 ' outevents="events.fits"'+ \ 74 ' outevents="events.fits"'+ \
75 ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ 75 ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \
76 ' ra=83.63 dec=22.01 rad=10.0'+ \ 76 ' ra=83.63 dec=22.01 rad=10.0'+ \
77 - ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0' 77 + ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'+ \
  78 + ' logfile="ctobssim_cmd1.log" chatter=1'
78 79
79 # Check if execution of wrong command fails 80 # Check if execution of wrong command fails
80 self.test_assert(self._execute('command_that_does_not_exist') != 0, 81 self.test_assert(self._execute('command_that_does_not_exist') != 0,
@@ -93,7 +94,8 @@ class Test(test): @@ -93,7 +94,8 @@ class Test(test):
93 ' outevents="events.fits"'+ \ 94 ' outevents="events.fits"'+ \
94 ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ 95 ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \
95 ' ra=83.63 dec=22.01 rad=10.0'+ \ 96 ' ra=83.63 dec=22.01 rad=10.0'+ \
96 - ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0' 97 + ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'+ \
  98 + ' logfile="ctobssim_cmd2.log" chatter=1'
97 99
98 # Check if execution failed 100 # Check if execution failed
99 self.test_assert(self._execute(cmd) != 0, 101 self.test_assert(self._execute(cmd) != 0,
@@ -120,8 +122,11 @@ class Test(test): @@ -120,8 +122,11 @@ class Test(test):
120 sim['tmax'] = 1800.0 122 sim['tmax'] = 1800.0
121 sim['emin'] = 0.1 123 sim['emin'] = 0.1
122 sim['emax'] = 100.0 124 sim['emax'] = 100.0
  125 + sim['logfile'] = 'ctobssim_py1.log'
  126 + sim['chatter'] = 2
123 127
124 # Run tool 128 # Run tool
  129 + sim.logFileOpen()
125 sim.run() 130 sim.run()
126 131
127 # Check content of observation 132 # Check content of observation
@@ -146,8 +151,11 @@ class Test(test): @@ -146,8 +151,11 @@ class Test(test):
146 sim = ctools.ctobssim(obs) 151 sim = ctools.ctobssim(obs)
147 sim['outevents'] = 'sim_events.xml' 152 sim['outevents'] = 'sim_events.xml'
148 sim['inmodel'] = self._model 153 sim['inmodel'] = self._model
  154 + sim['logfile'] = 'ctobssim_py2.log'
  155 + sim['chatter'] = 3
149 156
150 # Run tool 157 # Run tool
  158 + sim.logFileOpen()
151 sim.run() 159 sim.run()
152 160
153 # Retrieve observation and check content 161 # Retrieve observation and check content
@@ -182,10 +190,13 @@ class Test(test): @@ -182,10 +190,13 @@ class Test(test):
182 sim['tmax'] = 1800.0 190 sim['tmax'] = 1800.0
183 sim['emin'] = 0.1 191 sim['emin'] = 0.1
184 sim['emax'] = 100.0 192 sim['emax'] = 100.0
  193 + sim['logfile'] = 'ctobssim_py3.log'
  194 + sim['chatter'] = 4
185 195
186 # Run ctbin tool 196 # Run ctbin tool
187 self.test_try('Run ctobssim with invalid model file') 197 self.test_try('Run ctobssim with invalid model file')
188 try: 198 try:
  199 + sim.logFileOpen()
189 sim.run() 200 sim.run()
190 self.test_try_failure() 201 self.test_try_failure()
191 except: 202 except: