casa
$Rev:20696$
|
00001 import os 00002 from taskinit import * 00003 00004 def importuvfits(fitsfile, vis, antnamescheme=None): 00005 """ 00006 00007 Convert a UVFITS file to a CASA visibility data set (MS): 00008 00009 Keyword arguments: 00010 fitsfile -- Name of input UV FITS file 00011 default = none; example='3C273XC1.fits' 00012 vis -- Name of output visibility file (MS) 00013 default = none; example: vis='3C273XC1.ms' 00014 antnamescheme -- Naming scheme for VLA/JVLA/CARMA antennas 00015 default = old; 00016 old: Antenna name is a number, '04' 00017 This option exists for backwards compatibility 00018 but can lead to ambiguous results when antenna 00019 indices are used for data selection. 00020 new: Antenna name is not a number, 'VA04' or 'EA04' 00021 With this scheme, data selection via 00022 antenna names and indices is non-ambiguous. 00023 async -- Run asynchronously 00024 default = false; do not run asychronously 00025 00026 00027 """ 00028 00029 #Python script 00030 00031 ok = True 00032 try: 00033 casalog.origin('importuvfits') 00034 casalog.post("") 00035 myms = mstool() 00036 myms.fromfits(vis, fitsfile, antnamescheme=antnamescheme) 00037 myms.close() 00038 except Exception, instance: 00039 ok = False 00040 casalog.post("Failed to import %s to %s" % (fitsfile, vis)) 00041 00042 if not ok: 00043 return; 00044 00045 # Write the args to HISTORY. 00046 try: 00047 param_names = \ 00048 importuvfits.func_code.co_varnames[:importuvfits.func_code.co_argcount] 00049 param_vals = [eval(p) for p in param_names] 00050 ok &= write_history(myms, vis, 'importuvfits', param_names, 00051 param_vals, casalog) 00052 except Exception, instance: 00053 casalog.post("Failed to updated HISTORY table", 'WARN') 00054 00055 #if not ok: 00056 # return; 00057 00058 #sleep(1) 00059 # save original flagversion 00060 #try: 00061 #aflocal = aftool() 00062 #ok &= aflocal.open(vis) 00063 #ok &= aflocal.saveflagversion('Original', 00064 #comment='Original flags at import into CASA', 00065 #merge='replace') 00066 #ok &= aflocal.done() 00067 #except Exception, instance: 00068 #casalog.post('Failed to save original flags', 'WARN') 00069 #raise Exception #, instance