casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
virtualconcat.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_virtualconcat
00013 def virtualconcat(vis=[''], concatvis='', freqtol='', dirtol='', respectname=True, visweightscale=[], keepcopy=False, copypointing=True):
00014 
00015         """Concatenate several visibility data sets into a multi-MS
00016 
00017 The list of data sets given in the vis argument are moved into an output
00018 multi-MS data set concatvis and virtually concatenated. 
00019 
00020 NOTE: This task will modify the input datasets by moving them and reindexing them.
00021 If you want to keep a copy of your original data, please set the parameter 
00022 keepcopy to True.
00023 
00024 There is no limit to the number of input data sets.
00025 
00026 If none of the input data sets have any scratch columns (model and corrected
00027 columns), none are created in the concatvis.  Otherwise these columns are
00028 created on output and initialized to their default value (1 in model column,
00029 data in corrected column) for those data with no input columns.
00030 
00031 Spectral windows for each data set with the same chanelization, and within a
00032 specified frequency tolerance of another data set will be combined into one
00033 spectral window.
00034 
00035 A field position in one data set that is within a specified direction tolerance
00036 of another field position in any other data set will be combined into one
00037 field.  The field names need not be the same---only their position is used.
00038 
00039 Each appended dataset is assigned a new observation id if the corresponding
00040 rows in the observation table are not the same.
00041 
00042 Keyword arguments:
00043 vis -- Name of input visibility files to be combined
00044         default: none; example: vis = ['src2.ms','ngc5921.ms','ngc315.ms']
00045 concatvis -- Name of visibility file that will contain the concatenated data
00046         note: if this file exits on disk then the input files are 
00047               added to this file.  Otherwise the new file contains  
00048               the concatenated data.  Be careful here when concatenating to
00049               an existing file.
00050         default: none; example: concatvis='src2.ms'
00051                  example: concatvis='outvis.ms'
00052 
00053         other examples: 
00054            virtualconcat(vis=['src2.ms','ngc5921.ms'], concatvis='out.mms') 
00055                will concatenate 'ngc5921.ms' and 'src2.ms' into a file named 
00056                'out.mms'; the original 'ngc5921.ms' and 'src2.ms' are gone.
00057                'out.mms' is a multims. As most of the data is only moved, not 
00058                copied, this is faster and subsequent tasks can run in parallel
00059                on the subMSs of out.mms.
00060            virtualconcat(vis=['src2.ms','ngc5921.ms'], concatvis='out.mms', keepcopy=True) 
00061                will concatenate 'ngc5921.ms' and 'src2.ms' into a file named 
00062                'out.mms'; the original 'ngc5921.ms' and 'src2.ms' are as before
00063                but you consume more disk space and time for the copy.
00064                .
00065 
00066      Note: run flagmanager to save flags in the concatvis
00067 
00068 freqtol -- Frequency shift tolerance for considering data to be in the same
00069            spwid.  The number of channels must also be the same.
00070         default: ''  do not combine unless frequencies are equal
00071         example: freqtol='10MHz' will not combine spwid unless they are
00072            within 10 MHz.
00073         Note: This option is useful to conbine spectral windows with very slight
00074            frequency differences caused by Doppler tracking, for example.
00075 
00076 dirtol -- Direction shift tolerance for considering data as the same field
00077         default: '' means always combine.
00078         example: dirtol='1.arcsec' will not combine data for a field unless
00079            their phase center differ by less than 1 arcsec.  If the field names
00080            are different in the input data sets, the name in the output data
00081            set will be the first relevant data set in the list.
00082 
00083 respectname -- If true, fields with a different name are not merged even if their 
00084         direction agrees (within dirtol). 
00085         default: True
00086 
00087 visweightscale -- The weights of the individual MSs will be scaled in the concatenated
00088         output MS by the factors in this list. Useful for handling heterogeneous arrays.
00089         Use plotms to inspect the "Wt" column as a reference for determining the scaling 
00090         factors. See the cookbook for more details.
00091         example: [1.,3.,3.] - scale the weights of the second and third MS by a factor 3.
00092         default: [] (empty list) - no scaling
00093 
00094 keepcopy -- If true, a copy of the input MSs is kept in their original place.
00095         default: false
00096 
00097 copypointing -- If true, the POINTING table information will be present in the output.
00098                 If false, the result is an empty POINTING table.
00099          default: true
00100 
00101 
00102         """
00103         if type(vis)==str: vis=[vis]
00104         if type(visweightscale)==float: visweightscale=[visweightscale]
00105 
00106 #
00107 #    The following is work around to avoid a bug with current python translation
00108 #
00109         mytmp = {}
00110 
00111         mytmp['vis'] = vis
00112         mytmp['concatvis'] = concatvis
00113         mytmp['freqtol'] = freqtol
00114         mytmp['dirtol'] = dirtol
00115         mytmp['respectname'] = respectname
00116         mytmp['visweightscale'] = visweightscale
00117         mytmp['keepcopy'] = keepcopy
00118         mytmp['copypointing'] = copypointing
00119         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00120         trec = casac.utils().torecord(pathname+'virtualconcat.xml')
00121 
00122         casalog.origin('virtualconcat')
00123         if trec.has_key('virtualconcat') and casac.utils().verify(mytmp, trec['virtualconcat']) :
00124             result = task_virtualconcat.virtualconcat(vis, concatvis, freqtol, dirtol, respectname, visweightscale, keepcopy, copypointing)
00125 
00126         else :
00127           result = False
00128         return result