casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
hanningsmooth.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2009, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from  casac import *
00009 import string
00010 from taskinit import casalog
00011 #from taskmanager import tm
00012 import task_hanningsmooth
00013 def hanningsmooth(vis='', datacolumn='all', outputvis=''):
00014 
00015         """Hanning smooth frequency channel data to remove Gibbs ringing
00016 
00017     This function Hanning smoothes the frequency channels with
00018     a weighted running average. The weights are 0.5 for the central 
00019     channel and 0.25 for each of the two adjacent channels. The first 
00020     and last channels are flagged.
00021     Inclusion of a flagged value in an average causes that data value
00022     to be flagged. 
00023     If an 'outputvis' filename is given, the task will copy the input file to the 
00024     output file name first, including all columns that are present in the input MS. 
00025     After that step it will smooth the column(s) as requested in the 'datacolumn' parameter. 
00026     Alternatively, if no 'outputvis' is specified, hanningsmooth will work directly on the 
00027     input visibility file. 
00028     If the 'CORRECTED' data column is requested for an MS that does not contain this column, 
00029     it will be filled from the 'DATA' column and then smoothed.
00030     
00031     WARNING: by default, all visibility columns will be smoothed. This will 
00032              modify the DATA column of the output MS in order to make sure that
00033              later gaincal will work on the smoothed data, e.g. as part of self-cal.
00034 
00035     Keyword arguments:
00036     vis -- Name of input visibility file (MS)
00037            default: none; example: vis='ngc5921.ms'
00038     datacolumn -- the name of the MS column to be Hanning smoothed
00039                   default='all'; example: datacolumn='corrected'
00040                   options: 'corrected', 'data', 'all'
00041     outputvis -- name of the output visibility file (MS)
00042                  default=none (write to the input MS); example: outputvis='ngc5921_src.ms'
00043 
00044     hanningsmooth(vis='ngc4852.ms', datacolumn='data', outputvis='ngc4852-hs.ms')                
00045 
00046 
00047  
00048         """
00049 
00050 #
00051 #    The following is work around to avoid a bug with current python translation
00052 #
00053         mytmp = {}
00054 
00055         mytmp['vis'] = vis
00056         mytmp['datacolumn'] = datacolumn
00057         mytmp['outputvis'] = outputvis
00058         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00059         trec = casac.utils().torecord(pathname+'hanningsmooth.xml')
00060 
00061         casalog.origin('hanningsmooth')
00062         if trec.has_key('hanningsmooth') and casac.utils().verify(mytmp, trec['hanningsmooth']) :
00063             result = task_hanningsmooth.hanningsmooth(vis, datacolumn, outputvis)
00064 
00065         else :
00066           result = False
00067         return result