diff --git a/ChangeLog b/ChangeLog index ff210d1..5d90b91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -2016-02-17 Juergen Knoedlseder +2016-02-24 Juergen Knoedlseder * Version 1.1.0 released ======================== + Add publish() methods to tools producing images (#1710) + Read ahead output filename in cterror (#1700) Subdivide simulation energy range in ctobssim (#1673) Delete existing events before simulation in ctobssim (#1663) Add csiactcopy script (#1661) diff --git a/NEWS b/NEWS index 9adf406..8a744a2 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 1.1.0 Author(s) : Juergen Knoedlseder -17 February 2016 +24 February 2016 1. Introduction @@ -81,7 +81,8 @@ Intervals) extensions. 7. ctbin - CTA event binning ---------------------------- -None +Add publish() method to publish the counts cube via a SAMP Hub to Virtual +Observatory interoperable tools (e.g. Aladin). 8. ctlike - Maximum likelihood fitting @@ -89,24 +90,28 @@ None None -9. cttsmap - Generation of Test Statistics map ----------------------------------------------- -None +9. cttsmap - Generation of Test Statistic map +--------------------------------------------- +Add publish() method to publish the Test Statistic map via a SAMP Hub to +Virtual Observatory interoperable tools (e.g. Aladin). 10. ctskymap - CTA sky mapping ------------------------------ -None +Add publish() method to publish the sky map via a SAMP Hub to Virtual +Observatory interoperable tools (e.g. Aladin). 11. ctmodel - CTA counts cube modelling --------------------------------------- -None +Add publish() method to publish the model cube via a SAMP Hub to Virtual +Observatory interoperable tools (e.g. Aladin). 12. ctexpcube - CTA exposure cube generation -------------------------------------------- -None +Add publish() method to publish the exposure cube via a SAMP Hub to +Virtual Observatory interoperable tools (e.g. Aladin). 13. ctpsfcube - CTA point spread function cube generation @@ -116,12 +121,14 @@ None 14. ctbkgcube - CTA background cube generation ---------------------------------------------- -None +Add publish() method to publish the background cube via a SAMP Hub to +Virtual Observatory interoperable tools (e.g. Aladin). 15. ctcubemask - CTA cube filtering ----------------------------------- -None +Add publish() method to publish the masked counts cube via a SAMP Hub +to Virtual Observatory interoperable tools (e.g. Aladin). 16. ctbutterfly - Generate butterfly diagrams @@ -136,7 +143,8 @@ None 18. cterror - Likelihood profile error computation -------------------------------------------------- -None +The output filename is now read ahead in case that the tool is executed +(#1700). 19. cscripts @@ -144,6 +152,9 @@ None Added the csiactcopy script that copies IACT data from a remote machine to the user's machine (#1661). +Add csresmap::publish() method to publish the residual map via a SAMP Hub +to Virtual Observatory interoperable tools (e.g. Aladin). + 20. Examples ------------ diff --git a/cscripts/csresmap.py b/cscripts/csresmap.py index f63cc93..4d3968e 100755 --- a/cscripts/csresmap.py +++ b/cscripts/csresmap.py @@ -36,18 +36,19 @@ class csresmap(ctools.cscript): """ Constructor. """ - # Set name self.name = "csresmap" - self.version = "1.0.0" + self.version = "1.1.0" # Initialise some members self.obs = None self.algorithm = "SUB" self.resmap = None self.m_modcube = "None" + self.m_outmap = "None" self.m_use_maps = False self.m_skip_binning = False + self.m_publish = False # Initialise some members if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations): @@ -126,6 +127,7 @@ class csresmap(ctools.cscript): pars.append(gammalib.GApplicationPar("nypix","i","a","200","","","Size of the Y axis in pixels")) pars.append(gammalib.GApplicationPar("binsz","r","a","0.02","","","Pixel size (deg/pixel)")) pars.append(gammalib.GApplicationPar("algorithm","s","a","SUBDIV","SUB|SUBDIV|SUBDIVSQRT","","Residual map computation algorithm")) + pars.append(gammalib.GApplicationPar("publish","b","h","no","","","Publish residual map on VO Hub?")) pars.append_standard() pars.append(gammalib.GApplicationPar("logfile","f","h","csresmap.log","","","Log filename")) pars.save(parfile) @@ -193,18 +195,22 @@ class csresmap(ctools.cscript): self.m_binsz = self["binsz"].real() # Read energy dispersion flag - self.m_edisp = self["edisp"].boolean() + self.m_edisp = self["edisp"].boolean() - # Read necessary parameters - self.m_outfile = self["outmap"].filename() + # Read algorithm self.m_algorithm = self["algorithm"].string() - # Set some fixed parameters + # Read standard parameters + self.m_publish = self["publish"].boolean() self.m_log = False # Logging in client tools self.m_chatter = self["chatter"].integer() self.m_clobber = self["clobber"].boolean() self.m_debug = self["debug"].boolean() + # Read ahead output parameters + if (self.read_ahead()): + self.m_outmap = self["outmap"].filename() + # Return return @@ -222,11 +228,64 @@ class csresmap(ctools.cscript): """ Execute the script. """ + # Read ahead output parameters + self.read_ahead(True) + # Run the script self.run() # Save residual map - self.resmap.save(self.m_outfile, self.m_clobber) + self.save() + + # Return + return + + def save(self): + """ + Save residual map. + """ + # Write header + if self.logTerse(): + self.log("\n") + self.log.header1("Save residual map") + + # Continue only filename and residual map are valid + if self.m_outmap != "None" and self.resmap != None: + + # Log file name + if self.logTerse(): + self.log("Save residual map into \""+self.m_outmap+"\".\n") + + # Save residual map + self.resmap.save(self.m_outmap, self.m_clobber) + + # Return + return + + def publish(self, name=""): + """ + Publish residual map. + """ + # Write header + if self.logTerse(): + self.log("\n") + self.log.header1("Publish sky map") + + # Continue only if residual map is valid + if self.resmap != None: + + # Set default name is user name is empty + if not name: + user_name = self.name + else: + user_name = name + + # Log map name + if self.logTerse(): + self.log("Publish residual map \""+user_name+"\".\n") + + # Publish map + self.resmap.publish(user_name) # Return return @@ -353,6 +412,10 @@ class csresmap(ctools.cscript): # Raise error if algorithm is unkown raise TypeError("Algorithm \""+self.m_algorithm+"\" not known") + # Optionally publish map + if self.m_publish: + self.publish() + # Return return diff --git a/doc/source/reference_manual/cscaldb.rst b/doc/source/reference_manual/cscaldb.rst index 625acf8..acb70de 100644 --- a/doc/source/reference_manual/cscaldb.rst +++ b/doc/source/reference_manual/cscaldb.rst @@ -36,7 +36,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csfindobs.rst b/doc/source/reference_manual/csfindobs.rst index 009940b..a3ba7a8 100644 --- a/doc/source/reference_manual/csfindobs.rst +++ b/doc/source/reference_manual/csfindobs.rst @@ -80,7 +80,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output runlist should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csiactcopy.rst b/doc/source/reference_manual/csiactcopy.rst index 182417b..6d0cf23 100644 --- a/doc/source/reference_manual/csiactcopy.rst +++ b/doc/source/reference_manual/csiactcopy.rst @@ -60,7 +60,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing output files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csiactdata.rst b/doc/source/reference_manual/csiactdata.rst index 116a29c..885281e 100644 --- a/doc/source/reference_manual/csiactdata.rst +++ b/doc/source/reference_manual/csiactdata.rst @@ -44,7 +44,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing output files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csiactobs.rst b/doc/source/reference_manual/csiactobs.rst index 571b408..900faf1 100644 --- a/doc/source/reference_manual/csiactobs.rst +++ b/doc/source/reference_manual/csiactobs.rst @@ -124,7 +124,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing output files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cslightcrv.rst b/doc/source/reference_manual/cslightcrv.rst index b870c77..cc2196d 100644 --- a/doc/source/reference_manual/cslightcrv.rst +++ b/doc/source/reference_manual/cslightcrv.rst @@ -131,7 +131,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing source spectrum output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csmodelinfo.rst b/doc/source/reference_manual/csmodelinfo.rst index 7baa7e9..2acce45 100644 --- a/doc/source/reference_manual/csmodelinfo.rst +++ b/doc/source/reference_manual/csmodelinfo.rst @@ -83,7 +83,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing output files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csmodelmerge.rst b/doc/source/reference_manual/csmodelmerge.rst index cb92c09..63398fb 100644 --- a/doc/source/reference_manual/csmodelmerge.rst +++ b/doc/source/reference_manual/csmodelmerge.rst @@ -49,7 +49,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output model file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csobs2caldb.rst b/doc/source/reference_manual/csobs2caldb.rst index d97e572..a169546 100644 --- a/doc/source/reference_manual/csobs2caldb.rst +++ b/doc/source/reference_manual/csobs2caldb.rst @@ -54,7 +54,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csobsdef.rst b/doc/source/reference_manual/csobsdef.rst index e2da151..7962157 100644 --- a/doc/source/reference_manual/csobsdef.rst +++ b/doc/source/reference_manual/csobsdef.rst @@ -97,7 +97,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing Observation Definition XML file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csobsinfo.rst b/doc/source/reference_manual/csobsinfo.rst index 6f47bd3..6d1ef78 100644 --- a/doc/source/reference_manual/csobsinfo.rst +++ b/doc/source/reference_manual/csobsinfo.rst @@ -70,7 +70,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cspull.rst b/doc/source/reference_manual/cspull.rst index c477682..8c45426 100644 --- a/doc/source/reference_manual/cspull.rst +++ b/doc/source/reference_manual/cspull.rst @@ -121,7 +121,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csresmap.rst b/doc/source/reference_manual/csresmap.rst index d4d0f0c..a6c6663 100644 --- a/doc/source/reference_manual/csresmap.rst +++ b/doc/source/reference_manual/csresmap.rst @@ -101,6 +101,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the residual map should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -114,7 +117,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing residual map file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cssens.rst b/doc/source/reference_manual/cssens.rst index f9aa459..bf22f90 100644 --- a/doc/source/reference_manual/cssens.rst +++ b/doc/source/reference_manual/cssens.rst @@ -120,7 +120,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/csspec.rst b/doc/source/reference_manual/csspec.rst index a4df063..4a8e55d 100644 --- a/doc/source/reference_manual/csspec.rst +++ b/doc/source/reference_manual/csspec.rst @@ -123,7 +123,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing source spectrum output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cstsdist.rst b/doc/source/reference_manual/cstsdist.rst index 0078a68..aa705dd 100644 --- a/doc/source/reference_manual/cstsdist.rst +++ b/doc/source/reference_manual/cstsdist.rst @@ -122,7 +122,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cstsmapmerge.rst b/doc/source/reference_manual/cstsmapmerge.rst index 3683a29..ddf620f 100644 --- a/doc/source/reference_manual/cstsmapmerge.rst +++ b/doc/source/reference_manual/cstsmapmerge.rst @@ -54,7 +54,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output TS map file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctbin.rst b/doc/source/reference_manual/ctbin.rst index 729654c..e0bb555 100644 --- a/doc/source/reference_manual/ctbin.rst +++ b/doc/source/reference_manual/ctbin.rst @@ -78,6 +78,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the counts cube should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -91,7 +94,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output counts cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctbkgcube.rst b/doc/source/reference_manual/ctbkgcube.rst index efac46d..fa97e02 100644 --- a/doc/source/reference_manual/ctbkgcube.rst +++ b/doc/source/reference_manual/ctbkgcube.rst @@ -111,6 +111,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the background cube should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -124,7 +127,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output background cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctbutterfly.rst b/doc/source/reference_manual/ctbutterfly.rst index a715705..cd8cbd2 100644 --- a/doc/source/reference_manual/ctbutterfly.rst +++ b/doc/source/reference_manual/ctbutterfly.rst @@ -111,7 +111,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctcubemask.rst b/doc/source/reference_manual/ctcubemask.rst index e7feb23..59fddd8 100644 --- a/doc/source/reference_manual/ctcubemask.rst +++ b/doc/source/reference_manual/ctcubemask.rst @@ -69,6 +69,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the counts cube should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -82,7 +85,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output counts cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cterror.rst b/doc/source/reference_manual/cterror.rst index 73a76c8..ac1d520 100644 --- a/doc/source/reference_manual/cterror.rst +++ b/doc/source/reference_manual/cterror.rst @@ -85,7 +85,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctexpcube.rst b/doc/source/reference_manual/ctexpcube.rst index b776c44..0cf1512 100644 --- a/doc/source/reference_manual/ctexpcube.rst +++ b/doc/source/reference_manual/ctexpcube.rst @@ -105,6 +105,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the exposure cube should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -118,7 +121,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output exposure cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctlike.rst b/doc/source/reference_manual/ctlike.rst index 94f9887..70dfc1f 100644 --- a/doc/source/reference_manual/ctlike.rst +++ b/doc/source/reference_manual/ctlike.rst @@ -111,7 +111,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output model file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctmodel.rst b/doc/source/reference_manual/ctmodel.rst index f71d373..7a356c1 100644 --- a/doc/source/reference_manual/ctmodel.rst +++ b/doc/source/reference_manual/ctmodel.rst @@ -138,6 +138,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the model cube should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -151,7 +154,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output model cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctobssim.rst b/doc/source/reference_manual/ctobssim.rst index f6caca0..2c021d2 100644 --- a/doc/source/reference_manual/ctobssim.rst +++ b/doc/source/reference_manual/ctobssim.rst @@ -119,7 +119,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctpsfcube.rst b/doc/source/reference_manual/ctpsfcube.rst index c3c5537..254a82d 100644 --- a/doc/source/reference_manual/ctpsfcube.rst +++ b/doc/source/reference_manual/ctpsfcube.rst @@ -122,7 +122,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output point spread function cube file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctselect.rst b/doc/source/reference_manual/ctselect.rst index ef61b61..7e281f1 100644 --- a/doc/source/reference_manual/ctselect.rst +++ b/doc/source/reference_manual/ctselect.rst @@ -108,7 +108,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether existing output files should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctskymap.rst b/doc/source/reference_manual/ctskymap.rst index 96a713f..e7abc02 100644 --- a/doc/source/reference_manual/ctskymap.rst +++ b/doc/source/reference_manual/ctskymap.rst @@ -60,6 +60,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the sky map should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -73,7 +76,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output sky map file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/cttsmap.rst b/doc/source/reference_manual/cttsmap.rst index b52e37b..aa26737 100644 --- a/doc/source/reference_manual/cttsmap.rst +++ b/doc/source/reference_manual/cttsmap.rst @@ -94,6 +94,9 @@ General parameters Standard parameters ------------------- +``(publish = no) [boolean]`` + Specifies whether the TS map should be published on VO Hub. + ``(chatter = 2) [integer]`` Verbosity of the executable: chatter = 0: no information will be logged @@ -107,7 +110,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output TS map file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/doc/source/reference_manual/ctulimit.rst b/doc/source/reference_manual/ctulimit.rst index 1964c39..4ef7f43 100644 --- a/doc/source/reference_manual/ctulimit.rst +++ b/doc/source/reference_manual/ctulimit.rst @@ -97,7 +97,7 @@ Standard parameters chatter = 4: detailed report about the task execution ``(clobber = yes) [boolean]`` - Specifies whether an existing output counts cube should be overwritten. + Specifies whether an existing output file should be overwritten. ``(debug = no) [boolean]`` Enables debug mode. In debug mode the executable will dump any log file output to the console. diff --git a/pyext/ctbin.i b/pyext/ctbin.i index 76b70fc..8fcea66 100644 --- a/pyext/ctbin.i +++ b/pyext/ctbin.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctbin - Event binning tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2014 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; GCTAEventCube cube(void) const; }; diff --git a/pyext/ctbkgcube.i b/pyext/ctbkgcube.i index 1e321da..ced3574 100644 --- a/pyext/ctbkgcube.i +++ b/pyext/ctbkgcube.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - Background cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GCTACubeBackground& bkgcube(void) const; const GModels& models(void) const; }; diff --git a/pyext/ctcubemask.i b/pyext/ctcubemask.i index caeab73..6877bea 100644 --- a/pyext/ctcubemask.i +++ b/pyext/ctcubemask.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - Cube filter tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 Chia-Chun Lu * + * copyright (C) 2014-2016 Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; }; diff --git a/pyext/ctexpcube.i b/pyext/ctexpcube.i index e1c7404..a672876 100644 --- a/pyext/ctexpcube.i +++ b/pyext/ctexpcube.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctexpcube - Exposure cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GCTACubeExposure& expcube(void) const; }; diff --git a/pyext/ctmodel.i b/pyext/ctmodel.i index 33d5f56..9a4e823 100644 --- a/pyext/ctmodel.i +++ b/pyext/ctmodel.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctmodel - Model cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; const GCTAEventCube& cube(void) const; void cube(const GCTAEventCube& cube); diff --git a/pyext/ctool.i b/pyext/ctool.i index 1fdee62..4e3d25b 100644 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -136,3 +136,14 @@ public: virtual void save(void); }; + +/***********************************************************************//** + * @brief ctool base class Python extension + ***************************************************************************/ +%extend ctool { + void read_ahead(const bool& flag) { + self->m_read_ahead = flag; + return; + } +} + diff --git a/pyext/ctskymap.i b/pyext/ctskymap.i index ad99ed6..8ad7396 100644 --- a/pyext/ctskymap.i +++ b/pyext/ctskymap.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - Sky mapping tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GSkyMap& map(void) const; }; diff --git a/pyext/cttsmap.i b/pyext/cttsmap.i index 99104e5..0954d2c 100644 --- a/pyext/cttsmap.i +++ b/pyext/cttsmap.i @@ -1,7 +1,7 @@ /*************************************************************************** * cttsmap - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -47,6 +47,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; const GSkyMap& tsmap(void) const; }; diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index ddffa12..b169956 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbin - Event binning tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -302,6 +302,11 @@ void ctbin::run(void) log << m_obs << std::endl; } + // Optionally publish counts cube + if (m_publish) { + publish(); + } + // Return return; } @@ -310,26 +315,21 @@ void ctbin::run(void) /***********************************************************************//** * @brief Save counts cube * - * This method saves the counts cube into a FITS file. + * Saves the counts cube into a FITS file. ***************************************************************************/ void ctbin::save(void) { // Write header if (logTerse()) { log << std::endl; - if (m_obs.size() > 1) { - log.header1("Save observations"); - } - else { - log.header1("Save observation"); - } + log.header1("Save counts cube"); } - // Get output filename + // Get counts cube filename m_outcube = (*this)["outcube"].filename(); // Save only if filename is non-empty - if (m_outcube.length() > 0) { + if (!m_outcube.is_empty()) { // Get CTA observation from observation container GCTAObservation* obs = dynamic_cast(m_obs[0]); @@ -337,9 +337,10 @@ void ctbin::save(void) // Save only if observation is valid if (obs != NULL) { - // Dump filename + // Log filename if (logTerse()) { - log << "Save \""+m_outcube+"\"" << std::endl; + log << "Save counts cube into file \""+m_outcube+"\"."; + log << std::endl; } // Save cube @@ -354,6 +355,38 @@ void ctbin::save(void) } +/***********************************************************************//** + * @brief Publish counts cube + * + * @param[in] name Counts cube name. + ***************************************************************************/ +void ctbin::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish counts cube"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTBIN_NAME; + } + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" counts cube." << std::endl; + } + + // Publish counts cube + m_cube.publish(user_name); + + // Return + return; +} + + /*========================================================================== = = = Private methods = @@ -367,7 +400,8 @@ void ctbin::init_members(void) { // Initialise members m_outcube.clear(); - m_usepnt = false; + m_usepnt = false; + m_publish = false; // Initialise protected members m_obs.clear(); @@ -392,6 +426,7 @@ void ctbin::copy_members(const ctbin& app) // Copy attributes m_outcube = app.m_outcube; m_usepnt = app.m_usepnt; + m_publish = app.m_publish; // Copy protected members m_obs = app.m_obs; @@ -452,6 +487,9 @@ void ctbin::get_parameters(void) // Get energy boundaries m_ebounds = cube.ebounds(); + // Get remaining parameters + m_publish = (*this)["publish"].boolean(); + // Optionally read ahead parameters so that they get correctly // dumped into the log file if (read_ahead()) { diff --git a/src/ctbin/ctbin.hpp b/src/ctbin/ctbin.hpp index f589eff..7c67aae 100644 --- a/src/ctbin/ctbin.hpp +++ b/src/ctbin/ctbin.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbin - Event binning tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTBIN_NAME "ctbin" -#define CTBIN_VERSION "1.0.0" +#define CTBIN_VERSION "1.1.0" /***********************************************************************//** @@ -78,6 +78,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; GCTAEventCube cube(void) const; @@ -91,8 +92,9 @@ protected: void obs_cube(void); // User parameters - std::string m_outcube; //!< Output counts map file + GFilename m_outcube; //!< Output counts map file name bool m_usepnt; //!< Use pointing instead of xref/yref parameters + bool m_publish; //!< Publish counts cube? // Protected members GObservations m_obs; //!< Observation container diff --git a/src/ctbin/ctbin.par b/src/ctbin/ctbin.par index 8cb60ab..8ce64dc 100644 --- a/src/ctbin/ctbin.par +++ b/src/ctbin/ctbin.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctbin.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Jurgen Knodlseder # # Jurgen.Knodlseder@irap.omp.eu # @@ -44,6 +44,7 @@ proj, s, a, "CAR",AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" # # Standard parameters #==================== +publish, b, h, no,,, "Publish counts cube on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/ctbkgcube/ctbkgcube.cpp b/src/ctbkgcube/ctbkgcube.cpp index 47535b0..ad98167 100644 --- a/src/ctbkgcube/ctbkgcube.cpp +++ b/src/ctbkgcube/ctbkgcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - Background cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -340,6 +340,11 @@ void ctbkgcube::run(void) // Recover original models m_obs.models(models_orig); + // Optionally publish background cube + if (m_publish) { + publish(); + } + // Return return; } @@ -348,7 +353,8 @@ void ctbkgcube::run(void) /***********************************************************************//** * @brief Save background cube * - * Save the background cube into the file specified by the outfile parameter. + * Save the background cube into a FITS file and the output model into an + * XML file. ***************************************************************************/ void ctbkgcube::save(void) { @@ -358,21 +364,71 @@ void ctbkgcube::save(void) log.header1("Save background cube"); } - // Get output filenames - std::string outfile = (*this)["outcube"].filename(); - std::string outmodel = (*this)["outmodel"].filename(); + // Get background cube and model file names + m_outcube = (*this)["outcube"].filename(); + m_outmodel = (*this)["outmodel"].filename(); + + // Save only if filename is non-empty + if (!m_outcube.is_empty()) { - // Save background cube - m_background.save(outfile, clobber()); + // Log filename + if (logTerse()) { + log << "Save background cube into file \""+m_outcube+"\"."; + log << std::endl; + } + + // Save background cube + m_background.save(m_outcube, clobber()); + + } // Write output models if filename is valid - if ((outmodel.length() > 0) && (gammalib::tolower(outmodel) != "none")) { + if ((!m_outmodel.is_empty()) && + (gammalib::tolower(m_outmodel.url()) != "none")) { + + // Log filename + if (logTerse()) { + log << "Save model into file \""+m_outmodel.url()+"\"."; + log << std::endl; + } + + // Save output model for stacked analyses + m_outmdl.save(m_outmodel.url()); + + } + + // Return + return; +} - // Save output model for binned analyses - m_outmdl.save(outmodel); +/***********************************************************************//** + * @brief Publish background cube + * + * @param[in] name Background cube name. + ***************************************************************************/ +void ctbkgcube::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish background cube"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTBKGCUBE_NAME; + } + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" background cube." << std::endl; } + // Publish exposure cube + m_background.cube().publish(user_name); + // Return return; } @@ -392,6 +448,7 @@ void ctbkgcube::init_members(void) // Initialise members m_outcube.clear(); m_outmodel.clear(); + m_publish = false; m_obs.clear(); m_background.clear(); m_bkgmdl.clear(); @@ -412,6 +469,7 @@ void ctbkgcube::copy_members(const ctbkgcube& app) // Copy members m_outmodel = app.m_outmodel; m_outcube = app.m_outcube; + m_publish = app.m_publish; m_obs = app.m_obs; m_background = app.m_background; m_bkgmdl = app.m_bkgmdl; @@ -499,6 +557,9 @@ void ctbkgcube::get_parameters(void) m_obs.models(models); } + // Get remaining parameters + m_publish = (*this)["publish"].boolean(); + // Read output filenames (if needed) if (read_ahead()) { m_outcube = (*this)["outcube"].filename(); diff --git a/src/ctbkgcube/ctbkgcube.hpp b/src/ctbkgcube/ctbkgcube.hpp index 86a5093..8de0f5b 100644 --- a/src/ctbkgcube/ctbkgcube.hpp +++ b/src/ctbkgcube/ctbkgcube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - Background cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTBKGCUBE_NAME "ctbkgcube" -#define CTBKGCUBE_VERSION "1.0.0" +#define CTBKGCUBE_VERSION "1.1.0" /***********************************************************************//** @@ -59,6 +59,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GCTACubeBackground& bkgcube(void) const; const GModels& models(void) const; @@ -70,11 +71,14 @@ protected: void get_parameters(void); void fill_cube(GCTAObservation* obs); + // User parameters + GFilename m_outcube; //!< Filename of output cube + GFilename m_outmodel; //!< Filename of output XML model + bool m_publish; //!< Publish background cube? + // Protected members - std::string m_outcube; //!< Filename of output cube - std::string m_outmodel; //!< Filename of output XML model GObservations m_obs; //!< Observation container - GCTACubeBackground m_background; //!< Background cube response + GCTACubeBackground m_background; //!< Background cube GModels m_bkgmdl; //!< CTA background models GModels m_outmdl; //!< Output models }; diff --git a/src/ctbkgcube/ctbkgcube.par b/src/ctbkgcube/ctbkgcube.par index da61602..0de9d88 100644 --- a/src/ctbkgcube/ctbkgcube.par +++ b/src/ctbkgcube/ctbkgcube.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctbkgcube.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Chia-Chun Lu # # c.lu@mpi-hd.mpg.de # @@ -49,6 +49,7 @@ proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" # # Standard parameters #==================== +publish, b, h, no,,, "Publish sky map on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/ctbutterfly/ctbutterfly.cpp b/src/ctbutterfly/ctbutterfly.cpp index b63d8c8..deb2a21 100644 --- a/src/ctbutterfly/ctbutterfly.cpp +++ b/src/ctbutterfly/ctbutterfly.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbutterfly - butterfly calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -501,25 +501,36 @@ void ctbutterfly::save(void) // Write header if (logTerse()) { log << std::endl; - log.header1("Save Butterfly to file"); + log.header1("Save Butterfly diagram"); } // Get output filename m_outfile = (*this)["outfile"].filename(); - // Create CSV table with 4 columns - GCsv table(m_energies.size(), 4); + // Save only if filename is non-empty + if (!m_outfile.is_empty()) { - // Fill CSV table - for (int i = 0; i < m_energies.size(); ++i) { - table.real(i, 0, m_energies[i]); - table.real(i, 1, m_intensities[i]); - table.real(i, 2, m_min_intensities[i]); - table.real(i, 3, m_max_intensities[i]); - } + // Log filename + if (logTerse()) { + log << "Save butterfly diagram into file \""+m_outfile+"\"."; + log << std::endl; + } + + // Create CSV table with 4 columns + GCsv table(m_energies.size(), 4); - // Save CSV table - table.save(m_outfile, " ", clobber()); + // Fill CSV table + for (int i = 0; i < m_energies.size(); ++i) { + table.real(i, 0, m_energies[i]); + table.real(i, 1, m_intensities[i]); + table.real(i, 2, m_min_intensities[i]); + table.real(i, 3, m_max_intensities[i]); + } + + // Save CSV table + table.save(m_outfile, " ", clobber()); + + } // Return return; diff --git a/src/ctbutterfly/ctbutterfly.hpp b/src/ctbutterfly/ctbutterfly.hpp index 0002f7f..a7e79c6 100644 --- a/src/ctbutterfly/ctbutterfly.hpp +++ b/src/ctbutterfly/ctbutterfly.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbutterfly - butterfly calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTBUTTERFLY_NAME "ctbutterfly" -#define CTBUTTERFLY_VERSION "1.0.0" +#define CTBUTTERFLY_VERSION "1.1.0" /***********************************************************************//** @@ -95,7 +95,7 @@ protected: bool m_apply_edisp; //!< Apply energy dispersion? bool m_fit; //!< Do fit? GEbounds m_ebounds; //!< Energy binning definition - std::string m_outfile; //!< Output ascii file + GFilename m_outfile; //!< Output ASCII file name // Protected members GOptimizerLM m_opt; //!< Optimizer @@ -107,6 +107,7 @@ protected: std::vector m_max_intensities; //!< Maximum intensities }; + /***********************************************************************//** * @brief Return observation container * diff --git a/src/ctcubemask/ctcubemask.cpp b/src/ctcubemask/ctcubemask.cpp index 19216a3..d390546 100644 --- a/src/ctcubemask/ctcubemask.cpp +++ b/src/ctcubemask/ctcubemask.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - Cube filter tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -282,6 +282,11 @@ void ctcubemask::run(void) log << m_obs << std::endl; } + // Optionally publish counts cube + if (m_publish) { + publish(); + } + // Return return; } @@ -312,15 +317,23 @@ void ctcubemask::save(void) if (logTerse()) { log << std::endl; if (m_obs.size() > 1) { - log.header1("Save observations"); + log.header1("Save counts cubes"); } else { - log.header1("Save observation"); + log.header1("Save counts cube"); } } + // Get counts cube filename + m_outcube = (*this)["outcube"].filename(); + // Case A: Save event file(s) and XML metadata information if (m_use_xml) { + + // Get prefix + m_prefix = (*this)["prefix"].string(); + + // Save XML save_xml(); } @@ -335,6 +348,52 @@ void ctcubemask::save(void) /***********************************************************************//** + * @brief Publish counts cube + * + * @param[in] name Counts cube name. + * + * Publishes the first counts cube in the observation container on the VO + * Hub. + ***************************************************************************/ +void ctcubemask::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish counts cube"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTCUBEMASK_NAME; + } + + // Get first CTA observation from observation container + GCTAObservation* obs = dynamic_cast(m_obs[0]); + if (obs != NULL) { + + // Get counts cube + GCTAEventCube* cube = dynamic_cast(obs->events()); + if (cube != NULL) { + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" counts cube." << std::endl; + } + + // Publish counts cube + cube->map().publish(user_name); + + } + } + + // Return + return; +} + + +/***********************************************************************//** * @brief Get application parameters * * @exception GException::invalid_value @@ -402,10 +461,14 @@ void ctcubemask::get_parameters(void) m_select_energy = false; } + // Get remaining parameters + m_publish = (*this)["publish"].boolean(); + // Optionally read ahead parameters so that they get correctly // dumped into the log file if (read_ahead()) { m_outcube = (*this)["outcube"].filename(); + m_prefix = (*this)["prefix"].string(); } // Return @@ -586,12 +649,13 @@ void ctcubemask::init_members(void) m_regfile.clear(); m_outcube.clear(); m_prefix.clear(); - m_usepnt = false; - m_ra = 0.0; - m_dec = 0.0; - m_rad = 0.0; - m_emin = 0.0; - m_emax = 0.0; + m_usepnt = false; + m_ra = 0.0; + m_dec = 0.0; + m_rad = 0.0; + m_emin = 0.0; + m_emax = 0.0; + m_publish = false; // Initialise protected members m_obs.clear(); @@ -621,6 +685,7 @@ void ctcubemask::copy_members(const ctcubemask& app) m_rad = app.m_rad; m_emin = app.m_emin; m_emax = app.m_emax; + m_publish = app.m_publish; // Copy protected members m_obs = app.m_obs; @@ -698,21 +763,29 @@ std::string ctcubemask::set_outfile_name(const std::string& filename) const /***********************************************************************//** - * @brief Save counts map in FITS format. + * @brief Save counts cube in FITS format. * - * Save the counts map as a FITS file. The filename of the FITS file is + * Save the counts cube as a FITS file. The filename of the FITS file is * specified by the m_outfile member. ***************************************************************************/ void ctcubemask::save_fits(void) { - // Get output filename - m_outcube = (*this)["outcube"].filename(); + // Save only if filename is non-empty + if (!m_outcube.is_empty()) { + + // Get CTA observation from observation container + GCTAObservation* obs = dynamic_cast(m_obs[0]); - // Get CTA observation from observation container - GCTAObservation* obs = dynamic_cast(m_obs[0]); + // Log filename + if (logTerse()) { + log << "Save counts cube into file \""+m_outcube+"\"."; + log << std::endl; + } - // Save event list - save_counts_map(obs, m_outcube); + // Save event list + save_counts_map(obs, m_outcube); + + } // Return return; @@ -732,12 +805,8 @@ void ctcubemask::save_fits(void) ***************************************************************************/ void ctcubemask::save_xml(void) { - // Get output filename and prefix - m_outcube = (*this)["m_outcube"].filename(); - m_prefix = (*this)["prefix"].string(); - // Issue warning if output filename has no .xml suffix - std::string suffix = gammalib::tolower(m_outcube.substr(m_outcube.length()-4,4)); + std::string suffix = gammalib::tolower(m_outcube.url().substr(m_outcube.length()-4,4)); if (suffix != ".xml") { log << "*** WARNING: Name of observation definition output file \""+ m_outcube+"\"" << std::endl; @@ -763,6 +832,12 @@ void ctcubemask::save_xml(void) // Store output file name in observation obs->eventfile(outfile); + // Log filename + if (logTerse()) { + log << "Save counts cube into file \""+outfile+"\"."; + log << std::endl; + } + // Save event list save_counts_map(obs, outfile); diff --git a/src/ctcubemask/ctcubemask.hpp b/src/ctcubemask/ctcubemask.hpp index d967532..4011766 100644 --- a/src/ctcubemask/ctcubemask.hpp +++ b/src/ctcubemask/ctcubemask.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - Cube filter tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -36,7 +36,7 @@ /* __Definitions _________________________________________________________ */ #define CTCUBEMASK_NAME "ctcubemask" -#define CTCUBEMASK_VERSION "1.0.0" +#define CTCUBEMASK_VERSION "1.1.0" /***********************************************************************//** @@ -61,6 +61,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; protected: @@ -78,9 +79,8 @@ protected: const std::string& outfile) const; // User parameters - //std::string m_infile; //!< Input event list or XML file - std::string m_regfile; //!< ds9 region file - std::string m_outcube; //!< Output event list or XML file + GFilename m_regfile; //!< ds9 region file + GFilename m_outcube; //!< Output event list or XML file std::string m_prefix; //!< Prefix for multiple counts maps bool m_usepnt; //!< Use pointing instead of RA/DEC parameters double m_ra; //!< RA of ROI centre @@ -88,6 +88,7 @@ protected: double m_rad; //!< ROI radius double m_emin; //!< Lower energy double m_emax; //!< Upper energy + bool m_publish; //!< Publish counts cube? // Protected members GObservations m_obs; //!< Observations container diff --git a/src/ctcubemask/ctcubemask.par b/src/ctcubemask/ctcubemask.par index 56669df..bfc48c9 100644 --- a/src/ctcubemask/ctcubemask.par +++ b/src/ctcubemask/ctcubemask.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctcubemask.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Chia-Chun Lu # # c.lu@mpi-hd.mpg.de # @@ -17,7 +17,7 @@ # # General parameters #=================== -inobs, f, a, "cntmap.fits",,, "Input counts cube or observation definition XML file" +inobs, f, a, "cntcube.fits",,, "Input counts cube or observation definition XML file" outcube, f, a, "filtered_cube.fits",,, "Output counts cube or observation definition XML file" prefix, s, h, "filtered_",,, "Prefix for counts cube in observation definition XML file" @@ -35,7 +35,9 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)" # # Standard parameters #==================== +publish, b, h, no,,, "Publish counts cube on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" mode, s, h, "ql",,, "Mode of automatic parameters" +logfile, f, h, "ctcubemask.par.log",,, "Log filename" diff --git a/src/cterror/cterror.cpp b/src/cterror/cterror.cpp index 15f0e6d..510a2a1 100644 --- a/src/cterror/cterror.cpp +++ b/src/cterror/cterror.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cterror - Parameter error calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Florent Forest * + * copyright (C) 2015-2016 by Florent Forest * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -51,6 +51,8 @@ /***********************************************************************//** * @brief Void constructor + * + * Constructs an empty cterror tool. ***************************************************************************/ cterror::cterror(void) : ctool(CTERROR_NAME, CTERROR_VERSION) { @@ -67,8 +69,8 @@ cterror::cterror(void) : ctool(CTERROR_NAME, CTERROR_VERSION) * * param[in] obs Observation container. * - * This method creates an instance of the class by copying an existing - * observations container. + * Constructs an instance of the cterror tool that will operate on the + * provided observation container. ***************************************************************************/ cterror::cterror(const GObservations& obs) : ctool(CTERROR_NAME, CTERROR_VERSION) @@ -90,6 +92,9 @@ cterror::cterror(const GObservations& obs) : * * @param[in] argc Number of arguments in command line. * @param[in] argv Array of command line arguments. + * + * Constructs an instance of the cterror tool that will parse user + * parameters that are provided as command line arguments. ***************************************************************************/ cterror::cterror(int argc, char *argv[]) : ctool(CTERROR_NAME, CTERROR_VERSION, argc, argv) @@ -106,6 +111,9 @@ cterror::cterror(int argc, char *argv[]) : * @brief Copy constructor * * @param[in] app Application. + * + * Constructs an instance of the cterror tool by copying information from + * another ctulimit tool. ***************************************************************************/ cterror::cterror(const cterror& app) : ctool(app) { @@ -122,6 +130,8 @@ cterror::cterror(const cterror& app) : ctool(app) /***********************************************************************//** * @brief Destructor + * + * Destructs the cterror tool. ***************************************************************************/ cterror::~cterror(void) { @@ -144,6 +154,8 @@ cterror::~cterror(void) * * @param[in] app Application. * @return Application. + * + * Assigns a cterror tool. ***************************************************************************/ cterror& cterror::operator=(const cterror& app) { @@ -177,6 +189,8 @@ cterror& cterror::operator=(const cterror& app) /***********************************************************************//** * @brief Clear instance + * + * Resets the cterror tool to a clean initial state. ***************************************************************************/ void cterror::clear(void) { @@ -196,7 +210,9 @@ void cterror::clear(void) /***********************************************************************//** - * @brief Computes + * @brief Compute parameter errors using a likelihood profile method + * + * Computes the parameter errors using a likelihood profile method. ***************************************************************************/ void cterror::run(void) { @@ -381,9 +397,9 @@ void cterror::run(void) /***********************************************************************//** - * @brief Save source model + * @brief Save model * - * This method saves the soutce model to an XML file. + * Saves the model into an XML file. ***************************************************************************/ void cterror::save(void) { @@ -394,11 +410,21 @@ void cterror::save(void) } // Get output filename - std::string outmodel = (*this)["outmodel"].filename(); + m_outmodel = (*this)["outmodel"].filename(); + + // Save only if filename is non-empty + if (!m_outmodel.is_empty() && + gammalib::toupper(m_outmodel.url()) != "NONE") { + + // Log filename + if (logTerse()) { + log << "Save errors into file \""+m_outmodel+"\"."; + log << std::endl; + } + + // Write results out as XML model + m_obs.models().save(m_outmodel); - // Write results out as XML model - if (gammalib::toupper(outmodel) != "NONE") { - m_obs.models().save(outmodel); } // Return @@ -419,6 +445,7 @@ void cterror::init_members(void) { // Initialise user parameters m_srcname.clear(); + m_outmodel.clear(); m_confidence = 0.68; m_tol = 1.0e-3; m_max_iter = 50; @@ -427,9 +454,9 @@ void cterror::init_members(void) // Initialise protected members m_obs.clear(); m_opt.clear(); - m_dlogL = 0.0; - m_best_logL = 0.0; - m_model_par = NULL; + m_dlogL = 0.0; + m_best_logL = 0.0; + m_model_par = NULL; m_apply_edisp = false; // Set optimizer parameters @@ -449,10 +476,11 @@ void cterror::init_members(void) void cterror::copy_members(const cterror& app) { // Copy user parameters - m_srcname = app.m_srcname; - m_confidence = app.m_confidence; - m_tol = app.m_tol; - m_max_iter = app.m_max_iter; + m_srcname = app.m_srcname; + m_outmodel = app.m_outmodel; + m_confidence = app.m_confidence; + m_tol = app.m_tol; + m_max_iter = app.m_max_iter; m_apply_edisp = app.m_apply_edisp; // Copy protected members @@ -534,18 +562,24 @@ void cterror::get_parameters(void) m_tol = (*this)["tol"].real(); m_max_iter = (*this)["max_iter"].integer(); + // Read ahead parameters that are only needed when the tool gets + // executed + if (read_ahead()) { + m_outmodel = (*this)["outmodel"].filename(); + } + // Return return; } /***********************************************************************//** - * @brief Performs error computation by using a bisection method + * @brief Calculate error using a bisection method * * @param[in] min Minimum parameter value * @param[in] max Maximum parameter value * - * This method calculates the error using a bisection method. + * Calculates the error using a bisection method. ***************************************************************************/ double cterror::error_bisection(const double& min, const double& max) { @@ -667,8 +701,7 @@ double cterror::error_bisection(const double& min, const double& max) * @param[in] value Parameter factor value * @return Log-likelihood value * - * This method evaluates the log-likelihood as a function of the parameter - * of interest. + * Evaluates the log-likelihood as a function of the parameter of interest. ***************************************************************************/ double cterror::evaluate(const double& value) { diff --git a/src/cterror/cterror.hpp b/src/cterror/cterror.hpp index fbdb669..8db9fa4 100644 --- a/src/cterror/cterror.hpp +++ b/src/cterror/cterror.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * cterror - Parameter error calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Florent Forest * + * copyright (C) 2015-2016 by Florent Forest * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -28,20 +28,20 @@ #define CTERROR_HPP /* __ Includes ___________________________________________________________ */ +#include #include "GammaLib.hpp" #include "GCTALib.hpp" #include "ctool.hpp" /* __Definitions _________________________________________________________ */ #define CTERROR_NAME "cterror" -#define CTERROR_VERSION "01-00-00" +#define CTERROR_VERSION "1.1.0" /***********************************************************************//** * @class cterror * * @brief Parameter error calculation tool - * ***************************************************************************/ class cterror : public ctool { @@ -74,6 +74,7 @@ protected: // User parameters std::string m_srcname; //!< Name of source + GFilename m_outmodel; //!< Output model XML file double m_confidence; //!< Confidence level double m_tol; //!< Tolerance for limit determination int m_max_iter; //!< Maximum number of iterations diff --git a/src/ctexpcube/ctexpcube.cpp b/src/ctexpcube/ctexpcube.cpp index 21bab79..b0e987f 100644 --- a/src/ctexpcube/ctexpcube.cpp +++ b/src/ctexpcube/ctexpcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctexpcube - Exposure cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -258,6 +258,11 @@ void ctexpcube::run(void) } } + // Optionally publish exposure cube + if (m_publish) { + publish(); + } + // Return return; } @@ -265,6 +270,8 @@ void ctexpcube::run(void) /***********************************************************************//** * @brief Save exposure cube + * + * Saves the exposure cube into a FITS file. ***************************************************************************/ void ctexpcube::save(void) { @@ -274,11 +281,54 @@ void ctexpcube::save(void) log.header1("Save exposure cube"); } - // Get output filename + // Get exposure cube filename m_outcube = (*this)["outcube"].filename(); - // Save exposure cube - m_expcube.save(m_outcube, clobber()); + // Save only if filename is non-empty + if (!m_outcube.is_empty()) { + + // Log filename + if (logTerse()) { + log << "Save exposure cube into file \""+m_outcube+"\"."; + log << std::endl; + } + + // Save exposure cube + m_expcube.save(m_outcube, clobber()); + + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Publish exposure cube + * + * @param[in] name Exposure cube name. + ***************************************************************************/ +void ctexpcube::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish exposure cube"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTEXPCUBE_NAME; + } + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" exposure cube." << std::endl; + } + + // Publish exposure cube + m_expcube.cube().publish(user_name); // Return return; @@ -299,6 +349,7 @@ void ctexpcube::init_members(void) // Initialise members m_outcube.clear(); m_apply_edisp = false; + m_publish = false; // Initialise protected members m_obs.clear(); @@ -319,6 +370,7 @@ void ctexpcube::copy_members(const ctexpcube& app) // Copy attributes m_outcube = app.m_outcube; m_apply_edisp = app.m_apply_edisp; + m_publish = app.m_publish; // Copy protected members m_obs = app.m_obs; @@ -390,6 +442,9 @@ void ctexpcube::get_parameters(void) } // endelse: cube loaded from file + // Get remaining parameters + m_publish = (*this)["publish"].boolean(); + // Read output filename (if needed) if (read_ahead()) { m_outcube = (*this)["outcube"].filename(); diff --git a/src/ctexpcube/ctexpcube.hpp b/src/ctexpcube/ctexpcube.hpp index 8a6cfda..e0d78f0 100644 --- a/src/ctexpcube/ctexpcube.hpp +++ b/src/ctexpcube/ctexpcube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctexpcube - Exposure cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTEXPCUBE_NAME "ctexpcube" -#define CTEXPCUBE_VERSION "1.0.0" +#define CTEXPCUBE_VERSION "1.1.0" /***********************************************************************//** @@ -59,6 +59,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GCTACubeExposure& expcube(void) const; protected: @@ -69,8 +70,9 @@ protected: void get_parameters(void); // User parameters - std::string m_outcube; //!< Output exposure cube file - bool m_apply_edisp; //!< Apply energy dispersion? + GFilename m_outcube; //!< Output exposure cube file + bool m_apply_edisp; //!< Apply energy dispersion? + bool m_publish; //!< Publish exposure cube? // Protected members GObservations m_obs; //!< Observation container diff --git a/src/ctexpcube/ctexpcube.par b/src/ctexpcube/ctexpcube.par index f0ea8bf..987a956 100644 --- a/src/ctexpcube/ctexpcube.par +++ b/src/ctexpcube/ctexpcube.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctexpcube.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Juergen Knoedlseder # # Jurgen.Knodlseder@irap.omp.eu # @@ -48,6 +48,7 @@ proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" # # Standard parameters #==================== +publish, b, h, no,,, "Publish sky map on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/ctlike/ctlike.cpp b/src/ctlike/ctlike.cpp index 43ee690..add2241 100644 --- a/src/ctlike/ctlike.cpp +++ b/src/ctlike/ctlike.cpp @@ -353,9 +353,19 @@ void ctlike::save(void) // Get output filename m_outmodel = (*this)["outmodel"].filename(); - // Write results out as XML model - if (gammalib::toupper(m_outmodel) != "NONE") { + // Save only if filename is non-empty + if (!m_outmodel.is_empty() && + gammalib::toupper(m_outmodel.url()) != "NONE") { + + // Log filename + if (logTerse()) { + log << "Save fitted parameters into file \""+m_outmodel+"\"."; + log << std::endl; + } + + // Write results out as XML model m_obs.models().save(m_outmodel); + } // Return diff --git a/src/ctlike/ctlike.hpp b/src/ctlike/ctlike.hpp index ae3a846..7cd094e 100644 --- a/src/ctlike/ctlike.hpp +++ b/src/ctlike/ctlike.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctlike - Maximum likelihood fitting tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -35,7 +35,7 @@ /* __Definitions _________________________________________________________ */ #define CTLIKE_NAME "ctlike" -#define CTLIKE_VERSION "1.0.0" +#define CTLIKE_VERSION "1.1.0" /***********************************************************************//** @@ -74,7 +74,7 @@ protected: // User parameters bool m_refit; //!< Refitting - std::string m_outmodel; //!< Source model output XML file + GFilename m_outmodel; //!< Source model output XML file name bool m_apply_edisp; //!< Apply energy dispersion? bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index e7280ea..45a7445 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -324,6 +324,11 @@ void ctmodel::run(void) } } + // Optionally publish model cube + if (m_publish) { + publish(); + } + // Return return; } @@ -343,15 +348,16 @@ void ctmodel::save(void) log.header1("Save cube"); } - // Make sure we have the FITS filename + // Get model cube filename m_outcube = (*this)["outcube"].filename(); // Save only if filename is non-empty - if (m_outcube.length() > 0) { + if (!m_outcube.is_empty()) { - // Dump filename + // Log filename if (logTerse()) { - log << "Save \""+m_outcube+"\"" << std::endl; + log << "Save model cube into file \""+m_outcube+"\"."; + log << std::endl; } // Save model cube into FITS file @@ -365,6 +371,38 @@ void ctmodel::save(void) /***********************************************************************//** + * @brief Publish model cube + * + * @param[in] name Model cube name. + ***************************************************************************/ +void ctmodel::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish model cube"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTMODEL_NAME; + } + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" model cube." << std::endl; + } + + // Publish model cube + m_cube.map().publish(user_name); + + // Return + return; +} + + +/***********************************************************************//** * @brief Set model cube * * @param[in] cube Model cube. @@ -403,6 +441,7 @@ void ctmodel::init_members(void) // Initialise members m_outcube.clear(); m_apply_edisp = false; + m_publish = false; // Initialise protected members m_obs.clear(); @@ -427,6 +466,7 @@ void ctmodel::copy_members(const ctmodel& app) // Copy attributes m_outcube = app.m_outcube; m_apply_edisp = app.m_apply_edisp; + m_publish = app.m_publish; // Copy protected members m_obs = app.m_obs; @@ -550,6 +590,9 @@ void ctmodel::get_parameters(void) } // endif: we had no cube yet + // Get remaining parameters + m_publish = (*this)["publish"].boolean(); + // Read optionally output cube filenames if (read_ahead()) { m_outcube = (*this)["outcube"].filename(); diff --git a/src/ctmodel/ctmodel.hpp b/src/ctmodel/ctmodel.hpp index 17bdd5d..5fd44c5 100644 --- a/src/ctmodel/ctmodel.hpp +++ b/src/ctmodel/ctmodel.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctmodel - Model cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTMODEL_NAME "ctmodel" -#define CTMODEL_VERSION "1.0.1" +#define CTMODEL_VERSION "1.1.0" /***********************************************************************//** @@ -68,6 +68,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; const GCTAEventCube& cube(void) const; void cube(const GCTAEventCube& cube); @@ -84,8 +85,9 @@ protected: bool has_cube(void) const; // User parameters - std::string m_outcube; //!< Output model cube - bool m_apply_edisp; //!< Apply energy dispersion? + GFilename m_outcube; //!< Output model cube + bool m_apply_edisp; //!< Apply energy dispersion? + bool m_publish; //!< Publish model cube? // Protected members GObservations m_obs; //!< Observation container diff --git a/src/ctmodel/ctmodel.par b/src/ctmodel/ctmodel.par index 39ae83b..acfdb69 100644 --- a/src/ctmodel/ctmodel.par +++ b/src/ctmodel/ctmodel.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctmodel.par # -# Version: 1.0.1 # +# Version: 1.1.0 # # # # Author: Juergen Knoedlseder # # Jurgen.Knodlseder@irap.omp.eu # @@ -62,6 +62,7 @@ proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" # # Standard parameters #==================== +publish, b, h, no,,, "Publish model cube on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index 6a68812..8893fe8 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -1454,6 +1454,12 @@ void ctobssim::save_fits(void) // Get CTA observation from observation container GCTAObservation* obs = dynamic_cast(m_obs[0]); + // Log filename + if (logTerse()) { + log << "Save event list into file \""+m_outevents+"\"."; + log << std::endl; + } + // Save observation into FITS file obs->save(m_outevents, clobber()); @@ -1513,6 +1519,12 @@ void ctobssim::save_xml(void) // Store output file name in observation obs->eventfile(outfile); + // Log filename + if (logTerse()) { + log << "Save event list into file \""+outfile+"\"."; + log << std::endl; + } + // Save observation into FITS file obs->save(outfile, clobber()); diff --git a/src/ctpsfcube/ctpsfcube.cpp b/src/ctpsfcube/ctpsfcube.cpp index 31b9b56..7684358 100644 --- a/src/ctpsfcube/ctpsfcube.cpp +++ b/src/ctpsfcube/ctpsfcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctpsfcube - PSF cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -276,8 +276,19 @@ void ctpsfcube::save(void) // Get output filename m_outcube = (*this)["outcube"].filename(); - // Save PSF cube - m_psfcube.save(m_outcube, clobber()); + // Save only if filename is non-empty + if (!m_outcube.is_empty()) { + + // Log filename + if (logTerse()) { + log << "Save PSF cube into file \""+m_outcube+"\"."; + log << std::endl; + } + + // Save PSF cube + m_psfcube.save(m_outcube, clobber()); + + } // Return return; diff --git a/src/ctpsfcube/ctpsfcube.hpp b/src/ctpsfcube/ctpsfcube.hpp index d17f006..55d9e49 100644 --- a/src/ctpsfcube/ctpsfcube.hpp +++ b/src/ctpsfcube/ctpsfcube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctpsfcube - PSF cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTPSFCUBE_NAME "ctpsfcube" -#define CTPSFCUBE_VERSION "1.0.0" +#define CTPSFCUBE_VERSION "1.1.0" /***********************************************************************//** @@ -69,7 +69,7 @@ protected: void get_parameters(void); // User parameters - std::string m_outcube; //!< Output PSF cube file + GFilename m_outcube; //!< Output PSF cube file name bool m_apply_edisp; //!< Apply energy dispersion? // Protected members diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index d73c24c..cc5d5a9 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -413,10 +413,10 @@ void ctselect::save(void) if (logTerse()) { log << std::endl; if (m_obs.size() > 1) { - log.header1("Save observations"); + log.header1("Save event lists"); } else { - log.header1("Save observation"); + log.header1("Save event list"); } } @@ -1267,7 +1267,8 @@ void ctselect::save_fits(void) // Log filename if (logTerse()) { - log << "Save \""+outfile+"\"" << std::endl; + log << "Save event list into file \""+outfile+"\"."; + log << std::endl; } // Save event list @@ -1335,7 +1336,8 @@ void ctselect::save_xml(void) // Log filename if (logTerse()) { - log << "Save \""+outfile+"\"" << std::endl; + log << "Save event list into file \""+outfile+"\"."; + log << std::endl; } // Store output file name in observation diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index 2fce299..65a5c60 100644 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - Sky mapping tool * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2015 by Juergen Knoedlseder * + * copyright (C) 2011-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -290,15 +290,21 @@ void ctskymap::run(void) } // endfor: looped over observations + // Optionally publish sky map + if (m_publish) { + publish(); + } + // Return return; } /***********************************************************************//** - * @brief Save observation + * @brief Save sky map * - * This method saves the counts map(s) into (a) FITS file(s). + * Saves the sky map into a FITS file. The FITS file name is specified by the + * @p outname parameter. ***************************************************************************/ void ctskymap::save(void) { @@ -308,15 +314,15 @@ void ctskymap::save(void) log.header1("Save sky map"); } - // Get output filename - m_outmap = (*this)["outmap"].filename(); + // Get sky map filename + m_outmap = (*this)["outmap"].filename(); // Save only if filename is non-empty - if (m_outmap.length() > 0) { + if (!m_outmap.is_empty()) { - // Dump filename + // Log filename if (logTerse()) { - log << "Save \""+m_outmap+"\"" << std::endl; + log << "Save sky map into file \""+m_outmap+"\"." << std::endl; } // Save sky map @@ -330,6 +336,38 @@ void ctskymap::save(void) /***********************************************************************//** + * @brief Publish sky map + * + * @param[in] name Sky map name. + ***************************************************************************/ +void ctskymap::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish sky map"); + } + + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTSKYMAP_NAME; + } + + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" sky map." << std::endl; + } + + // Publish sky map + m_skymap.publish(user_name); + + // Return + return; +} + + +/***********************************************************************//** * @brief Get application parameters * * Get all task parameters from parameter file or (if required) by querying @@ -359,12 +397,13 @@ void ctskymap::get_parameters(void) m_skymap = create_map(m_obs); // Get remaining parameters - m_emin = (*this)["emin"].real(); - m_emax = (*this)["emax"].real(); + m_emin = (*this)["emin"].real(); + m_emax = (*this)["emax"].real(); + m_publish = (*this)["publish"].boolean(); // Read ahead parameters if (read_ahead()) { - m_outmap = (*this)["outmap"].filename(); + m_outmap = (*this)["outmap"].filename(); } // Return @@ -478,8 +517,9 @@ void ctskymap::init_members(void) // Initialise members m_obs.clear(); m_skymap.clear(); - m_emin = 0.0; - m_emax = 0.0; + m_emin = 0.0; + m_emax = 0.0; + m_publish = false; // Return return; @@ -494,10 +534,11 @@ void ctskymap::init_members(void) void ctskymap::copy_members(const ctskymap& app) { // Copy attributes - m_obs = app.m_obs; - m_skymap = app.m_skymap; - m_emin = app.m_emin; - m_emax = app.m_emax; + m_obs = app.m_obs; + m_skymap = app.m_skymap; + m_emin = app.m_emin; + m_emax = app.m_emax; + m_publish = app.m_publish; // Return return; diff --git a/src/ctskymap/ctskymap.hpp b/src/ctskymap/ctskymap.hpp index 0b7ccd3..5f6498b 100644 --- a/src/ctskymap/ctskymap.hpp +++ b/src/ctskymap/ctskymap.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - Sky mapping tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTSKYMAP_NAME "ctskymap" -#define CTSKYMAP_VERSION "1.0.0" +#define CTSKYMAP_VERSION "1.1.0" /***********************************************************************//** @@ -61,6 +61,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GSkyMap& map(void) const; protected: @@ -72,10 +73,10 @@ protected: void map_events(GCTAObservation* obs); // User parameters - std::string m_outmap; //!< Output counts map + GFilename m_outmap; //!< Output file name double m_emin; //!< Minimum energy (TeV) double m_emax; //!< Maximum energy (TeV) - + bool m_publish; //!< Publish sky map? // Protected members GObservations m_obs; //!< Observation container diff --git a/src/ctskymap/ctskymap.par b/src/ctskymap/ctskymap.par index 0ba7fad..1604c3d 100644 --- a/src/ctskymap/ctskymap.par +++ b/src/ctskymap/ctskymap.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctskymap.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Jurgen Knodlseder # # knodlseder@cesr.fr # @@ -41,6 +41,7 @@ proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" # # Standard parameters #==================== +publish, b, h, no,,, "Publish sky map on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/cttsmap/cttsmap.cpp b/src/cttsmap/cttsmap.cpp index 460ec20..cca8a2a 100644 --- a/src/cttsmap/cttsmap.cpp +++ b/src/cttsmap/cttsmap.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cttsmap - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -368,6 +368,11 @@ void cttsmap::run(void) } } + // Optionally publish TS map + if (m_publish) { + publish(); + } + // Return return; } @@ -386,31 +391,73 @@ void cttsmap::save(void) log.header1("Save TS map"); } - // Get output filename + // Get TS map filename m_outmap = (*this)["outmap"].filename(); - // Create fits file instance - GFits fitsfile = GFits(); + // Save only if filename is non-empty + if (!m_outmap.is_empty()) { + + // Log filename + if (logTerse()) { + log << "Save TS map into file \""+m_outmap+"\"." << std::endl; + } + + // Create fits file + GFits fits; + + // Write the sky maps to the FITS file + m_tsmap.write(fits); + for (int i = 0; i < m_mapnames.size(); i++) { + m_maps[i].write(fits); + } + + // Set extension name for all maps + for (int i = 0; i < m_mapnames.size(); i++) { + fits[i+1]->extname(m_mapnames[i]); + } + + // Add computation log if not all bins are computed + if (m_binmin != -1 || m_binmax != -1) { + m_statusmap.write(fits); + fits[m_mapnames.size()+1]->extname("STATUS MAP"); + } + + // Save FITS file + fits.saveto(m_outmap, clobber()); + + } // endif: TS map filename was valid - // Write the sky maps to the FITS file - m_tsmap.write(fitsfile); - for (int i = 0; i < m_mapnames.size(); i++) { - m_maps[i].write(fitsfile); + // Return + return; +} + + +/***********************************************************************//** + * @brief Publish TS map + * + * @param[in] name TS map name. + ***************************************************************************/ +void cttsmap::publish(const std::string& name) +{ + // Write header + if (logTerse()) { + log << std::endl; + log.header1("Publish TS map"); } - // Set extension name for all maps - for (int i = 0; i < m_mapnames.size(); i++) { - fitsfile[i+1]->extname(m_mapnames[i]); + // Set default name is user name is empty + std::string user_name(name); + if (user_name.empty()) { + user_name = CTTSMAP_NAME; } - // Add computation log if not all bins are computed - if (m_binmin != -1 || m_binmax != -1) { - m_statusmap.write(fitsfile); - fitsfile[m_mapnames.size()+1]->extname("STATUS MAP"); + // Log filename + if (logTerse()) { + log << "Publish \""+user_name+"\" TS map." << std::endl; } - // Save FITS file - fitsfile.saveto(m_outmap,true); + // Publish TS map + m_tsmap.publish(user_name); // Return return; @@ -432,6 +479,7 @@ void cttsmap::init_members(void) m_srcname.clear(); m_outmap.clear(); m_apply_edisp = false; + m_publish = false; // Initialise protected members m_obs.clear(); @@ -457,9 +505,10 @@ void cttsmap::init_members(void) void cttsmap::copy_members(const cttsmap& app) { // Copy attributes - m_srcname = app.m_srcname; - m_outmap = app.m_outmap; + m_srcname = app.m_srcname; + m_outmap = app.m_outmap; m_apply_edisp = app.m_apply_edisp; + m_publish = app.m_publish; // Copy protected members m_binmin = app.m_binmin; @@ -568,9 +617,10 @@ void cttsmap::get_parameters(void) m_apply_edisp = (*this)["edisp"].boolean(); // Get optional splitting parameters - m_binmin = (*this)["binmin"].integer(); - m_binmax = (*this)["binmax"].integer(); - m_logL0 = (*this)["logL0"].real(); + m_binmin = (*this)["binmin"].integer(); + m_binmax = (*this)["binmax"].integer(); + m_logL0 = (*this)["logL0"].real(); + m_publish = (*this)["publish"].boolean(); // Optionally read ahead parameters so that they get correctly // dumped into the log file diff --git a/src/cttsmap/cttsmap.hpp b/src/cttsmap/cttsmap.hpp index f2ce58a..49ff6cf 100644 --- a/src/cttsmap/cttsmap.hpp +++ b/src/cttsmap/cttsmap.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * cttsmap - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,7 +34,7 @@ /* __Definitions _________________________________________________________ */ #define CTTSMAP_NAME "cttsmap" -#define CTTSMAP_VERSION "1.0.0" +#define CTTSMAP_VERSION "1.1.0" /***********************************************************************//** @@ -72,6 +72,7 @@ public: void clear(void); void run(void); void save(void); + void publish(const std::string& name = ""); const GObservations& obs(void) const; const GSkyMap& tsmap(void) const; @@ -85,8 +86,9 @@ protected: // User parameters std::string m_srcname; //!< Name of source which is moved around - std::string m_outmap; //!< Output counts map or XML file + GFilename m_outmap; //!< Output TS map file name bool m_apply_edisp; //!< Apply energy dispersion? + bool m_publish; //!< Publish TS map? // Parameters to control speed and job splitting int m_binmin; //!< Map bin number from which computation should start diff --git a/src/cttsmap/cttsmap.par b/src/cttsmap/cttsmap.par index ba60b32..89b784c 100644 --- a/src/cttsmap/cttsmap.par +++ b/src/cttsmap/cttsmap.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: cttsmap.par # -# Version: 1.0.0 # +# Version: 1.1.0 # # # # Author: Michael Mayer # # michael.mayer@desy.de # @@ -50,6 +50,7 @@ logL0, r, h, 0.0,,, "LogLikelihood value of null hypothesis" # # Standard parameters #==================== +publish, b, h, no,,, "Publish Test Statistic map on VO Hub?" chatter, i, h, 2,0,4, "Chattiness of output" clobber, b, h, yes,,, "Overwrite existing output files with new output files?" debug, b, h, no,,, "Debugging mode activated" diff --git a/src/ctulimit/ctulimit.cpp b/src/ctulimit/ctulimit.cpp index a858edc..d979a6d 100644 --- a/src/ctulimit/ctulimit.cpp +++ b/src/ctulimit/ctulimit.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctulimit - Upper limit calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Michael Mayer * + * copyright (C) 2015-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -52,6 +52,8 @@ /***********************************************************************//** * @brief Void constructor + * + * Constructs an empty ctulimit tool. ***************************************************************************/ ctulimit::ctulimit(void) : ctool(CTULIMIT_NAME, CTULIMIT_VERSION) { @@ -68,8 +70,8 @@ ctulimit::ctulimit(void) : ctool(CTULIMIT_NAME, CTULIMIT_VERSION) * * param[in] obs Observation container. * - * This method creates an instance of the class by copying an existing - * observations container. + * Constructs an instance of the ctulimit tool that will operate on the + * provided observation container. ***************************************************************************/ ctulimit::ctulimit(const GObservations& obs) : ctool(CTULIMIT_NAME, CTULIMIT_VERSION) @@ -91,6 +93,9 @@ ctulimit::ctulimit(const GObservations& obs) : * * @param[in] argc Number of arguments in command line. * @param[in] argv Array of command line arguments. + * + * Constructs an instance of the ctulimit tool that will parse user + * parameters that are provided as command line arguments. ***************************************************************************/ ctulimit::ctulimit(int argc, char *argv[]) : ctool(CTULIMIT_NAME, CTULIMIT_VERSION, argc, argv) @@ -107,6 +112,9 @@ ctulimit::ctulimit(int argc, char *argv[]) : * @brief Copy constructor * * @param[in] app Application. + * + * Constructs an instance of the ctulimit tool by copying information from + * another ctulimit tool. ***************************************************************************/ ctulimit::ctulimit(const ctulimit& app) : ctool(app) { @@ -123,6 +131,8 @@ ctulimit::ctulimit(const ctulimit& app) : ctool(app) /***********************************************************************//** * @brief Destructor + * + * Destructs the ctulimit tool. ***************************************************************************/ ctulimit::~ctulimit(void) { @@ -145,6 +155,8 @@ ctulimit::~ctulimit(void) * * @param[in] app Application. * @return Application. + * + * Assigns a ctulimit tool. ***************************************************************************/ ctulimit& ctulimit::operator=(const ctulimit& app) { @@ -177,7 +189,9 @@ ctulimit& ctulimit::operator=(const ctulimit& app) ==========================================================================*/ /***********************************************************************//** - * @brief Clear instance + * @brief Clear ctulimit tool + * + * Resets the ctulimit tool to a clean initial state. ***************************************************************************/ void ctulimit::clear(void) { @@ -197,9 +211,9 @@ void ctulimit::clear(void) /***********************************************************************//** - * @brief Computes the upper limit + * @brief Compute upper limit * - * This method calculates the upper limit depending on the given algorithm + * Computes the upper limit depending on the given algorithm ***************************************************************************/ void ctulimit::run(void) { @@ -369,22 +383,22 @@ void ctulimit::run(void) /***********************************************************************//** - * @brief Save maps + * @brief Save upper limits * - * This method saves the upper limit to an ascii file. + * Saves the upper limit to an ASCII file in comma-separated value format. * * @todo No yet implemented as we have no clear use case yet for saving * the result. ***************************************************************************/ void ctulimit::save(void) { + /* // Write header if (logTerse()) { log << std::endl; log.header1("Save upper limit"); } - /* // Get output filename m_outfile = (*this)["outfile"].filename(); @@ -417,14 +431,14 @@ void ctulimit::init_members(void) { // Initialise user parameters m_srcname.clear(); - m_confidence = 0.95; - m_sigma_min = 0.0; - m_sigma_max = 0.0; - m_eref = 0.0; - m_emin = 0.0; - m_emax = 0.0; - m_tol = 1.0e-6; - m_max_iter = 50; + m_confidence = 0.95; + m_sigma_min = 0.0; + m_sigma_max = 0.0; + m_eref = 0.0; + m_emin = 0.0; + m_emax = 0.0; + m_tol = 1.0e-6; + m_max_iter = 50; m_apply_edisp = false; // Initialise protected members @@ -455,15 +469,15 @@ void ctulimit::init_members(void) void ctulimit::copy_members(const ctulimit& app) { // Copy user parameters - m_srcname = app.m_srcname; - m_confidence = app.m_confidence; - m_sigma_min = app.m_sigma_min; - m_sigma_max = app.m_sigma_max; - m_eref = app.m_eref; - m_emin = app.m_emin; - m_emax = app.m_emax; - m_tol = app.m_tol; - m_max_iter = app.m_max_iter; + m_srcname = app.m_srcname; + m_confidence = app.m_confidence; + m_sigma_min = app.m_sigma_min; + m_sigma_max = app.m_sigma_max; + m_eref = app.m_eref; + m_emin = app.m_emin; + m_emax = app.m_emax; + m_tol = app.m_tol; + m_max_iter = app.m_max_iter; m_apply_edisp = app.m_apply_edisp; // Copy protected members @@ -624,12 +638,12 @@ void ctulimit::get_model_parameter(void) /***********************************************************************//** - * @brief Performs upper limit computation by using a bisection method + * @brief Calculate upper limit using a bisection method * * @param[in] min Minimum parameter value * @param[in] max Maximum parameter value * - * This method calculates the upper limit using a bisection method. + * Calculates the upper limit using a bisection method. ***************************************************************************/ void ctulimit::ulimit_bisection(const double& min, const double& max) { @@ -697,8 +711,7 @@ void ctulimit::ulimit_bisection(const double& min, const double& max) * @param[in] value Parameter factor value * @return Log-likelihood value * - * This method evaluates the log-likelihood as a function of the parameter - * of interest. + * Evaluates the log-likelihood as a function of the parameter of interest. ***************************************************************************/ double ctulimit::evaluate(const double& value) { diff --git a/src/support/ctool.hpp b/src/support/ctool.hpp index 0189588..5355efa 100644 --- a/src/support/ctool.hpp +++ b/src/support/ctool.hpp @@ -91,12 +91,14 @@ protected: GSkyDir get_mean_pointing(const GObservations& obs); size_t get_current_rss(void); + // Protected members + bool m_read_ahead; //!< Read ahead parameters + protected: // Protected methods void provide_help(void) const; // Protected members - bool m_read_ahead; //!< Read ahead parameters bool m_use_xml; //!< Use XML file instead of FITS file for observations GTimeReference m_cta_ref; //!< CTA time reference }; diff --git a/test/test_ctbin.py b/test/test_ctbin.py index 3abdd03..29fcc1a 100755 --- a/test/test_ctbin.py +++ b/test/test_ctbin.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbin tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -83,16 +83,18 @@ class Test(gammalib.GPythonTestSuite): try: bin.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctbin.") + except Exception, e: + msg = "Exception occured in ctbin: %s." % (e,) + self.test_try_failure(msg) # Save counts cube self.test_try("Save counts cube") try: bin.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving counts cube.") + except Exception, e: + msg = "Exception occured in saving counts cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctbkgcube.py b/test/test_ctbkgcube.py index df17278..6a1a2b4 100755 --- a/test/test_ctbkgcube.py +++ b/test/test_ctbkgcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbkgcube tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -91,16 +91,18 @@ class Test(gammalib.GPythonTestSuite): try: bkgcube.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctbkgcube.") + except Exception, e: + msg = "Exception occured in ctbkgcube: %s." % (e,) + self.test_try_failure(msg) # Save background cube self.test_try("Save background cube") try: bkgcube.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving background cube.") + except Exception, e: + msg = "Exception occured in saving background cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctbutterfly.py b/test/test_ctbutterfly.py index ce148ac..18542ad 100755 --- a/test/test_ctbutterfly.py +++ b/test/test_ctbutterfly.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctbutterfly tool. # -# Copyright (C) 2014 Michal Mayer +# Copyright (C) 2014-2016 Michal Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): try: butterfly.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in butterfly.") + except Exception, e: + msg = "Exception occured in ctbutterfly: %s." % (e,) + self.test_try_failure(msg) # Save results self.test_try("Save results") try: butterfly.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving results.") + except Exception, e: + msg = "Exception occured in saving butterfly diagram: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctcubemask.py b/test/test_ctcubemask.py index 8b6f8e8..83c940c 100755 --- a/test/test_ctcubemask.py +++ b/test/test_ctcubemask.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctcubemask tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): try: mask.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctcubemask.") + except Exception, e: + msg = "Exception occured in ctcubemask: %s." % (e,) + self.test_try_failure(msg) # Save counts cube self.test_try("Save counts cube") try: mask.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving counts cube.") + except Exception, e: + msg = "Exception occured in saving counts cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_cterror.py b/test/test_cterror.py index 2e90bef..f9774a6 100755 --- a/test/test_cterror.py +++ b/test/test_cterror.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cterror tool. # -# Copyright (C) 2015 Florent Forest +# Copyright (C) 2015-2016 Florent Forest # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -80,16 +80,18 @@ class Test(gammalib.GPythonTestSuite): try: error.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in cterror.") + except Exception, e: + msg = "Exception occured in cterror: %s." % (e,) + self.test_try_failure(msg) # Save results self.test_try("Save results") try: error.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving results.") + except Exception, e: + msg = "Exception occured in saving results: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctexpcube.py b/test/test_ctexpcube.py index 2e98ff5..8995736 100755 --- a/test/test_ctexpcube.py +++ b/test/test_ctexpcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctexpcube tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -88,16 +88,18 @@ class Test(gammalib.GPythonTestSuite): try: expcube.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctexpcube.") + except Exception, e: + msg = "Exception occured in ctexpcube: %s." % (e,) + self.test_try_failure(msg) # Save exposure cube self.test_try("Save exposure cube") try: expcube.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving exposure cube.") + except Exception, e: + msg = "Exception occured in saving exposure cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctlike.py b/test/test_ctlike.py index 2912bbc..646fa2b 100755 --- a/test/test_ctlike.py +++ b/test/test_ctlike.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctlike tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): try: like.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctlike.") + except Exception, e: + msg = "Exception occured in ctlike: %s." % (e,) + self.test_try_failure(msg) # Save results self.test_try("Save results") try: like.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving results.") + except Exception, e: + msg = "Exception occured in saving results: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctmodel.py b/test/test_ctmodel.py index 22581c0..c3b3dd5 100755 --- a/test/test_ctmodel.py +++ b/test/test_ctmodel.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctmodel tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -96,16 +96,18 @@ class Test(gammalib.GPythonTestSuite): try: model.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctmodel.") + except Exception, e: + msg = "Exception occured in ctmodel: %s." % (e,) + self.test_try_failure(msg) # Save counts cube self.test_try("Save model cube") try: model.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving model cube.") + except Exception, e: + msg = "Exception occured in saving model cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index edc5b92..483cac4 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -84,8 +84,9 @@ class Test(gammalib.GPythonTestSuite): try: sim.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctobssim.") + except Exception, e: + msg = "Exception occured in ctobssim: %s." % (e,) + self.test_try_failure(msg) # Retrieve observation and check content obs = gammalib.GCTAObservation(sim.obs()[0]) @@ -104,8 +105,9 @@ class Test(gammalib.GPythonTestSuite): try: sim.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving events.") + except Exception, e: + msg = "Exception occured in saving events: %s." % (e,) + self.test_try_failure(msg) # Test ctobssim on observation container def test_container(self): @@ -124,8 +126,9 @@ class Test(gammalib.GPythonTestSuite): try: sim.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctobssim.") + except Exception, e: + msg = "Exception occured in ctobssim: %s." % (e,) + self.test_try_failure(msg) # Retrieve observation and check content self.test_value(sim.obs().size(), 4, "There are not 4 observations") @@ -135,8 +138,9 @@ class Test(gammalib.GPythonTestSuite): try: sim.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving events.") + except Exception, e: + msg = "Exception occured in saving events: %s." % (e,) + self.test_try_failure(msg) # Setup observation container def set_obs(self, number): diff --git a/test/test_ctpsfcube.py b/test/test_ctpsfcube.py index 15bf77f..bf6e500 100755 --- a/test/test_ctpsfcube.py +++ b/test/test_ctpsfcube.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctpsfcube tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -90,16 +90,18 @@ class Test(gammalib.GPythonTestSuite): try: psfcube.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctpsfcube.") + except Exception, e: + msg = "Exception occured in ctpsfcube: %s." % (e,) + self.test_try_failure(msg) # Save PSF cube self.test_try("Save PSF cube") try: psfcube.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving PSF cube.") + except Exception, e: + msg = "Exception occured in saving PSF cube: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctselect.py b/test/test_ctselect.py index b02237f..f4c7c7d 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctselect tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -79,16 +79,18 @@ class Test(gammalib.GPythonTestSuite): try: select.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctselect.") + except Exception, e: + msg = "Exception occured in ctselect: %s." % (e,) + self.test_try_failure(msg) # Save events self.test_try("Save events") try: select.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving events.") + except Exception, e: + msg = "Exception occured in saving events: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index bc557e2..c10a82a 100755 --- a/test/test_ctskymap.py +++ b/test/test_ctskymap.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctskymap tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -81,16 +81,18 @@ class Test(gammalib.GPythonTestSuite): try: skymap.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctskymap.") + except Exception, e: + msg = "Exception occured in ctskymap: %s." % (e,) + self.test_try_failure(msg) # Save counts cube self.test_try("Save sky map") try: skymap.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving sky map.") + except Exception, e: + msg = "Exception occured in saving sky map: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_cttsmap.py b/test/test_cttsmap.py index e78439b..41baf6c 100755 --- a/test/test_cttsmap.py +++ b/test/test_cttsmap.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cttsmap tool. # -# Copyright (C) 2014 Juergen Knoedlseder +# Copyright (C) 2014-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -86,16 +86,18 @@ class Test(gammalib.GPythonTestSuite): try: tsmap.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in cttsmap.") + except Exception, e: + msg = "Exception occured in cttsmap: %s." % (e,) + self.test_try_failure(msg) # Save results self.test_try("Save results") try: tsmap.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving results.") + except Exception, e: + msg = "Exception occured in saving results: %s." % (e,) + self.test_try_failure(msg) # Return return diff --git a/test/test_ctulimit.py b/test/test_ctulimit.py index 8deec9f..69a4d03 100755 --- a/test/test_ctulimit.py +++ b/test/test_ctulimit.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the ctulimit tool. # -# Copyright (C) 2015 Michael Mayer +# Copyright (C) 2015-2016 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -78,16 +78,18 @@ class Test(gammalib.GPythonTestSuite): try: ulimit.run() self.test_try_success() - except: - self.test_try_failure("Exception occured in ctulimit.") + except Exception, e: + msg = "Exception occured in ctulimit: %s." % (e,) + self.test_try_failure(msg) # Save results self.test_try("Save results") try: ulimit.save() self.test_try_success() - except: - self.test_try_failure("Exception occured in saving results.") + except Exception, e: + msg = "Exception occured in saving results: %s." % (e,) + self.test_try_failure(msg) # Return return