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

52 statements  

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

1import os 

2import numpy as np 

3 

4from casatools import calibrater 

5from casatasks import casalog 

6from .callibrary import * 

7 

8def accor(vis=None,caltable=None, 

9 field=None,spw=None,intent=None, 

10 selectdata=None,timerange=None,antenna=None,scan=None, 

11 observation=None, msselect=None, 

12 solint=None,combine=None,corrdepflags=None,append=None, 

13 docallib=None,callib=None, 

14 gaintable=None,gainfield=None,interp=None,spwmap=None): 

15 

16 #Python script 

17 casalog.origin('accor') 

18 

19 try: 

20 mycb = calibrater() 

21 

22 if ((type(vis)==str) & (os.path.exists(vis))): 

23 mycb.open(filename=vis,compress=False,addcorr=False,addmodel=False) 

24 else: 

25 raise ValueError('Visibility data set not found - please verify the name') 

26 

27 # Do data selection according to selectdata 

28 casalog.post("NB: accor automatically excludes crosso-correlations.") 

29 if (selectdata): 

30 # insist only CCs 

31 if len(msselect)>0: 

32 msselect='('+msselect+') && ANTENNA==ANTENNA2' 

33 else: 

34 msselect='ANTENNA1==ANTENNA2' 

35 

36 # pass all data selection parameters in as specified 

37 mycb.selectvis(time=timerange,spw=spw, scan=scan, field=field, 

38 intent=intent, observation=str(observation), 

39 baseline=antenna,uvrange='',chanmode='none', 

40 msselect=msselect); 

41 else: 

42 # selectdata=F, so time,scan,baseline,uvrange,msselect='' 

43 # using spw and field specifications only 

44 # also insist only CCs 

45 mycb.selectvis(time='',spw=spw,scan='',field=field,intent=intent, 

46 observation='', baseline='', uvrange='', 

47 chanmode='none', msselect='ANTENNA1==ANTENNA2') 

48 

49 # signal use of correlation-dependent flags, if requested 

50 if corrdepflags: 

51 mycb.setcorrdepflags(True) 

52 

53 # Arrange applies.... 

54 

55 if docallib: 

56 # by cal library from file 

57 mycallib=callibrary() 

58 mycallib.read(callib) 

59 mycb.setcallib(mycallib.cld) 

60 

61 else: 

62 

63 # by traditional parameters 

64 

65 ngaintab = 0; 

66 if (gaintable!=['']): 

67 ngaintab=len(gaintable) 

68 

69 ngainfld = len(gainfield) 

70 nspwmap = len(spwmap) 

71 ninterp = len(interp) 

72 

73 # handle list of list issues with spwmap 

74 if (nspwmap>0): 

75 if (type(spwmap[0])!=list): 

76 # first element not a list, only one spwmap specified 

77 # make it a list of list 

78 spwmap=[spwmap]; 

79 nspwmap=1; 

80 

81 for igt in range(ngaintab): 

82 if (gaintable[igt]!=''): 

83 

84 # field selection is null unless specified 

85 thisgainfield='' 

86 if (igt<ngainfld): 

87 thisgainfield=gainfield[igt] 

88 

89 # spwmap is null unless specifed 

90 thisspwmap=[-1] 

91 if (igt<nspwmap): 

92 thisspwmap=spwmap[igt]; 

93 

94 # interp is 'linear' unless specified 

95 thisinterp='linear' 

96 if (igt<ninterp): 

97 if (interp[igt]==''): 

98 interp[igt]=thisinterp; 

99 thisinterp=interp[igt]; 

100 

101 mycb.setapply(t=0.0,table=gaintable[igt],field=thisgainfield, 

102 calwt=True,spwmap=thisspwmap,interp=thisinterp) 

103 

104 # Set up for solving:  

105 mycb.setsolve(type='ACCOR',t=solint,combine=combine, 

106 table=caltable, append=append) 

107 mycb.solve() 

108 

109 finally: 

110 mycb.close( )