casa
$Rev:20696$
|
00001 from taskinit import * 00002 00003 def peel(vis, ptcs=None, remove=None, calmode=None): 00004 casalog.origin('peel') 00005 for arg in ('vis', 'ptcs', 'remove', 'calmode'): 00006 casalog.post("parameter %7s: %s" % (arg, eval(arg)), 'DEBUG1') 00007 00008 try: 00009 tb.open(vis) 00010 00011 # What's here is a modification of James Miller-Jones' script. 00012 nvis=tb.nrows() 00013 00014 start = 0 00015 incr = 10000 00016 while start < nvis: 00017 print start, 'of', nvis 00018 if(nvis - start < incr): 00019 incr = nvis - start 00020 model = numpy.array(tb.getcol('MODEL_DATA', startrow=start, 00021 nrow=incr)) 00022 corr = numpy.array(tb.getcol('CORRECTED_DATA', startrow=start, 00023 nrow=incr)) 00024 for k in range(incr): 00025 corr[:, :, k] = corr[:, :, k] - model[:, :, k] 00026 tb.putcol('CORRECTED_DATA', corr.tolist(), startrow=start, 00027 nrow=incr) 00028 start += incr 00029 tb.close() 00030 00031 tb.open(vis + 'selfcal_all_ap.tab', nomodify=False) 00032 start = 0 00033 incr = 10000 00034 while start < nvis: 00035 print start, 'of', nvis 00036 if(nvis - start < incr): 00037 incr = nvis - start 00038 g = tb.getcol('GAIN', startrow=start, nrow=incr) 00039 mask = abs(g) > 0.0 00040 g[mask] = 1.0 / g[mask] 00041 tb.putcol('GAIN', g, startrow=start, nrow=incr) 00042 start += incr 00043 00044 start = 0 00045 incr = 10000 00046 while start < nvis: 00047 print start, 'of', nvis 00048 if(nvis - start < incr): 00049 incr = nvis - start 00050 00051 data = numpy.array(tb.getcol('DATA', startrow=start, nrow=incr)) 00052 corr = numpy.array(tb.getcol('CORRECTED_DATA', startrow=start, 00053 nrow=incr)) 00054 for k in range(incr): 00055 corr[:, :, k] = data[:, :, k] 00056 00057 tb.putcol('CORRECTED_DATA', corr.tolist(), startrow=start, 00058 nrow=incr) 00059 00060 # End of James' script. 00061 tb.close() 00062 except Exception, instance: 00063 casalog.post('*** Error *** ' + str(instance), 'SEVERE') 00064 return