casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2007, Associated Universities Inc., Washington DC 00005 # 00006 import os 00007 from taskinit import * 00008 00009 def hanningsmooth(vis=None, datacolumn=None, outputvis=None): 00010 00011 """Hanning smooth frequency channel data to remove Gibbs ringing 00012 00013 hanningsmooth(vis='ngc5921.ms') 00014 00015 This function Hanning smooths the frequency channels with 00016 a weighted running average of smoothedData[i] = 00017 0.25*correctedData[i-1] + 0.50*correctedData[i] + 00018 0.25*correctedData[i+1]. The first and last channels are flagged. 00019 Inclusion of a flagged value in an average causes that data value 00020 to be flagged. 00021 00022 Keyword arguments: 00023 vis -- Name of input visibility file (MS) 00024 default: none; example: vis='ngc5921.ms' 00025 datacolumn -- the name of the MS column into which to write the smoothed data 00026 default='corrected'; example: datacolumn='data' 00027 options: 'corrected' or 'data' 00028 outputvis -- name of the output visibility file (MS) 00029 default=none (write to the input MS); example: outputvis='ngc5921_src.ms' 00030 00031 """ 00032 00033 #Python script 00034 # 00035 try: 00036 casalog.origin('hanningsmooth') 00037 casalog.post('vis=\''+vis+'\', datacolumn=\''+datacolumn+'\', outputvis=\''+outputvis+'\'', 'INFO') 00038 newvis = vis; 00039 00040 if os.path.exists(outputvis): 00041 ms.close() 00042 raise Exception, "Output MS %s already exists - will not overwrite." % outputvis 00043 00044 if(type(outputvis)==str and not outputvis==''): 00045 newvis = outputvis 00046 casalog.post('copying '+vis+' to '+newvis , 'INFO') 00047 tb.open(vis) 00048 tmptb = tb.copy(newvis, deep=True, valuecopy=True) 00049 tmptb.close() 00050 # note that the resulting copy is writable even if the original was read-only 00051 tb.close() 00052 else: 00053 newvis = vis 00054 00055 if ((type(newvis)==str) & (os.path.exists(newvis))): 00056 ms.open(thems=newvis,nomodify=False) 00057 else: 00058 raise Exception, 'Visibility data set not found - please verify the name' 00059 00060 ms.hanningsmooth(datacolumn=str.lower(datacolumn)) 00061 00062 # write history 00063 ms.writehistory(message='taskname = hanningsmooth',origin='hanningsmooth') 00064 ms.writehistory(message='vis = "'+str(vis)+'"',origin='hanningsmooth') 00065 ms.writehistory(message='datacolumn = "'+str(datacolumn)+'"',origin='hanningsmooth') 00066 ms.writehistory(message='outputvis = "'+str(outputvis)+'"',origin='hanningsmooth') 00067 ms.close() 00068 00069 except Exception, instance: 00070 print '*** Error ***',instance 00071 return