Commit ab095b4b4795f6437adb0df80f2fc02ada76a2fd
Merge branch 'integration' into devel
Showing
7 changed files
with
103 additions
and
15 deletions
AUTHORS
ChangeLog
| 1 | -2013-11-19 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 1 | +2013-11-20 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 2 | 2 | |
| 3 | 3 | * Version 0.7.0 released |
| 4 | 4 | ======================== |
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | Adapt to GammaLib-00-08-00 interface |
| 7 | 7 | ctobssim now only simulates events within ROI and supports |
| 8 | 8 | all kinds of data space models |
| 9 | + ctbin now implements LIN and FILE binning algorithms | |
| 9 | 10 | |
| 10 | 11 | 2012-12-21 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> |
| 11 | 12 | ... | ... |
NEWS
| ... | ... | @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-07-00 |
| 2 | 2 | |
| 3 | 3 | Author(s) : Juergen Knoedlseder |
| 4 | 4 | |
| 5 | -19 November 2013 | |
| 5 | +20 November 2013 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | 1. Introduction |
| ... | ... | @@ -45,7 +45,12 @@ None |
| 45 | 45 | |
| 46 | 46 | 6. ctbin - CTA event binning |
| 47 | 47 | ---------------------------- |
| 48 | -None | |
| 48 | +The ebinalg parameter is now used to specify the type of binning. | |
| 49 | +Linear (LIN) binning and binning retrieved from a FITS file (FILE) | |
| 50 | +is now supported. For the latter, an extension named EBOUNDS or | |
| 51 | +ENERGYBINS is expected. | |
| 52 | + | |
| 53 | +The ebinalg and ebinfile parameters are now automatic. | |
| 49 | 54 | |
| 50 | 55 | |
| 51 | 56 | 7. ctlike - CTA maximum likelihood fitting | ... | ... |
src/ctbin/ctbin.cpp
| ... | ... | @@ -432,9 +432,19 @@ void ctbin::get_parameters(void) |
| 432 | 432 | m_xref = (*this)["xref"].real(); |
| 433 | 433 | m_yref = (*this)["yref"].real(); |
| 434 | 434 | } |
| 435 | - m_emin = (*this)["emin"].real(); | |
| 436 | - m_emax = (*this)["emax"].real(); | |
| 437 | - m_enumbins = (*this)["enumbins"].integer(); | |
| 435 | + m_ebinalg = (*this)["ebinalg"].string(); | |
| 436 | + | |
| 437 | + // If we have the binning given by a file then read filename | |
| 438 | + if (m_ebinalg == "FILE") { | |
| 439 | + m_ebinfile = (*this)["ebinfile"].filename(); | |
| 440 | + } | |
| 441 | + | |
| 442 | + // ... otherwise read emin, emax and nebins | |
| 443 | + else{ | |
| 444 | + m_emin = (*this)["emin"].real(); | |
| 445 | + m_emax = (*this)["emax"].real(); | |
| 446 | + m_enumbins = (*this)["enumbins"].integer(); | |
| 447 | + } | |
| 438 | 448 | m_proj = (*this)["proj"].string(); |
| 439 | 449 | m_coordsys = (*this)["coordsys"].string(); |
| 440 | 450 | m_binsz = (*this)["binsz"].real(); |
| ... | ... | @@ -483,10 +493,74 @@ void ctbin::bin_events(GCTAObservation* obs) |
| 483 | 493 | throw GException::no_list(G_BIN_EVENTS); |
| 484 | 494 | } |
| 485 | 495 | |
| 486 | - // Setup energy range covered by data | |
| 487 | - GEnergy emin(m_emin, "TeV"); | |
| 488 | - GEnergy emax(m_emax, "TeV"); | |
| 489 | - GEbounds ebds(m_enumbins, emin, emax); | |
| 496 | + // Initialise empty Ebounds object | |
| 497 | + GEbounds ebds; | |
| 498 | + | |
| 499 | + // First check wether we have FITS-file defining | |
| 500 | + // the binning | |
| 501 | + if (m_ebinalg == "FILE") { | |
| 502 | + | |
| 503 | + // Open fits file to check which extension is given | |
| 504 | + GFits file(m_ebinfile); | |
| 505 | + | |
| 506 | + if (file.hashdu("EBOUNDS")) { | |
| 507 | + | |
| 508 | + // Close file and load ebounds | |
| 509 | + file.close(); | |
| 510 | + ebds.load(m_ebinfile,"EBOUNDS"); | |
| 511 | + | |
| 512 | + } // endif: EBOUNDS extension was given | |
| 513 | + | |
| 514 | + else if (file.hashdu("ENERGYBINS")) { | |
| 515 | + | |
| 516 | + // Close file and load ebounds | |
| 517 | + file.close(); | |
| 518 | + ebds.load(m_ebinfile,"ENERGYBINS"); | |
| 519 | + | |
| 520 | + } // endelse: ENERGYBINS extension was given | |
| 521 | + | |
| 522 | + else { | |
| 523 | + | |
| 524 | + // Close file | |
| 525 | + file.close(); | |
| 526 | + | |
| 527 | + // Signal that no energy boundaries have been found | |
| 528 | + std::string msg = "No extension with name \"EBOUNDS\" or" | |
| 529 | + " \"ENERGYBINS\" found in FITS file" | |
| 530 | + " \""+m_ebinfile+"\".\n" | |
| 531 | + "An \"EBOUNDS\" or \"ENERGYBINS\" extension" | |
| 532 | + " is required if the parameter \"ebinalg\"" | |
| 533 | + " is set to \"FILE\"."; | |
| 534 | + throw GException::invalid_value(G_BIN_EVENTS, msg); | |
| 535 | + | |
| 536 | + } // endelse: no suited extension found | |
| 537 | + | |
| 538 | + // Set enumbins parameter to number of ebounds | |
| 539 | + m_enumbins = ebds.size(); | |
| 540 | + | |
| 541 | + } // endif: ebinalg was "FILE" | |
| 542 | + | |
| 543 | + else { | |
| 544 | + | |
| 545 | + // Initialise log mode for ebinning | |
| 546 | + bool log = true; | |
| 547 | + | |
| 548 | + // check if algorithm is linear | |
| 549 | + if (m_ebinalg == "LIN") { | |
| 550 | + log = false; | |
| 551 | + } | |
| 552 | + | |
| 553 | + // todo: should we also check if m_ebinalg is "LOG" | |
| 554 | + // and throw an exception if neither LIN/LOG/FILE | |
| 555 | + // is given? | |
| 556 | + | |
| 557 | + // Setup energy range covered by data | |
| 558 | + GEnergy emin(m_emin, "TeV"); | |
| 559 | + GEnergy emax(m_emax, "TeV"); | |
| 560 | + GEbounds ebounds(m_enumbins, emin, emax,log); | |
| 561 | + ebds = ebounds; | |
| 562 | + | |
| 563 | + } //endif: ebinalg was not "FILE" | |
| 490 | 564 | |
| 491 | 565 | // Get Good Time intervals |
| 492 | 566 | GGti gti = obs->events()->gti(); |
| ... | ... | @@ -605,6 +679,8 @@ void ctbin::init_members(void) |
| 605 | 679 | m_prefix.clear(); |
| 606 | 680 | m_proj.clear(); |
| 607 | 681 | m_coordsys.clear(); |
| 682 | + m_ebinalg.clear(); | |
| 683 | + m_ebinfile.clear(); | |
| 608 | 684 | m_usepnt = false; |
| 609 | 685 | m_emin = 0.0; |
| 610 | 686 | m_emax = 0.0; |
| ... | ... | @@ -642,6 +718,8 @@ void ctbin::copy_members(const ctbin& app) |
| 642 | 718 | m_prefix = app.m_prefix; |
| 643 | 719 | m_proj = app.m_proj; |
| 644 | 720 | m_coordsys = app.m_coordsys; |
| 721 | + m_ebinalg = app.m_ebinalg; | |
| 722 | + m_ebinfile = app.m_ebinfile; | |
| 645 | 723 | m_usepnt = app.m_usepnt; |
| 646 | 724 | m_emin = app.m_emin; |
| 647 | 725 | m_emax = app.m_emax; | ... | ... |
src/ctbin/ctbin.hpp
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | |
| 34 | 34 | /* __Definitions _________________________________________________________ */ |
| 35 | 35 | #define CTBIN_NAME "ctbin" |
| 36 | -#define CTBIN_VERSION "00-04-00" | |
| 36 | +#define CTBIN_VERSION "00-05-00" | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /***********************************************************************//** |
| ... | ... | @@ -89,6 +89,8 @@ protected: |
| 89 | 89 | int m_enumbins; //!< Number of energy bins |
| 90 | 90 | std::string m_proj; //!< WCS projection |
| 91 | 91 | std::string m_coordsys; //!< Coordinate system |
| 92 | + std::string m_ebinalg; //!< Algorithm for energy binning | |
| 93 | + std::string m_ebinfile; //!< FITS-file containing energy binning | |
| 92 | 94 | double m_xref; //!< Longitude reference coordinate |
| 93 | 95 | double m_yref; //!< Latitude reference coordinate |
| 94 | 96 | double m_binsz; //!< Pixel size | ... | ... |
src/ctbin/ctbin.par
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctbin.par # |
| 8 | -# Version: 00-04-00 # | |
| 8 | +# Version: 00-05-00 # | |
| 9 | 9 | # # |
| 10 | 10 | # Author: Jurgen Knodlseder # |
| 11 | 11 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -23,11 +23,11 @@ prefix, s, h, "cntmap_",,,"Prefix for counts maps in observation definition fil |
| 23 | 23 | # |
| 24 | 24 | # Energy binning parameters |
| 25 | 25 | #========================== |
| 26 | -ebinalg, s, h, "LOG", FILE|LIN|LOG,,"Algorithm for defining energy bins" | |
| 26 | +ebinalg, s, a, "LOG", FILE|LIN|LOG,,"Algorithm for defining energy bins" | |
| 27 | 27 | emin, r, a, 0.1,,,"Start value for first energy bin in TeV" |
| 28 | 28 | emax, r, a, 100.0,,,"Stop value for last energy bin in TeV" |
| 29 | 29 | enumbins, i, a, 20,,,"Number of energy bins" |
| 30 | -ebinfile, f, h, "NONE",,,"Name of the file containing the energy bin definition" | |
| 30 | +ebinfile, f, a, "NONE",,,"Name of the file containing the energy bin definition" | |
| 31 | 31 | # |
| 32 | 32 | # Spatial binning parameters |
| 33 | 33 | #=========================== | ... | ... |
test/test_ctools.sh
| ... | ... | @@ -143,6 +143,7 @@ $ctbin evfile="events.fits" \ |
| 143 | 143 | emin=0.1 \ |
| 144 | 144 | emax=100.0 \ |
| 145 | 145 | enumbins=20 \ |
| 146 | + ebinalg="LOG" \ | |
| 146 | 147 | nxpix=200 \ |
| 147 | 148 | nypix=200 \ |
| 148 | 149 | binsz=0.02 \ |
| ... | ... | @@ -165,6 +166,7 @@ $ctbin evfile="events2.fits" \ |
| 165 | 166 | emin=0.3 \ |
| 166 | 167 | emax=8.0 \ |
| 167 | 168 | enumbins=10 \ |
| 169 | + ebinalg="LOG" \ | |
| 168 | 170 | nxpix=50 \ |
| 169 | 171 | nypix=50 \ |
| 170 | 172 | binsz=0.02 \ | ... | ... |