Commit 51c7615b69d100f186d9f6fcbf5cbffa63776717
Try solving merge conflicts
Showing
8 changed files
with
212 additions
and
28 deletions
cscripts/cstsmapmerge.py
| ... | ... | @@ -46,7 +46,7 @@ class cstsmapmerge(ctools.cscript): |
| 46 | 46 | self._files = None |
| 47 | 47 | self._in_filename = '' |
| 48 | 48 | self._tsmap = gammalib.GSkyMap() # Empty sky map |
| 49 | - self._statusmap = gammalib.GSkyMap() # Empty sky map | |
| 49 | + self._statusmap = gammalib.GSkyMap() # Empty sky map | |
| 50 | 50 | self._maps = [] |
| 51 | 51 | self._mapnames = [] |
| 52 | 52 | self._merged_files = [] |
| ... | ... | @@ -118,7 +118,11 @@ class cstsmapmerge(ctools.cscript): |
| 118 | 118 | if self._read_ahead(): |
| 119 | 119 | self['outmap'].filename() |
| 120 | 120 | |
| 121 | +<<<<<<< HEAD | |
| 121 | 122 | # Write input parameters into logger |
| 123 | +======= | |
| 124 | + # Write input parameters into logger | |
| 125 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 122 | 126 | self._log_parameters(gammalib.TERSE) |
| 123 | 127 | |
| 124 | 128 | # Return |
| ... | ... | @@ -153,7 +157,11 @@ class cstsmapmerge(ctools.cscript): |
| 153 | 157 | for hdu in fits: |
| 154 | 158 | |
| 155 | 159 | # Leave out primary and status extension |
| 160 | +<<<<<<< HEAD | |
| 156 | 161 | if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP': |
| 162 | +======= | |
| 163 | + if hdu.extname() != "IMAGE" and hdu.extname() != 'STATUS MAP': | |
| 164 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 157 | 165 | |
| 158 | 166 | # Add present maps |
| 159 | 167 | skymap = gammalib.GSkyMap() |
| ... | ... | @@ -192,7 +200,11 @@ class cstsmapmerge(ctools.cscript): |
| 192 | 200 | for hdu in fits: |
| 193 | 201 | |
| 194 | 202 | # Leave out primary and status extension |
| 203 | +<<<<<<< HEAD | |
| 195 | 204 | if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP': |
| 205 | +======= | |
| 206 | + if hdu.extname() != "IMAGE" and hdu.extname() != 'STATUS MAP': | |
| 207 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 196 | 208 | |
| 197 | 209 | # Add present maps |
| 198 | 210 | skymap = gammalib.GSkyMap() |
| ... | ... | @@ -213,14 +225,22 @@ class cstsmapmerge(ctools.cscript): |
| 213 | 225 | for i in range(self._tsmap.npix()): |
| 214 | 226 | |
| 215 | 227 | # Consider only bins that have been computed |
| 216 | - if add_statusmap[i] > 0.5: | |
| 228 | + if add_statusmap[i] > -0.5: | |
| 217 | 229 | |
| 218 | 230 | # Raise exception if this bin has already been computed |
| 231 | +<<<<<<< HEAD | |
| 219 | 232 | if self._statusmap[i] > 0.5 and not self._overwrite: |
| 220 | 233 | msg = ('Attempt to merge bin which apparently has already ' |
| 221 | 234 | 'been merged. File "%s" contains already merged ' |
| 222 | 235 | 'bins. Set hidden parameter "overwrite=yes" to ' |
| 223 | 236 | 'avoid this error.' % fitsfile) |
| 237 | +======= | |
| 238 | + if self._statusmap[i] > -0.5 and not self._overwrite: | |
| 239 | + msg = "Attempt to merge bin which apparently has "+\ | |
| 240 | + "already been merged. File \""+fitsfile+"\" "+\ | |
| 241 | + "contains already merged bins. Set hidden "+\ | |
| 242 | + "parameter \"overwrite=yes\" to avoid this error." | |
| 243 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 224 | 244 | raise RuntimeError(msg) |
| 225 | 245 | |
| 226 | 246 | # Copy TS values |
| ... | ... | @@ -256,7 +276,7 @@ class cstsmapmerge(ctools.cscript): |
| 256 | 276 | # Count number of pixels with TS status set |
| 257 | 277 | count = 0 |
| 258 | 278 | for pix in status: |
| 259 | - if pix > 0.5: | |
| 279 | + if pix > -0.5: | |
| 260 | 280 | count += 1 |
| 261 | 281 | |
| 262 | 282 | # Return number of pixels |
| ... | ... | @@ -290,8 +310,16 @@ class cstsmapmerge(ctools.cscript): |
| 290 | 310 | |
| 291 | 311 | # Skip file if it's not a FITS file |
| 292 | 312 | if not gammalib.GFilename(fitsfile).is_fits(): |
| 313 | +<<<<<<< HEAD | |
| 293 | 314 | self._log_value(gammalib.EXPLICIT, 'Skip file', |
| 294 | 315 | '%s (not a FITS file)' % fitsfile) |
| 316 | +======= | |
| 317 | + | |
| 318 | + # Log message | |
| 319 | + self._log_value(gammalib.EXPLICIT, "Skip file", fitsfile +" (not a FITS file)") | |
| 320 | + | |
| 321 | + # Continue | |
| 322 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 295 | 323 | continue |
| 296 | 324 | |
| 297 | 325 | # Open FITS file |
| ... | ... | @@ -299,18 +327,35 @@ class cstsmapmerge(ctools.cscript): |
| 299 | 327 | |
| 300 | 328 | # If file contains a status map then use it |
| 301 | 329 | if fits.contains('STATUS MAP'): |
| 330 | +<<<<<<< HEAD | |
| 331 | +======= | |
| 332 | + | |
| 333 | + # Close FITS file | |
| 334 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 302 | 335 | fits.close() |
| 336 | + | |
| 337 | + # Set filename to initial filename | |
| 303 | 338 | file0 = fitsfile |
| 339 | +<<<<<<< HEAD | |
| 304 | 340 | if self._logTerse(): |
| 305 | 341 | self._log(gammalib.parformat('Initial TS map file')) |
| 306 | 342 | self._log(fitsfile) |
| 307 | 343 | count = self._get_number_of_ts_pixels(fitsfile) |
| 308 | 344 | self._log(' (%d TS pixels computed)' % count) |
| 309 | 345 | self._log('\n') |
| 346 | +======= | |
| 347 | + | |
| 348 | + # Log message | |
| 349 | + pix_info = " (%d TS pixels computed)" % self._get_number_of_ts_pixels(fitsfile) | |
| 350 | + self._log_value(gammalib.TERSE, "Initial TS map file", fitsfile + pix_info) | |
| 351 | + | |
| 352 | + # Leave loop | |
| 353 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 310 | 354 | break |
| 311 | 355 | |
| 312 | 356 | # ... otherwise signal that file is useless |
| 313 | 357 | else: |
| 358 | +<<<<<<< HEAD | |
| 314 | 359 | fits.close() |
| 315 | 360 | self._log_value(gammalib.EXPLICIT, 'Skip file', |
| 316 | 361 | '%s (no "STATUS MAP" extension)' % fitsfile) |
| ... | ... | @@ -322,6 +367,24 @@ class cstsmapmerge(ctools.cscript): |
| 322 | 367 | self._log('None of the provided files seems to be a sliced ' |
| 323 | 368 | 'TS map file (none has a "STATUS MAP" extension).\n') |
| 324 | 369 | |
| 370 | +======= | |
| 371 | + | |
| 372 | + # Close fits file | |
| 373 | + fits.close() | |
| 374 | + | |
| 375 | + # Info message | |
| 376 | + self._log_value(gammalib.EXPLICIT, "Skip file", fitsfile +" (no \"STATUS MAP\" extension)") | |
| 377 | + | |
| 378 | + # Continue | |
| 379 | + continue | |
| 380 | + | |
| 381 | + # Signal if no suitable file was found | |
| 382 | + if file0 == "": | |
| 383 | + self._log_string(gammalib.TERSE, "None of the provided files seems to be a sliced " | |
| 384 | + "TS map file (none has a \"STATUS MAP\" " | |
| 385 | + "extension).\n") | |
| 386 | + | |
| 387 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 325 | 388 | # ... otherwise merge files |
| 326 | 389 | else: |
| 327 | 390 | |
| ... | ... | @@ -342,9 +405,14 @@ class cstsmapmerge(ctools.cscript): |
| 342 | 405 | |
| 343 | 406 | # Skip if file is not FITS |
| 344 | 407 | if not gammalib.GFilename(fitsfile).is_fits(): |
| 408 | +<<<<<<< HEAD | |
| 345 | 409 | self._log_value(gammalib.EXPLICIT, 'Skip file', |
| 346 | 410 | '%s (not a FITS file)' % fitsfile) |
| 347 | 411 | continue |
| 412 | +======= | |
| 413 | + self._log_value(gammalib.EXPLICIT, "Skip file", fitsfile +" (not a FITS file)") | |
| 414 | + continue | |
| 415 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 348 | 416 | |
| 349 | 417 | # Open FITS file |
| 350 | 418 | fits = gammalib.GFits(fitsfile) |
| ... | ... | @@ -352,20 +420,29 @@ class cstsmapmerge(ctools.cscript): |
| 352 | 420 | # Skip if file does not contain status map |
| 353 | 421 | if not fits.contains('STATUS MAP'): |
| 354 | 422 | fits.close() |
| 423 | +<<<<<<< HEAD | |
| 355 | 424 | self._log_value(gammalib.EXPLICIT, 'Skip file', |
| 356 | 425 | '%s (no "STATUS MAP" extension)' % fitsfile) |
| 426 | +======= | |
| 427 | + self._log_value(gammalib.EXPLICIT, "Skip file", fitsfile +" (no \"STATUS MAP\" extension)") | |
| 428 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 357 | 429 | continue |
| 358 | 430 | |
| 359 | 431 | # Close FITS file |
| 360 | 432 | fits.close() |
| 361 | 433 | |
| 362 | 434 | # Logging |
| 435 | +<<<<<<< HEAD | |
| 363 | 436 | if self._logTerse(): |
| 364 | 437 | self._log(gammalib.parformat('Merge TS map file')) |
| 365 | 438 | self._log(fitsfile) |
| 366 | 439 | count = self._get_number_of_ts_pixels(fitsfile) |
| 367 | 440 | self._log(' (%d TS pixels computed)' % count) |
| 368 | 441 | self._log('\n') |
| 442 | +======= | |
| 443 | + pix_info = " (%d TS pixels computed)" % self._get_number_of_ts_pixels(fitsfile) | |
| 444 | + self._log_value(gammalib.TERSE, "Merge TS map file", fitsfile + pix_info) | |
| 445 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 369 | 446 | |
| 370 | 447 | # Merge TS map |
| 371 | 448 | self._merge_ts_map(fitsfile) |
| ... | ... | @@ -380,6 +457,7 @@ class cstsmapmerge(ctools.cscript): |
| 380 | 457 | """ |
| 381 | 458 | Save TS map and remove slices if requested |
| 382 | 459 | """ |
| 460 | +<<<<<<< HEAD | |
| 383 | 461 | # Write header |
| 384 | 462 | self._log_header1(gammalib.TERSE, 'Save TS map') |
| 385 | 463 | |
| ... | ... | @@ -388,6 +466,11 @@ class cstsmapmerge(ctools.cscript): |
| 388 | 466 | |
| 389 | 467 | # Log filename |
| 390 | 468 | self._log_value(gammalib.TERSE, 'TS map file', outmap.url()) |
| 469 | +======= | |
| 470 | + | |
| 471 | + # Get output filename in case it was not read ahead | |
| 472 | + outmap = self["outmap"].filename() | |
| 473 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 391 | 474 | |
| 392 | 475 | # Create FITS file |
| 393 | 476 | fits = gammalib.GFits() |
| ... | ... | @@ -403,26 +486,67 @@ class cstsmapmerge(ctools.cscript): |
| 403 | 486 | for i in range(len(self._mapnames)): |
| 404 | 487 | fits[i+1].extname(self._mapnames[i]) |
| 405 | 488 | |
| 489 | + # Treat status map separately | |
| 490 | + self._statusmap.write(fits) | |
| 491 | + fits[fits.size()-1].extname('STATUS MAP') | |
| 492 | + | |
| 406 | 493 | # Check if map is fully done |
| 407 | - done = True | |
| 494 | + bins_merged = 0 | |
| 408 | 495 | for pix in self._statusmap: |
| 409 | - if pix < 0.5: | |
| 410 | - done = False | |
| 411 | - break | |
| 496 | + if pix > -0.5: | |
| 497 | + bins_merged += 1 | |
| 498 | + | |
| 499 | + # Set boolean if map is fully done | |
| 500 | + done = (bins_merged == self._tsmaps.npix()) | |
| 412 | 501 | |
| 502 | + # Log summary header | |
| 503 | + self._log_header2(gammalib.TERSE, "Merging Summary") | |
| 504 | + | |
| 413 | 505 | # Write status map if we are not done yet |
| 414 | 506 | if not done: |
| 507 | +<<<<<<< HEAD | |
| 415 | 508 | self._statusmap.write(fits) |
| 416 | 509 | fits[fits.size()-1].extname('STATUS MAP') |
| 510 | +======= | |
| 511 | + | |
| 512 | + # Log bins that were computed and those that were missing | |
| 513 | + self._log_value(gammalib.TERSE, "TS map bins", self._tsmap.npix()) | |
| 514 | + self._log_value(gammalib.TERSE, "Bins computed and merged", bins_merged ) | |
| 515 | + self._log_value(gammalib.TERSE, "Bins missing", self._tsmap.npix() - bins_merged) | |
| 516 | + | |
| 517 | + else: | |
| 518 | + | |
| 519 | + # Write success message | |
| 520 | + self._log_string(gammalib.TERSE, "TS map was fully computed and successfully merged") | |
| 521 | + | |
| 522 | + # Write header | |
| 523 | + self._log_header1(gammalib.TERSE, "Save TS map") | |
| 524 | + | |
| 525 | + # Log filename | |
| 526 | + self._log_value(gammalib.TERSE, "TS map file", outmap.url()) | |
| 527 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 417 | 528 | |
| 418 | 529 | # Save FITS file |
| 419 | - fits.saveto(outmap, self._clobber()) | |
| 530 | + fits.saveto(outmap, self._clobber()) | |
| 420 | 531 | |
| 421 | - # Delete TS input maps if requested | |
| 422 | - if self._delete: | |
| 532 | + # Delete TS input maps if requested and map is fully done | |
| 533 | + if self._delete and done: | |
| 534 | + | |
| 535 | + # Log header | |
| 536 | + self._log_header2(gammalib.TERSE, "Delete slices TS map files") | |
| 537 | + | |
| 538 | + # Loop over sliced files | |
| 423 | 539 | for filename in self._merged_files: |
| 540 | + | |
| 541 | + # Remove file | |
| 424 | 542 | os.remove(filename) |
| 543 | +<<<<<<< HEAD | |
| 425 | 544 | self._log_value(gammalib.TERSE, 'Deleted input file', filename) |
| 545 | +======= | |
| 546 | + | |
| 547 | + # Log message about file | |
| 548 | + self._log_value(gammalib.TERSE,"Deleted input file", filename) | |
| 549 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 426 | 550 | |
| 427 | 551 | # Return |
| 428 | 552 | return | ... | ... |
cscripts/cstsmapsplit.par
| ... | ... | @@ -27,6 +27,7 @@ bkgcube, f, a, NONE,,, "Input background cube file (only needed for stacke |
| 27 | 27 | caldb, s, a, prod2,,, "Calibration database" |
| 28 | 28 | irf, s, a, South_0.5h,,, "Instrument response function" |
| 29 | 29 | edisp, b, h, no,,, "Apply energy dispersion?" |
| 30 | +errors, b, h, no,,, "Compute/store parameter errors?" | |
| 30 | 31 | outmap, f, a, tsmap.fits,,, "Output Test Statistic map file" |
| 31 | 32 | bins_per_job, i, a, 5,,, "Number of TS map bins per task" |
| 32 | 33 | compute_null, b, a, yes,,,"Compute null hypothesis first?" | ... | ... |
src/cttsmap/cttsmap.cpp
| ... | ... | @@ -215,6 +215,12 @@ void cttsmap::run(void) |
| 215 | 215 | // Get task parameters |
| 216 | 216 | get_parameters(); |
| 217 | 217 | |
| 218 | +<<<<<<< HEAD | |
| 219 | +======= | |
| 220 | + // Write parameters into logger | |
| 221 | + log_parameters(TERSE); | |
| 222 | + | |
| 223 | +>>>>>>> b7dd76b35e6d2fd74ff010258ffa7606e072dbf5 | |
| 218 | 224 | // Set energy dispersion flag for all CTA observations and save old |
| 219 | 225 | // values in save_edisp vector |
| 220 | 226 | std::vector<bool> save_edisp; |
| ... | ... | @@ -315,6 +321,14 @@ void cttsmap::run(void) |
| 315 | 321 | // Optimize observation container |
| 316 | 322 | m_obs.optimize(*opt); |
| 317 | 323 | |
| 324 | + // Compute errors if necessary | |
| 325 | + if (m_errors) { | |
| 326 | + m_obs.errors(*opt); | |
| 327 | + } | |
| 328 | + | |
| 329 | + // Get status of optimization | |
| 330 | + int status = opt->status(); | |
| 331 | + | |
| 318 | 332 | // Retrieve the Likelihood value |
| 319 | 333 | double logL1 = -(opt->value()); |
| 320 | 334 | |
| ... | ... | @@ -326,6 +340,7 @@ void cttsmap::run(void) |
| 326 | 340 | log << " TS value ....: "; |
| 327 | 341 | log << ts << std::endl; |
| 328 | 342 | } |
| 343 | + | |
| 329 | 344 | else if (logTerse()) { |
| 330 | 345 | log << "TS for bin number "; |
| 331 | 346 | log << i; |
| ... | ... | @@ -345,12 +360,23 @@ void cttsmap::run(void) |
| 345 | 360 | // Extract fitted test source parameters |
| 346 | 361 | if (m_testsource != NULL) { |
| 347 | 362 | for (int j = 0; j < m_mapnames.size(); ++j) { |
| 348 | - m_maps[j](i) = (*testsource)[m_mapnames[j]].value(); | |
| 363 | + | |
| 364 | + // Set parameter value and error maps | |
| 365 | + if (m_mapnames[j].substr(0,2) == "e_") { | |
| 366 | + | |
| 367 | + // Get Parameter name by removing the error prefix | |
| 368 | + std::string parname = m_mapnames[j].substr(2, m_mapnames[j].size()); | |
| 369 | + m_maps[j](i) = (*testsource)[parname].error(); | |
| 370 | + | |
| 371 | + } | |
| 372 | + else { | |
| 373 | + m_maps[j](i) = (*testsource)[m_mapnames[j]].value(); | |
| 374 | + } | |
| 349 | 375 | } |
| 350 | 376 | } |
| 351 | 377 | |
| 352 | - // Set status of bin to true | |
| 353 | - m_statusmap(i) = 1.0; | |
| 378 | + // Set Fit status of the bin | |
| 379 | + m_statusmap(i) = status; | |
| 354 | 380 | |
| 355 | 381 | // Remove model from container |
| 356 | 382 | models.remove(m_srcname); |
| ... | ... | @@ -417,11 +443,9 @@ void cttsmap::save(void) |
| 417 | 443 | fits[i+1]->extname(m_mapnames[i]); |
| 418 | 444 | } |
| 419 | 445 | |
| 420 | - // Add computation log if not all bins are computed | |
| 421 | - if (m_binmin != -1 || m_binmax != -1) { | |
| 422 | - m_statusmap.write(fits); | |
| 423 | - fits[m_mapnames.size()+1]->extname("STATUS MAP"); | |
| 424 | - } | |
| 446 | + // Write Fit status map | |
| 447 | + m_statusmap.write(fits); | |
| 448 | + fits[fits.size()-1]->extname("FITSTATUS"); | |
| 425 | 449 | |
| 426 | 450 | // Save FITS file |
| 427 | 451 | fits.saveto(m_outmap, clobber()); |
| ... | ... | @@ -482,6 +506,7 @@ void cttsmap::init_members(void) |
| 482 | 506 | m_outmap.clear(); |
| 483 | 507 | m_apply_edisp = false; |
| 484 | 508 | m_publish = false; |
| 509 | + m_errors = false; | |
| 485 | 510 | |
| 486 | 511 | // Initialise protected members |
| 487 | 512 | m_obs.clear(); |
| ... | ... | @@ -511,16 +536,17 @@ void cttsmap::copy_members(const cttsmap& app) |
| 511 | 536 | m_outmap = app.m_outmap; |
| 512 | 537 | m_apply_edisp = app.m_apply_edisp; |
| 513 | 538 | m_publish = app.m_publish; |
| 539 | + m_errors = app.m_errors; | |
| 514 | 540 | |
| 515 | 541 | // Copy protected members |
| 516 | - m_binmin = app.m_binmin; | |
| 517 | - m_binmax = app.m_binmax; | |
| 518 | - m_logL0 = app.m_logL0; | |
| 519 | - m_obs = app.m_obs; | |
| 520 | - m_tsmap = app.m_tsmap; | |
| 521 | - m_mapnames = app.m_mapnames; | |
| 522 | - m_maps = app.m_maps; | |
| 523 | - m_statusmap = app.m_statusmap; | |
| 542 | + m_binmin = app.m_binmin; | |
| 543 | + m_binmax = app.m_binmax; | |
| 544 | + m_logL0 = app.m_logL0; | |
| 545 | + m_obs = app.m_obs; | |
| 546 | + m_tsmap = app.m_tsmap; | |
| 547 | + m_mapnames = app.m_mapnames; | |
| 548 | + m_maps = app.m_maps; | |
| 549 | + m_statusmap = app.m_statusmap; | |
| 524 | 550 | |
| 525 | 551 | // Clone protected members |
| 526 | 552 | m_testsource = (app.m_testsource != NULL) ? app.m_testsource->clone() : NULL; |
| ... | ... | @@ -612,6 +638,9 @@ void cttsmap::get_parameters(void) |
| 612 | 638 | // Create sky map based on task parameters |
| 613 | 639 | GSkyMap map = create_map(m_obs); |
| 614 | 640 | |
| 641 | + // Check if errors should be computed | |
| 642 | + m_errors = (*this)["errors"].boolean(); | |
| 643 | + | |
| 615 | 644 | // Initialise maps from user parameters |
| 616 | 645 | init_maps(map); |
| 617 | 646 | |
| ... | ... | @@ -654,9 +683,13 @@ void cttsmap::init_maps(const GSkyMap& map) |
| 654 | 683 | // Initialise map information |
| 655 | 684 | m_statusmap.clear(); |
| 656 | 685 | |
| 657 | - // Create status map | |
| 686 | + // Create status map and progress map | |
| 658 | 687 | m_statusmap = GSkyMap(map); |
| 659 | 688 | |
| 689 | + // Set status map to invalid value -1 to signal | |
| 690 | + // that bin wasn't computed yet | |
| 691 | + m_statusmap = -1.0; | |
| 692 | + | |
| 660 | 693 | // Initialise maps of free parameters |
| 661 | 694 | if (m_testsource != NULL) { |
| 662 | 695 | |
| ... | ... | @@ -674,6 +707,16 @@ void cttsmap::init_maps(const GSkyMap& map) |
| 674 | 707 | |
| 675 | 708 | // Store parameter name |
| 676 | 709 | m_mapnames.push_back((*m_testsource)[i].name()); |
| 710 | + | |
| 711 | + // Add parameter errors if requested | |
| 712 | + if (m_errors) { | |
| 713 | + | |
| 714 | + // Add sky map for fit error of the free parameter | |
| 715 | + m_maps.push_back(map); | |
| 716 | + | |
| 717 | + // Store name of parameter error | |
| 718 | + m_mapnames.push_back("e_" + (*m_testsource)[i].name()); | |
| 719 | + } | |
| 677 | 720 | |
| 678 | 721 | } // endfor: looped over all model parameters |
| 679 | 722 | ... | ... |
src/cttsmap/cttsmap.hpp
| ... | ... | @@ -89,6 +89,7 @@ protected: |
| 89 | 89 | GFilename m_outmap; //!< Output TS map file name |
| 90 | 90 | bool m_apply_edisp; //!< Apply energy dispersion? |
| 91 | 91 | bool m_publish; //!< Publish TS map? |
| 92 | + bool m_errors; //!< Compute and store parameter errors? | |
| 92 | 93 | |
| 93 | 94 | // Parameters to control speed and job splitting |
| 94 | 95 | int m_binmin; //!< Map bin number from which computation should start |
| ... | ... | @@ -98,7 +99,7 @@ protected: |
| 98 | 99 | // Protected members |
| 99 | 100 | GObservations m_obs; //!< Observation container |
| 100 | 101 | GSkyMap m_tsmap; //!< TS map |
| 101 | - GSkyMap m_statusmap; //!< Map of computed bins | |
| 102 | + GSkyMap m_statusmap; //!< Map of optimizer fit status | |
| 102 | 103 | std::vector<std::string> m_mapnames; //!< Names of free parameters |
| 103 | 104 | std::vector<GSkyMap> m_maps; //!< Sky maps for each free parameter |
| 104 | 105 | GModel* m_testsource; //!< Pointer to test source for TS computation | ... | ... |
src/cttsmap/cttsmap.par
| ... | ... | @@ -27,6 +27,7 @@ bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked |
| 27 | 27 | caldb, s, a, "prod2",,, "Calibration database" |
| 28 | 28 | irf, s, a, "South_0.5h",,, "Instrument response function" |
| 29 | 29 | edisp, b, h, no,,, "Apply energy dispersion?" |
| 30 | +errors, b, h, no,,, "Compute/store parameter errors?" | |
| 30 | 31 | outmap, f, a, "tsmap.fits",,, "Output Test Statistic map file" |
| 31 | 32 | |
| 32 | 33 | # | ... | ... |
test/data/tsmap_0.fits
No preview for this file type
test/data/tsmap_1.fits
No preview for this file type
test/test_cttsmap.py
| ... | ... | @@ -96,6 +96,20 @@ class Test(test): |
| 96 | 96 | # Check if execution failed |
| 97 | 97 | self.test_assert(self._execute(cmd) != 0, |
| 98 | 98 | 'Check invalid input file when executed from command line') |
| 99 | + | |
| 100 | + # Setup cttsmap command | |
| 101 | + cmd = cttsmap+' inobs="'+self._events+'"'+ \ | |
| 102 | + ' inmodel="'+self._model+'" srcname="Crab"'+ \ | |
| 103 | + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ | |
| 104 | + ' errors=yes'+ \ | |
| 105 | + ' outmap="cttsmap_cmd1.fits"'+ \ | |
| 106 | + ' nxpix=5 nypix=5 binsz=0.02'+ \ | |
| 107 | + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ | |
| 108 | + ' logfile="cttsmap_cmd1.log" chatter=1' | |
| 109 | + | |
| 110 | + # Check if execution was successful | |
| 111 | + self.test_assert(self._execute(cmd) == 0, | |
| 112 | + 'Check successful execution from command line') | |
| 99 | 113 | |
| 100 | 114 | # Return |
| 101 | 115 | return | ... | ... |