Commit 88522bdbe6bd2b6cb6dae611c7f0668fa9dfea8e
1 parent
3d7a63b2
Integrate code.
Showing
6 changed files
with
33 additions
and
30 deletions
ChangeLog
| 1 | -2015-06-06 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 1 | +2015-06-09 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 2 | 2 | |
| 3 | 3 | * Version 0.11.0 released |
| 4 | 4 | ========================= |
| 5 | 5 | |
| 6 | 6 | Correct model gradient computation |
| 7 | + Add is_valid() method to GCTARoi and write keywords only if ROI is valid (#1476) | |
| 7 | 8 | Increased number of integration iterations for energy dispersion (#1472) |
| 8 | 9 | Add GOptimizerLM::logger() method, logger constructor takes pointer (#1471) |
| 9 | 10 | Replaced fixed precision integration by fixed iterations (#1466) | ... | ... |
NEWS
| ... | ... | @@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 0.11.0 |
| 2 | 2 | |
| 3 | 3 | Author(s) : Juergen Knoedlseder |
| 4 | 4 | |
| 5 | -6 June 2015 | |
| 5 | +9 June 2015 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | 1. Introduction |
| ... | ... | @@ -131,6 +131,10 @@ likelihood function is smooth. |
| 131 | 131 | The number of integration iterations for the energy dispersion was changed from |
| 132 | 132 | 4 to 5 to make it compatible with the default integration order. |
| 133 | 133 | |
| 134 | +An is_valid() method has been added to GCTARoi that returns true if the ROI | |
| 135 | +has a positive radius. DS keywords are only written for a valid ROI into the | |
| 136 | +event list file. | |
| 137 | + | |
| 134 | 138 | |
| 135 | 139 | 21. COMPTEL interface |
| 136 | 140 | --------------------- | ... | ... |
inst/cta/include/GCTARoi.hpp
| ... | ... | @@ -66,13 +66,13 @@ public: |
| 66 | 66 | virtual std::string print(const GChatter& chatter = NORMAL) const; |
| 67 | 67 | |
| 68 | 68 | // Other methods |
| 69 | + bool is_valid(void) const; | |
| 69 | 70 | const GCTAInstDir& centre(void) const; |
| 70 | 71 | const double& radius(void) const; |
| 71 | 72 | void centre(const GCTAInstDir& centre); |
| 72 | 73 | void radius(const double& radius); |
| 73 | 74 | void read(const GXmlElement& xml); |
| 74 | 75 | void write(GXmlElement& xml) const; |
| 75 | - bool is_valid(void) const; | |
| 76 | 76 | |
| 77 | 77 | protected: |
| 78 | 78 | // Protected methods |
| ... | ... | @@ -142,9 +142,9 @@ void GCTARoi::centre(const GCTAInstDir& centre) |
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | /***********************************************************************//** |
| 145 | - * @brief Checks sanity of RoI | |
| 145 | + * @brief Checks if RoI is valid | |
| 146 | 146 | * |
| 147 | - * @return Bool Flag if ROI information is valid. | |
| 147 | + * @return Bool flag if ROI information is valid. | |
| 148 | 148 | ***************************************************************************/ |
| 149 | 149 | inline |
| 150 | 150 | bool GCTARoi::is_valid(void) const | ... | ... |
inst/cta/pyext/GCTARoi.i
| ... | ... | @@ -51,13 +51,13 @@ public: |
| 51 | 51 | virtual bool contains(const GEvent& event) const; |
| 52 | 52 | |
| 53 | 53 | // Other methods |
| 54 | + bool is_valid(void) const; | |
| 54 | 55 | const GCTAInstDir& centre(void) const; |
| 55 | 56 | const double& radius(void) const; |
| 56 | 57 | void centre(const GCTAInstDir& centre); |
| 57 | 58 | void radius(const double& radius); |
| 58 | 59 | void read(const GXmlElement& xml); |
| 59 | 60 | void write(GXmlElement& xml) const; |
| 60 | - bool is_valid(void) const; | |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | ... | ... |
inst/cta/src/GCTAEventList.cpp
| ... | ... | @@ -1060,12 +1060,6 @@ void GCTAEventList::write_ds_keys(GFitsHDU& hdu) const |
| 1060 | 1060 | std::string dsval2 = gammalib::str(e_min) + ":" + |
| 1061 | 1061 | gammalib::str(e_max); |
| 1062 | 1062 | |
| 1063 | - // Set cone selection string | |
| 1064 | - std::string dsval3 = "CIRCLE(" + | |
| 1065 | - gammalib::str(ra) + "," + | |
| 1066 | - gammalib::str(dec) + "," + | |
| 1067 | - gammalib::str(rad) + ")"; | |
| 1068 | - | |
| 1069 | 1063 | // Add time selection keywords |
| 1070 | 1064 | hdu.card("DSTYP1", "TIME", "Data selection type"); |
| 1071 | 1065 | hdu.card("DSUNI1", "s", "Data selection unit"); |
| ... | ... | @@ -1080,15 +1074,22 @@ void GCTAEventList::write_ds_keys(GFitsHDU& hdu) const |
| 1080 | 1074 | // Initialise number of NDSKEYS |
| 1081 | 1075 | int ndskeys = 2; |
| 1082 | 1076 | |
| 1083 | - // Check if RoI information is valid before writing it | |
| 1077 | + // Add acceptance cone only if RoI information is valid | |
| 1084 | 1078 | if (m_roi.is_valid()) { |
| 1085 | 1079 | |
| 1086 | - // Add acceptance cone selection | |
| 1080 | + // Set cone selection string | |
| 1081 | + std::string dsval3 = "CIRCLE(" + | |
| 1082 | + gammalib::str(ra) + "," + | |
| 1083 | + gammalib::str(dec) + "," + | |
| 1084 | + gammalib::str(rad) + ")"; | |
| 1085 | + | |
| 1086 | + // Write DS keywords | |
| 1087 | 1087 | hdu.card("DSTYP3", "POS(RA,DEC)", "Data selection type"); |
| 1088 | 1088 | hdu.card("DSUNI3", "deg", "Data selection unit"); |
| 1089 | 1089 | hdu.card("DSVAL3", dsval3, "Data selection value"); |
| 1090 | - ndskeys = 3; | |
| 1091 | - } | |
| 1090 | + ndskeys++; | |
| 1091 | + | |
| 1092 | + } // endif: RoI was valid | |
| 1092 | 1093 | |
| 1093 | 1094 | // Set number of data selection keys |
| 1094 | 1095 | hdu.card("NDSKEYS", ndskeys, "Number of data selections"); | ... | ... |
inst/cta/src/GCTARoi.cpp
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | /* __ Method name definitions ____________________________________________ */ |
| 36 | 36 | #define G_READ "GCTARoi::read(GXmlElement&)" |
| 37 | 37 | #define G_WRITE "GCTARoi::write(GXmlElement&)" |
| 38 | -#define G_RADIUS "GCTARoi::radius(const double&)" | |
| 38 | +#define G_RADIUS "GCTARoi::radius(double&)" | |
| 39 | 39 | |
| 40 | 40 | /* __ Macros _____________________________________________________________ */ |
| 41 | 41 | |
| ... | ... | @@ -348,27 +348,24 @@ std::string GCTARoi::print(const GChatter& chatter) const |
| 348 | 348 | * |
| 349 | 349 | * @param[in] radius Region of interest radius (degrees). |
| 350 | 350 | * |
| 351 | - * @exception GException::invalid_value | |
| 351 | + * @exception GException::invalid_argument | |
| 352 | 352 | * Non-positive ROI radius encountered |
| 353 | 353 | * |
| 354 | 354 | * Set the radius of the region of interest. |
| 355 | 355 | ***************************************************************************/ |
| 356 | 356 | void GCTARoi::radius(const double& radius) |
| 357 | 357 | { |
| 358 | - // Check for sanity of radius | |
| 359 | - if (radius > 0.0) { | |
| 360 | - | |
| 361 | - // Set radius value | |
| 362 | - m_radius = radius; | |
| 363 | - } | |
| 364 | - else { | |
| 365 | - // Throw exception if radius invalid | |
| 366 | - std::string msg = "Trying to set invalid radius to RoI." | |
| 367 | - " Encountered radius of "+gammalib::str(radius)+"" | |
| 368 | - " while radius should be strictly positive"; | |
| 369 | - throw GException::invalid_value(G_RADIUS, msg); | |
| 358 | + // Throw an exception if argument is not valid | |
| 359 | + if (radius <= 0.0) { | |
| 360 | + std::string msg = "Invalid RoI radius "+gammalib::str(radius)+ | |
| 361 | + " encountered. Please specify a strictly" | |
| 362 | + " positive radius."; | |
| 363 | + throw GException::invalid_argument(G_RADIUS, msg); | |
| 370 | 364 | } |
| 371 | 365 | |
| 366 | + // Set radius value | |
| 367 | + m_radius = radius; | |
| 368 | + | |
| 372 | 369 | // Return |
| 373 | 370 | return; |
| 374 | 371 | } | ... | ... |