Commit f8d59545aff2a4ce48d0016753fe00cef1d7b0d0

Authored by Jürgen Knödlseder
1 parent d9c127cd

Add csresmap::publish() method to publish residual maps on VO Hub.

@@ -152,6 +152,9 @@ The output filename is now read ahead in case that the tool is executed @@ -152,6 +152,9 @@ The output filename is now read ahead in case that the tool is executed
152 Added the csiactcopy script that copies IACT data from a remote machine to 152 Added the csiactcopy script that copies IACT data from a remote machine to
153 the user's machine (#1661). 153 the user's machine (#1661).
154 154
  155 +Add csresmap::publish() method to publish the residual map via a SAMP Hub
  156 +to Virtual Observatory interoperable tools (e.g. Aladin).
  157 +
155 158
156 20. Examples 159 20. Examples
157 ------------ 160 ------------
cscripts/csresmap.py
@@ -36,18 +36,19 @@ class csresmap(ctools.cscript): @@ -36,18 +36,19 @@ class csresmap(ctools.cscript):
36 """ 36 """
37 Constructor. 37 Constructor.
38 """ 38 """
39 -  
40 # Set name 39 # Set name
41 self.name = "csresmap" 40 self.name = "csresmap"
42 - self.version = "1.0.0" 41 + self.version = "1.1.0"
43 42
44 # Initialise some members 43 # Initialise some members
45 self.obs = None 44 self.obs = None
46 self.algorithm = "SUB" 45 self.algorithm = "SUB"
47 self.resmap = None 46 self.resmap = None
48 self.m_modcube = "None" 47 self.m_modcube = "None"
  48 + self.m_outmap = "None"
49 self.m_use_maps = False 49 self.m_use_maps = False
50 self.m_skip_binning = False 50 self.m_skip_binning = False
  51 + self.m_publish = False
51 52
52 # Initialise some members 53 # Initialise some members
53 if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations): 54 if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations):
@@ -126,6 +127,7 @@ class csresmap(ctools.cscript): @@ -126,6 +127,7 @@ class csresmap(ctools.cscript):
126 pars.append(gammalib.GApplicationPar("nypix","i","a","200","","","Size of the Y axis in pixels")) 127 pars.append(gammalib.GApplicationPar("nypix","i","a","200","","","Size of the Y axis in pixels"))
127 pars.append(gammalib.GApplicationPar("binsz","r","a","0.02","","","Pixel size (deg/pixel)")) 128 pars.append(gammalib.GApplicationPar("binsz","r","a","0.02","","","Pixel size (deg/pixel)"))
128 pars.append(gammalib.GApplicationPar("algorithm","s","a","SUBDIV","SUB|SUBDIV|SUBDIVSQRT","","Residual map computation algorithm")) 129 pars.append(gammalib.GApplicationPar("algorithm","s","a","SUBDIV","SUB|SUBDIV|SUBDIVSQRT","","Residual map computation algorithm"))
  130 + pars.append(gammalib.GApplicationPar("publish","b","h","no","","","Publish residual map on VO Hub?"))
129 pars.append_standard() 131 pars.append_standard()
130 pars.append(gammalib.GApplicationPar("logfile","f","h","csresmap.log","","","Log filename")) 132 pars.append(gammalib.GApplicationPar("logfile","f","h","csresmap.log","","","Log filename"))
131 pars.save(parfile) 133 pars.save(parfile)
@@ -193,18 +195,22 @@ class csresmap(ctools.cscript): @@ -193,18 +195,22 @@ class csresmap(ctools.cscript):
193 self.m_binsz = self["binsz"].real() 195 self.m_binsz = self["binsz"].real()
194 196
195 # Read energy dispersion flag 197 # Read energy dispersion flag
196 - self.m_edisp = self["edisp"].boolean() 198 + self.m_edisp = self["edisp"].boolean()
197 199
198 - # Read necessary parameters  
199 - self.m_outfile = self["outmap"].filename() 200 + # Read algorithm
200 self.m_algorithm = self["algorithm"].string() 201 self.m_algorithm = self["algorithm"].string()
201 202
202 - # Set some fixed parameters 203 + # Read standard parameters
  204 + self.m_publish = self["publish"].boolean()
203 self.m_log = False # Logging in client tools 205 self.m_log = False # Logging in client tools
204 self.m_chatter = self["chatter"].integer() 206 self.m_chatter = self["chatter"].integer()
205 self.m_clobber = self["clobber"].boolean() 207 self.m_clobber = self["clobber"].boolean()
206 self.m_debug = self["debug"].boolean() 208 self.m_debug = self["debug"].boolean()
207 209
  210 + # Read ahead output parameters
  211 + if (self.read_ahead()):
  212 + self.m_outmap = self["outmap"].filename()
  213 +
208 # Return 214 # Return
209 return 215 return
210 216
@@ -222,11 +228,64 @@ class csresmap(ctools.cscript): @@ -222,11 +228,64 @@ class csresmap(ctools.cscript):
222 """ 228 """
223 Execute the script. 229 Execute the script.
224 """ 230 """
  231 + # Read ahead output parameters
  232 + self.read_ahead(True)
  233 +
225 # Run the script 234 # Run the script
226 self.run() 235 self.run()
227 236
228 # Save residual map 237 # Save residual map
229 - self.resmap.save(self.m_outfile, self.m_clobber) 238 + self.save()
  239 +
  240 + # Return
  241 + return
  242 +
  243 + def save(self):
  244 + """
  245 + Save residual map.
  246 + """
  247 + # Write header
  248 + if self.logTerse():
  249 + self.log("\n")
  250 + self.log.header1("Save residual map")
  251 +
  252 + # Continue only filename and residual map are valid
  253 + if self.m_outmap != "None" and self.resmap != None:
  254 +
  255 + # Log file name
  256 + if self.logTerse():
  257 + self.log("Save residual map into \""+self.m_outmap+"\".\n")
  258 +
  259 + # Save residual map
  260 + self.resmap.save(self.m_outmap, self.m_clobber)
  261 +
  262 + # Return
  263 + return
  264 +
  265 + def publish(self, name=""):
  266 + """
  267 + Publish residual map.
  268 + """
  269 + # Write header
  270 + if self.logTerse():
  271 + self.log("\n")
  272 + self.log.header1("Publish sky map")
  273 +
  274 + # Continue only if residual map is valid
  275 + if self.resmap != None:
  276 +
  277 + # Set default name is user name is empty
  278 + if not name:
  279 + user_name = self.name
  280 + else:
  281 + user_name = name
  282 +
  283 + # Log map name
  284 + if self.logTerse():
  285 + self.log("Publish residual map \""+user_name+"\".\n")
  286 +
  287 + # Publish map
  288 + self.resmap.publish(user_name)
230 289
231 # Return 290 # Return
232 return 291 return
@@ -353,6 +412,10 @@ class csresmap(ctools.cscript): @@ -353,6 +412,10 @@ class csresmap(ctools.cscript):
353 # Raise error if algorithm is unkown 412 # Raise error if algorithm is unkown
354 raise TypeError("Algorithm \""+self.m_algorithm+"\" not known") 413 raise TypeError("Algorithm \""+self.m_algorithm+"\" not known")
355 414
  415 + # Optionally publish map
  416 + if self.m_publish:
  417 + self.publish()
  418 +
356 # Return 419 # Return
357 return 420 return
358 421
doc/source/reference_manual/csresmap.rst
@@ -101,6 +101,9 @@ General parameters @@ -101,6 +101,9 @@ General parameters
101 Standard parameters 101 Standard parameters
102 ------------------- 102 -------------------
103 103
  104 +``(publish = no) [boolean]``
  105 + Specifies whether the residual map should be published on VO Hub.
  106 +
104 ``(chatter = 2) [integer]`` 107 ``(chatter = 2) [integer]``
105 Verbosity of the executable: 108 Verbosity of the executable:
106 chatter = 0: no information will be logged 109 chatter = 0: no information will be logged
@@ -114,7 +117,7 @@ Standard parameters @@ -114,7 +117,7 @@ Standard parameters
114 chatter = 4: detailed report about the task execution 117 chatter = 4: detailed report about the task execution
115 118
116 ``(clobber = yes) [boolean]`` 119 ``(clobber = yes) [boolean]``
117 - Specifies whether an existing output file should be overwritten. 120 + Specifies whether an existing residual map file should be overwritten.
118 121
119 ``(debug = no) [boolean]`` 122 ``(debug = no) [boolean]``
120 Enables debug mode. In debug mode the executable will dump any log file output to the console. 123 Enables debug mode. In debug mode the executable will dump any log file output to the console.