Commits

Darrell Schiebel authored f5ce24ff1c6 Merge
Merge pull request #1086 in CASA/casa from bugfix/CAS-12603 to master

* commit '95ca29a5954f9d4735b028be8c51ecbdf830adca': Trivial change to trigger bamboo re-builds... CAS-12603: Fix additional dangling table cache issues which occurs in inner antenna loop when insufficient data triggers a continue (added missing st.close()). CAS-12603: Added close of the table tool created by the deep copy of the input table, so it doesn't get stuck in the table cache.

gcwrap/python/scripts/task_polfromgain.py

Modified
28 28
29 29 rempol=False
30 30 if ((type(tablein)==str) & (os.path.exists(tablein))):
31 31 if type(caltable)==str and len(caltable)>0:
32 32
33 33 if os.path.exists(caltable):
34 34 raise Exception, 'Output caltable='+caltable+' exists. Choose another name or delete it.'
35 35
36 36 casalog.post("New caltable, "+caltable+", corrected for linear polarization, will be generated.")
37 37 mytb.open(tablein)
38 - mytb.copy(newtablename=caltable,deep=True)
38 + myout=mytb.copy(newtablename=caltable,deep=True)
39 39 mytb.close()
40 + myout.close()
40 41 rempol=True
42 +
41 43 else:
42 44 casalog.post("No new caltable will be generated")
43 45 caltable=tablein
44 46 else:
45 47 raise Exception, 'input calibration table not found - please verify the name'
46 48
47 49
48 50 if paoffset!=0.0:
49 51 casalog.post("NB: default band position angle will be offset by "+str(paoffset)+"deg.")
50 52
79 81 decr=dirs[1,ifld]
80 82 IQUV[fldnames[ifld]]={}
81 83 for ispw in uspws:
82 84
83 85 r=mypl.zeros(nant)
84 86 q=mypl.zeros(nant)
85 87 u=mypl.zeros(nant)
86 88 antok=mypl.zeros(nant,dtype=bool)
87 89
88 90 for iant in range(nant):
89 - st=mytb.query('FIELD_ID=='+str(ifld)+' && SPECTRAL_WINDOW_ID=='+str(ispw)+' && ANTENNA1=='+str(iant))
91 + qstring='FIELD_ID=='+str(ifld)+' && SPECTRAL_WINDOW_ID=='+str(ispw)+' && ANTENNA1=='+str(iant)
92 + st=mytb.query(query=qstring)
90 93 nrows=st.nrows()
91 94 if nrows > 0:
92 95
93 96 times=st.getcol('TIME')
94 97 gains=st.getcol('CPARAM')
95 98 flags=st.getcol('FLAG')
96 99 flags=mypl.logical_or(flags[0,0,:],flags[1,0,:]) # 1D
97 100
98 101 # Escape if insufficient data
99 102 if (nrows-mypl.sum(flags))<3:
100 103 antok[iant]=False
104 + st.close()
101 105 continue
102 106
103 107
104 108 # parang
105 109 parang=mypl.zeros(len(times))
106 110
107 111 apos=mymd.antennaposition(iant)
108 112 latr=myme.measure(apos,'WGS84')['m1']['value']
109 113 myme.doframe(apos)
110 114 har=mypl.zeros(nrows)
150 154
151 155 if rempol:
152 156 if p<1.0:
153 157 Qpsi=q[iant]*mypl.cos(2*parang) + u[iant]*mypl.sin(2*parang)
154 158 gains[0,0,:]/=mypl.sqrt(1.0+Qpsi)
155 159 gains[1,0,:]/=mypl.sqrt(1.0-Qpsi)
156 160 st.putcol('CPARAM',gains)
157 161 else:
158 162 st.close()
159 163 raise Exception, 'Spurious fractional polarization!'
160 -
164 +
161 165 st.close()
162 166
163 167 nantok=mypl.sum(antok)
164 168 if nantok>0:
165 169 Q[ispw,ifld]=mypl.sum(q)/nantok
166 170 U[ispw,ifld]=mypl.sum(u)/nantok
167 171 R[ispw,ifld]=mypl.sum(r)/nantok
168 172 mask[ispw,ifld]=True
169 173
170 174 P=sqrt(Q[ispw,ifld]**2+U[ispw,ifld]**2)

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut