casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
msmoments.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_msmoments
00013 def msmoments(infile='', moments=[0], antenna='', field='', spw='', includemask=-1, excludemask=-1, outfile='', overwrite=False):
00014 
00015         """Compute moments from an MS
00016         The spectral moment distributions at each row in input MS are
00017         determined. Input MS must have FLOAT_DATA column, i.e. 
00018         autocorrelation data.  
00019         See the cookbook and User Reference Manual for
00020         mathematical details.
00021 
00022         The main control of the calculation is given by parameter
00023         moments:
00024         
00025         moments=-1  - mean value of the spectrum
00026         moments=0   - integrated value of the spectrum
00027         moments=1   - intensity weighted coordinate;traditionally used to get 
00028                       'velocity fields'
00029         moments=2   - intensity weighted dispersion of the coordinate; traditionally
00030                       used to get "velocity dispersion"
00031         moments=3   - median of I
00032         moments=4   - median coordinate
00033         moments=5   - standard deviation about the mean of the spectrum
00034         moments=6   - root mean square of the spectrum
00035         moments=7   - absolute mean deviation of the spectrum
00036         moments=8   - maximum value of the spectrum
00037         moments=9   - coordinate of the maximum value of the spectrum
00038         moments=10  - minimum value of the spectrum
00039         moments=11  - coordinate of the minimum value of the spectrum
00040 
00041         Note that includemask and excludemask cannot set simultaneously. 
00042 
00043         Keyword arguments:
00044         infile -- Name of input MS data
00045                 default: none; example: infile="OrionS_rawACSmod"
00046         moments -- List of moments you would like to compute
00047                 default: 0 (integrated spectrum);example: moments=[0,1]
00048                 see list above
00049         antenna -- antenna name or id that the user wants to compute moments
00050                 default: '' (all antennae)
00051         field -- field name or id that the user wants to compute moments
00052                 default: '' (all fields)
00053         spw -- spectral window id that the user wants to compute moments
00054                 default: '' (all spectral windows)
00055 
00056         includemask -- List of masks to include
00057                 default: [-1] (include all channels); example=[2,100]
00058         excludemask -- List of masks to exclude
00059                 default: [-1] (don't exclude channels); example=[100,200]
00060         outfile -- Output MS file name (or root for multiple moments)
00061                 default: '' (input+auto-determined suffix);example: outfile='source_moment'
00062         overwrite -- Overwrite existing output files
00063                 default: false
00064 
00065         Example for finding the 1-momment, intensity-weighted
00066         coordinate, often used for finding velocity fields.
00067         msmoments( infile='mydata', moment=1, outfile='velocityfields' )
00068 
00069 
00070         """
00071         if type(moments)==int: moments=[moments]
00072 
00073 #
00074 #    The following is work around to avoid a bug with current python translation
00075 #
00076         mytmp = {}
00077 
00078         mytmp['infile'] = infile
00079         mytmp['moments'] = moments
00080         mytmp['antenna'] = antenna
00081         mytmp['field'] = field
00082         mytmp['spw'] = spw
00083         mytmp['includemask'] = includemask
00084         mytmp['excludemask'] = excludemask
00085         mytmp['outfile'] = outfile
00086         mytmp['overwrite'] = overwrite
00087         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00088         trec = casac.utils().torecord(pathname+'msmoments.xml')
00089 
00090         casalog.origin('msmoments')
00091         if trec.has_key('msmoments') and casac.utils().verify(mytmp, trec['msmoments']) :
00092             result = task_msmoments.msmoments(infile, moments, antenna, field, spw, includemask, excludemask, outfile, overwrite)
00093 
00094         else :
00095           result = False
00096         return result