Coverage for /home/casatest/venv/lib/python3.12/site-packages/casatasks/smoothcal.py: 56%

27 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-21 07:43 +0000

1##################### generated by xml-casa (v2) from smoothcal.xml ################# 

2##################### 5e44183b734257bc390af5e908f562f2 ############################## 

3from __future__ import absolute_import 

4import numpy 

5from casatools.typecheck import CasaValidator as _val_ctor 

6_pc = _val_ctor( ) 

7from casatools.coercetype import coerce as _coerce 

8from casatools.errors import create_error_string 

9from .private.task_smoothcal import smoothcal as _smoothcal_t 

10from casatasks.private.task_logging import start_log as _start_log 

11from casatasks.private.task_logging import end_log as _end_log 

12from casatasks.private.task_logging import except_log as _except_log 

13 

14class _smoothcal: 

15 """ 

16 smoothcal ---- Smooth calibration solution(s) derived from one or more sources 

17 

18  

19 A G- or T-type gain calibration can be smoothed. Amplitude and 

20 phase are currently smoothed with the same time. Calibration values 

21 will be smoothed over all fields. 

22  

23 

24 --------- parameter descriptions --------------------------------------------- 

25 

26 vis Name of input visibility file (MS) 

27 tablein Input calibration table 

28 caltable Output calibration table (overwrite tablein if unspecified) 

29 field Field name list 

30 smoothtype Smoothing filter to use 

31 smoothtime Smoothing time (sec) 

32 ratesmooth Use rate aware smoothing. This is an experimental feature 

33 RETURNS void 

34 

35 --------- examples ----------------------------------------------------------- 

36 

37  

38  

39  

40 A G- or T-type gain calibration can be smoothed. The amplitude and 

41 phase smoothing times are currently the same. Calibration values 

42 will be smoothed for only the specified fields. Smoothing is 

43 performed independently per field, per spw, and per antenna. 

44  

45 Keyword arguments: 

46 vis -- Name of input visibility file 

47 default: none; example: vis='ngc5921.ms' 

48 tablein -- Input calibration table (G or T) 

49 default: none; example: tablein='ngc5921.gcal' 

50 caltable -- Output calibration table (smoothed) 

51 default: '' (will overwrite tablein); 

52 example: caltable='ngc5921_smooth.gcal' 

53 field -- subset of fields to select and smooth 

54 default: '' means all; example: field='0319_415_1,3C286' 

55 smoothtype -- The smoothing filter to be used for both amp and phase 

56 default: 'median'; example: smoothtype='mean' 

57 Options: 'median','mean' 

58 smoothtime -- Smoothing filter time (sec) 

59 default: 300.0; example: smoothtime=60. 

60 ratesmooth -- On fringefit data use rate-aware smoothing 

61 default: False 

62  

63 

64 

65 """ 

66 

67 _info_group_ = """calibration""" 

68 _info_desc_ = """Smooth calibration solution(s) derived from one or more sources""" 

69 

70 def __call__( self, vis='', tablein='', caltable='', field=[ ], smoothtype='median', smoothtime=float(60.0), ratesmooth=False ): 

71 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'tablein': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'caltable': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'smoothtype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'median', 'mean' ]}, 'smoothtime': {'anyof': [{'type': 'cFloat', 'coerce': _coerce.to_float}, {'type': 'cInt'}]}, 'ratesmooth': {'type': 'cBool'}} 

72 doc = {'vis': vis, 'tablein': tablein, 'caltable': caltable, 'field': field, 'smoothtype': smoothtype, 'smoothtime': smoothtime, 'ratesmooth': ratesmooth} 

73 assert _pc.validate(doc,schema), create_error_string(_pc.errors) 

74 _logging_state_ = _start_log( 'smoothcal', [ 'vis=' + repr(_pc.document['vis']), 'tablein=' + repr(_pc.document['tablein']), 'caltable=' + repr(_pc.document['caltable']), 'field=' + repr(_pc.document['field']), 'smoothtype=' + repr(_pc.document['smoothtype']), 'smoothtime=' + repr(_pc.document['smoothtime']), 'ratesmooth=' + repr(_pc.document['ratesmooth']) ] ) 

75 task_result = None 

76 try: 

77 task_result = _smoothcal_t( _pc.document['vis'], _pc.document['tablein'], _pc.document['caltable'], _pc.document['field'], _pc.document['smoothtype'], _pc.document['smoothtime'], _pc.document['ratesmooth'] ) 

78 except Exception as exc: 

79 _except_log('smoothcal', exc) 

80 raise 

81 finally: 

82 task_result = _end_log( _logging_state_, 'smoothcal', task_result ) 

83 return task_result 

84 

85smoothcal = _smoothcal( ) 

86