Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_sdsmooth.py: 42%

26 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 19:53 +0000

1import os 

2 

3from casatasks import casalog 

4from casatools import ms as mstool 

5from casatools import singledishms, table 

6 

7from . import sdutil 

8from .mstools import write_history 

9 

10ms = mstool() 

11sdms = singledishms() 

12tb = table() 

13 

14 

15@sdutil.callable_sdtask_decorator 

16def sdsmooth(infile=None, datacolumn=None, antenna=None, 

17 field=None, spw=None, timerange=None, scan=None, 

18 pol=None, intent=None, reindex=None, 

19 kernel=None, kwidth=None, 

20 outfile=None, overwrite=None): 

21 

22 try: 

23 if len(outfile) == 0: 

24 errmsg = 'outfile is empty.' 

25 raise ValueError(errmsg) 

26 

27 if (os.path.exists(outfile)) and (not overwrite): 

28 errmsg = outfile + ' exists.' 

29 raise ValueError(errmsg) 

30 

31 sdms.open(infile) 

32 sdms.set_selection(spw=spw, field=field, 

33 antenna=antenna, 

34 timerange=timerange, scan=scan, 

35 polarization=pol, intent=intent, 

36 reindex=reindex) 

37 sdms.smooth(type=kernel, width=kwidth, datacolumn=datacolumn, outfile=outfile) 

38 

39 # Write to HISTORY of outfile MS 

40 param_names = sdsmooth.__code__.co_varnames[:sdsmooth.__code__.co_argcount] 

41 vars = locals() 

42 param_vals = [vars[p] for p in param_names] 

43 write_history(ms, outfile, 'sdsmooth', param_names, 

44 param_vals, casalog) 

45 

46 finally: 

47 sdms.close()