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_sdcal 00013 def sdcal(infile='', antenna=0, fluxunit='', telescopeparm='', specunit='', frame='', doppler='', calmode='none', fraction='10%', noff=-1, width=0.5, elongated=False, markonly=False, plotpointings=False, scanlist=[], field='', iflist=[], pollist=[], channelrange=[], scanaverage=False, timeaverage=False, tweight='none', averageall=False, polaverage=False, pweight='none', tau=0.0, verify=False, outfile='', outform='ASAP', overwrite=False, plotlevel=0): 00014 00015 """ASAP SD task: do data selection, calibration, and averaging 00016 Keyword arguments: 00017 infile -- name of input SD dataset 00018 antenna -- antenna name or id (only effective for MS input). 00019 fluxunit -- units for line flux 00020 options: 'K','Jy','' 00021 default: '' (keep current fluxunit) 00022 WARNING: For GBT data, see description below. 00023 00024 >>> fluxunit expandable parameter 00025 telescopeparm -- the telescope characteristics 00026 options: (str) name or (list) list of gain info 00027 default: '' (none set) 00028 example: if telescopeparm='', it tries to get the telescope 00029 name from the data. 00030 Full antenna parameters (diameter,ap.eff.) known 00031 to ASAP are 00032 'ATPKSMB', 'ATPKSHOH', 'ATMOPRA', 'DSS-43', 00033 'CEDUNA','HOBART'. For GBT, it fixes default fluxunit 00034 to 'K' first then convert to a new fluxunit. 00035 telescopeparm=[104.9,0.43] diameter(m), ap.eff. 00036 telescopeparm=[0.743] gain in Jy/K 00037 telescopeparm='FIX' to change default fluxunit 00038 see description below 00039 00040 specunit -- units for spectral axis 00041 options: (str) 'channel','km/s','GHz','MHz','kHz','Hz' 00042 default: '' (=current) 00043 example: this will be the units for masklist 00044 frame -- frequency frame for spectral axis 00045 options: (str) 'LSRK','REST','TOPO','LSRD','BARY', 00046 'GEO','GALACTO','LGROUP','CMB' 00047 default: currently set frame in scantable 00048 WARNING: frame='REST' not yet implemented 00049 doppler -- doppler mode 00050 options: (str) 'RADIO','OPTICAL','Z','BETA','GAMMA' 00051 default: currently set doppler in scantable 00052 calmode -- calibration mode 00053 options: 'ps','nod','otf','otfraster', 00054 'fs','fsotf','quotient','none' 00055 default: 'none' 00056 example: choose mode 'none' if you have 00057 already calibrated and want to 00058 try averaging 00059 WARNING: 'fsotf' is not implemented yet 00060 >>> calmode expandable parameter 00061 fraction -- Edge marking parameter for 'otf' and 'otfraster'. 00062 specify a number of OFF scans as a fraction of 00063 total number of data points. 00064 default: '10%' 00065 options: '20%' in string style or float value less 00066 than 1.0 (e.g. 0.15). 00067 'auto' is available only for 'otfraster'. 00068 noff -- Edge marking parameter for 'otfraster'. 00069 It is used to specify a number of OFF scans near 00070 edge directly. Value of noff comes before setting 00071 by fraction. 00072 default: -1 (use fraction) 00073 options: any positive integer 00074 width -- Edge marking parameter for 'otf'. 00075 Pixel width with respect to a median spatial 00076 separation between neighboring two data in time. 00077 Default will be fine in most cases. 00078 default: 0.5 00079 options: float value 00080 elongated -- Edge marking parameter for 'otf'. 00081 Set True only if observed area is elongeted 00082 in one direction. 00083 default: False 00084 markonly -- Set True if you want to save data just after 00085 edge marking (i.e. uncalibrated data) to see 00086 how OFF scans are defined. 00087 default: False 00088 scanlist -- list of scan numbers to process 00089 default: [] (use all scans) 00090 example: [21,22,23,24] 00091 this selection is in addition to field, iflist, and pollist 00092 field -- selection string for selecting scans by name 00093 default: '' (no name selection) 00094 example: 'FLS3a*' 00095 this selection is in addition to scanlist, iflist, and pollist 00096 iflist -- list of IF id numbers to select 00097 default: [] (use all IFs) 00098 example: [15] 00099 this selection is in addition to scanlist, field, and pollist 00100 pollist -- list of polarization id numbers to select 00101 default: [] (use all polarizations) 00102 example: [1] 00103 this selection is in addition to scanlist, field, and iflist 00104 channelrange -- channel range selection 00105 default: [] (use all channel) 00106 example: [0,5000] 00107 Note that specified values are recognized as 'channel' 00108 regardless of the value of specunit 00109 scanaverage -- average integrations within scans 00110 options: (bool) True,False 00111 default: False 00112 timeaverage -- average times for multiple scan cycles 00113 options: (bool) True,False 00114 default: False 00115 example: if True, this happens after calibration 00116 00117 >>>timeaverage expandable parameter 00118 tweight -- weighting for time average 00119 options: 'none' 00120 'var' (1/var(spec) weighted) 00121 'tsys' (1/Tsys**2 weighted) 00122 'tint' (integration time weighted) 00123 'tintsys' (Tint/Tsys**2) 00124 'median' ( median averaging) 00125 default: 'none' 00126 00127 averageall -- average multi-resolution spectra 00128 spectra are averaged by referring 00129 their frequency coverage 00130 default: False 00131 00132 polaverage -- average polarizations 00133 options: (bool) True,False 00134 default: False 00135 00136 >>>polaverage expandable parameter 00137 pweight -- weighting for polarization average 00138 options: 'none' 00139 'var' (1/var(spec) weighted) 00140 'tsys' (1/Tsys**2 weighted) 00141 default: 'none' 00142 00143 tau -- atmospheric optical depth 00144 default: 0.0 (no correction) 00145 verify -- verify the results of calibration. Only effective if 00146 calmode is not 'none'. 00147 options: (bool) True,False 00148 default: False 00149 WARNING: Currently this just asks whether you accept 00150 the displayed calibration and if not, continues 00151 without doing any calibration. 00152 outfile -- Name of output file 00153 default: '' (<infile>_cal) 00154 outform -- format of output file 00155 options: 'ASCII','SDFITS','MS','ASAP' 00156 default: 'ASAP' 00157 example: the ASAP format is easiest for further sd 00158 processing; use MS for CASA imaging. 00159 If ASCII, then will append some stuff to 00160 the outfile name 00161 overwrite -- overwrite the output file if already exists 00162 options: (bool) True,False 00163 default: False 00164 WARNING: if outform='ASCII', this parameter is ignored 00165 plotlevel -- control for plotting of results 00166 options: (int) 0=none, 1=some, 2=more, <0=hardcopy 00167 default: 0 (no plotting) 00168 example: plotlevel<0 as abs(plotlevel), e.g. 00169 -1 => hardcopy of final plot (will be named 00170 <outfile>_calspec.eps) 00171 WARNING: be careful plotting in fsotf mode! 00172 00173 00174 DESCRIPTION: 00175 00176 Task sdcal performs data selection, calibration for single-dish 00177 spectra. By setting calmode='none', one can run sdcal on already 00178 calibrated data, for further selection , averaging and atmospheric 00179 optical depth correction. To save the output spectra in a certain 00180 range of channels, you set the range in channelrange. 00181 00182 If you give multiple IFs in iflist, then your scantable will have 00183 multiple IFs by default. Averaging of multi-resolution (multi-IFs) 00184 spectra can be achieved by setting a sub-parameter in timeaverage, 00185 averageall, to True. It handles multi-IFs by selecting overlaps in 00186 frequency coverages and assigning new IFs in the output spectra. 00187 00188 ASAP recognizes the data of the "AT" telescopes, but currently 00189 does not know about the GBT or any other telescope. This task 00190 does know about GBT. Telescope name is obtained from the data. 00191 If you wish to change the fluxunit (see below), by leaving 00192 the sub-parameter telescopeparm unset (telescopeparm=''), 00193 it will use internal telescope parameters for 00194 flux conversion for the data from AT telescopes and it will use an 00195 approximate aperture efficiency conversion for the GBT data. 00196 If you give telescopeparm a list, then if the list has a single 00197 float it is assumed to be the gain in Jy/K, if two or more elements 00198 they are assumed to be telescope diameter (m) and aperture efficiency 00199 respectively. 00200 00201 Note that sdcal assumes that the fluxunit is set correctly in 00202 the data already. If not, then set telescopeparm='FIX' and it 00203 will set the default units to fluxunit without conversion. 00204 NOTE: If the data in infile is an ms from GBT and the default flux 00205 unit is missing, this task automatically fixes the default fluxunit 00206 to 'K' before the conversion. 00207 00208 Two new calmode, 'otf' and 'otfraster', are available. If you 00209 specify those modes, the task first try to define several scans 00210 near edge as OFF scans, then the data are calibrated using those 00211 OFF scans. Those modes are designed for OTF observations without 00212 explicit OFF scans. If the observing pattern is 'raster', you 00213 should use the 'otfraster' mode to calibrate data. Otherwise, the 00214 'otf' mode should be used. For detail about edge marking, see 00215 online help of sd.edgemarker module. 00216 00217 WARNING for the GBT raw SDFITS format data as input: 00218 SDtasks are able to handle GBT raw SDFITS format data since the 00219 data filler is available. However, the functionality is not well 00220 tested yet, so that there may be unknown bugs. 00221 00222 00223 """ 00224 if type(scanlist)==int: scanlist=[scanlist] 00225 if type(iflist)==int: iflist=[iflist] 00226 if type(pollist)==int: pollist=[pollist] 00227 if type(channelrange)==int: channelrange=[channelrange] 00228 00229 # 00230 # The following is work around to avoid a bug with current python translation 00231 # 00232 mytmp = {} 00233 00234 mytmp['infile'] = infile 00235 mytmp['antenna'] = antenna 00236 mytmp['fluxunit'] = fluxunit 00237 mytmp['telescopeparm'] = telescopeparm 00238 mytmp['specunit'] = specunit 00239 mytmp['frame'] = frame 00240 mytmp['doppler'] = doppler 00241 mytmp['calmode'] = calmode 00242 mytmp['fraction'] = fraction 00243 mytmp['noff'] = noff 00244 mytmp['width'] = width 00245 mytmp['elongated'] = elongated 00246 mytmp['markonly'] = markonly 00247 mytmp['plotpointings'] = plotpointings 00248 mytmp['scanlist'] = scanlist 00249 mytmp['field'] = field 00250 mytmp['iflist'] = iflist 00251 mytmp['pollist'] = pollist 00252 mytmp['channelrange'] = channelrange 00253 mytmp['scanaverage'] = scanaverage 00254 mytmp['timeaverage'] = timeaverage 00255 mytmp['tweight'] = tweight 00256 mytmp['averageall'] = averageall 00257 mytmp['polaverage'] = polaverage 00258 mytmp['pweight'] = pweight 00259 mytmp['tau'] = tau 00260 mytmp['verify'] = verify 00261 mytmp['outfile'] = outfile 00262 mytmp['outform'] = outform 00263 mytmp['overwrite'] = overwrite 00264 mytmp['plotlevel'] = plotlevel 00265 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00266 trec = casac.utils().torecord(pathname+'sdcal.xml') 00267 00268 casalog.origin('sdcal') 00269 if trec.has_key('sdcal') and casac.utils().verify(mytmp, trec['sdcal']) : 00270 result = task_sdcal.sdcal(infile, antenna, fluxunit, telescopeparm, specunit, frame, doppler, calmode, fraction, noff, width, elongated, markonly, plotpointings, scanlist, field, iflist, pollist, channelrange, scanaverage, timeaverage, tweight, averageall, polaverage, pweight, tau, verify, outfile, outform, overwrite, plotlevel) 00271 00272 else : 00273 result = False 00274 return result