diff --git a/NEWS b/NEWS index 7302d9e..8a744a2 100644 --- a/NEWS +++ b/NEWS @@ -152,6 +152,9 @@ The output filename is now read ahead in case that the tool is executed 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/csresmap.rst b/doc/source/reference_manual/csresmap.rst index 7029574..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 file 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.