Changeset 794 for trunk/python
- Timestamp:
- 12/09/05 14:50:59 (19 years ago)
- Location:
- trunk/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r780 r794 298 298 get_time - get the timestamps of the integrations 299 299 get_sourcename - get the source names of the scans 300 get_azimuth - get the azimuth of the scans 301 get_elevation - get the elevation of the scans 302 get_parangle - get the parallactic angle of the scans 300 303 get_unit - get the currnt unit 301 304 set_unit - set the abcissa unit to be used from this -
trunk/python/asapfitter.py
r723 r794 432 432 print_log() 433 433 434 def auto_fit(self, insitu=None ):434 def auto_fit(self, insitu=None, allaxes=True): 435 435 """ 436 436 Return a scan where the function is applied to all rows for … … 454 454 rows = range(scan.nrow()) 455 455 from asap import asaplog 456 for i in range(scan.nbeam()): 457 scan.setbeam(i) 458 for j in range(scan.nif()): 459 scan.setif(j) 460 for k in range(scan.npol()): 461 scan.setpol(k) 462 asaplog.push("Fitting:") 463 out = 'Beam[%d], IF[%d], Pol[%d]' % (i,j,k) 464 asaplog.push(out) 465 for iRow in rows: 466 self.x = scan._getabcissa(iRow) 467 self.y = scan._getspectrum(iRow) 468 self.data = None 469 self.fit() 470 x = self.get_parameters() 471 scan._setspectrum(self.fitter.getresidual(),iRow) 456 if allaxes: 457 for i in range(scan.nbeam()): 458 scan.setbeam(i) 459 for j in range(scan.nif()): 460 scan.setif(j) 461 for k in range(scan.npol()): 462 scan.setpol(k) 463 asaplog.push("Fitting:") 464 out = 'Beam[%d], IF[%d], Pol[%d]' % (i,j,k) 465 asaplog.push(out) 466 for iRow in rows: 467 self.x = scan._getabcissa(iRow) 468 self.y = scan._getspectrum(iRow) 469 self.data = None 470 self.fit() 471 x = self.get_parameters() 472 scan._setspectrum(self.fitter.getresidual(),iRow) 473 else: 474 asaplog.push("Fitting:") 475 out = 'Beam[%d], IF[%d], Pol[%d]' % sel 476 asaplog.push(out) 477 for iRow in rows: 478 self.x = scan._getabcissa(iRow) 479 self.y = scan._getspectrum(iRow) 480 self.data = None 481 self.fit() 482 x = self.get_parameters() 483 scan._setspectrum(self.fitter.getresidual(),iRow) 484 472 485 scan.set_cursor(sel[0],sel[1],sel[2]) 473 486 print_log() -
trunk/python/asapplotter.py
r762 r794 148 148 else: 149 149 self._plotter.set_panels() 150 allxlim=[] 150 151 rows = self._cursor["t"] 151 152 rows = rows[:n] … … 228 229 if self._minmaxx is not None: 229 230 xlim = self._minmaxx 230 self._plotter.axes.set_xlim(xlim) 231 allxlim += xlim 232 allxlim.sort() 233 self._plotter.axes.set_xlim([allxlim[0],allxlim[-1]]) 231 234 self._plotter.set_axes('xlabel',xlab) 232 235 self._plotter.set_axes('ylabel',ylab) 233 236 self._plotter.set_axes('title',tlab) 237 234 238 return 235 239 … … 269 273 colvals = eval(cdict2.get(colmode)) 270 274 rowsel = self._cursor["t"][0] 275 allxlim=[] 271 276 for j in colvals: 272 277 polmode = "raw" … … 331 336 if self._minmaxx is not None: 332 337 xlim = self._minmaxx 333 self._plotter.axes.set_xlim(xlim) 334 338 allxlim += xlim 339 allxlim.sort() 340 self._plotter.axes.set_xlim([allxlim[0],allxlim[-1]]) 335 341 self._plotter.set_axes('xlabel',xlab) 336 342 self._plotter.set_axes('ylabel',ylab) … … 377 383 eval(cdict.get(self._panelling)) 378 384 385 allxlim=[] 379 386 colvals = eval(cdict2.get(colmode)) 380 387 for j in colvals: … … 404 411 eval(cdict.get(colmode)) 405 412 i = savei 406 if self._panelling == "p":407 413 #if self._panelling == "p": 414 eval(cdict.get(self._panelling)) 408 415 x = None 409 416 y = None … … 470 477 if self._minmaxx is not None: 471 478 xlim = self._minmaxx 472 self._plotter.axes.set_xlim(xlim) 479 allxlim += xlim 480 allxlim.sort() 481 self._plotter.axes.set_xlim([allxlim[0],allxlim[-1]]) 473 482 474 483 self._plotter.set_axes('xlabel',xlab) -
trunk/python/scantable.py
r780 r794 226 226 raise IOError(msg) 227 227 if rcParams['verbose']: 228 print info 228 try: 229 from IPython.genutils import page as pager 230 except ImportError: 231 from pydoc import pager 232 pager(info) 229 233 else: 230 234 return info … … 429 433 def get_sourcename(self, row=-1): 430 434 """ 431 Get a list source anmes for the observations.435 Get a list source names for the observations. 432 436 Return a string for each integration in the scantable. 433 437 Parameters: … … 442 446 if 0 <= row < self.nrow(): 443 447 return self._getsourcename(row) 448 449 def get_elevation(self, row=-1): 450 """ 451 Get a list of elevations for the observations. 452 Return a float for each integration in the scantable. 453 Parameters: 454 row: row no of integration. Default -1 return all rows 455 Example: 456 none 457 """ 458 out = [] 459 if row == -1: 460 return [self._getelevation(i) for i in range(self.nrow())] 461 else: 462 if 0 <= row < self.nrow(): 463 return self._getelevation(row) 464 465 def get_azimuth(self, row=-1): 466 """ 467 Get a list of azimuths for the observations. 468 Return a float for each integration in the scantable. 469 Parameters: 470 row: row no of integration. Default -1 return all rows 471 Example: 472 none 473 """ 474 out = [] 475 if row == -1: 476 return [self._getazimuth(i) for i in range(self.nrow())] 477 else: 478 if 0 <= row < self.nrow(): 479 return self._getazimuth(row) 480 481 def get_parangle(self, row=-1): 482 """ 483 Get a list of parallactic angles for the observations. 484 Return a float for each integration in the scantable. 485 Parameters: 486 row: row no of integration. Default -1 return all rows 487 Example: 488 none 489 """ 490 out = [] 491 if row == -1: 492 return [self._getparangle(i) for i in range(self.nrow())] 493 else: 494 if 0 <= row < self.nrow(): 495 return self._getparangle(row) 444 496 445 497 def set_unit(self, unit='channel'): … … 717 769 def history(self): 718 770 hist = list(self._gethistory()) 719 print"-"*80771 out = "-"*80 720 772 for h in hist: 721 773 if h.startswith("---"): 722 printh774 out += "\n"+h 723 775 else: 724 776 items = h.split("##") … … 726 778 func = items[1] 727 779 items = items[2:] 728 print date729 print"Function: %s\n Parameters:" % (func)780 out += "\n"+date+"\n" 781 out += "Function: %s\n Parameters:" % (func) 730 782 for i in items: 731 783 s = i.split("=") 732 print " %s = %s" % (s[0],s[1]) 733 print "-"*80 784 out += "\n %s = %s" % (s[0],s[1]) 785 out += "\n"+"-"*80 786 try: 787 from IPython.genutils import page as pager 788 except ImportError: 789 from pydoc import pager 790 pager(out) 734 791 return 735 792 … … 1055 1112 return 1056 1113 1057 def poly_baseline(self, mask=None, order=0, insitu=None ):1114 def poly_baseline(self, mask=None, order=0, insitu=None, allaxes=None): 1058 1115 """ 1059 1116 Return a scan which has been baselined (all rows) by a polynomial. 1060 1117 Parameters: 1061 scan: a scantable 1062 mask: an optional mask 1063 order: the order of the polynomial (default is 0) 1064 insitu: if False a new scantable is returned. 1065 Otherwise, the scaling is done in-situ 1066 The default is taken from .asaprc (False) 1118 scan: a scantable 1119 mask: an optional mask 1120 order: the order of the polynomial (default is 0) 1121 insitu: if False a new scantable is returned. 1122 Otherwise, the scaling is done in-situ 1123 The default is taken from .asaprc (False) 1124 allaxes: If True (default) apply to all spectra. Otherwise 1125 apply only to the selected (beam/pol/if)spectra only 1126 The default is taken from .asaprc (True if none) 1067 1127 Example: 1068 1128 # return a scan baselined by a third order polynomial, … … 1070 1130 bscan = scan.poly_baseline(order=3) 1071 1131 """ 1132 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 1072 1133 if insitu is None: insitu = rcParams['insitu'] 1073 1134 varlist = vars() … … 1079 1140 f.set_scan(self, mask) 1080 1141 f.set_function(poly=order) 1081 sf = f.auto_fit(insitu )1142 sf = f.auto_fit(insitu,allaxes) 1082 1143 if insitu: 1083 1144 self._add_history("poly_baseline", varlist) … … 1291 1352 refs = self.get_scan("*[_ewR]") 1292 1353 if isinstance(srcs,scantable) and isinstance(refs,scantable): 1354 from asap import asaplog 1293 1355 ns,nr = srcs.nrow(),refs.nrow() 1356 msg = "Found %i Off and %i On scans" % (ns,nr) 1357 asaplog.push(msg) 1294 1358 if nr > ns: 1359 asaplog("Found more Off integrations than On scans - dropping excess Offs.") 1295 1360 refs = refs.get_scan(range(ns)) 1296 1361 print_log()
Note:
See TracChangeset
for help on using the changeset viewer.