casa
$Rev:20696$
|
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_exportuvfits 00013 def exportuvfits(vis='', fitsfile='', datacolumn='corrected', field='', spw='', antenna='', timerange='', avgchan=1, writesyscal=False, multisource=True, combinespw=True, writestation=True, padwithflags=False): 00014 00015 """Convert a CASA visibility data set to a UVFITS file: 00016 00017 This task writes a UVFITS file, a general format data set used 00018 to transfer data between different software systems. It is 00019 written in floating point format. Different programs have different 00020 restrictions on what forms of UVFITS files they will use, especially 00021 whether they will accept multiple sources and/or spectral windows in 00022 the same file. See the spw, multisource, and combinespw descriptions 00023 below. 00024 00025 Keyword arguments: 00026 vis -- Name of input visibility file 00027 default: none; example: vis='ngc5921.ms' 00028 fitsfile -- Name of output UV FITS file 00029 default: none; example='3C273XC1.fits' 00030 datacolumn -- Visibility file data column 00031 default: => 'corrected'; example: datacolumn='model' 00032 Options: 'data' (raw),'corrected','model','weight' 00033 field -- Select field using field id(s) or field name(s). 00034 [run listobs to obtain the list id's or names] 00035 default: ''=all fields 00036 If field string is a non-negative integer, it is assumed a field index 00037 otherwise, it is assumed a field name 00038 field='0~2'; field ids 0,1,2 00039 field='0,4,5~7'; field ids 0,4,5,6,7 00040 field='3C286,3C295'; field named 3C286 adn 3C295 00041 field = '3,4C*'; field id 3, all names starting with 4C 00042 spw -- Select spectral window/channels 00043 type 'help par.selection' for more examples. 00044 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00045 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00046 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00047 spw='*:5~61'; all spw with channels 5 to 62 00048 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00049 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00050 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00051 NOTE ';' to separate channel selections 00052 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00053 spw 1, channels 20,25,30 00054 antenna -- Select data based on antenna/baseline 00055 default: '' (all) 00056 If antenna string is a non-negative integer, it is assumed 00057 an antenna index 00058 otherwise, it is assumed as an antenna name 00059 antenna='5&6'; baseline between antenna index 5 and index 6. 00060 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00061 antenna='5&6;7&8'; baseline 5-6 and 7-8 00062 antenna='5'; all baselines with antenna index 5 00063 antenna='05'; all baselines with antenna name '05', vla antenna 00064 antenna='5,6,10'; all baselines with antennas 5, 6 and 10 00065 timerange -- Select data based on time range: 00066 default = '' (all); examples, 00067 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00068 Note: if YYYY/MM/DD is missing dat defaults to first day in data set 00069 timerange='09:14:0~09:54:0' picks 40 min on first day 00070 timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00071 timerange='09:44:00' data within one integration of time 00072 timerange='>10:24:00' data after this time 00073 avgchan -- Channel averaging width (value > 1 indicates averaging) 00074 default =>1; example: avgchan=3 00075 output data will average channels in groups of three. 00076 multisource -- Write in multi-source format 00077 default: => True; 00078 false if one source is selected 00079 True works with AIPS, but not difmap. 00080 combinespw -- If True, export the spectral windows as IFs. 00081 Otherwise multiple windows will use multiple FREQIDs. 00082 default: => True; 00083 all spectral windows must have same shape. 00084 True is recommended for AIPS, and mandatory for difmap. 00085 padwithflags -- If True, and combinespw is True, fill in missing 00086 data as needed to fit the IF structure. This is 00087 appropriate if the MS had a few frequency-dependent 00088 flags applied, and was then time-averaged by split, or 00089 when exporting for use by difmap. If the spectral 00090 windows were observed at different times, 00091 padwithflags=True will add a large number of flags, 00092 making the output file significantly longer. It does 00093 not yet support spectral windows with different widths. 00094 writestation -- Write station name instead of antenna name 00095 default: True; 00096 writesyscal -- Write GC and TY tables 00097 default: => False; Not yet available 00098 async -- Run asynchronously 00099 default = False; 00100 00101 00102 """ 00103 00104 # 00105 # The following is work around to avoid a bug with current python translation 00106 # 00107 mytmp = {} 00108 00109 mytmp['vis'] = vis 00110 mytmp['fitsfile'] = fitsfile 00111 mytmp['datacolumn'] = datacolumn 00112 mytmp['field'] = field 00113 mytmp['spw'] = spw 00114 mytmp['antenna'] = antenna 00115 mytmp['timerange'] = timerange 00116 mytmp['avgchan'] = avgchan 00117 mytmp['writesyscal'] = writesyscal 00118 mytmp['multisource'] = multisource 00119 mytmp['combinespw'] = combinespw 00120 mytmp['writestation'] = writestation 00121 mytmp['padwithflags'] = padwithflags 00122 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00123 trec = casac.utils().torecord(pathname+'exportuvfits.xml') 00124 00125 casalog.origin('exportuvfits') 00126 if trec.has_key('exportuvfits') and casac.utils().verify(mytmp, trec['exportuvfits']) : 00127 result = task_exportuvfits.exportuvfits(vis, fitsfile, datacolumn, field, spw, antenna, timerange, avgchan, writesyscal, multisource, combinespw, writestation, padwithflags) 00128 00129 else : 00130 result = False 00131 return result