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_sdsave 00013 def sdsave(infile='', antenna=0, getpt=True, rowlist=[], scanlist=[], field='', iflist=[], pollist=[], scanaverage=False, timeaverage=False, tweight='none', polaverage=False, pweight='none', restfreq='', outfile='', outform='ASAP', overwrite=False): 00014 00015 """ASAP SD task: save the sd spectra in various format 00016 Keyword arguments: 00017 infile -- name of input SD dataset 00018 antenna -- antenna name or id (only effective for MS input). 00019 getpt -- fill DIRECTION column properly, or reuse POINTING table 00020 in original MS (only effective for MS input) 00021 default: True 00022 options: True (fill DIRECTION column properly) 00023 False (reuse POINTING table in original MS) 00024 rowlist -- list of row numbers to process 00025 default: [] (use all rows) 00026 example: [0,2,4,6] 00027 For expert users only! 00028 this selection is applied first, and then followed by 00029 the selection with scans, fields, ifs, and polarizations. 00030 scanlist -- list of to process 00031 default: [] (use all scans) 00032 example: [21,22,23,24] 00033 this selection is in addition to field, iflist, and pollist 00034 field -- selection string for selecting scans by name 00035 default: '' (no name selection) 00036 example: 'FLS3a*' 00037 this selection is in addition to scanlist, iflist, and pollist 00038 iflist -- list of IF id numbers to select 00039 default: [] (use all IFs) 00040 example: [15] 00041 this selection is in addition to scanlist, field, and pollist 00042 pollist -- list of polarization id numbers to select 00043 default: [] (use all polarizations) 00044 example: [1] 00045 this selection is in addition to scanlist, field, and iflist 00046 scanaverage -- average integrations within scans 00047 options: (bool) True,False 00048 default: False 00049 example: if True, average integrations before it is saved 00050 timeaverage -- average times for multiple scan cycles 00051 options: (bool) True,False 00052 default: False 00053 >>>timeaverage expandable parameter 00054 tweight -- weighting for time average 00055 options: 'none' 00056 'var' (1/var(spec) weighted) 00057 'tsys' (1/Tsys**2 weighted) 00058 'tint' (integration time weighted) 00059 'tintsys' (Tint/Tsys**2) 00060 'median' ( median averaging) 00061 default: 'none' 00062 00063 polaverage -- average polarizations 00064 options: (bool) True,False 00065 default: False 00066 >>>polaverage expandable parameter 00067 pweight -- weighting for polarization average 00068 options: 'none' 00069 'var' (1/var(spec) weighted) 00070 'tsys' (1/Tsys**2 weighted) 00071 restfreq -- rest frequencies of output data 00072 Available types are a number, string, a list of numbers or 00073 strings (see examples below), and list of dictionaries. 00074 The default unit of restfreq is Hz, if not specified. 00075 A list can be used to set different rest frequencies to 00076 each IF. the length of list input must be nIF. Dictionary 00077 input should be a pair of molecule name and frequency with 00078 keys of 'name' and 'value', respectively. The 'value's in the 00079 dictionary input follows the same manner as for single 00080 float or string input. 00081 default: '' (use current setting) 00082 example: 4.6e10 (float value in Hz), 00083 '46GHz' (string with unit), 00084 ['345.8GHz', '347.0GHz', 356.7e9] (for each IF) 00085 [{'name':'CO','value':345e9}] (a value with name) 00086 outfile -- name of output dataset 00087 default: '' 00088 outform -- output data format 00089 default: 'ASAP' 00090 Options: 'ASAP', 'MS2', 'SDFITS', 'ASCII' 00091 overwrite -- overwrite the output file if already exists 00092 options: (bool) True,False 00093 default: False 00094 WARNING: if outform='ASCII', this parameter is ignored 00095 00096 00097 DESCRIPTION: 00098 00099 Task sdsave writes the single dish data to a disk file in 00100 specified format (ASAP, MS2, SDFITS, ASCII). It is possible to 00101 save the subset of the data by selecting row numbers, scan numbers, 00102 IF ids, polarization ids and field names. The ASAP (scantable) format 00103 is recommended for further analysis using Sd tool. For further 00104 imaging using imager, save the data to the Measurement Set (MS2). 00105 00106 Note that setting getpt=False needs a lot of attention. 00107 If you set getpt=False, the task retrieves pointing direction from 00108 MS's FIELD table, which might not be correct for single dish 00109 observation, instead to check MS's POINTING table, which is the 00110 default behavior of the task (getpt=True). To compensate this, 00111 absolute path to MS's POINTING table is stored, and it will be used 00112 for POINTING table when the data is converted back to MS format. 00113 In general, getpt=False is faster especially for large data. However, 00114 MS created from Scantable cannot have correct POINTING table if 00115 original MS's POINTING table doesn't exist. Such situation will 00116 happen when original MS is removed or renamed, or imported Scantable 00117 is moved to other computer alone. 00118 00119 WARNING for the GBT raw SDFITS format data as input: 00120 SDtasks are able to handle GBT raw SDFITS format data since the 00121 data filler is available. However, the functionality is not well 00122 tested yet, so that there may be unknown bugs. 00123 00124 00125 """ 00126 if type(rowlist)==int: rowlist=[rowlist] 00127 if type(scanlist)==int: scanlist=[scanlist] 00128 if type(iflist)==int: iflist=[iflist] 00129 if type(pollist)==int: pollist=[pollist] 00130 00131 # 00132 # The following is work around to avoid a bug with current python translation 00133 # 00134 mytmp = {} 00135 00136 mytmp['infile'] = infile 00137 mytmp['antenna'] = antenna 00138 mytmp['getpt'] = getpt 00139 mytmp['rowlist'] = rowlist 00140 mytmp['scanlist'] = scanlist 00141 mytmp['field'] = field 00142 mytmp['iflist'] = iflist 00143 mytmp['pollist'] = pollist 00144 mytmp['scanaverage'] = scanaverage 00145 mytmp['timeaverage'] = timeaverage 00146 mytmp['tweight'] = tweight 00147 mytmp['polaverage'] = polaverage 00148 mytmp['pweight'] = pweight 00149 mytmp['restfreq'] = restfreq 00150 mytmp['outfile'] = outfile 00151 mytmp['outform'] = outform 00152 mytmp['overwrite'] = overwrite 00153 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00154 trec = casac.utils().torecord(pathname+'sdsave.xml') 00155 00156 casalog.origin('sdsave') 00157 if trec.has_key('sdsave') and casac.utils().verify(mytmp, trec['sdsave']) : 00158 result = task_sdsave.sdsave(infile, antenna, getpt, rowlist, scanlist, field, iflist, pollist, scanaverage, timeaverage, tweight, polaverage, pweight, restfreq, outfile, outform, overwrite) 00159 00160 else : 00161 result = False 00162 return result