Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_specsmooth.py: 16%
32 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
1from casatools import image
2from casatasks import casalog
3from .ialib import write_image_history
5import sys
7def specsmooth(
8 imagename, outfile, box, chans, stokes, region, mask,
9 overwrite, stretch, axis, function, width, dmethod
10):
11 casalog.origin('specsmooth')
12 myia = image()
13 myia.dohistory(False)
14 outia = None
15 try:
16 if (not myia.open(imagename)):
17 raise RuntimeError(f"Cannot create image analysis tool using {imagename}")
18 if (len(outfile) == 0):
19 raise ValueError("outfile must be specified.")
20 function = function.lower()
21 drop = len(dmethod) > 0
22 if (function.startswith("b")):
23 outia = myia.boxcar(
24 outfile=outfile, region=region, mask=mask, overwrite=overwrite,
25 stretch=stretch, axis=axis, width=width, drop=drop, dmethod=dmethod
26 )
27 elif (function.startswith("h")):
28 outia = myia.hanning(
29 outfile=outfile, region=region, mask=mask, overwrite=overwrite,
30 stretch=stretch, axis=axis, drop=drop, dmethod=dmethod
31 )
32 else:
33 raise Exception("Unsupported convolution function " + function)
34 try:
35 local_vars = locals( )
36 param_names = specsmooth.__code__.co_varnames[:specsmooth.__code__.co_argcount]
37 param_vals = [local_vars[p] for p in param_names]
38 write_image_history(
39 outia, sys._getframe().f_code.co_name,
40 param_names, param_vals, casalog
41 )
42 except Exception as instance:
43 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')
45 finally:
46 if myia:
47 myia.done()
48 if outia:
49 outia.done()