Commit 48cb48d742ed67af26daef6cdfa44f81155cfd93
1 parent
90bf75e9
correct routine name definitions
Showing
1 changed file
with
42 additions
and
42 deletions
src/obs/GEbounds.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GEbounds.cpp - Energy boundary class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2010 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software; you can redistribute it and/or modify * |
| ... | ... | @@ -27,12 +27,12 @@ |
| 27 | 27 | #include "GEbounds.hpp" |
| 28 | 28 | |
| 29 | 29 | /* __ Method name definitions ____________________________________________ */ |
| 30 | -#define G_COPY_MEMBERS "GEbounds::copy_members(const GEbounds&)" | |
| 31 | -#define G_LOAD "GEbounds::load(const std::string&, const std::string&)" | |
| 32 | -#define G_EMIN "GEbounds::emin(int) const" | |
| 33 | -#define G_EMAX "GEbounds::emax(int) const" | |
| 34 | -#define G_EMEAN "GEbounds::emean(int) const" | |
| 35 | -#define G_ELOGMEAN "GEbounds::elogmean(int) const" | |
| 30 | +#define G_COPY_MEMBERS "GEbounds::copy_members(GEbounds)" | |
| 31 | +#define G_LOAD "GEbounds::load(std::string,std::string)" | |
| 32 | +#define G_EMIN "GEbounds::emin(int)" | |
| 33 | +#define G_EMAX "GEbounds::emax(int)" | |
| 34 | +#define G_EMEAN "GEbounds::emean(int)" | |
| 35 | +#define G_ELOGMEAN "GEbounds::elogmean(int)" | |
| 36 | 36 | |
| 37 | 37 | /* __ Macros _____________________________________________________________ */ |
| 38 | 38 | |
| ... | ... | @@ -151,21 +151,21 @@ GEbounds& GEbounds::operator= (const GEbounds& ebds) |
| 151 | 151 | ***************************************************************************/ |
| 152 | 152 | void GEbounds::load(const std::string& filename, const std::string& extname) |
| 153 | 153 | { |
| 154 | - // Allocate FITS file | |
| 155 | - GFits file; | |
| 156 | - | |
| 157 | - // Open FITS file | |
| 158 | - file.open(filename); | |
| 159 | - | |
| 160 | - // Get energy boundary HDU | |
| 161 | - GFitsHDU* hdu = file.hdu(extname); | |
| 154 | + // Allocate FITS file | |
| 155 | + GFits file; | |
| 156 | + | |
| 157 | + // Open FITS file | |
| 158 | + file.open(filename); | |
| 159 | + | |
| 160 | + // Get energy boundary HDU | |
| 161 | + GFitsHDU* hdu = file.hdu(extname); | |
| 162 | 162 | |
| 163 | 163 | // Load energy boundaries |
| 164 | 164 | load(hdu); |
| 165 | 165 | |
| 166 | - // Close FITS file | |
| 167 | - file.close(); | |
| 168 | - | |
| 166 | + // Close FITS file | |
| 167 | + file.close(); | |
| 168 | + | |
| 169 | 169 | // Return |
| 170 | 170 | return; |
| 171 | 171 | } |
| ... | ... | @@ -178,19 +178,19 @@ void GEbounds::load(const std::string& filename, const std::string& extname) |
| 178 | 178 | ***************************************************************************/ |
| 179 | 179 | void GEbounds::load(GFitsHDU* hdu) |
| 180 | 180 | { |
| 181 | - // Free members | |
| 182 | - free_members(); | |
| 181 | + // Free members | |
| 182 | + free_members(); | |
| 183 | + | |
| 184 | + // Initialise attributes | |
| 185 | + init_members(); | |
| 183 | 186 | |
| 184 | - // Initialise attributes | |
| 185 | - init_members(); | |
| 186 | - | |
| 187 | 187 | // Continue only if HDU is valid |
| 188 | 188 | if (hdu != NULL) { |
| 189 | 189 | |
| 190 | 190 | // Extract energy boundary information from FITS file |
| 191 | 191 | m_num = hdu->card("NAXIS2")->integer(); |
| 192 | 192 | if (m_num > 0) { |
| 193 | - | |
| 193 | + | |
| 194 | 194 | // Allocate memory |
| 195 | 195 | m_channel = new int[m_num]; |
| 196 | 196 | m_emin = new double[m_num]; |
| ... | ... | @@ -204,21 +204,21 @@ void GEbounds::load(GFitsHDU* hdu) |
| 204 | 204 | m_emin[i] = hdu->column("E_MIN")->real(i) / 1000.0; |
| 205 | 205 | m_emax[i] = hdu->column("E_MAX")->real(i) / 1000.0; |
| 206 | 206 | } |
| 207 | - | |
| 207 | + | |
| 208 | 208 | } // endif: there were channels to read |
| 209 | - | |
| 209 | + | |
| 210 | 210 | // Get OGIP keywords |
| 211 | 211 | m_telescope = hdu->card("TELESCOP")->string(); |
| 212 | 212 | m_instrument = hdu->card("INSTRUME")->string(); |
| 213 | 213 | m_filter = hdu->card("FILTER")->string(); |
| 214 | 214 | m_chantype = hdu->card("CHANTYPE")->string(); |
| 215 | 215 | m_detchannels = hdu->card("DETCHANS")->string(); |
| 216 | - | |
| 216 | + | |
| 217 | 217 | // Fix energy scale |
| 218 | 218 | m_escale = 1.0; |
| 219 | - | |
| 219 | + | |
| 220 | 220 | } |
| 221 | - | |
| 221 | + | |
| 222 | 222 | // Return |
| 223 | 223 | return; |
| 224 | 224 | } |
| ... | ... | @@ -233,7 +233,7 @@ double GEbounds::emin(int index) const |
| 233 | 233 | { |
| 234 | 234 | #if defined(G_RANGE_CHECK) |
| 235 | 235 | if (index < 0 || index >= m_num) |
| 236 | - throw GException::out_of_range(G_MIN, index, 0, m_num-1); | |
| 236 | + throw GException::out_of_range(G_EMIN, index, 0, m_num-1); | |
| 237 | 237 | #endif |
| 238 | 238 | |
| 239 | 239 | // Return |
| ... | ... | @@ -250,7 +250,7 @@ double GEbounds::emax(int index) const |
| 250 | 250 | { |
| 251 | 251 | #if defined(G_RANGE_CHECK) |
| 252 | 252 | if (index < 0 || index >= m_num) |
| 253 | - throw GException::out_of_range(G_MAX, index, 0, m_num-1); | |
| 253 | + throw GException::out_of_range(G_EMAX, index, 0, m_num-1); | |
| 254 | 254 | #endif |
| 255 | 255 | |
| 256 | 256 | // Return |
| ... | ... | @@ -267,12 +267,12 @@ double GEbounds::emean(int index) const |
| 267 | 267 | { |
| 268 | 268 | #if defined(G_RANGE_CHECK) |
| 269 | 269 | if (index < 0 || index >= m_num) |
| 270 | - throw GException::out_of_range(G_MEAN, index, 0, m_num-1); | |
| 270 | + throw GException::out_of_range(G_EMEAN, index, 0, m_num-1); | |
| 271 | 271 | #endif |
| 272 | 272 | |
| 273 | 273 | // Compute mean energy |
| 274 | 274 | double emean = 0.5 * (m_emin[index] + m_emax[index]); |
| 275 | - | |
| 275 | + | |
| 276 | 276 | // Return |
| 277 | 277 | return emean; |
| 278 | 278 | } |
| ... | ... | @@ -287,14 +287,14 @@ double GEbounds::elogmean(int index) const |
| 287 | 287 | { |
| 288 | 288 | #if defined(G_RANGE_CHECK) |
| 289 | 289 | if (index < 0 || index >= m_num) |
| 290 | - throw GException::out_of_range(G_LOGMEAN, index, 0, m_num-1); | |
| 290 | + throw GException::out_of_range(G_ELOGMEAN, index, 0, m_num-1); | |
| 291 | 291 | #endif |
| 292 | 292 | |
| 293 | 293 | // Compute logarithmic mean energy |
| 294 | 294 | double elogmin = log10(m_emin[index]); |
| 295 | 295 | double elogmax = log10(m_emax[index]); |
| 296 | 296 | double elogmean = pow(10.0, 0.5 * (elogmin + elogmax)); |
| 297 | - | |
| 297 | + | |
| 298 | 298 | // Return |
| 299 | 299 | return elogmean; |
| 300 | 300 | } |
| ... | ... | @@ -313,9 +313,9 @@ void GEbounds::init_members(void) |
| 313 | 313 | { |
| 314 | 314 | // Initialise members |
| 315 | 315 | m_num = 0; |
| 316 | - m_channel = NULL; | |
| 317 | - m_emin = NULL; | |
| 318 | - m_emax = NULL; | |
| 316 | + m_channel = NULL; | |
| 317 | + m_emin = NULL; | |
| 318 | + m_emax = NULL; | |
| 319 | 319 | m_escale = 1.0; |
| 320 | 320 | m_telescope.clear(); |
| 321 | 321 | m_instrument.clear(); |
| ... | ... | @@ -374,9 +374,9 @@ void GEbounds::free_members(void) |
| 374 | 374 | if (m_emax != NULL) delete [] m_emax; |
| 375 | 375 | |
| 376 | 376 | // Signal free pointers |
| 377 | - m_channel = NULL; | |
| 378 | - m_emin = NULL; | |
| 379 | - m_emax = NULL; | |
| 377 | + m_channel = NULL; | |
| 378 | + m_emin = NULL; | |
| 379 | + m_emax = NULL; | |
| 380 | 380 | |
| 381 | 381 | // Return |
| 382 | 382 | return; |
| ... | ... | @@ -407,7 +407,7 @@ std::ostream& operator<< (std::ostream& os, const GEbounds& ebds) |
| 407 | 407 | os << " Channel type ..............: " << ebds.m_chantype << std::endl; |
| 408 | 408 | os << " Telescope .................: " << ebds.m_telescope << std::endl; |
| 409 | 409 | os << " Instrument ................: " << ebds.m_instrument; |
| 410 | - | |
| 410 | + | |
| 411 | 411 | // Return output stream |
| 412 | 412 | return os; |
| 413 | 413 | } | ... | ... |