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 | * GEbounds.cpp - Energy boundary class * | 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 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
| @@ -27,12 +27,12 @@ | @@ -27,12 +27,12 @@ | ||
| 27 | #include "GEbounds.hpp" | 27 | #include "GEbounds.hpp" |
| 28 | 28 | ||
| 29 | /* __ Method name definitions ____________________________________________ */ | 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 | /* __ Macros _____________________________________________________________ */ | 37 | /* __ Macros _____________________________________________________________ */ |
| 38 | 38 | ||
| @@ -151,21 +151,21 @@ GEbounds& GEbounds::operator= (const GEbounds& ebds) | @@ -151,21 +151,21 @@ GEbounds& GEbounds::operator= (const GEbounds& ebds) | ||
| 151 | ***************************************************************************/ | 151 | ***************************************************************************/ |
| 152 | void GEbounds::load(const std::string& filename, const std::string& extname) | 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 | // Load energy boundaries | 163 | // Load energy boundaries |
| 164 | load(hdu); | 164 | load(hdu); |
| 165 | 165 | ||
| 166 | - // Close FITS file | ||
| 167 | - file.close(); | ||
| 168 | - | 166 | + // Close FITS file |
| 167 | + file.close(); | ||
| 168 | + | ||
| 169 | // Return | 169 | // Return |
| 170 | return; | 170 | return; |
| 171 | } | 171 | } |
| @@ -178,19 +178,19 @@ void GEbounds::load(const std::string& filename, const std::string& extname) | @@ -178,19 +178,19 @@ void GEbounds::load(const std::string& filename, const std::string& extname) | ||
| 178 | ***************************************************************************/ | 178 | ***************************************************************************/ |
| 179 | void GEbounds::load(GFitsHDU* hdu) | 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 | // Continue only if HDU is valid | 187 | // Continue only if HDU is valid |
| 188 | if (hdu != NULL) { | 188 | if (hdu != NULL) { |
| 189 | 189 | ||
| 190 | // Extract energy boundary information from FITS file | 190 | // Extract energy boundary information from FITS file |
| 191 | m_num = hdu->card("NAXIS2")->integer(); | 191 | m_num = hdu->card("NAXIS2")->integer(); |
| 192 | if (m_num > 0) { | 192 | if (m_num > 0) { |
| 193 | - | 193 | + |
| 194 | // Allocate memory | 194 | // Allocate memory |
| 195 | m_channel = new int[m_num]; | 195 | m_channel = new int[m_num]; |
| 196 | m_emin = new double[m_num]; | 196 | m_emin = new double[m_num]; |
| @@ -204,21 +204,21 @@ void GEbounds::load(GFitsHDU* hdu) | @@ -204,21 +204,21 @@ void GEbounds::load(GFitsHDU* hdu) | ||
| 204 | m_emin[i] = hdu->column("E_MIN")->real(i) / 1000.0; | 204 | m_emin[i] = hdu->column("E_MIN")->real(i) / 1000.0; |
| 205 | m_emax[i] = hdu->column("E_MAX")->real(i) / 1000.0; | 205 | m_emax[i] = hdu->column("E_MAX")->real(i) / 1000.0; |
| 206 | } | 206 | } |
| 207 | - | 207 | + |
| 208 | } // endif: there were channels to read | 208 | } // endif: there were channels to read |
| 209 | - | 209 | + |
| 210 | // Get OGIP keywords | 210 | // Get OGIP keywords |
| 211 | m_telescope = hdu->card("TELESCOP")->string(); | 211 | m_telescope = hdu->card("TELESCOP")->string(); |
| 212 | m_instrument = hdu->card("INSTRUME")->string(); | 212 | m_instrument = hdu->card("INSTRUME")->string(); |
| 213 | m_filter = hdu->card("FILTER")->string(); | 213 | m_filter = hdu->card("FILTER")->string(); |
| 214 | m_chantype = hdu->card("CHANTYPE")->string(); | 214 | m_chantype = hdu->card("CHANTYPE")->string(); |
| 215 | m_detchannels = hdu->card("DETCHANS")->string(); | 215 | m_detchannels = hdu->card("DETCHANS")->string(); |
| 216 | - | 216 | + |
| 217 | // Fix energy scale | 217 | // Fix energy scale |
| 218 | m_escale = 1.0; | 218 | m_escale = 1.0; |
| 219 | - | 219 | + |
| 220 | } | 220 | } |
| 221 | - | 221 | + |
| 222 | // Return | 222 | // Return |
| 223 | return; | 223 | return; |
| 224 | } | 224 | } |
| @@ -233,7 +233,7 @@ double GEbounds::emin(int index) const | @@ -233,7 +233,7 @@ double GEbounds::emin(int index) const | ||
| 233 | { | 233 | { |
| 234 | #if defined(G_RANGE_CHECK) | 234 | #if defined(G_RANGE_CHECK) |
| 235 | if (index < 0 || index >= m_num) | 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 | #endif | 237 | #endif |
| 238 | 238 | ||
| 239 | // Return | 239 | // Return |
| @@ -250,7 +250,7 @@ double GEbounds::emax(int index) const | @@ -250,7 +250,7 @@ double GEbounds::emax(int index) const | ||
| 250 | { | 250 | { |
| 251 | #if defined(G_RANGE_CHECK) | 251 | #if defined(G_RANGE_CHECK) |
| 252 | if (index < 0 || index >= m_num) | 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 | #endif | 254 | #endif |
| 255 | 255 | ||
| 256 | // Return | 256 | // Return |
| @@ -267,12 +267,12 @@ double GEbounds::emean(int index) const | @@ -267,12 +267,12 @@ double GEbounds::emean(int index) const | ||
| 267 | { | 267 | { |
| 268 | #if defined(G_RANGE_CHECK) | 268 | #if defined(G_RANGE_CHECK) |
| 269 | if (index < 0 || index >= m_num) | 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 | #endif | 271 | #endif |
| 272 | 272 | ||
| 273 | // Compute mean energy | 273 | // Compute mean energy |
| 274 | double emean = 0.5 * (m_emin[index] + m_emax[index]); | 274 | double emean = 0.5 * (m_emin[index] + m_emax[index]); |
| 275 | - | 275 | + |
| 276 | // Return | 276 | // Return |
| 277 | return emean; | 277 | return emean; |
| 278 | } | 278 | } |
| @@ -287,14 +287,14 @@ double GEbounds::elogmean(int index) const | @@ -287,14 +287,14 @@ double GEbounds::elogmean(int index) const | ||
| 287 | { | 287 | { |
| 288 | #if defined(G_RANGE_CHECK) | 288 | #if defined(G_RANGE_CHECK) |
| 289 | if (index < 0 || index >= m_num) | 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 | #endif | 291 | #endif |
| 292 | 292 | ||
| 293 | // Compute logarithmic mean energy | 293 | // Compute logarithmic mean energy |
| 294 | double elogmin = log10(m_emin[index]); | 294 | double elogmin = log10(m_emin[index]); |
| 295 | double elogmax = log10(m_emax[index]); | 295 | double elogmax = log10(m_emax[index]); |
| 296 | double elogmean = pow(10.0, 0.5 * (elogmin + elogmax)); | 296 | double elogmean = pow(10.0, 0.5 * (elogmin + elogmax)); |
| 297 | - | 297 | + |
| 298 | // Return | 298 | // Return |
| 299 | return elogmean; | 299 | return elogmean; |
| 300 | } | 300 | } |
| @@ -313,9 +313,9 @@ void GEbounds::init_members(void) | @@ -313,9 +313,9 @@ void GEbounds::init_members(void) | ||
| 313 | { | 313 | { |
| 314 | // Initialise members | 314 | // Initialise members |
| 315 | m_num = 0; | 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 | m_escale = 1.0; | 319 | m_escale = 1.0; |
| 320 | m_telescope.clear(); | 320 | m_telescope.clear(); |
| 321 | m_instrument.clear(); | 321 | m_instrument.clear(); |
| @@ -374,9 +374,9 @@ void GEbounds::free_members(void) | @@ -374,9 +374,9 @@ void GEbounds::free_members(void) | ||
| 374 | if (m_emax != NULL) delete [] m_emax; | 374 | if (m_emax != NULL) delete [] m_emax; |
| 375 | 375 | ||
| 376 | // Signal free pointers | 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 | // Return | 381 | // Return |
| 382 | return; | 382 | return; |
| @@ -407,7 +407,7 @@ std::ostream& operator<< (std::ostream& os, const GEbounds& ebds) | @@ -407,7 +407,7 @@ std::ostream& operator<< (std::ostream& os, const GEbounds& ebds) | ||
| 407 | os << " Channel type ..............: " << ebds.m_chantype << std::endl; | 407 | os << " Channel type ..............: " << ebds.m_chantype << std::endl; |
| 408 | os << " Telescope .................: " << ebds.m_telescope << std::endl; | 408 | os << " Telescope .................: " << ebds.m_telescope << std::endl; |
| 409 | os << " Instrument ................: " << ebds.m_instrument; | 409 | os << " Instrument ................: " << ebds.m_instrument; |
| 410 | - | 410 | + |
| 411 | // Return output stream | 411 | // Return output stream |
| 412 | return os; | 412 | return os; |
| 413 | } | 413 | } |