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_sdstat 00013 def sdstat(infile='', antenna=0, fluxunit='', telescopeparm='', specunit='', restfreq='', frame='', doppler='', scanlist=[], field='', iflist=[], pollist=[], masklist=[], invertmask=False, interactive=False, outfile='', format='3.3f', overwrite=False): 00014 00015 """ASAP SD task: list statistics of spectral region 00016 Keyword arguments: 00017 infile -- name of input SD dataset 00018 default: none - must input file name 00019 example: 'mysd.asap' 00020 See sdcal for allowed formats. 00021 antenna -- antenna name or id (only effective for MS input). 00022 fluxunit -- units for line flux 00023 options: (str) 'K','Jy','' 00024 default: '' (keep current fluxunit) 00025 WARNING: For GBT data, see description below. 00026 >>> fluxunit expandable parameter 00027 telescopeparm -- the telescope characteristics 00028 options: (str) name or (list) list of gain info 00029 default: '' (none set) 00030 example: if telescopeparm='', it tries to get the telescope 00031 name from the data. 00032 Full antenna parameters (diameter,ap.eff.) known 00033 to ASAP are 00034 'ATPKSMB', 'ATPKSHOH', 'ATMOPRA', 'DSS-43', 00035 'CEDUNA','HOBART'. For GBT, it fixes default fluxunit 00036 to 'K' first then convert to a new fluxunit. 00037 telescopeparm=[104.9,0.43] diameter(m), ap.eff. 00038 telescopeparm=[0.743] gain in Jy/K 00039 telescopeparm='FIX' to change default fluxunit 00040 see description below 00041 00042 specunit -- units for spectral axis 00043 options: (str) 'channel','km/s','GHz','MHz','kHz','Hz','' 00044 default: '' (=current) 00045 >>> specunit expandable parameter 00046 restfreq -- rest frequency 00047 default: '' (use current setting) 00048 example: 4.6e10 (float value in Hz), 00049 '46GHz' (string with unit), 00050 ['345.8GHz', 347.0e9, 356.7e9] (for each IF) 00051 [{'name':'CO','value':345e9}] (a value with name) 00052 frame -- frequency frame for spectral axis 00053 options: (str) 'LSRK','REST','TOPO','LSRD','BARY', 00054 'GEO','GALACTO','LGROUP','CMB' 00055 default: currently set frame in scantable 00056 WARNING: frame='REST' not yet implemented 00057 doppler -- doppler mode 00058 options: (str) 'RADIO','OPTICAL','Z','BETA','GAMMA' 00059 default: currently set doppler in scantable 00060 scanlist -- list of scan numbers to process 00061 default: [] (use all scans) 00062 example: [21,22,23,24] 00063 this selection is in addition to field, iflist, and pollist 00064 field -- selection string for selecting scans by name 00065 default: '' (no name selection) 00066 example: 'FLS3a*' 00067 this selection is in addition to scanlist, iflist, and pollist 00068 iflist -- list of IF id numbers to select 00069 default: [] (use all IFs) 00070 example: [15] 00071 this selection is in addition to field, scanlist, and pollist 00072 pollist -- list of polarization id numbers to select 00073 default: [] (use all pols) 00074 example: [1] 00075 this selection is in addition to field, scanlist, and iflist 00076 masklist -- list of mask regions to INCLUDE in stats 00077 default: [] (whole spectrum) 00078 example: [4000,4500] for one region 00079 [[1000,3000],[5000,7000]] 00080 these must be pairs of [lo,hi] boundaries 00081 invertmask -- invert mask (EXCLUDE masklist instead) 00082 options: (bool) True,False 00083 default: false 00084 interactive -- determines interactive masking 00085 options: (bool) True,False 00086 default: False 00087 example: interactive=True allows adding and deleting mask 00088 regions by drawing rectangles on the plot with mouse. 00089 Draw a rectangle with LEFT-mouse to ADD the region to 00090 the mask and with RIGHT-mouse to DELETE the region. 00091 outfile -- name of output file for line statistics 00092 default: '' (no output statistics file) 00093 example: 'stat.txt' 00094 format -- format string to print statistic values 00095 default: '3.3f' 00096 overwrite -- overwrite the statistics file if already exists 00097 options: (bool) True,False 00098 default: False 00099 00100 ------------------------------------------------------------------- 00101 Returns: a Python dictionary of line statistics 00102 keys: 'rms','stddev','max','min','max_abscissa', 00103 'min_abscissa','sum','median','mean','totint','eqw' 00104 example: xstat=sdstat(); print "rms = ",xstat['rms'] 00105 these can be used for testing in scripts or 00106 for regression 00107 00108 'max_abscissa' and 'min_abscissa' refer to the abscissa 00109 (channel/frequency/velocity) of max and min intensity. 00110 'totint' is the integrated intensity (sum*dx) 00111 where dx is the abscissa interval in 'specunit'. 00112 'eqw' is equivalent width (totint/mag) where mag 00113 is either max or min depending on which has 00114 greater magnitude. 00115 Note that 'max_abscissa', 'min_abscissa', 'totint' 00116 and 'eqw' are quantities (python dictionaries with 00117 keys, 'unit' and 'value'). 00118 00119 00120 DESCRIPTION: 00121 00122 Task sdstat computes basic statistics (rms,mean,median,sum) 00123 for single-dish spectra. It assumes that the spectra have 00124 been calibrated. Furthermore, it assumes that any 00125 time and channel averaging/smoothing has also already been done as 00126 there are no controls for these. 00127 00128 Note that multiple scans and IFs can in principle be handled, but 00129 we recommend that you use scanlist, field, iflist, and pollist to give 00130 a single selection for each run. 00131 00132 WARNING: If you do have multiple scantable rows, then the returning 00133 values will be lists. 00134 00135 ASAP recognizes the data of the "AT" telescopes, but currently 00136 does not know about the GBT or any other telescope. This task 00137 does know about GBT. Telescope name is obtained from the data. 00138 If you wish to change the fluxunit (see below), and telescopeparm='', 00139 for the AT telescopes it will use internal telescope parameters for 00140 flux conversion. For GBT, it will use an approximate aperture 00141 efficiency conversion. If you give telescopeparm a list, then 00142 if the list has a single float it is assumed to be the gain in Jy/K, 00143 if two or more elements they are assumed to be telescope diameter (m) 00144 and aperture efficiency respectively. 00145 00146 WARNING for the GBT raw SDFITS format data as input: 00147 SDtasks are able to handle GBT raw SDFITS format data since the 00148 data filler is available. However, the functionality is not well 00149 tested yet, so that there may be unknown bugs. 00150 00151 00152 """ 00153 if type(scanlist)==int: scanlist=[scanlist] 00154 if type(iflist)==int: iflist=[iflist] 00155 if type(pollist)==int: pollist=[pollist] 00156 if type(masklist)==int: masklist=[masklist] 00157 00158 # 00159 # The following is work around to avoid a bug with current python translation 00160 # 00161 mytmp = {} 00162 00163 mytmp['infile'] = infile 00164 mytmp['antenna'] = antenna 00165 mytmp['fluxunit'] = fluxunit 00166 mytmp['telescopeparm'] = telescopeparm 00167 mytmp['specunit'] = specunit 00168 mytmp['restfreq'] = restfreq 00169 mytmp['frame'] = frame 00170 mytmp['doppler'] = doppler 00171 mytmp['scanlist'] = scanlist 00172 mytmp['field'] = field 00173 mytmp['iflist'] = iflist 00174 mytmp['pollist'] = pollist 00175 mytmp['masklist'] = masklist 00176 mytmp['invertmask'] = invertmask 00177 mytmp['interactive'] = interactive 00178 mytmp['outfile'] = outfile 00179 mytmp['format'] = format 00180 mytmp['overwrite'] = overwrite 00181 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00182 trec = casac.utils().torecord(pathname+'sdstat.xml') 00183 00184 casalog.origin('sdstat') 00185 if trec.has_key('sdstat') and casac.utils().verify(mytmp, trec['sdstat']) : 00186 result = task_sdstat.sdstat(infile, antenna, fluxunit, telescopeparm, specunit, restfreq, frame, doppler, scanlist, field, iflist, pollist, masklist, invertmask, interactive, outfile, format, overwrite) 00187 00188 else : 00189 result = False 00190 return result