- Timestamp:
- 01/07/05 11:49:09 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r158 r181 12 12 Create a scantable from a saved one or make a reference 13 13 Parameters: 14 filename: the name of an asap table on disk, or 15 [advanced] a refernce to an existing 14 filename: the name of an asap table on disk 15 or 16 the name of a rpfits/sdfits/ms file 17 (integrations within scans are auto averaged 18 and the whole file is read) 19 or 20 [advanced] a reference to an existing 16 21 scantable 17 22 """ 18 23 self._vb = True 19 24 self._p = None 20 sdtable.__init__(self, filename) 25 from os import stat as st 26 import stat 27 if isinstance(filename,sdtable): 28 sdtable.__init__(self, filename) 29 else: 30 mode = st(filename)[stat.ST_MODE] 31 if stat.S_ISDIR(mode): 32 # crude check if asap table 33 if stat.S_ISREG(st(filename+'/table.info')[stat.ST_MODE]): 34 sdtable.__init__(self, filename) 35 else: 36 print 'The given file is not a valid asap table' 37 else: 38 from asap._asap import sdreader 39 r = sdreader(filename) 40 print 'Importing data...' 41 r.read([-1]) 42 tbl = r.getdata() 43 44 from asap._asap import average 45 tmp = tuple([tbl]) 46 print 'Auto averging integrations...' 47 tbl2 = average(tmp,(),True,'none') 48 sdtable.__init__(self,tbl2) 49 del r,tbl 21 50 22 51 def save(self, name, format='ASAP'): … … 26 55 name: the name of the outputfile 27 56 format: an optional file format. Default is ASAP. 28 All lowed are 'ASAP', 'SDFITS' and 'MS2'57 Allowed are 'ASAP', 'SDFITS' and 'MS2' 29 58 Example: 30 59 scan.save('myscan.asap') … … 109 138 scan.set_selection(0,0,1) 110 139 pol1sig = scan.stats(all=False) # returns std dev for beam=0 111 # if=0, pol=1140 # if=0, pol=1 112 141 """ 113 142 self.setbeam(thebeam) … … 130 159 k = self.getpol() 131 160 if self._vb: 161 print "--------------------------------------------------" 162 print " Cursor selection" 163 print "--------------------------------------------------" 132 164 out = 'Beam=%d IF=%d Pol=%d '% (i,j,k) 133 165 print out … … 158 190 out = '' 159 191 tmp = [] 160 for i in range(self.nbeam()): 161 self.setbeam(i) 162 for j in range(self.nif()): 163 self.setif(j) 164 for k in range(self.npol()): 165 self.setpol(k) 166 statVal = _stats(self,mask,stat) 167 tmp.append(statVal) 168 # out += 'Beam[%d], IF[%d], Pol[%d] = %3.3f\n' % (i,j,k,statVal) 169 # if self._vb: 170 # print out 192 for l in range(self.nrow()): 193 tm = self._gettime(l) 194 out += 'Time[%s]:\n' % (tm) 195 for i in range(self.nbeam()): 196 self.setbeam(i) 197 if self.nbeam() > 1: out += ' Beam[%d] ' % (i) 198 for j in range(self.nif()): 199 self.setif(j) 200 if self.nif() > 1: out += ' IF[%d] ' % (j) 201 for k in range(self.npol()): 202 self.setpol(k) 203 if self.npol() > 1: out += ' Pol[%d] ' % (k) 204 statval = _stats(self,mask,stat) 205 tmp.append(statval) 206 out += '= %3.3f\n' % (statval[l]) 207 out += "--------------------------------------------------\n" 208 209 if self._vb: 210 print "--------------------------------------------------" 211 print " ",stat 212 out += "--------------------------------------------------\n" 213 print out 171 214 return tmp 172 215 … … 175 218 j = self.getif() 176 219 k = self.getpol() 177 statVal = _stats(self,mask,stat) 178 # out = 'Beam[%d], IF[%d], Pol[%d] = %3.3f' % (i,j,k,statVal) 179 # if self._vb: 180 # print out 181 return statVal 220 statval = _stats(self,mask,stat) 221 out = '' 222 for l in range(self.nrow()): 223 tm = self._gettime(l) 224 out += 'Time[%s]:\n' % (tm) 225 if self.nbeam() > 1: out += ' Beam[%d] ' % (i) 226 if self.nif() > 1: out += ' IF[%d] ' % (j) 227 if self.npol() > 1: out += ' Pol[%d] ' % (k) 228 out += '= %3.3f\n' % (statval[l]) 229 out += "--------------------------------------------------\n" 230 if self._vb: 231 print "--------------------------------------------------" 232 print " ",stat 233 print "--------------------------------------------------" 234 print out 235 return statval 182 236 183 237 def stddev(self,mask=None, all=True): … … 211 265 """ 212 266 if all: 267 out = '' 213 268 tmp = [] 214 out = '' 215 for i in range(self.nbeam()): 216 self.setbeam(i) 217 for j in range(self.nif()): 218 self.setif(j) 219 for k in range(self.npol()): 220 self.setpol(k) 221 ts = self._gettsys() 222 tmp.append(ts) 223 # out += 'TSys: Beam[%d], IF[%d], Pol[%d] = %3.3f\n' % (i,j,k,ts) 224 # if self._vb: 225 # print out 269 for l in range(self.nrow()): 270 tm = self._gettime(l) 271 out += 'Time[%s]:\n' % (tm) 272 for i in range(self.nbeam()): 273 self.setbeam(i) 274 if self.nbeam() > 1: out += ' Beam[%d] ' % (i) 275 for j in range(self.nif()): 276 self.setif(j) 277 if self.nif() > 1: out += ' IF[%d] ' % (j) 278 for k in range(self.npol()): 279 self.setpol(k) 280 if self.npol() > 1: out += ' Pol[%d] ' % (k) 281 ts = self._gettsys() 282 tmp.append(ts) 283 out += '= %3.3f\n' % (ts[l]) 284 out+= "--------------------------------------------------\n" 285 286 if self._vb: 287 print "--------------------------------------------------" 288 print " Tsys" 289 print "--------------------------------------------------" 290 print out 226 291 return tmp 227 292 else: … … 230 295 k = self.getpol() 231 296 ts = self._gettsys() 232 # out = 'TSys: Beam[%d], IF[%d], Pol[%d] = %3.3f' % (i,j,k,ts) 233 # if self._vb: 234 # print out 297 out = '' 298 for l in range(self.nrow()): 299 tm = self._gettime(l) 300 out += 'Time[%s]:\n' % (tm) 301 if self.nbeam() > 1: out += ' Beam[%d] ' % (i) 302 if self.nif() > 1: out += ' IF[%d] ' % (j) 303 if self.npol() > 1: out += ' Pol[%d] ' % (k) 304 out += '= %3.3f\n' % (ts[l]) 305 out += "--------------------------------------------------\n" 306 307 if self._vb: 308 print "--------------------------------------------------" 309 print " Tsys" 310 print "--------------------------------------------------" 311 print out 235 312 return ts 236 313 … … 238 315 """ 239 316 Get a list of time stamps for the observations. 240 Return a string for each inte rgration in the scantable.317 Return a string for each integration in the scantable. 241 318 Parameters: 242 319 none
Note:
See TracChangeset
for help on using the changeset viewer.