Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_blcal.py: 11%
45 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:10 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:10 +0000
1import os
2import numpy as np
4from casatasks import casalog
5from casatools import calibrater
7def blcal(vis=None,caltable=None,
8 field=None,spw=None,intent=None,
9 selectdata=None,timerange=None,uvrange=None,antenna=None,scan=None,
10 observation=None, msselect=None,
11 solint=None,combine=None,freqdep=None,calmode=None,solnorm=None,
12 gaintable=None,gainfield=None,interp=None,spwmap=None,
13 parang=None):
15 #Python script
17 try:
19 mycb = calibrater()
21 casalog.origin('blcal')
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 mycb.reset()
29 # Do data selection according to selectdata
30 if (selectdata):
31 # pass all data selection parameters in as specified
32 mycb.selectvis(time=timerange,spw=spw,scan=scan,field=field,
33 intent=intent, observation=str(observation),
34 baseline=antenna,uvrange=uvrange,chanmode='none',
35 msselect=msselect);
36 else:
37 # selectdata=F, so time,scan,baseline,uvrange,msselect=''
38 # using spw and field specifications only
39 mycb.selectvis(time='',spw=spw,scan='',field=field,intent=intent,
40 baseline='',uvrange='',chanmode='none',
41 observation='', msselect='')
44 # Arrange apply of existing other calibrations
45 # First do the existing cal tables...
46 ngaintab = 0;
47 if (gaintable!=['']):
48 ngaintab=len(gaintable)
49 ngainfld = len(gainfield)
50 nspwmap = len(spwmap)
51 ninterp = len(interp)
53 # handle list of list issues with spwmap
54 if (nspwmap>0):
55 if (type(spwmap[0])!=list):
56 # first element not a list, only one spwmap specified
57 # make it a list of list
58 spwmap=[spwmap];
59 nspwmap=1;
61 for igt in range(ngaintab):
62 if (gaintable[igt]!=''):
64 # field selection is null unless specified
65 thisgainfield=''
66 if (igt<ngainfld):
67 thisgainfield=gainfield[igt]
69 # spwmap is null unless specifed
70 thisspwmap=[-1]
71 if (igt<nspwmap):
72 thisspwmap=spwmap[igt];
74 # interp is 'linear' unless specified
75 thisinterp='linear'
76 if (igt<ninterp):
77 if (interp[igt]==''):
78 interp[igt]=thisinterp
79 thisinterp=interp[igt]
81 mycb.setapply(t=0.0,table=gaintable[igt],field=thisgainfield,
82 calwt=True,spwmap=thisspwmap,interp=thisinterp)
84 # ...and now the specialized terms
85 # (BTW, interp irrelevant for these, since they are evaluated)
87 # Apply parallactic angle, if requested
88 if parang: mycb.setapply(type='P')
90 # Set up the solve
91 if freqdep:
92 mycb.setsolve(type='MF',t=solint,combine=combine,refant='',table=caltable,apmode=calmode,solnorm=solnorm)
93 else:
94 mycb.setsolve(type='M',t=solint,combine=combine,refant='',table=caltable,apmode=calmode,solnorm=solnorm)
96 mycb.solve()
97 finally:
98 mycb.close()