Commit 2ccf1353474a2519862a1d1eb99fe59ef5da9e2b
Merge branch '1871-add-publish-tables' into integration
Showing
28 changed files
with
284 additions
and
31 deletions
ChangeLog
| 1 | -2016-10-05 | |
| 1 | +2016-10-07 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.2.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Add publish parameter and methods to ctobssim, ctselect, cslightcrv and csspec (#1871) | |
| 6 | 7 | Add csviscube script (#1853) |
| 7 | 8 | Add zenith and azimuth angle information to IRF caldb (#1853) |
| 8 | 9 | Fix ctbin segfault bug for varying energy thresholds (#1850) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in ctools 1.2.0 |
| 2 | 2 | |
| 3 | -5 October 2016 | |
| 3 | +7 October 2016 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -63,6 +63,9 @@ ctobssim - CTA observation simulation |
| 63 | 63 | The clear() method now calls GApplication::clear() to conserve the properties |
| 64 | 64 | of the tool (#1835). |
| 65 | 65 | |
| 66 | +A publish() method has been added that publishes the simulated event lists on | |
| 67 | +a VO hub (#1871). | |
| 68 | + | |
| 66 | 69 | |
| 67 | 70 | ctselect - CTA event selection |
| 68 | 71 | ------------------------------ |
| ... | ... | @@ -72,6 +75,9 @@ of the tool (#1835). |
| 72 | 75 | The time_reference() method has been removed since the method is part of the |
| 73 | 76 | ctool base class, and exposed in Python as _time_reference(). |
| 74 | 77 | |
| 78 | +A publish() method has been added that publishes the simulated event lists on | |
| 79 | +a VO hub (#1871). | |
| 80 | + | |
| 75 | 81 | |
| 76 | 82 | ctbin - CTA event binning |
| 77 | 83 | ------------------------- |
| ... | ... | @@ -200,6 +206,9 @@ of hours that a given position on the sky is observable under a given zenith |
| 200 | 206 | angle by an IACT array during a given time period. The tool implements so far |
| 201 | 207 | a Sun constraint, but no Moon constraint (#1835). |
| 202 | 208 | |
| 209 | +A publish() method has been added to cslightcrv and csspec that publishes the | |
| 210 | +results on a VO hub (#1871). | |
| 211 | + | |
| 203 | 212 | |
| 204 | 213 | Examples |
| 205 | 214 | -------- | ... | ... |
cscripts/cslightcrv.par
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: cslightcrv.par # |
| 8 | -# Version: 1.1.0 # | |
| 8 | +# Version: 1.2.0 # | |
| 9 | 9 | # # |
| 10 | 10 | # Author: Juergen Knoedlseder # |
| 11 | 11 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -55,6 +55,7 @@ fix_bkg, b, h, no,,, "Fix background model parameters?" |
| 55 | 55 | # |
| 56 | 56 | # Standard parameters |
| 57 | 57 | #==================== |
| 58 | +publish, b, h, no,,, "Publish light curve on VO Hub?" | |
| 58 | 59 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 59 | 60 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 60 | 61 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
cscripts/cslightcrv.py
| ... | ... | @@ -614,6 +614,10 @@ class cslightcrv(ctools.cscript): |
| 614 | 614 | self._fits = gammalib.GFits() |
| 615 | 615 | self._fits.append(table) |
| 616 | 616 | |
| 617 | + # Optionally publish light curve | |
| 618 | + if self['publish'].boolean(): | |
| 619 | + self.publish() | |
| 620 | + | |
| 617 | 621 | # Return |
| 618 | 622 | return |
| 619 | 623 | |
| ... | ... | @@ -658,6 +662,36 @@ class cslightcrv(ctools.cscript): |
| 658 | 662 | # Return |
| 659 | 663 | return |
| 660 | 664 | |
| 665 | + def publish(self, name=''): | |
| 666 | + """ | |
| 667 | + Publish light curve | |
| 668 | + | |
| 669 | + Parameters | |
| 670 | + ---------- | |
| 671 | + name : str, optional | |
| 672 | + Name of light curve | |
| 673 | + """ | |
| 674 | + # Write header | |
| 675 | + self._log_header1(gammalib.TERSE, 'Publish light curve') | |
| 676 | + | |
| 677 | + # Continue only if light curve is valid | |
| 678 | + if self._fits.contains('LIGHTCURVE'): | |
| 679 | + | |
| 680 | + # Set default name is user name is empty | |
| 681 | + if not name: | |
| 682 | + user_name = self._name | |
| 683 | + else: | |
| 684 | + user_name = name | |
| 685 | + | |
| 686 | + # Log file name | |
| 687 | + self._log_value(gammalib.NORMAL, 'Light curve name', user_name) | |
| 688 | + | |
| 689 | + # Publish light curve | |
| 690 | + self._fits.publish('LIGHTCURVE', user_name) | |
| 691 | + | |
| 692 | + # Return | |
| 693 | + return | |
| 694 | + | |
| 661 | 695 | def lightcurve(self): |
| 662 | 696 | """ |
| 663 | 697 | Return light curve FITS file | ... | ... |
cscripts/csresmap.py
cscripts/csspec.par
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: csspec.par # |
| 8 | -# Version: 1.1.0 # | |
| 8 | +# Version: 1.2.0 # | |
| 9 | 9 | # # |
| 10 | 10 | # Author: Juergen Knoedlseder # |
| 11 | 11 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -45,6 +45,7 @@ fix_bkg, b, h, no,,, "Fix background parameters" |
| 45 | 45 | # |
| 46 | 46 | # Standard parameters |
| 47 | 47 | #==================== |
| 48 | +publish, b, h, no,,, "Publish spectrum on VO Hub?" | |
| 48 | 49 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 49 | 50 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 50 | 51 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
cscripts/csspec.py
| ... | ... | @@ -268,18 +268,17 @@ class csspec(ctools.cscript): |
| 268 | 268 | par.fix() |
| 269 | 269 | |
| 270 | 270 | # Write header |
| 271 | + self._log_header1(gammalib.TERSE, 'Generate spectrum') | |
| 271 | 272 | if self._logTerse(): |
| 272 | - self._log("\n") | |
| 273 | - self._log.header1("Generate spectrum") | |
| 274 | - self._log(str(self._ebounds)) | |
| 273 | + self._log(str(self._ebounds)) | |
| 275 | 274 | |
| 276 | 275 | # Initialise FITS Table with extension "SPECTRUM" |
| 277 | 276 | table = gammalib.GFitsBinTable(self._ebounds.size()) |
| 278 | - table.extname("SPECTRUM") | |
| 277 | + table.extname('SPECTRUM') | |
| 279 | 278 | |
| 280 | 279 | # Add Header for compatibility with gammalib.GMWLSpectrum |
| 281 | - table.card("INSTRUME", "CTA", "Name of Instrument") | |
| 282 | - table.card("TELESCOP", "CTA", "Name of Telescope") | |
| 280 | + table.card('INSTRUME', 'CTA', 'Name of Instrument') | |
| 281 | + table.card('TELESCOP', 'CTA', 'Name of Telescope') | |
| 283 | 282 | |
| 284 | 283 | # Create FITS table columns |
| 285 | 284 | nrows = self._ebounds.size() |
| ... | ... | @@ -470,12 +469,16 @@ class csspec(ctools.cscript): |
| 470 | 469 | self._fits = gammalib.GFits() |
| 471 | 470 | self._fits.append(table) |
| 472 | 471 | |
| 472 | + # Optionally publish light curve | |
| 473 | + if self['publish'].boolean(): | |
| 474 | + self.publish() | |
| 475 | + | |
| 473 | 476 | # Return |
| 474 | 477 | return |
| 475 | 478 | |
| 476 | 479 | def execute(self): |
| 477 | 480 | """ |
| 478 | - Execute the script. | |
| 481 | + Execute the script | |
| 479 | 482 | """ |
| 480 | 483 | # Open logfile |
| 481 | 484 | self.logFileOpen() |
| ... | ... | @@ -494,24 +497,19 @@ class csspec(ctools.cscript): |
| 494 | 497 | |
| 495 | 498 | def save(self): |
| 496 | 499 | """ |
| 497 | - Save spectrum. | |
| 500 | + Save spectrum | |
| 498 | 501 | """ |
| 499 | 502 | # Write header |
| 500 | - if self._logTerse(): | |
| 501 | - self._log("\n") | |
| 502 | - self._log.header1("Save spectrum") | |
| 503 | + self._log_header1(gammalib.TERSE, 'Save spectrum') | |
| 503 | 504 | |
| 504 | 505 | # Get outmap parameter |
| 505 | - outfile = self["outfile"].filename() | |
| 506 | + outfile = self['outfile'].filename() | |
| 506 | 507 | |
| 507 | 508 | # Continue only filename and residual map are valid |
| 508 | 509 | if self._fits != None: |
| 509 | 510 | |
| 510 | 511 | # Log file name |
| 511 | - if self._logTerse(): | |
| 512 | - self._log(gammalib.parformat("Spectrum file")) | |
| 513 | - self._log(outfile.url()) | |
| 514 | - self._log("\n") | |
| 512 | + self._log_value(gammalib.NORMAL, 'Spectrum file', outfile.url()) | |
| 515 | 513 | |
| 516 | 514 | # Save spectrum |
| 517 | 515 | self._fits.saveto(outfile, self._clobber) |
| ... | ... | @@ -519,6 +517,36 @@ class csspec(ctools.cscript): |
| 519 | 517 | # Return |
| 520 | 518 | return |
| 521 | 519 | |
| 520 | + def publish(self, name=''): | |
| 521 | + """ | |
| 522 | + Publish spectrum | |
| 523 | + | |
| 524 | + Parameters | |
| 525 | + ---------- | |
| 526 | + name : str, optional | |
| 527 | + Name of spectrum | |
| 528 | + """ | |
| 529 | + # Write header | |
| 530 | + self._log_header1(gammalib.TERSE, 'Publish spectrum') | |
| 531 | + | |
| 532 | + # Continue only if spectrum is valid | |
| 533 | + if self._fits.contains('SPECTRUM'): | |
| 534 | + | |
| 535 | + # Set default name is user name is empty | |
| 536 | + if not name: | |
| 537 | + user_name = self._name | |
| 538 | + else: | |
| 539 | + user_name = name | |
| 540 | + | |
| 541 | + # Log file name | |
| 542 | + self._log_value(gammalib.NORMAL, 'Spectrum name', user_name) | |
| 543 | + | |
| 544 | + # Publish spectrum | |
| 545 | + self._fits.publish('SPECTRUM', user_name) | |
| 546 | + | |
| 547 | + # Return | |
| 548 | + return | |
| 549 | + | |
| 522 | 550 | def spectrum(self): |
| 523 | 551 | """ |
| 524 | 552 | Return spectrum FITS file. | ... | ... |
cscripts/csviscube.par
| ... | ... | @@ -35,6 +35,7 @@ zmax, r, h, 60.0,,, "Maximum zenith angle (deg)" |
| 35 | 35 | # |
| 36 | 36 | # Standard parameters |
| 37 | 37 | #==================== |
| 38 | +publish, b, h, no,,, "Publish visibility cube on VO Hub?" | |
| 38 | 39 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 39 | 40 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 40 | 41 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
cscripts/csviscube.py
| ... | ... | @@ -459,6 +459,10 @@ class csviscube(ctools.cscript): |
| 459 | 459 | # Compute visibility cube |
| 460 | 460 | self._visibility_cube() |
| 461 | 461 | |
| 462 | + # Optionally publish map | |
| 463 | + if self['publish'].boolean(): | |
| 464 | + self.publish() | |
| 465 | + | |
| 462 | 466 | # Return |
| 463 | 467 | return |
| 464 | 468 | |
| ... | ... | @@ -481,6 +485,33 @@ class csviscube(ctools.cscript): |
| 481 | 485 | # Return |
| 482 | 486 | return |
| 483 | 487 | |
| 488 | + def publish(self, name=''): | |
| 489 | + """ | |
| 490 | + Publish visibility cube | |
| 491 | + | |
| 492 | + Parameters | |
| 493 | + ---------- | |
| 494 | + name : str, optional | |
| 495 | + Name of visibility cube | |
| 496 | + """ | |
| 497 | + # Write header | |
| 498 | + self._log_header1(gammalib.TERSE, 'Publish visibility cube') | |
| 499 | + | |
| 500 | + # Set default name is user name is empty | |
| 501 | + if not name: | |
| 502 | + user_name = self._name | |
| 503 | + else: | |
| 504 | + user_name = name | |
| 505 | + | |
| 506 | + # Log cube name | |
| 507 | + self._log_value(gammalib.TERSE, 'Visibility cube name', user_name) | |
| 508 | + | |
| 509 | + # Publish cube | |
| 510 | + self._cube.publish(user_name) | |
| 511 | + | |
| 512 | + # Return | |
| 513 | + return | |
| 514 | + | |
| 484 | 515 | def execute(self): |
| 485 | 516 | """ |
| 486 | 517 | Execute the script | ... | ... |
doc/source/users/reference_manual/cslightcrv.rst
| ... | ... | @@ -118,6 +118,9 @@ General parameters |
| 118 | 118 | Standard parameters |
| 119 | 119 | ------------------- |
| 120 | 120 | |
| 121 | +``(publish = no) [boolean]`` | |
| 122 | + Specifies whether the light curve should be published on VO Hub. | |
| 123 | + | |
| 121 | 124 | ``(chatter = 2) [integer]`` |
| 122 | 125 | Verbosity of the executable: |
| 123 | 126 | chatter = 0: no information will be logged | ... | ... |
doc/source/users/reference_manual/csspec.rst
| ... | ... | @@ -110,6 +110,9 @@ General parameters |
| 110 | 110 | Standard parameters |
| 111 | 111 | ------------------- |
| 112 | 112 | |
| 113 | +``(publish = no) [boolean]`` | |
| 114 | + Specifies whether the spectrum should be published on VO Hub. | |
| 115 | + | |
| 113 | 116 | ``(chatter = 2) [integer]`` |
| 114 | 117 | Verbosity of the executable: |
| 115 | 118 | chatter = 0: no information will be logged | ... | ... |
doc/source/users/reference_manual/csviscube.rst
| ... | ... | @@ -58,6 +58,9 @@ General parameters |
| 58 | 58 | Standard parameters |
| 59 | 59 | ------------------- |
| 60 | 60 | |
| 61 | +``(publish = no) [boolean]`` | |
| 62 | + Specifies whether the visibility cube should be published on VO Hub. | |
| 63 | + | |
| 61 | 64 | ``(chatter = 2) [integer]`` |
| 62 | 65 | Verbosity of the executable: |
| 63 | 66 | chatter = 0: no information will be logged | ... | ... |
doc/source/users/reference_manual/ctobssim.rst
| ... | ... | @@ -106,6 +106,9 @@ General parameters |
| 106 | 106 | Standard parameters |
| 107 | 107 | ------------------- |
| 108 | 108 | |
| 109 | +``(publish = no) [boolean]`` | |
| 110 | + Specifies whether the event list(s) should be published on VO Hub. | |
| 111 | + | |
| 109 | 112 | ``(chatter = 2) [integer]`` |
| 110 | 113 | Verbosity of the executable: |
| 111 | 114 | chatter = 0: no information will be logged | ... | ... |
doc/source/users/reference_manual/ctselect.rst
| ... | ... | @@ -95,6 +95,9 @@ General parameters |
| 95 | 95 | Standard parameters |
| 96 | 96 | ------------------- |
| 97 | 97 | |
| 98 | +``(publish = no) [boolean]`` | |
| 99 | + Specifies whether the event list(s) should be published on VO Hub. | |
| 100 | + | |
| 98 | 101 | ``(chatter = 2) [integer]`` |
| 99 | 102 | Verbosity of the executable: |
| 100 | 103 | chatter = 0: no information will be logged | ... | ... |
pyext/ctobssim.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctobssim - Observation simulator tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -47,6 +47,7 @@ public: |
| 47 | 47 | void clear(void); |
| 48 | 48 | void run(void); |
| 49 | 49 | void save(void); |
| 50 | + void publish(const std::string& name = ""); | |
| 50 | 51 | const double& max_rate(void) const; |
| 51 | 52 | void max_rate(const double& max_rate); |
| 52 | 53 | }; | ... | ... |
pyext/ctselect.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctselect - Data selection tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2014 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2016 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -47,6 +47,7 @@ public: |
| 47 | 47 | void clear(void); |
| 48 | 48 | void run(void); |
| 49 | 49 | void save(void); |
| 50 | + void publish(const std::string& name = ""); | |
| 50 | 51 | }; |
| 51 | 52 | |
| 52 | 53 | ... | ... |
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -32,6 +32,8 @@ |
| 32 | 32 | #include <typeinfo> |
| 33 | 33 | #include "ctobssim.hpp" |
| 34 | 34 | #include "GTools.hpp" |
| 35 | +#include "GFits.hpp" | |
| 36 | + | |
| 35 | 37 | |
| 36 | 38 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 39 | #define G_GET_PARAMETERS "ctobssim::get_parameters()" |
| ... | ... | @@ -415,6 +417,11 @@ void ctobssim::run(void) |
| 415 | 417 | // Restore energy dispersion flags of all CTA observations |
| 416 | 418 | restore_edisp(m_obs, save_edisp); |
| 417 | 419 | |
| 420 | + // Optionally publish event list(s) | |
| 421 | + if ((*this)["publish"].boolean()) { | |
| 422 | + publish(); | |
| 423 | + } | |
| 424 | + | |
| 418 | 425 | // Return |
| 419 | 426 | return; |
| 420 | 427 | } |
| ... | ... | @@ -459,6 +466,60 @@ void ctobssim::save(void) |
| 459 | 466 | } |
| 460 | 467 | |
| 461 | 468 | |
| 469 | +/***********************************************************************//** | |
| 470 | + * @brief Publish event lists | |
| 471 | + * | |
| 472 | + * @param[in] name Event list name. | |
| 473 | + ***************************************************************************/ | |
| 474 | +void ctobssim::publish(const std::string& name) | |
| 475 | +{ | |
| 476 | + // Write header into logger | |
| 477 | + log_header1(TERSE, gammalib::number("Publish event list", m_obs.size())); | |
| 478 | + | |
| 479 | + // Loop over all observation in the container | |
| 480 | + for (int i = 0; i < m_obs.size(); ++i) { | |
| 481 | + | |
| 482 | + // Get CTA observation | |
| 483 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | |
| 484 | + | |
| 485 | + // Handle only CTA observations | |
| 486 | + if (obs != NULL) { | |
| 487 | + | |
| 488 | + // Continue only if there is an event list | |
| 489 | + if (obs->events()->size() != 0) { | |
| 490 | + | |
| 491 | + // Set default name if user name is empty | |
| 492 | + std::string user_name(name); | |
| 493 | + if (user_name.empty()) { | |
| 494 | + user_name = CTOBSSIM_NAME; | |
| 495 | + } | |
| 496 | + | |
| 497 | + // If there are several event lists then add an index | |
| 498 | + if (m_use_xml) { | |
| 499 | + user_name += gammalib::str(i); | |
| 500 | + } | |
| 501 | + | |
| 502 | + // Write event list name into logger | |
| 503 | + log_value(NORMAL, "Event list name", user_name); | |
| 504 | + | |
| 505 | + // Write events into in-memory FITS file | |
| 506 | + GFits fits; | |
| 507 | + obs->write(fits); | |
| 508 | + | |
| 509 | + // Publish | |
| 510 | + fits.publish("EVENTS", user_name); | |
| 511 | + | |
| 512 | + } // endif: there were events | |
| 513 | + | |
| 514 | + } // endif: observation was a CTA observation | |
| 515 | + | |
| 516 | + } // endfor: looped over observations | |
| 517 | + | |
| 518 | + // Return | |
| 519 | + return; | |
| 520 | +} | |
| 521 | + | |
| 522 | + | |
| 462 | 523 | /*========================================================================== |
| 463 | 524 | = = |
| 464 | 525 | = Private methods = | ... | ... |
src/ctobssim/ctobssim.hpp
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | |
| 35 | 35 | /* __Definitions _________________________________________________________ */ |
| 36 | 36 | #define CTOBSSIM_NAME "ctobssim" |
| 37 | -#define CTOBSSIM_VERSION "1.1.0" | |
| 37 | +#define CTOBSSIM_VERSION "1.2.0" | |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /***********************************************************************//** |
| ... | ... | @@ -65,6 +65,7 @@ public: |
| 65 | 65 | void clear(void); |
| 66 | 66 | void run(void); |
| 67 | 67 | void save(void); |
| 68 | + void publish(const std::string& name = ""); | |
| 68 | 69 | const double& max_rate(void) const; |
| 69 | 70 | void max_rate(const double& max_rate); |
| 70 | 71 | ... | ... |
src/ctobssim/ctobssim.par
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctobssim.par # |
| 8 | -# Version: 1.1.0 # | |
| 8 | +# Version: 1.2.0 # | |
| 9 | 9 | # # |
| 10 | 10 | # Author: Juergen Knoedlseder # |
| 11 | 11 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -43,6 +43,7 @@ eslices, i, h, 10,1,100, "Number of energy slices" |
| 43 | 43 | # |
| 44 | 44 | # Standard parameters |
| 45 | 45 | #==================== |
| 46 | +publish, b, h, no,,, "Publish event list on VO Hub?" | |
| 46 | 47 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 47 | 48 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 48 | 49 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
src/ctselect/ctselect.cpp
| ... | ... | @@ -348,6 +348,11 @@ void ctselect::run(void) |
| 348 | 348 | // Write observation(s) into logger |
| 349 | 349 | log_observations(NORMAL, m_obs, "Output observation"); |
| 350 | 350 | |
| 351 | + // Optionally publish event list(s) | |
| 352 | + if ((*this)["publish"].boolean()) { | |
| 353 | + publish(); | |
| 354 | + } | |
| 355 | + | |
| 351 | 356 | // Return |
| 352 | 357 | return; |
| 353 | 358 | } |
| ... | ... | @@ -392,6 +397,60 @@ void ctselect::save(void) |
| 392 | 397 | } |
| 393 | 398 | |
| 394 | 399 | |
| 400 | +/***********************************************************************//** | |
| 401 | + * @brief Publish event lists | |
| 402 | + * | |
| 403 | + * @param[in] name Event list name. | |
| 404 | + ***************************************************************************/ | |
| 405 | +void ctselect::publish(const std::string& name) | |
| 406 | +{ | |
| 407 | + // Write header into logger | |
| 408 | + log_header1(TERSE, gammalib::number("Publish event list", m_obs.size())); | |
| 409 | + | |
| 410 | + // Loop over all observation in the container | |
| 411 | + for (int i = 0; i < m_obs.size(); ++i) { | |
| 412 | + | |
| 413 | + // Get CTA observation | |
| 414 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | |
| 415 | + | |
| 416 | + // Handle only CTA observations | |
| 417 | + if (obs != NULL) { | |
| 418 | + | |
| 419 | + // Continue only if there is an event list | |
| 420 | + if (obs->events()->size() != 0) { | |
| 421 | + | |
| 422 | + // Set default name if user name is empty | |
| 423 | + std::string user_name(name); | |
| 424 | + if (user_name.empty()) { | |
| 425 | + user_name = CTSELECT_NAME; | |
| 426 | + } | |
| 427 | + | |
| 428 | + // If there are several event lists then add an index | |
| 429 | + if (m_use_xml) { | |
| 430 | + user_name += gammalib::str(i); | |
| 431 | + } | |
| 432 | + | |
| 433 | + // Write event list name into logger | |
| 434 | + log_value(NORMAL, "Event list name", user_name); | |
| 435 | + | |
| 436 | + // Write events into in-memory FITS file | |
| 437 | + GFits fits; | |
| 438 | + obs->write(fits); | |
| 439 | + | |
| 440 | + // Publish | |
| 441 | + fits.publish("EVENTS", user_name); | |
| 442 | + | |
| 443 | + } // endif: there were events | |
| 444 | + | |
| 445 | + } // endif: observation was a CTA observation | |
| 446 | + | |
| 447 | + } // endfor: looped over observations | |
| 448 | + | |
| 449 | + // Return | |
| 450 | + return; | |
| 451 | +} | |
| 452 | + | |
| 453 | + | |
| 395 | 454 | /*========================================================================== |
| 396 | 455 | = = |
| 397 | 456 | = Private methods = | ... | ... |
src/ctselect/ctselect.hpp
src/ctselect/ctselect.par
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # File: ctselect.par # |
| 8 | -# Version: 1.0.0 # | |
| 8 | +# Version: 1.2.0 # | |
| 9 | 9 | # # |
| 10 | 10 | # Author: Jurgen Knodlseder # |
| 11 | 11 | # Jurgen.Knodlseder@irap.omp.eu # |
| ... | ... | @@ -38,6 +38,7 @@ usethres,s, h, "NONE",NONE|DEFAULT|USER,, "Energy threshold type" |
| 38 | 38 | # |
| 39 | 39 | # Standard parameters |
| 40 | 40 | #==================== |
| 41 | +publish, b, h, no,,, "Publish event list on VO Hub?" | |
| 41 | 42 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 42 | 43 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 43 | 44 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -294,7 +294,7 @@ void ctskymap::publish(const std::string& name) |
| 294 | 294 | // Write header into logger |
| 295 | 295 | log_header1(TERSE, "Publish sky map"); |
| 296 | 296 | |
| 297 | - // Set default name is user name is empty | |
| 297 | + // Set default name if user name is empty | |
| 298 | 298 | std::string user_name(name); |
| 299 | 299 | if (user_name.empty()) { |
| 300 | 300 | user_name = CTSKYMAP_NAME; | ... | ... |
test/test_cslightcrv.py
| ... | ... | @@ -126,6 +126,7 @@ class Test(test): |
| 126 | 126 | lcrv['outfile'] = 'cslightcrv_py1.fits' |
| 127 | 127 | lcrv['logfile'] = 'cslightcrv_py1.log' |
| 128 | 128 | lcrv['chatter'] = 2 |
| 129 | + lcrv['publish'] = True | |
| 129 | 130 | |
| 130 | 131 | # Run cslightcrv script and save light curve |
| 131 | 132 | lcrv.logFileOpen() # Make sure we get a log file | ... | ... |
test/test_csspec.py
| ... | ... | @@ -130,6 +130,7 @@ class Test(test): |
| 130 | 130 | spec['emax'] = 100.0 |
| 131 | 131 | spec['logfile'] = 'csspec_py1.log' |
| 132 | 132 | spec['chatter'] = 2 |
| 133 | + spec['publish'] = True | |
| 133 | 134 | |
| 134 | 135 | # Run csspec script |
| 135 | 136 | spec.logFileOpen() # Make sure we get a log file |
| ... | ... | @@ -155,6 +156,7 @@ class Test(test): |
| 155 | 156 | spec['emax'] = 100.0 |
| 156 | 157 | spec['logfile'] = 'csspec_py2.log' |
| 157 | 158 | spec['chatter'] = 3 |
| 159 | + spec['publish'] = False | |
| 158 | 160 | |
| 159 | 161 | # Execute csspec script |
| 160 | 162 | spec.execute() | ... | ... |
test/test_csviscube.py
| ... | ... | @@ -34,7 +34,7 @@ class Test(test): |
| 34 | 34 | # Constructor |
| 35 | 35 | def __init__(self): |
| 36 | 36 | """ |
| 37 | - Constructor. | |
| 37 | + Constructor | |
| 38 | 38 | """ |
| 39 | 39 | # Call base class constructor |
| 40 | 40 | test.__init__(self) |
| ... | ... | @@ -45,7 +45,7 @@ class Test(test): |
| 45 | 45 | # Set test functions |
| 46 | 46 | def set(self): |
| 47 | 47 | """ |
| 48 | - Set all test functions. | |
| 48 | + Set all test functions | |
| 49 | 49 | """ |
| 50 | 50 | # Set test name |
| 51 | 51 | self.name('csviscube') |
| ... | ... | @@ -60,7 +60,7 @@ class Test(test): |
| 60 | 60 | # Test csviscube on command line |
| 61 | 61 | def _test_cmd(self): |
| 62 | 62 | """ |
| 63 | - Test csviscube on the command line. | |
| 63 | + Test csviscube on the command line | |
| 64 | 64 | """ |
| 65 | 65 | # Set script name |
| 66 | 66 | csviscube = self._script('csviscube') |
| ... | ... | @@ -84,7 +84,7 @@ class Test(test): |
| 84 | 84 | # Test csviscube from Python |
| 85 | 85 | def _test_python(self): |
| 86 | 86 | """ |
| 87 | - Test csviscube from Python. | |
| 87 | + Test csviscube from Python | |
| 88 | 88 | """ |
| 89 | 89 | # Set-up csviscube |
| 90 | 90 | viscube = cscripts.csviscube() |
| ... | ... | @@ -96,6 +96,7 @@ class Test(test): |
| 96 | 96 | viscube['outfile'] = 'csviscube_py1.fits' |
| 97 | 97 | viscube['logfile'] = 'csviscube_py1.log' |
| 98 | 98 | viscube['chatter'] = 2 |
| 99 | + viscube['publish'] = True | |
| 99 | 100 | |
| 100 | 101 | # Run script |
| 101 | 102 | viscube.logFileOpen() # Make sure we get a log file | ... | ... |
test/test_ctobssim.py
| ... | ... | @@ -228,6 +228,7 @@ class Test(test): |
| 228 | 228 | cpy_sim['outevents'] = 'ctobssim_py3.xml' |
| 229 | 229 | cpy_sim['logfile'] = 'ctobssim_py3.log' |
| 230 | 230 | cpy_sim['chatter'] = 4 |
| 231 | + cpy_sim['publish'] = True | |
| 231 | 232 | cpy_sim.logFileOpen() # Needed to get a new log file |
| 232 | 233 | cpy_sim.execute() |
| 233 | 234 | ... | ... |
test/test_ctselect.py
| ... | ... | @@ -177,6 +177,7 @@ class Test(test): |
| 177 | 177 | cpy_select['outobs'] = 'ctselect_py2.fits' |
| 178 | 178 | cpy_select['logfile'] = 'ctselect_py2.log' |
| 179 | 179 | cpy_select['chatter'] = 3 |
| 180 | + cpy_select['publish'] = True | |
| 180 | 181 | cpy_select.logFileOpen() # Needed to get a new log file |
| 181 | 182 | cpy_select.execute() |
| 182 | 183 | ... | ... |