Commits

George Moellenbrock authored 8cc62cdc693
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
41 42 else:
42 43 casalog.post("No new caltable will be generated")
43 44 caltable=tablein
44 45 else:
45 46 raise Exception, 'input calibration table not found - please verify the name'
46 47
47 48
48 49 if paoffset!=0.0:
49 50 casalog.post("NB: default band position angle will be offset by "+str(paoffset)+"deg.")
79 80 decr=dirs[1,ifld]
80 81 IQUV[fldnames[ifld]]={}
81 82 for ispw in uspws:
82 83
83 84 r=mypl.zeros(nant)
84 85 q=mypl.zeros(nant)
85 86 u=mypl.zeros(nant)
86 87 antok=mypl.zeros(nant,dtype=bool)
87 88
88 89 for iant in range(nant):
89 - st=mytb.query('FIELD_ID=='+str(ifld)+' && SPECTRAL_WINDOW_ID=='+str(ispw)+' && ANTENNA1=='+str(iant))
90 + qstring='FIELD_ID=='+str(ifld)+' && SPECTRAL_WINDOW_ID=='+str(ispw)+' && ANTENNA1=='+str(iant)
91 + st=mytb.query(query=qstring)
90 92 nrows=st.nrows()
91 93 if nrows > 0:
92 94
93 95 times=st.getcol('TIME')
94 96 gains=st.getcol('CPARAM')
95 97 flags=st.getcol('FLAG')
96 98 flags=mypl.logical_or(flags[0,0,:],flags[1,0,:]) # 1D
97 99
98 100 # Escape if insufficient data
99 101 if (nrows-mypl.sum(flags))<3:
150 152
151 153 if rempol:
152 154 if p<1.0:
153 155 Qpsi=q[iant]*mypl.cos(2*parang) + u[iant]*mypl.sin(2*parang)
154 156 gains[0,0,:]/=mypl.sqrt(1.0+Qpsi)
155 157 gains[1,0,:]/=mypl.sqrt(1.0-Qpsi)
156 158 st.putcol('CPARAM',gains)
157 159 else:
158 160 st.close()
159 161 raise Exception, 'Spurious fractional polarization!'
160 -
162 +
161 163 st.close()
162 164
163 165 nantok=mypl.sum(antok)
164 166 if nantok>0:
165 167 Q[ispw,ifld]=mypl.sum(q)/nantok
166 168 U[ispw,ifld]=mypl.sum(u)/nantok
167 169 R[ispw,ifld]=mypl.sum(r)/nantok
168 170 mask[ispw,ifld]=True
169 171
170 172 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