Changeset 226 for trunk/python/scantable.py
- Timestamp:
- 01/19/05 18:24:16 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r200 r226 1 1 from asap._asap import sdtable 2 from asap import rcParams 2 3 from numarray import ones,zeros 3 4 import sys … … 21 22 scantable 22 23 """ 23 self._vb = True24 self._vb = rcParams['verbose'] 24 25 self._p = None 25 26 from os import stat as st … … 28 29 sdtable.__init__(self, filename) 29 30 else: 30 mode = st(filename)[stat.ST_MODE] 31 try: 32 mode = st(filename)[stat.ST_MODE] 33 except OSError: 34 print "File not found" 35 return 31 36 if stat.S_ISDIR(mode): 32 37 # crude check if asap table … … 35 40 else: 36 41 print 'The given file is not a valid asap table' 37 else: 42 return 43 else: 44 autoav = rcParams['scantable.autoaverage'] 45 38 46 from asap._asap import sdreader 39 47 r = sdreader(filename) … … 41 49 r.read([-1]) 42 50 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 50 51 def save(self, name="", format='ASAP'): 51 if autoav: 52 from asap._asap import average 53 tmp = tuple([tbl]) 54 print 'Auto averaging integrations...' 55 tbl2 = average(tmp,(),True,'none') 56 sdtable.__init__(self,tbl2) 57 del r,tbl 58 else: 59 sdtable.__init__(self,tbl) 60 61 def save(self, name="", format=None): 52 62 """ 53 63 Store the scantable on disk. This can be a asap file or SDFITS/MS2. … … 60 70 'FITS' (saves each row as a FITS Image) 61 71 'ASCII' (saves as ascii text file) 62 'MS2' (saves as an aips++ MeasurementSet V2) 72 'MS2' (saves as an aips++ 73 MeasurementSet V2) 63 74 Example: 64 75 scan.save('myscan.asap') 65 76 scan.save('myscan.sdfits','SDFITS') 66 77 """ 78 if format is None: format = rcParams['scantable.save'] 67 79 if format == 'ASAP': 68 80 self._save(name) … … 72 84 w.write(self, name) 73 85 return 74 75 def _verbose(self, *args):76 """77 Set the verbose level True or False, to indicate if output78 should be printed as well as returned.79 """80 if len(args) == 0:81 return self._vb82 elif type(args[0]) is bool:83 self._vb = args[0]84 return85 86 86 87 def copy(self): … … 166 167 print " Cursor selection" 167 168 print "--------------------------------------------------" 168 out = 'Beam=%d IF=%d Pol=%d ' % (i,j,k)169 out = 'Beam=%d IF=%d Pol=%d ' % (i,j,k) 169 170 print out 170 171 return i,j,k 171 172 172 def stats(self, stat='stddev', mask=None, all= True):173 def stats(self, stat='stddev', mask=None, all=None): 173 174 """ 174 175 Determine the specified statistic of the current beam/if/pol … … 180 181 mask: an optional mask specifying where the statistic 181 182 should be determined. 182 all: optional flag to show all (default ) or a selected183 spectrum of Beam/IF/Pol183 all: optional flag to show all (default or .asaprc) or a 184 cursor selected spectrum of Beam/IF/Pol 184 185 185 186 Example: … … 188 189 scan.stats(stat='mean', mask=m) 189 190 """ 191 if all is None: all = rcParams['scantable.allaxes'] 190 192 from asap._asap import stats as _stats 191 193 if mask == None: … … 210 212 out += '= %3.3f\n' % (statval[l]) 211 213 out += "--------------------------------------------------\n" 212 213 214 if self._vb: 214 215 print "--------------------------------------------------" … … 232 233 out += '= %3.3f\n' % (statval[l]) 233 234 out += "--------------------------------------------------\n" 235 234 236 if self._vb: 235 237 print "--------------------------------------------------" … … 239 241 return statval 240 242 241 def stddev(self,mask=None, all= True):243 def stddev(self,mask=None, all=None): 242 244 """ 243 245 Determine the standard deviation of the current beam/if/pol … … 247 249 mask: an optional mask specifying where the standard 248 250 deviation should be determined. 249 all: optional flag to show all or a selected 250 spectrum of Beam/IF/Pol 251 all: optional flag to show all or a cursor selected 252 spectrum of Beam/IF/Pol. Default is all or taken 253 from .asaprc 251 254 252 255 Example: … … 255 258 scan.stddev(mask=m) 256 259 """ 260 if all is None: all = rcParams['scantable.allaxes'] 257 261 return self.stats(stat='stddev',mask=mask, all=all); 258 262 259 def get_tsys(self, all= True):263 def get_tsys(self, all=None): 260 264 """ 261 265 Return the System temperatures. … … 268 272 a list of Tsys values. 269 273 """ 274 if all is None: all = rcParams['scantable.allaxes'] 270 275 if all: 271 276 out = '' … … 287 292 out += '= %3.3f\n' % (ts[l]) 288 293 out+= "--------------------------------------------------\n" 289 290 294 if self._vb: 291 295 print "--------------------------------------------------" … … 308 312 out += '= %3.3f\n' % (ts[l]) 309 313 out += "--------------------------------------------------\n" 310 311 314 if self._vb: 312 315 print "--------------------------------------------------" … … 345 348 if self._p: self.plot() 346 349 347 def set_freqframe(self, frame= 'LSRK'):350 def set_freqframe(self, frame=None): 348 351 """ 349 352 Set the frame type of the Spectral Axis. … … 353 356 scan.set_freqframe('BARY') 354 357 """ 358 if not frame: frame = rcParams['scantable.freqframe'] 355 359 valid = ['REST','TOPO','LSRD','LSRK','BARY', \ 356 360 'GEO','GALACTO','LGROUP','CMB'] … … 379 383 selected Beam/IF/Pol 380 384 Parameters: 381 none 385 rowno: an optional row number in the scantable. Default is the 386 first row, i.e. rowno=0 382 387 Returns: 383 388 The abcissa values and it's format string. … … 501 506 self._p.set_panels(rows=npan) 502 507 xlab,ylab,tlab = None,None,None 503 vb = self._verbose() 504 self._verbose(False) 505 sel = self.get_selection() 508 self._vb = False 509 sel = self.get_selection() 506 510 for i in range(npan): 507 self._p.subplot(i) 511 if npan > 1: 512 self._p.subplot(i) 508 513 for j in range(validcol[col]): 509 514 x = None … … 540 545 self._p.release() 541 546 self.set_selection(sel[0],sel[1],sel[2]) 542 self._v erbose(vb)547 self._vb = rcParams['verbose'] 543 548 return
Note: See TracChangeset
for help on using the changeset viewer.