casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
uvcontsub.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_uvcontsub
00013 def uvcontsub(vis='', field='', fitspw='', combine='', solint='int', fitorder=0, spw='', want_cont=False):
00014 
00015         """Continuum fitting and subtraction in the uv plane
00016 
00017         Continuum fitting and subtraction in the uv plane:
00018         
00019         This task estimates the continuum emission by fitting polynomials to
00020         the real and imaginary parts of the spectral windows and channels
00021         selected by fitspw.  This fit represents a model of the continuum in 
00022         all channels.
00023         
00024         The fitted continuum spectrum is subtracted from all channels 
00025         selected in spw, and the result (presumably only line emission)
00026         is stored in a new MS (vis + ".contsub").
00027         It will read from the CORRECTED_DATA column of vis if it is present,
00028         or DATA if it is not.  Whichever column is read is presumed to have
00029         already been calibrated.
00030 
00031         If want_cont is True, the continuum fit is placed in a second new MS
00032         (vis + '.cont').  N.B. because the continuum model is necessarily a
00033         smoothed fit, images made with it are liable to have their field of
00034         view reduced in some strange way.  Images of the continuum should be
00035         made by simply excluding the line channels (and probably averaging the
00036         remaining ones) in clean.
00037 
00038         Keyword arguments:
00039         vis -- Name of input visibility file
00040                 default: none; example: vis='ngc5921.ms'
00041         field -- Field selection for continuum estimation and subtraction.
00042                  The estimation and subtraction is done for each selected field
00043                  in turn.  (Run listobs to get lists of the ID and names.)
00044                 default: field = '' means select all fields
00045                 field = 1 # will get field_id=1 (if you give it an 
00046                         integer, it will retrieve the source with that index.
00047                 field = '1328+307'  specifies source '1328+307'
00048                 field = '13*' will retrieve '1328+307' and any other fields
00049                    beginning with '13'
00050         fitspw -- Selection of spectral windows and channels to use in the
00051                   fit for the continuum, using general spw:chan syntax.
00052                   See the note under combine.
00053                 default: '' (all)
00054                 example: fitspw='0:5~30;40~55'
00055         combine -- Data axes to combine for the continuum estimate.
00056                 It must include 'spw' if spw contains spws that are not in
00057                 fitspw!
00058                 default: '' --> solutions will break at scan, field, and spw
00059                       boundaries according to solint
00060               Options: '', 'spw'', 'scan', or 'spw, scan'
00061               example: combine='spw' --> form spw-merged continuum estimate
00062         solint -- Timescale for per-baseline fit (units optional)
00063                 default (recommended): 'int' --> no time averaging, do a
00064                                        fit for each integration and let the
00065                                        noisy fits average out in the image.
00066 
00067                 example: solint='10s'  --> average to 10s before fitting
00068                          10 or '10' --> '10s' (unitless: assumes seconds)
00069                 options: 'int' --> per integration
00070                          'inf' --> per scan
00071 
00072                 If solint is longer than 'int', the continuum estimate can be
00073                 corrupted by time smearing!
00074 
00075         fitorder -- Polynomial order for the fits of the continuum w.r.t.
00076                     frequency.  fitorders > 1 are strongly discouraged
00077                     because high order polynomials have more flexibility, may
00078                     absorb line emission, and tend go wild at the edges of
00079                     fitspw, which is not what you want.
00080 
00081                 default: 0 (constant); example: fitorder=1
00082 
00083         spw -- Optional per spectral window selection of channels to include
00084                in the output.  See the note under combine.
00085 
00086                The spectral windows will be renumbered to start from 0, as in
00087                split.
00088         want_cont -- Create vis + '.cont' to hold the continuum estimate.
00089                 default: 'False'; example: want_cont=True
00090                 The continuum estimate will be placed in vis + '.cont'
00091         async -- Run task in a separate process (return CASA prompt)
00092                 default: False; example: async=True
00093 
00094 
00095         """
00096 
00097 #
00098 #    The following is work around to avoid a bug with current python translation
00099 #
00100         mytmp = {}
00101 
00102         mytmp['vis'] = vis
00103         mytmp['field'] = field
00104         mytmp['fitspw'] = fitspw
00105         mytmp['combine'] = combine
00106         mytmp['solint'] = solint
00107         mytmp['fitorder'] = fitorder
00108         mytmp['spw'] = spw
00109         mytmp['want_cont'] = want_cont
00110         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00111         trec = casac.utils().torecord(pathname+'uvcontsub.xml')
00112 
00113         casalog.origin('uvcontsub')
00114         if trec.has_key('uvcontsub') and casac.utils().verify(mytmp, trec['uvcontsub']) :
00115             result = task_uvcontsub.uvcontsub(vis, field, fitspw, combine, solint, fitorder, spw, want_cont)
00116 
00117         else :
00118           result = False
00119         return result