Commit f8d59545aff2a4ce48d0016753fe00cef1d7b0d0
1 parent
d9c127cd
Add csresmap::publish() method to publish residual maps on VO Hub.
Showing
3 changed files
with
77 additions
and
8 deletions
NEWS
| ... | ... | @@ -152,6 +152,9 @@ The output filename is now read ahead in case that the tool is executed |
| 152 | 152 | Added the csiactcopy script that copies IACT data from a remote machine to |
| 153 | 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 | 159 | 20. Examples |
| 157 | 160 | ------------ | ... | ... |
cscripts/csresmap.py
| ... | ... | @@ -36,18 +36,19 @@ class csresmap(ctools.cscript): |
| 36 | 36 | """ |
| 37 | 37 | Constructor. |
| 38 | 38 | """ |
| 39 | - | |
| 40 | 39 | # Set name |
| 41 | 40 | self.name = "csresmap" |
| 42 | - self.version = "1.0.0" | |
| 41 | + self.version = "1.1.0" | |
| 43 | 42 | |
| 44 | 43 | # Initialise some members |
| 45 | 44 | self.obs = None |
| 46 | 45 | self.algorithm = "SUB" |
| 47 | 46 | self.resmap = None |
| 48 | 47 | self.m_modcube = "None" |
| 48 | + self.m_outmap = "None" | |
| 49 | 49 | self.m_use_maps = False |
| 50 | 50 | self.m_skip_binning = False |
| 51 | + self.m_publish = False | |
| 51 | 52 | |
| 52 | 53 | # Initialise some members |
| 53 | 54 | if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations): |
| ... | ... | @@ -126,6 +127,7 @@ class csresmap(ctools.cscript): |
| 126 | 127 | pars.append(gammalib.GApplicationPar("nypix","i","a","200","","","Size of the Y axis in pixels")) |
| 127 | 128 | pars.append(gammalib.GApplicationPar("binsz","r","a","0.02","","","Pixel size (deg/pixel)")) |
| 128 | 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 | 131 | pars.append_standard() |
| 130 | 132 | pars.append(gammalib.GApplicationPar("logfile","f","h","csresmap.log","","","Log filename")) |
| 131 | 133 | pars.save(parfile) |
| ... | ... | @@ -193,18 +195,22 @@ class csresmap(ctools.cscript): |
| 193 | 195 | self.m_binsz = self["binsz"].real() |
| 194 | 196 | |
| 195 | 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 | 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 | 205 | self.m_log = False # Logging in client tools |
| 204 | 206 | self.m_chatter = self["chatter"].integer() |
| 205 | 207 | self.m_clobber = self["clobber"].boolean() |
| 206 | 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 | 214 | # Return |
| 209 | 215 | return |
| 210 | 216 | |
| ... | ... | @@ -222,11 +228,64 @@ class csresmap(ctools.cscript): |
| 222 | 228 | """ |
| 223 | 229 | Execute the script. |
| 224 | 230 | """ |
| 231 | + # Read ahead output parameters | |
| 232 | + self.read_ahead(True) | |
| 233 | + | |
| 225 | 234 | # Run the script |
| 226 | 235 | self.run() |
| 227 | 236 | |
| 228 | 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 | 290 | # Return |
| 232 | 291 | return |
| ... | ... | @@ -353,6 +412,10 @@ class csresmap(ctools.cscript): |
| 353 | 412 | # Raise error if algorithm is unkown |
| 354 | 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 | 419 | # Return |
| 357 | 420 | return |
| 358 | 421 | ... | ... |
doc/source/reference_manual/csresmap.rst
| ... | ... | @@ -101,6 +101,9 @@ General parameters |
| 101 | 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 | 107 | ``(chatter = 2) [integer]`` |
| 105 | 108 | Verbosity of the executable: |
| 106 | 109 | chatter = 0: no information will be logged |
| ... | ... | @@ -114,7 +117,7 @@ Standard parameters |
| 114 | 117 | chatter = 4: detailed report about the task execution |
| 115 | 118 | |
| 116 | 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 | 122 | ``(debug = no) [boolean]`` |
| 120 | 123 | Enables debug mode. In debug mode the executable will dump any log file output to the console. | ... | ... |