Commits

George Moellenbrock authored f717e3cb890
For CAS-13523, fixsyscaltimes now returns True if MS.SYSCAL subtable's TIME/INTERVAL are corrected; returns False otherwise.

Also added a console message indicating same.

casa5/gcwrap/python/scripts/recipes/almahelpers.py

Modified
1 1 #!/usr/bin/env python
2 2 #
3 3 # almahelpers.py
4 4 #
5 5 # History:
6 6 # v1.0 (scorder, gmoellen, jkern; 2012Apr26) == initial version
7 7 # v1.1 (gmoellen; 2013Mar07) Lots of improvements from Eric Villard
8 8 # v1.2 (gmoellen; 2013Apr09) Added fixsyscaltimes and calantsub methods
9 9 # to handle Tsys irregularities
10 10 # v1.3 (dpetry; 2017Sept11) Added genImageName
11 +# v1.4 (gmoellen; 2021Jul08) fixsyscaltimes now returns True if a fix
12 +# was applied, otherwise returns False
11 13 #
12 14 # This script defines several functions useful for ALMA data processing.
13 15 #
14 16 # tsysspwmap - generate an "applycal-ready" spwmap for TDM to FDM
15 17 # transfer of Tsys
16 18 # fixsyscaltimes - repairs the TIME and INTERVAL columns of the MS
17 19 # SYSCAL subtable so that gencal properly generates
18 20 # the Tsys caltable
19 21 # calantsub - provides for substitution of cal solutions by antenna
20 22 #
209 211 """
210 212
211 213 import pylab as mypl
212 214 import math as mymath
213 215 myqa=taskinit.qatool()
214 216 mytb=taskinit.tbtool()
215 217 mytb.open(vis+'/SYSCAL',nomodify=False)
216 218
217 219 spws=mypl.unique(mytb.getcol("SPECTRAL_WINDOW_ID"))
218 220
221 + # Nominally, no fix applied
222 + fixapplied=False
223 +
219 224 for ispw in spws:
220 225 st=mytb.query('SPECTRAL_WINDOW_ID=='+str(ispw),name='byspw')
221 226 times=st.getcol('TIME')
222 227 interval=st.getcol('INTERVAL')
223 228 timestamps=times-interval/2
224 229 t0=86400.0*mymath.floor(timestamps[0]/86400.0)
225 230
226 231 utimes=mypl.unique(times-t0)
227 232 nT=len(utimes)
228 233 utimestamps=mypl.unique(mypl.floor(timestamps)-t0)
229 234 nTS=len(utimestamps)
230 235
231 236 msg='In spw='+str(ispw)+' found '+str(nTS)+' Tsys measurements with '+str(nT)+' TIMEs...'
232 237 if nT==nTS:
233 238 msg+='OK.'
234 239 print msg
235 240
236 241 else:
242 + # If we reach here, then a fix is being applied, and we'll return True
243 + fixapplied=True
244 +
237 245 msg+=' which is too many, so fixing it:'
238 246 print msg
239 247
240 248 for uts in utimestamps:
241 249 mask = ((mypl.floor(timestamps))-t0==uts)
242 250 uTIMEs=mypl.unique(times[mask])
243 251 nTIMEs=len(uTIMEs)
244 252 newtime = mypl.mean(times[mask]-interval[mask]/2) + newinterval/2
245 253 msg=' Found '+str(nTIMEs)+' TIMEs at timestamp='+str(myqa.time(str(newtime-newinterval/2)+'s',form='ymd')[0])
246 254 if nTIMEs>1:
250 258 times[mask]=newtime
251 259 interval[mask]=newinterval
252 260 st.putcol('TIME',times)
253 261 st.putcol('INTERVAL',interval)
254 262 else:
255 263 msg+='...ok.'
256 264 print msg
257 265 st.close()
258 266 mytb.close()
259 267
268 + if fixapplied:
269 + print('Some SYSCAL time corrections have been applied.')
270 + else:
271 + print('All SYSCAL times seem correct; no changes required.')
272 +
273 + # Return if a fix has been applied
274 + return fixapplied
275 +
260 276
261 277 def calantsub(incaltable,outcaltable='',
262 278 spw='',scan='',
263 279 ant='',subant=''):
264 280
265 281 """
266 282 Substitute cal solutions by antenna
267 283 Input:
268 284 incaltable Input caltable
269 285 outcaltable Output caltable (if '', overwrite result on incaltable)

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

Add shortcut