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 19:53 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
1import os
2import numpy as np
4from casatools import calibrater
5from casatasks import casalog
6from .callibrary import *
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):
16 #Python script
17 casalog.origin('accor')
19 try:
20 mycb = calibrater()
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')
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'
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')
49 # signal use of correlation-dependent flags, if requested
50 if corrdepflags:
51 mycb.setcorrdepflags(True)
53 # Arrange applies....
55 if docallib:
56 # by cal library from file
57 mycallib=callibrary()
58 mycallib.read(callib)
59 mycb.setcallib(mycallib.cld)
61 else:
63 # by traditional parameters
65 ngaintab = 0;
66 if (gaintable!=['']):
67 ngaintab=len(gaintable)
69 ngainfld = len(gainfield)
70 nspwmap = len(spwmap)
71 ninterp = len(interp)
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;
81 for igt in range(ngaintab):
82 if (gaintable[igt]!=''):
84 # field selection is null unless specified
85 thisgainfield=''
86 if (igt<ngainfld):
87 thisgainfield=gainfield[igt]
89 # spwmap is null unless specifed
90 thisspwmap=[-1]
91 if (igt<nspwmap):
92 thisspwmap=spwmap[igt];
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];
101 mycb.setapply(t=0.0,table=gaintable[igt],field=thisgainfield,
102 calwt=True,spwmap=thisspwmap,interp=thisinterp)
104 # Set up for solving:
105 mycb.setsolve(type='ACCOR',t=solint,combine=combine,
106 table=caltable, append=append)
107 mycb.solve()
109 finally:
110 mycb.close( )