Commit 72aad6b0ee45a8e301a1fc0dc52be857f7e5ec54

Authored by Jürgen Knödlseder
1 parent c8951789

Put cscript.execute() method in the cscripts base class

cscripts/cscaldb.py
... ... @@ -31,7 +31,7 @@ import ctools
31 31 class cscaldb(ctools.cscript):
32 32 """
33 33 Shows the content of the ctools calibration database.
34   -
  34 +
35 35 The ``cscaldb`` script writes the content of the calibration database
36 36 into the ``cscaldb.log`` log file. If the ``debug`` parameter is set
37 37 to ``yes`` the calibration database is also logged in the console.
... ... @@ -41,7 +41,7 @@ class cscaldb(ctools.cscript):
41 41 def __init__(self, *argv):
42 42 """
43 43 Constructor.
44   -
  44 +
45 45 Parameters
46 46 ----------
47 47 argv : list of str
... ... @@ -132,7 +132,7 @@ class cscaldb(ctools.cscript):
132 132 name = cal[5:istop]
133 133 if names.count(name) == 0:
134 134 names.append(name)
135   -
  135 +
136 136 # Sort response names
137 137 names.sort()
138 138  
... ... @@ -197,22 +197,6 @@ class cscaldb(ctools.cscript):
197 197 # Return
198 198 return
199 199  
200   - def execute(self):
201   - """
202   - Execute the script.
203   - """
204   - # Open logfile
205   - self.logFileOpen()
206   -
207   - # Read ahead output parameters
208   - self._read_ahead(True)
209   -
210   - # Run the script
211   - self.run()
212   -
213   - # Return
214   - return
215   -
216 200  
217 201 # ======================== #
218 202 # Main routine entry point #
... ...
cscripts/csebins.py
... ... @@ -302,25 +302,6 @@ class csebins(ctools.cscript):
302 302 # Return
303 303 return self._ebounds
304 304  
305   - def execute(self):
306   - """
307   - Execute the script
308   - """
309   - # Open logfile
310   - self.logFileOpen()
311   -
312   - # Read ahead output parameters
313   - self._read_ahead(True)
314   -
315   - # Run the scrip
316   - self.run()
317   -
318   - # Save energy boundaries
319   - self.save()
320   -
321   - # Return
322   - return
323   -
324 305  
325 306 # ======================== #
326 307 # Main routine entry point #
... ...
cscripts/csfindobs.py
... ... @@ -231,25 +231,6 @@ class csfindobs(ctools.cscript):
231 231 # Return
232 232 return
233 233  
234   - def execute(self):
235   - """
236   - Execute the script
237   - """
238   - # Open logfile
239   - self.logFileOpen()
240   -
241   - # Read ahead output parameters
242   - self._read_ahead(True)
243   -
244   - # Run the script
245   - self.run()
246   -
247   - # Save residual map
248   - self.save()
249   -
250   - # Return
251   - return
252   -
253 234 def save(self):
254 235 """
255 236 Save runlist
... ...
cscripts/csiactcopy.py
... ... @@ -736,23 +736,6 @@ class csiactcopy(ctools.cscript):
736 736 # Return
737 737 return
738 738  
739   - def execute(self):
740   - """
741   - Execute the script
742   - """
743   - # Open logfile
744   - self.logFileOpen()
745   -
746   - # Read ahead output parameters
747   - self._read_ahead(True)
748   -
749   - # Run the script
750   - self.run()
751   -
752   - # Return
753   - return
754   -
755   -
756 739 # ======================== #
757 740 # Main routine entry point #
758 741 # ======================== #
... ...
cscripts/csiactdata.py
... ... @@ -177,22 +177,6 @@ class csiactdata(ctools.cscript):
177 177 # Return
178 178 return
179 179  
180   - def execute(self):
181   - """
182   - Execute the script
183   - """
184   - # Open logfile
185   - self.logFileOpen()
186   -
187   - # Read ahead output parameters
188   - self._read_ahead(True)
189   -
190   - # Run the script
191   - self.run()
192   -
193   - # Return
194   - return
195   -
196 180 def names(self):
197 181 """
198 182 Return available FITS production names
... ...
cscripts/csiactobs.py
... ... @@ -774,25 +774,6 @@ class csiactobs(ctools.cscript):
774 774 # Return
775 775 return
776 776  
777   - def execute(self):
778   - """
779   - Execute the script
780   - """
781   - # Open logfile
782   - self.logFileOpen()
783   -
784   - # Read ahead output parameters
785   - self._read_ahead(True)
786   -
787   - # Run the script
788   - self.run()
789   -
790   - # Save residual map
791   - self.save()
792   -
793   - # Return
794   - return
795   -
796 777 def save(self):
797 778 """
798 779 Save observation definition and model definition XML file
... ...
cscripts/cslightcrv.py
... ... @@ -614,25 +614,6 @@ class cslightcrv(ctools.cscript):
614 614 # Return
615 615 return
616 616  
617   - def execute(self):
618   - """
619   - Execute the script
620   - """
621   - # Open logfile
622   - self.logFileOpen()
623   -
624   - # Read ahead output parameters
625   - self._read_ahead(True)
626   -
627   - # Run the script
628   - self.run()
629   -
630   - # Save lightcurve
631   - self.save()
632   -
633   - # Return
634   - return
635   -
636 617 def save(self):
637 618 """
638 619 Save light curve
... ...
cscripts/csmodelinfo.py
... ... @@ -292,25 +292,6 @@ class csmodelinfo(ctools.cscript):
292 292 # Return
293 293 return
294 294  
295   - def execute(self):
296   - """
297   - Execute the script
298   - """
299   - # Open logfile
300   - self.logFileOpen()
301   -
302   - # Read ahead output parameters
303   - self._read_ahead(True)
304   -
305   - # Run the script
306   - self.run()
307   -
308   - # Save ds9 file if required
309   - self.save()
310   -
311   - # Return
312   - return
313   -
314 295  
315 296 # ======================== #
316 297 # Main routine entry point #
... ...
cscripts/csmodelmerge.py
... ... @@ -187,25 +187,6 @@ class csmodelmerge(ctools.cscript):
187 187  
188 188 # Return
189 189 return
190   -
191   - def execute(self):
192   - """
193   - Execute the script
194   - """
195   - # Open logfile
196   - self.logFileOpen()
197   -
198   - # Read ahead output parameters
199   - self._read_ahead(True)
200   -
201   - # Run the script
202   - self.run()
203   -
204   - # Save ds9 file if required
205   - self.save()
206   -
207   - # Return
208   - return
209 190  
210 191  
211 192 # ======================== #
... ...
cscripts/csmodelselect.py
... ... @@ -295,25 +295,6 @@ class csmodelselect(ctools.cscript):
295 295 # Return
296 296 return
297 297  
298   - def execute(self):
299   - """
300   - Execute the script
301   - """
302   - # Open logfile
303   - self.logFileOpen()
304   -
305   - # Read ahead output parameters
306   - self._read_ahead(True)
307   -
308   - # Run the script
309   - self.run()
310   -
311   - # Save model file if required
312   - self.save()
313   -
314   - # Return
315   - return
316   -
317 298  
318 299 # ======================== #
319 300 # Main routine entry point #
... ...
cscripts/csmodelsois.py
... ... @@ -194,25 +194,6 @@ class csmodelsois(ctools.cscript):
194 194 # Return
195 195 return
196 196  
197   - def execute(self):
198   - """
199   - Execute the script
200   - """
201   - # Open logfile
202   - self.logFileOpen()
203   -
204   - # Read ahead output parameters
205   - self._read_ahead(True)
206   -
207   - # Run the script
208   - self.run()
209   -
210   - # Save model
211   - self.save()
212   -
213   - # Return
214   - return
215   -
216 197 def save(self):
217 198 """
218 199 Save the cube and optionally the updated XML model file
... ...
cscripts/csobs2caldb.py
... ... @@ -392,25 +392,6 @@ class csobs2caldb(ctools.cscript):
392 392  
393 393 # Return
394 394 return
395   -
396   - def execute(self):
397   - """
398   - Execute the script
399   - """
400   - # Open logfile
401   - self.logFileOpen()
402   -
403   - # Read ahead output parameters
404   - self._read_ahead(True)
405   -
406   - # Run the script
407   - self.run()
408   -
409   - # Save to disk
410   - self.save()
411   -
412   - # Return
413   - return
414 395  
415 396  
416 397 # ======================== #
... ...
cscripts/csobsdef.py
... ... @@ -370,25 +370,6 @@ class csobsdef(ctools.cscript):
370 370 # Return
371 371 return
372 372  
373   - def execute(self):
374   - """
375   - Execute the script
376   - """
377   - # Open logfile
378   - self.logFileOpen()
379   -
380   - # Read ahead output parameters
381   - self._read_ahead(True)
382   -
383   - # Run the script
384   - self.run()
385   -
386   - # Save observation definition file
387   - self.save()
388   -
389   - # Return
390   - return
391   -
392 373 def obs(self):
393 374 """
394 375 Returns observation container
... ...
cscripts/csobsinfo.py
... ... @@ -390,25 +390,6 @@ class csobsinfo(ctools.cscript):
390 390 Return good time intervals
391 391 """
392 392 return self._gti
393   -
394   - def execute(self):
395   - """
396   - Execute the script
397   - """
398   - # Open logfile
399   - self.logFileOpen()
400   -
401   - # Read ahead output parameters
402   - self._read_ahead(True)
403   -
404   - # Run the script
405   - self.run()
406   -
407   - # Save ds9 file if required
408   - self.save()
409   -
410   - # Return
411   - return
412 393  
413 394  
414 395 # ======================== #
... ...
cscripts/csobsselect.py
... ... @@ -335,25 +335,6 @@ class csobsselect(ctools.cscript):
335 335 """
336 336 return self._obs
337 337  
338   - def execute(self):
339   - """
340   - Execute the script
341   - """
342   - # Open logfile
343   - self.logFileOpen()
344   -
345   - # Read ahead output parameters
346   - self._read_ahead(True)
347   -
348   - # Run the script
349   - self.run()
350   -
351   - # Save observation definition file
352   - self.save()
353   -
354   - # Return
355   - return
356   -
357 338  
358 339 # ======================== #
359 340 # Main routine entry point #
... ...
cscripts/csphagen.py
... ... @@ -330,25 +330,6 @@ class csphagen(ctools.cscript):
330 330 """
331 331 return self._outobs
332 332  
333   - def execute(self):
334   - """
335   - Execute the script
336   - """
337   - # Open logfile
338   - self.logFileOpen()
339   -
340   - # Read ahead output parameters
341   - self._read_ahead(True)
342   -
343   - # Run the script
344   - self.run()
345   -
346   - # Save result
347   - self.save()
348   -
349   - # Return
350   - return
351   -
352 333  
353 334 # ======================== #
354 335 # Main routine entry point #
... ...
cscripts/csphasecrv.py
... ... @@ -408,25 +408,6 @@ class csphasecrv(ctools.cscript):
408 408 # Return
409 409 return
410 410  
411   - def execute(self):
412   - """
413   - Execute the script
414   - """
415   - # Open logfile
416   - self.logFileOpen()
417   -
418   - # Read ahead output parameters
419   - self._read_ahead(True)
420   -
421   - # Run the script
422   - self.run()
423   -
424   - # Save fitted models
425   - self.save()
426   -
427   - # Return
428   - return
429   -
430 411 def save(self):
431 412 """
432 413 Saves results to fits and XML
... ...
cscripts/cspull.py
... ... @@ -311,22 +311,6 @@ class cspull(ctools.cscript):
311 311 # Return
312 312 return
313 313  
314   - def execute(self):
315   - """
316   - Execute the script
317   - """
318   - # Open logfile
319   - self.logFileOpen()
320   -
321   - # Read ahead output parameters
322   - self._read_ahead(True)
323   -
324   - # Run the script
325   - self.run()
326   -
327   - # Return
328   - return
329   -
330 314 def models(self, models):
331 315 """
332 316 Set model
... ...
cscripts/csresmap.py
... ... @@ -285,25 +285,6 @@ class csresmap(ctools.cscript):
285 285 # Return
286 286 return
287 287  
288   - def execute(self):
289   - """
290   - Execute the script
291   - """
292   - # Open logfile
293   - self.logFileOpen()
294   -
295   - # Read ahead output parameters
296   - self._read_ahead(True)
297   -
298   - # Run the script
299   - self.run()
300   -
301   - # Save residual map
302   - self.save()
303   -
304   - # Return
305   - return
306   -
307 288 def save(self):
308 289 """
309 290 Save residual map
... ...
cscripts/csroot2caldb.py
... ... @@ -1777,22 +1777,6 @@ class csroot2caldb(ctools.cscript):
1777 1777 # Return
1778 1778 return
1779 1779  
1780   - def execute(self):
1781   - """
1782   - Execute the script
1783   - """
1784   - # Open logfile
1785   - self.logFileOpen()
1786   -
1787   - # Read ahead output parameters
1788   - self._read_ahead(True)
1789   -
1790   - # Run the script
1791   - self.run()
1792   -
1793   - # Return
1794   - return
1795   -
1796 1780  
1797 1781 # ======================== #
1798 1782 # Main routine entry point #
... ...
cscripts/cssens.py
... ... @@ -642,22 +642,6 @@ class cssens(ctools.cscript):
642 642 # Return
643 643 return
644 644  
645   - def execute(self):
646   - """
647   - Execute the script
648   - """
649   - # Open logfile
650   - self.logFileOpen()
651   -
652   - # Read ahead output parameters
653   - self._read_ahead(True)
654   -
655   - # Run the script
656   - self.run()
657   -
658   - # Return
659   - return
660   -
661 645  
662 646 # ======================== #
663 647 # Main routine entry point #
... ...
cscripts/csspec.py
... ... @@ -889,25 +889,6 @@ class csspec(ctools.cscript):
889 889 # Return
890 890 return
891 891  
892   - def execute(self):
893   - """
894   - Execute the script
895   - """
896   - # Open logfile
897   - self.logFileOpen()
898   -
899   - # Read ahead output parameters
900   - self._read_ahead(True)
901   -
902   - # Run the script
903   - self.run()
904   -
905   - # Save spectrum
906   - self.save()
907   -
908   - # Return
909   - return
910   -
911 892 def save(self):
912 893 """
913 894 Save spectrum
... ...
cscripts/cssrcdetect.py
... ... @@ -464,25 +464,6 @@ class cssrcdetect(ctools.cscript):
464 464 """
465 465 return self._models
466 466  
467   - def execute(self):
468   - """
469   - Execute the script
470   - """
471   - # Open logfile
472   - self.logFileOpen()
473   -
474   - # Read ahead output parameters
475   - self._read_ahead(True)
476   -
477   - # Run the script
478   - self.run()
479   -
480   - # Save observation definition file
481   - self.save()
482   -
483   - # Return
484   - return
485   -
486 467  
487 468 # ======================== #
488 469 # Main routine entry point #
... ...
cscripts/cstsdist.py
... ... @@ -279,22 +279,6 @@ class cstsdist(ctools.cscript):
279 279 # Return
280 280 return
281 281  
282   - def execute(self):
283   - """
284   - Execute the script
285   - """
286   - # Open logfile
287   - self.logFileOpen()
288   -
289   - # Read ahead output parameters
290   - self._read_ahead(True)
291   -
292   - # Run the script
293   - self.run()
294   -
295   - # Return
296   - return
297   -
298 282  
299 283 # ======================== #
300 284 # Main routine entry point #
... ...
cscripts/cstsmapmerge.py
... ... @@ -448,25 +448,6 @@ class cstsmapmerge(ctools.cscript):
448 448  
449 449 # Return
450 450 return
451   -
452   - def execute(self):
453   - """
454   - Execute the script.
455   - """
456   - # Open logfile
457   - self.logFileOpen()
458   -
459   - # Read ahead output parameters
460   - self._read_ahead(True)
461   -
462   - # Run the script
463   - self.run()
464   -
465   - # Save TS map if required
466   - self.save()
467   -
468   - # Return
469   - return
470 451  
471 452  
472 453 # ======================== #
... ...
cscripts/cstsmapsplit.py
... ... @@ -278,25 +278,6 @@ class cstsmapsplit(ctools.cscript):
278 278 # Return
279 279 return
280 280  
281   - def execute(self):
282   - """
283   - Execute the script
284   - """
285   - # Open logfile
286   - self.logFileOpen()
287   -
288   - # Read ahead output parameters
289   - self._read_ahead(True)
290   -
291   - # Run the script
292   - self.run()
293   -
294   - # Save results
295   - self.save()
296   -
297   - # Return
298   - return
299   -
300 281  
301 282 # ======================== #
302 283 # Main routine entry point #
... ...
cscripts/csviscube.py
... ... @@ -512,25 +512,6 @@ class csviscube(ctools.cscript):
512 512 # Return
513 513 return
514 514  
515   - def execute(self):
516   - """
517   - Execute the script
518   - """
519   - # Open logfile
520   - self.logFileOpen()
521   -
522   - # Read ahead output parameters
523   - self._read_ahead(True)
524   -
525   - # Run the script
526   - self.run()
527   -
528   - # Save the cube
529   - self.save()
530   -
531   - # Return
532   - return
533   -
534 515  
535 516 # ======================== #
536 517 # Main routine entry point #
... ...
cscripts/csworkflow.py
... ... @@ -353,22 +353,6 @@ class csworkflow(ctools.cscript):
353 353 # Return
354 354 return
355 355  
356   - def execute(self):
357   - """
358   - Execute the script
359   - """
360   - # Open logfile
361   - self.logFileOpen()
362   -
363   - # Read ahead output parameters
364   - self._read_ahead(True)
365   -
366   - # Run the script
367   - self.run()
368   -
369   - # Return
370   - return
371   -
372 356  
373 357 # ======================== #
374 358 # Main routine entry point #
... ...
pyext/ctool.i
... ... @@ -294,6 +294,14 @@ def _pardict(self, *args):
294 294 self[key] = args[0][key]
295 295 else:
296 296 raise TypeError('pardict() takes 0 or 1 arguments (%d given)' % len(args))
297   -ctool.pardict = _pardict
  297 +ctool.pardict = _pardict
298 298 cscript.pardict = _pardict
  299 +
  300 +# Execute the script
  301 +def _execute(self):
  302 + self.logFileOpen()
  303 + self._read_ahead(True)
  304 + self.run()
  305 + self.save()
  306 +cscript.execute = _execute
299 307 %}
... ...