Commit a71622cefb89ad71004889a7e4033dfb7c60967b
1 parent
f25aeb73
Rename "outcube" parameter to "outobs"
Showing
7 changed files
with
59 additions
and
34 deletions
doc/source/admin/release_history/1.6.rst
| ... | ... | @@ -42,7 +42,8 @@ Improvements |
| 42 | 42 | ------------ |
| 43 | 43 | |
| 44 | 44 | * [`2714 <https://cta-redmine.irap.omp.eu/issues/2714>`_] - |
| 45 | - Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis | |
| 45 | + Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis. | |
| 46 | + Rename ``outcube`` to ``outobs`` parameter. | |
| 46 | 47 | * [`2685 <https://cta-redmine.irap.omp.eu/issues/2685>`_] - |
| 47 | 48 | Add ``ctbkgcube::cntcube()`` method |
| 48 | 49 | Account for varying energy thresholds in :ref:`ctbin` weight computation | ... | ... |
doc/source/users/reference_manual/ctbin.rst
| ... | ... | @@ -14,17 +14,27 @@ a 3-dimensional data cube spanned by Right Ascension or Galactic longitude, |
| 14 | 14 | Declination or Galactic latitude, and energy. The energy binning may be either |
| 15 | 15 | linear, logarithmic, or custom defined using an input file. The events are |
| 16 | 16 | either taken from a single event list file or from the event lists that are |
| 17 | -specified in an observation definition file. In case that multiple event | |
| 18 | -lists are given in an observation definition file, the tool will loop over | |
| 19 | -all event lists and fill all events into a single counts cube. | |
| 17 | +specified in an observation definition file. | |
| 20 | 18 | |
| 21 | -:ref:`ctbin` generates a counts cube FITS file comprising three extensions. The | |
| 19 | +In case that multiple event lists are given in an observation definition file | |
| 20 | +there are two options. By default, the tool will loop over all event lists and | |
| 21 | +fill all events into a single counts cube. If ``stack=no`` is specified, the | |
| 22 | +tool will bin each event list into a separate counts cube. | |
| 23 | + | |
| 24 | +:ref:`ctbin` generates counts cube FITS file(s) comprising three extensions. The | |
| 22 | 25 | primary extension contains a 3-dimensional image that contains the counts |
| 23 | 26 | cube values. The next extension named ``EBOUNDS`` contains a binary table |
| 24 | 27 | that defines the energy boundaries of the counts cube. The last extension |
| 25 | 28 | named ``GTI`` contains a binary table that defines the Good Time Intervals |
| 26 | 29 | of all event lists that have been filled into the counts cube. |
| 27 | 30 | |
| 31 | +By default, the tool will write out a single, stacked, counts cube. If ``stack=no`` | |
| 32 | +is specified, the tool will write all counts cubes into a separate FITS file, | |
| 33 | +prefixing the input event list file name with the string that is specified by | |
| 34 | +the hidden ``prefix`` parameter. In addition, the tool will create an observation | |
| 35 | +definition XML file that lists all produced counts cubes, and that can be used | |
| 36 | +as input for any further analysis step. | |
| 37 | + | |
| 28 | 38 | |
| 29 | 39 | General parameters |
| 30 | 40 | ------------------ |
| ... | ... | @@ -32,8 +42,18 @@ General parameters |
| 32 | 42 | ``inobs [file]`` |
| 33 | 43 | Input event list or observation definition XML file. |
| 34 | 44 | |
| 35 | -``outcube [file]`` | |
| 36 | - Output counts cube file. | |
| 45 | +``outobs [file]`` | |
| 46 | + Output counts cube file or observation definition XML file. | |
| 47 | + | |
| 48 | +``(stack = yes) [boolean]`` | |
| 49 | + Specify whether stacking of the events in a single counts cube is requested. | |
| 50 | + By default this hidden parameter is set to yes, and the tool produces a | |
| 51 | + single counts cube FITS file on output. If ``no`` is specified, the tool | |
| 52 | + will produce a counts cube for each event list that is found in the input | |
| 53 | + observation, and will also write an observation definition XML file. | |
| 54 | + | |
| 55 | +``(prefix = "binned_") [string]`` | |
| 56 | + Prefix for output counts cube in observation definition XML file. | |
| 37 | 57 | |
| 38 | 58 | ``ebinalg <FILE|LIN|LOG> [string]`` |
| 39 | 59 | Algorithm for defining energy bins. For ``FILE``, the energy bins are defined | ... | ... |
doc/source/users/reference_manual/ctselect.rst
| ... | ... | @@ -52,7 +52,7 @@ General parameters |
| 52 | 52 | Output event list or observation definition XML file. |
| 53 | 53 | |
| 54 | 54 | ``(prefix = "selected_") [string]`` |
| 55 | - Prefix for output event lists in observation definition file. | |
| 55 | + Prefix for output event lists in observation definition XML file. | |
| 56 | 56 | |
| 57 | 57 | ``(usepnt = yes) [boolean]`` |
| 58 | 58 | Use pointing instead of RA/DEC parameters? | ... | ... |
src/ctbin/ctbin.cpp
| ... | ... | @@ -462,10 +462,10 @@ void ctbin::save(void) |
| 462 | 462 | |
| 463 | 463 | // Save only if filename is valid and if there is at least one |
| 464 | 464 | // observation |
| 465 | - if ((*this)["outcube"].is_valid() && m_obs.size() > 0) { | |
| 465 | + if ((*this)["outobs"].is_valid() && m_obs.size() > 0) { | |
| 466 | 466 | |
| 467 | 467 | // Get counts cube filename |
| 468 | - m_outcube = (*this)["outcube"].filename(); | |
| 468 | + GFilename outobs = (*this)["outobs"].filename(); | |
| 469 | 469 | |
| 470 | 470 | // Get CTA observation from observation container |
| 471 | 471 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]); |
| ... | ... | @@ -474,14 +474,14 @@ void ctbin::save(void) |
| 474 | 474 | if (obs != NULL) { |
| 475 | 475 | |
| 476 | 476 | // Log counts cube file name |
| 477 | - log_value(NORMAL, "Counts cube file", m_outcube.url()); | |
| 477 | + log_value(NORMAL, "Counts cube file", outobs.url()); | |
| 478 | 478 | |
| 479 | 479 | // Save cube |
| 480 | - obs->save(m_outcube, clobber()); | |
| 480 | + obs->save(outobs, clobber()); | |
| 481 | 481 | |
| 482 | 482 | } // endif: observation was valid |
| 483 | 483 | |
| 484 | - } // endif: outcube file was valid | |
| 484 | + } // endif: outobs file was valid | |
| 485 | 485 | |
| 486 | 486 | } // endif: counts cube was stacked |
| 487 | 487 | |
| ... | ... | @@ -495,7 +495,7 @@ void ctbin::save(void) |
| 495 | 495 | // Loop over all ids of observations that were binned |
| 496 | 496 | for (int j = 0; j < m_ids.size(); ++j) { |
| 497 | 497 | |
| 498 | - // Skip if ID differes | |
| 498 | + // Skip if ID differs | |
| 499 | 499 | if (m_ids[j] != m_obs[i]->id()) { |
| 500 | 500 | continue; |
| 501 | 501 | } |
| ... | ... | @@ -517,9 +517,16 @@ void ctbin::save(void) |
| 517 | 517 | } // endfor: looped over all observations |
| 518 | 518 | |
| 519 | 519 | // Write XML file |
| 520 | - if ((*this)["outcube"].is_valid()) { | |
| 521 | - m_outcube = (*this)["outcube"].filename(); | |
| 522 | - m_obs.save(m_outcube); | |
| 520 | + if ((*this)["outobs"].is_valid()) { | |
| 521 | + | |
| 522 | + // Get observation definition XML filename | |
| 523 | + std::string outobs = (*this)["outobs"].filename(); | |
| 524 | + | |
| 525 | + // Issue warning if output filename has no .xml suffix | |
| 526 | + log_string(TERSE, warn_xml_suffix(outobs)); | |
| 527 | + | |
| 528 | + // Save XML file | |
| 529 | + m_obs.save(outobs); | |
| 523 | 530 | } |
| 524 | 531 | |
| 525 | 532 | } // endelse: counts cube were not stacked |
| ... | ... | @@ -570,7 +577,6 @@ void ctbin::publish(const std::string& name) |
| 570 | 577 | void ctbin::init_members(void) |
| 571 | 578 | { |
| 572 | 579 | // Initialise members |
| 573 | - m_outcube.clear(); | |
| 574 | 580 | m_usepnt = false; |
| 575 | 581 | m_stack = true; |
| 576 | 582 | m_publish = false; |
| ... | ... | @@ -602,7 +608,6 @@ void ctbin::init_members(void) |
| 602 | 608 | void ctbin::copy_members(const ctbin& app) |
| 603 | 609 | { |
| 604 | 610 | // Copy attributes |
| 605 | - m_outcube = app.m_outcube; | |
| 606 | 611 | m_usepnt = app.m_usepnt; |
| 607 | 612 | m_stack = app.m_stack; |
| 608 | 613 | m_publish = app.m_publish; |
| ... | ... | @@ -669,7 +674,7 @@ void ctbin::get_parameters(void) |
| 669 | 674 | |
| 670 | 675 | // If needed later, query output filename now |
| 671 | 676 | if (read_ahead()) { |
| 672 | - (*this)["outcube"].query(); | |
| 677 | + (*this)["outobs"].query(); | |
| 673 | 678 | } |
| 674 | 679 | |
| 675 | 680 | // Set number of OpenMP threads | ... | ... |
src/ctbin/ctbin.hpp
| ... | ... | @@ -99,7 +99,6 @@ protected: |
| 99 | 99 | void obs_cube_stacked(void); |
| 100 | 100 | |
| 101 | 101 | // User parameters |
| 102 | - GFilename m_outcube; //!< Output counts map file name | |
| 103 | 102 | bool m_usepnt; //!< Use pointing instead of xref/yref parameters |
| 104 | 103 | bool m_stack; //!< Output one stacked cube or multiple cubes |
| 105 | 104 | std::string m_prefix; //!< Prefix for output path of multiple cubes | ... | ... |
src/ctbin/ctbin.par
| ... | ... | @@ -16,10 +16,10 @@ |
| 16 | 16 | # |
| 17 | 17 | # General parameters |
| 18 | 18 | #=================== |
| 19 | -inobs, f, a, events.fits,,, "Input event list or observation definition XML file" | |
| 20 | -outcube, f, a, cntcube.fits,,, "Output counts cube file" | |
| 21 | -stack, b, h, yes,,, "Stack events into one cube?" | |
| 22 | -prefix, s, h, binned_,,, "Prefix for counts cubes in observation definition XML file" | |
| 19 | +inobs, f, a, events.fits,,, "Input event list or observation definition XML file" | |
| 20 | +outobs, f, a, cntcube.fits,,, "Output counts cube file or observation definition XML file" | |
| 21 | +stack, b, h, yes,,, "Stack events into one cube?" | |
| 22 | +prefix, s, h, binned_,,, "Prefix for counts cubes in observation definition XML file" | |
| 23 | 23 | |
| 24 | 24 | # |
| 25 | 25 | # Energy binning parameters | ... | ... |
test/test_ctbin.py
| ... | ... | @@ -71,7 +71,7 @@ class Test(test): |
| 71 | 71 | |
| 72 | 72 | # Setup ctbin command |
| 73 | 73 | cmd = ctbin+' inobs="'+self._events+'"'+ \ |
| 74 | - ' outcube="cntmap_cmd1.fits"'+\ | |
| 74 | + ' outobs="cntmap_cmd1.fits"'+\ | |
| 75 | 75 | ' emin=1.0 emax=100.0 enumbins=10 ebinalg="LOG"'+ \ |
| 76 | 76 | ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ |
| 77 | 77 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| ... | ... | @@ -87,7 +87,7 @@ class Test(test): |
| 87 | 87 | |
| 88 | 88 | # Setup ctbin command |
| 89 | 89 | cmd = ctbin+' inobs="events_that_do_not_exist.fits"'+ \ |
| 90 | - ' outcube="cntmap_cmd2.fits"'+\ | |
| 90 | + ' outobs="cntmap_cmd2.fits"'+\ | |
| 91 | 91 | ' emin=1.0 emax=100.0 enumbins=10 ebinalg="LOG"'+ \ |
| 92 | 92 | ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ |
| 93 | 93 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| ... | ... | @@ -99,7 +99,7 @@ class Test(test): |
| 99 | 99 | |
| 100 | 100 | # Setup ctbin command with different ebounds than input |
| 101 | 101 | cmd = ctbin+' inobs="'+self._events+'"'+ \ |
| 102 | - ' outcube="cntmap_cmd3.fits"'+\ | |
| 102 | + ' outobs="cntmap_cmd3.fits"'+\ | |
| 103 | 103 | ' emin=2.0 emax=20.0 enumbins=10 ebinalg="LOG"'+ \ |
| 104 | 104 | ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ |
| 105 | 105 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| ... | ... | @@ -117,7 +117,7 @@ class Test(test): |
| 117 | 117 | |
| 118 | 118 | # Setup ctbin command |
| 119 | 119 | cmd = ctbin+' inobs="'+self._datadir+'/obs_unbinned_two.xml"'+ \ |
| 120 | - ' outcube="obs_unbinned_two_binned.xml"'+\ | |
| 120 | + ' outobs="obs_unbinned_two_binned.xml"'+\ | |
| 121 | 121 | ' emin=1.0 emax=100.0 enumbins=10 ebinalg="LOG"'+ \ |
| 122 | 122 | ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ |
| 123 | 123 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| ... | ... | @@ -170,7 +170,7 @@ class Test(test): |
| 170 | 170 | |
| 171 | 171 | # Check that saving does not nothing |
| 172 | 172 | binning['logfile'] = 'ctbin_py0.log' |
| 173 | - binning['outcube'] = 'ctbin_py0.fits' | |
| 173 | + binning['outobs'] = 'ctbin_py0.fits' | |
| 174 | 174 | binning.logFileOpen() |
| 175 | 175 | binning.save() |
| 176 | 176 | self.test_assert(not os.path.isfile('ctbin_py0.fits'), |
| ... | ... | @@ -184,7 +184,7 @@ class Test(test): |
| 184 | 184 | |
| 185 | 185 | # Now set ctbin parameters |
| 186 | 186 | binning['inobs'] = self._events |
| 187 | - binning['outcube'] = 'ctbin_py1.fits' | |
| 187 | + binning['outobs'] = 'ctbin_py1.fits' | |
| 188 | 188 | binning['ebinalg'] = 'LOG' |
| 189 | 189 | binning['emin'] = 1.0 |
| 190 | 190 | binning['emax'] = 100.0 |
| ... | ... | @@ -251,7 +251,7 @@ class Test(test): |
| 251 | 251 | |
| 252 | 252 | # Set-up ctbin using an observation container |
| 253 | 253 | binning = ctools.ctbin(obs) |
| 254 | - binning['outcube'] = 'ctbin_py3.fits' | |
| 254 | + binning['outobs'] = 'ctbin_py3.fits' | |
| 255 | 255 | binning['ebinalg'] = 'LOG' |
| 256 | 256 | binning['emin'] = 1.0 |
| 257 | 257 | binning['emax'] = 100.0 |
| ... | ... | @@ -285,7 +285,7 @@ class Test(test): |
| 285 | 285 | pars = {'inobs': self._events, 'ebinalg': 'LIN', 'emin': 1.0, |
| 286 | 286 | 'emax': 100.0, 'enumbins': 10, 'nxpix': 40, 'nypix': 40, |
| 287 | 287 | 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', |
| 288 | - 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits', | |
| 288 | + 'xref': 83.63, 'yref': 22.01, 'outobs': 'ctbin_py4.fits', | |
| 289 | 289 | 'logfile': 'ctbin_py4.log', 'chatter': 2} |
| 290 | 290 | binning = ctools.ctbin() |
| 291 | 291 | binning.pardict(pars) |
| ... | ... | @@ -300,7 +300,7 @@ class Test(test): |
| 300 | 300 | pars = {'inobs': self._datadir+'/obs_unbinned_two.xml', 'ebinalg': 'LIN', 'emin': 1.0, |
| 301 | 301 | 'emax': 100.0, 'enumbins': 10, 'nxpix': 40, 'nypix': 40, |
| 302 | 302 | 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', |
| 303 | - 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py5.xml', | |
| 303 | + 'xref': 83.63, 'yref': 22.01, 'outobs': 'ctbin_py5.xml', | |
| 304 | 304 | 'logfile': 'ctbin_py5.log', 'chatter': 2, |
| 305 | 305 | 'prefix': 'cntcube_py5_', 'stack' : False} |
| 306 | 306 | binning = ctools.ctbin() | ... | ... |