casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
task_importvla.py
Go to the documentation of this file.
00001 import os
00002 from taskinit import *
00003 
00004 def importvla(archivefiles,vis,
00005               bandname,frequencytol,
00006               project,
00007               starttime,stoptime,
00008               applytsys,
00009               autocorr,antnamescheme,keepblanks,evlabands):
00010         i=0
00011         overwrite=True
00012         ok = True
00013         try:
00014                 casalog.origin('importvla')
00015                 if ((type(vis)!=str) | (vis=='') | (os.path.exists(vis))): 
00016                         raise Exception, 'Need valid visibility file name (bad name or already exists)'
00017                 if (os.path.exists(vis)): raise Exception, 'Visibility file already exists - remove or rename'
00018                 for archivefile in archivefiles:
00019                         if i>0: overwrite=False
00020                         if ((type(archivefile)==str) & (os.path.exists(archivefile))):
00021                                 vlafiller(msname=vis,inputfile=archivefile,
00022                                           overwrite=overwrite,
00023                                           bandname=bandname,freqtol=frequencytol,
00024                                           project=project, start=starttime,
00025                                           stop=stoptime, applytsys=applytsys,
00026                                           keepautocorr=autocorr,
00027                                           antnamescheme=antnamescheme,
00028                                           keepblanks=keepblanks,
00029                                           evlabands=evlabands)
00030                                 i += 1
00031                         else:
00032                                 raise Exception, 'Archive file not found - please verify the name'
00033         except Exception, instance:
00034                 print '*** Error importing %s to %s:' % (archivefiles, vis)
00035                 raise Exception, instance
00036 
00037         # Write history
00038         try:
00039                 param_names = importvla.func_code.co_varnames[:importvla.func_code.co_argcount]
00040                 param_vals = [eval(p) for p in param_names]
00041                 ok &= write_history(mstool(), vis, 'importvla', param_names,
00042                                     param_vals, casalog)
00043         except Exception, instance:
00044                 casalog.post("*** Error \'%s\' updating HISTORY" % (instance),
00045                              'WARN')
00046 
00047         # write initial flag version
00048         try:
00049                 aflocal = casac.agentflagger()
00050                 ok &= aflocal.open(vis);
00051                 ok &= aflocal.saveflagversion('Original',
00052                                            comment='Original flags at import into CASA',
00053                                            merge='replace')
00054                 ok &= aflocal.done();
00055         except Exception, instance:
00056                 print '*** Error writing initial flag version of %s:' % vis
00057                 raise Exception, instance
00058 
00059