Changeset 710
- Timestamp:
- 11/11/05 10:01:49 (19 years ago)
- Location:
- trunk/python
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r706 r710 61 61 'plotter.colours' : ['', str], 62 62 'plotter.linestyles' : ['', str], 63 63 'plotter.decimate' : [False, _validate_bool], 64 'plotter.ganged' : [True, _validate_bool], 65 64 66 # scantable 65 67 'scantable.save' : ['ASAP', str], … … 87 89 88 90 # plotting 89 91 90 92 # do we want a GUI or plot to a file 91 93 plotter.gui : True 92 94 93 95 # default mode for colour stacking 94 96 plotter.stacking : Pol … … 96 98 # default mode for panelling 97 99 plotter.panelling : scan 100 101 # push panels together, to shar axislabels 102 plotter.ganged : True 98 103 99 104 # default colours/linestyles … … 221 226 return False 222 227 228 from asap._asap import LogSink as _asaplog 229 # use null sink if verbose==False 230 #asaplog=_asaplog(rcParams['verbose']) 231 asaplog=_asaplog() 232 global asaplog 223 233 from asapfitter import * 224 234 from asapreader import reader 235 225 236 from asapmath import * 237 from asap._asap import _math_setlog 238 _math_setlog(asaplog) 239 226 240 from scantable import * 227 241 from asaplinefind import * -
trunk/python/asaplotbase.py
r705 r710 12 12 from matplotlib.numerix import sqrt 13 13 from matplotlib import rc, rcParams 14 from asap import rcParams as asaprcParams 14 15 15 16 class asaplotbase: … … 34 35 self.set_panels(rows, cols) 35 36 36 # Set matplotlib default colour sequence. 37 self.colormap = ['blue', 'green', 'red', 'cyan', 'magenta', 'yellow', 'black', 'purple', 'orange', 'pink'] 37 # Set matplotlib default colour sequence. 38 self.colormap = "green red black cyan magenta orange blue purple yellow pink".split() 39 40 c = asaprcParams['plotter.colours'] 41 if isinstance(c,str) and len(c) > 0: 42 self.colormap = c.split() 43 44 self.lsalias = {"line": [1,0], 45 "dashdot": [4,2,1,2], 46 "dashed" : [4,2,4,2], 47 "dotted" : [1,2], 48 "dashdotdot": [4,2,1,2,1,2], 49 "dashdashdot": [4,2,4,2,1,2] 50 } 51 52 styles = "line dashed dotted dashdot".split() 53 c = asaprcParams['plotter.linestyles'] 54 if isinstance(c,str) and len(c) > 0: 55 styles = c.split() 56 s = [] 57 for ls in styles: 58 if self.lsalias.has_key(ls): 59 s.append(self.lsalias.get(ls)) 60 else: 61 s.append('-') 62 self.linestyles = s 63 38 64 self.color = 0; 65 self.linestyle = 0; 39 66 self.attributes = {} 40 67 self.loc = 0 … … 53 80 self.lines = [] 54 81 55 56 def palette(self, color, colormap=None): 82 def palette(self, color, colormap=None, linestyle=0, linestyles=None): 57 83 if colormap: 58 self.colormap = colormap 84 if isinstance(colormap,list): 85 self.colormap = colormap 86 elif isinstance(colormap,str): 87 self.colormap = colormap.split() 59 88 if 0 <= color < len(self.colormap): 60 89 self.color = color 90 if linestyles: 91 self.linestyles = [] 92 if isinstance(linestyles,list): 93 styles = linestyles 94 elif isinstance(linestyles,str): 95 styles = linestyles.split() 96 for ls in styles: 97 if self.lsalias.has_key(ls): 98 self.linestyles.append(self.lsalias.get(ls)) 99 else: 100 self.linestyles.append(self.lsalias.get('line')) 101 if 0 <= linestyle < len(self.linestyles): 102 self.linestyle = linestyle 61 103 62 104 def delete(self, numbers=None): … … 205 247 for segment in self.lines[i]: 206 248 getattr(segment, "set_color")(self.colormap[self.color]) 207 249 if len(self.colormap) == 1: 250 getattr(segment, "set_dashes")(self.linestyles[self.linestyle]) 208 251 self.color += 1 209 252 if self.color >= len(self.colormap): 210 253 self.color = 0 254 255 if len(self.colormap) == 1: 256 self.linestyle += 1 257 if self.linestyle >= len(self.linestyles): 258 self.linestyle = 0 211 259 212 260 self.show() -
trunk/python/asapmath.py
r665 r710 94 94 s._add_history("simple_math", varlist) 95 95 return s 96 97 -
trunk/python/asapplotter.py
r709 r710 12 12 """ 13 13 def __init__(self, visible=True): 14 15 if visible: 16 from asap.asaplotgui import asaplotgui as asaplot 17 else: 18 from asap.asaplot import asaplot 19 self._plotter = asaplot() 20 14 15 self._visible = visible 16 self._plotter = self._newplotter() 17 21 18 self._tdict = {'Time':'t','time':'t','t':'t','T':'t'} 22 19 self._bdict = {'Beam':'b','beam':'b','b':'b','B':'b'} … … 45 42 self._minmaxx = None 46 43 self._minmaxy = None 47 44 self._datamask = None 48 45 self._data = None 49 46 self._lmap = None … … 55 52 'i':None, 'p':None 56 53 } 54 self._usermask = None 55 self._usermaskspectra = None 56 57 def _newplotter(self): 58 if self._visible: 59 from asap.asaplotgui import asaplotgui as asaplot 60 else: 61 from asap.asaplot import asaplot 62 return asaplot() 63 57 64 58 65 def _translate(self, name): … … 73 80 are consistent e.g. all 'channel' or all 'velocity' etc. 74 81 """ 75 76 self._plotter = ASAPlot()82 if self._plotter.is_dead: 83 self._plotter = self._newplotter() 77 84 self._plotter.hold() 78 85 self._plotter.clear() … … 81 88 if list(args) != self._data: 82 89 self._data = list(args) 83 # reset cursor84 self. set_cursor(refresh=False)90 # reset 91 self._reset() 85 92 else: 86 self._data = list(args) 87 self.set_cursor(refresh=False) 93 if isinstance(args[0], list): 94 self._data = args[0] 95 else: 96 self._data = list(args) 97 self._reset() 88 98 # ranges become invalid when unit changes 89 99 if self._abcunit != self._data[0].get_unit(): … … 91 101 self._minmaxy = None 92 102 self._abcunit = self._data[0].get_unit() 93 103 self._datamask = None 94 104 if self._panelling == 't': 95 105 maxrows = 25 … … 125 135 ncol = eval(self._cdict.get(colmode)) 126 136 if n > 1: 137 ganged = rcParams['plotter.ganged'] 127 138 if self._rows and self._cols: 128 139 n = min(n,self._rows*self._cols) 129 140 self._plotter.set_panels(rows=self._rows,cols=self._cols, 130 nplots=n )141 nplots=n,ganged=ganged) 131 142 else: 132 self._plotter.set_panels(rows=n,cols=0,nplots=n )143 self._plotter.set_panels(rows=n,cols=0,nplots=n,ganged=ganged) 133 144 else: 134 145 self._plotter.set_panels() … … 171 182 if self._abcissa: xlab = self._abcissa 172 183 y = None 184 m = scan._getmask(rowsel) 185 if self._usermask and self._usermask.count(j): 186 m = logical_and(self._usermask, m) 173 187 if polmode == "stokes": 174 188 y = scan._getstokesspectrum(rowsel) … … 184 198 ylab = scan._get_ordinate_label() 185 199 m = scan._getmask(rowsel) 186 187 188 200 if self._datamask is not None: 201 if len(m) == len(self._datamask): 202 m = logical_and(m,self._datamask) 189 203 if self._lmap and len(self._lmap) > 0: 190 204 llab = self._lmap[jj] … … 200 214 y = y[s:e] 201 215 m = m[s:e] 216 if len(x) > 1024 and rcParams['plotter.decimate']: 217 fac = len(x)/1024 218 x = x[::fac] 219 m = m[::fac] 220 y = y[::fac] 202 221 self._plotter.plot(x,y,m) 203 222 xlim=[min(x),max(x)] 204 223 if self._minmaxx is not None: 205 206 224 xlim = self._minmaxx 225 self._plotter.axes.set_xlim(xlim) 207 226 self._plotter.set_axes('xlabel',xlab) 208 227 self._plotter.set_axes('ylabel',ylab) … … 211 230 212 231 def _plot_scans(self, scans, colmode): 213 print " Can only plot one row per scan."232 print "Plotting mode is scans across panels. Can only plot one row per scan." 214 233 if colmode == 's': 215 234 return … … 227 246 ncol = eval(self._cdict.get(colmode)) 228 247 if n > 1: 248 ganged = rcParams['plotter.ganged'] 229 249 if self._rows and self._cols: 230 250 n = min(n,self._rows*self._cols) 231 251 self._plotter.set_panels(rows=self._rows,cols=self._cols, 232 nplots=n )252 nplots=n,ganged=ganged) 233 253 else: 234 self._plotter.set_panels(rows=n,cols=0,nplots=n )254 self._plotter.set_panels(rows=n,cols=0,nplots=n,ganged=ganged) 235 255 else: 236 256 self._plotter.set_panels() … … 280 300 ylab = scan._get_ordinate_label() 281 301 m = scan._getmask(rowsel) 282 if self._datamask is not None: 283 if len(m) == len(self._datamask): 284 m = logical_and(m,self._datamask) 302 if self._usermask and self._usermask.count(j): 303 m = logical_and(self._usermask, m) 285 304 if self._lmap and len(self._lmap) > 0: 286 305 llab = self._lmap[jj] … … 296 315 y = y[s:e] 297 316 m = m[s:e] 298 317 if len(x) > 1024 and rcParams['plotter.decimate']: 318 fac = len(x)/1024 319 x = x[::fac] 320 m = m[::fac] 321 y = y[::fac] 299 322 self._plotter.plot(x,y,m) 300 323 xlim=[min(x),max(x)] 301 324 if self._minmaxx is not None: 302 325 xlim = self._minmaxx 303 326 self._plotter.axes.set_xlim(xlim) 304 327 … … 325 348 ncol = eval(self._cdict.get(colmode)) 326 349 if n > 1: 350 ganged = rcParams['plotter.ganged'] 327 351 if self._rows and self._cols: 328 352 n = min(n,self._rows*self._cols) 329 353 self._plotter.set_panels(rows=self._rows,cols=self._cols, 330 nplots=n )354 nplots=n,ganged=ganged) 331 355 else: 332 self._plotter.set_panels(rows=n,cols=0,nplots=n )356 self._plotter.set_panels(rows=n,cols=0,nplots=n,ganged=ganged) 333 357 else: 334 358 self._plotter.set_panels() … … 390 414 ylab = scan._get_ordinate_label() 391 415 m = scan._getmask(rowsel) 392 if self._datamask is not None:393 if len(m) == len(self._datamask): 394 m = logical_and(m,self._datamask) 416 if self._usermask and self._usermask.count(j): 417 m = logical_and(self._usermask, m) 418 395 419 if colmode == 's' or colmode == 't': 396 420 if self._title and len(self._title) > 0: … … 426 450 y = y[s:e] 427 451 m = m[s:e] 428 452 if len(x) > 1024 and rcParams['plotter.decimate']: 453 fac = len(x)/1024 454 x = x[::fac] 455 m = m[::fac] 456 y = y[::fac] 429 457 self._plotter.plot(x,y,m) 430 458 xlim=[min(x),max(x)] 431 459 if self._minmaxx is not None: 432 460 xlim = self._minmaxx 433 461 self._plotter.axes.set_xlim(xlim) 434 462 … … 445 473 Parameters: 446 474 stacking: tell the plotter which variable to plot 447 as line colo ur overlays (default 'pol')475 as line color overlays (default 'pol') 448 476 panelling: tell the plotter which variable to plot 449 477 across multiple panels (default 'scan' … … 531 559 mp: a list of 'strings'. This should have the same length 532 560 as the number of elements on the legend and then maps 533 to the indeces in order 561 to the indeces in order. It is possible to uses latex 562 math expression. These have to be enclosed in r'', e.g. r'$x^{2}$' 534 563 535 564 Example: … … 537 566 for CO and SiO: 538 567 plotter.set_stacking('i') 539 plotter.set_legend _map(['CO','SiO'])568 plotter.set_legend(['CO','SiO']) 540 569 plotter.plot() 570 plotter.set_legend([r'$^{12}CO$', r'SiO']) 541 571 """ 542 572 self._lmap = mp … … 545 575 546 576 def set_title(self, title=None): 577 """ 578 Set the title of the plot. If multiple panels are plotted, 579 multiple titles have to be specified. 580 Example: 581 # two panels are visible on the plotter 582 plotter.set_title(["First Panel","Second Panel"]) 583 """ 547 584 self._title = title 548 585 if self._data: self.plot() … … 550 587 551 588 def set_ordinate(self, ordinate=None): 589 """ 590 Set the y-axis label of the plot. If multiple panels are plotted, 591 multiple labels have to be specified. 592 Example: 593 # two panels are visible on the plotter 594 plotter.set_ordinate(["First Y-Axis","Second Y-Axis"]) 595 """ 552 596 self._ordinate = ordinate 553 597 if self._data: self.plot() … … 555 599 556 600 def set_abcissa(self, abcissa=None): 601 """ 602 Set the x-axis label of the plot. If multiple panels are plotted, 603 multiple labels have to be specified. 604 Example: 605 # two panels are visible on the plotter 606 plotter.set_ordinate(["First X-Axis","Second X-Axis"]) 607 """ 557 608 self._abcissa = abcissa 558 609 if self._data: self.plot() 559 610 return 560 611 561 def save(self, filename=None, orientation=None,dpi=None): 612 def set_colors(self, colormap): 613 """ 614 Set the colors to be used. The plotter will cycle through 615 these colors when lines are overlaid (stacking mode). 616 Example: 617 plotter.set_colors("red green blue") 618 # If for example four lines are overlaid e.g I Q U V 619 # 'I' will be 'red', 'Q' will be 'green', U will be 'blue' 620 # and 'V' will be 'red' again. 621 """ 622 if isinstance(colormap,str): 623 colormap = colormap.split() 624 self._plotter.palette(0,colormap=colormap) 625 if self._data: self.plot() 626 627 def set_linestyles(self, linestyles): 628 """ 629 Parameters: 630 linestyles: a list of linestyles to use. 631 'line', 'dashed', 'dotted', 'dashdot', 632 'dashdotdot' and 'dashdashdot' are 633 possible 634 635 Set the linestyles to be used. The plotter will cycle through 636 these linestyles when lines are overlaid (stacking mode) AND 637 only one color has been set. 638 Example: 639 plotter.set_colors("black") 640 plotter.set_linestyles("line dashed dotted dashdot") 641 # If for example four lines are overlaid e.g I Q U V 642 # 'I' will be 'solid', 'Q' will be 'dashed', 643 # U will be 'dotted' and 'V' will be 'dashdot'. 644 """ 645 if isinstance(linestyles,str): 646 linestyles = linestyles.split() 647 self._plotter.palette(color=0,linestyle=0,linestyles=linestyles) 648 if self._data: self.plot() 649 650 def save(self, filename=None, orientation=None, dpi=None): 562 651 """ 563 652 Save the plot to a file. The know formats are 'png', 'ps', 'eps'. … … 572 661 If None is choosen for 'ps' output, the plot is 573 662 automatically oriented to fill the page. 663 dpi: The dpi of the output non-ps plot 574 664 """ 575 665 self._plotter.save(filename,orientation,dpi) … … 640 730 dstokes2 = {"I":0,"Plinear":1,"Pangle":2,"V":3} 641 731 draw = {"XX":0, "YY":1,"Real(XY)":2, "Imag(XY)":3} 642 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag e(RL)":3}732 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag(RL)":3} 643 733 644 734 if pol is None: … … 677 767 if self._data and refresh: self.plot() 678 768 769 def set_mask(self, mask=None, pol=None): 770 if not self._data: 771 print "Can only set cursor after a first call to plot()" 772 return 773 if isinstance(mask, array): 774 self._usermask = mask 775 if isinstance(mask, list): 776 self._usermask = array(mask) 777 if mask is None and pol is None: 778 self._usermask = None 779 self._usermaskspectra = None 780 781 dstokes = {"I":0,"Q":1,"U":2,"V":3} 782 dstokes2 = {"I":0,"Plinear":1,"Pangle":2,"V":3} 783 draw = {"XX":0, "YY":1,"Real(XY)":2, "Imag(XY)":3} 784 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag(RL)":3} 785 if isinstance(pol, str): 786 pol = pol.split() 787 if isinstance(pol, list): 788 if isinstance(pol[0], str): 789 pass 790 else: 791 cpos = self._cursor[self._stacking] 792 self._usermaskspectra =filter(lambda i: filter(lambda j: j==i ,cpos),pol) 793 else: 794 return 795 self.plot() 796 679 797 def _get_pollabel(self, scan, polmode): 680 798 tlab = "" … … 711 829 return start,end 712 830 713 #if __name__ == '__main__': 714 # plotter = asapplotter() 831 def _reset(self): 832 self._usermask = None 833 self._usermaskspectra = None 834 self.set_cursor(refresh=False) -
trunk/python/scantable.py
r670 r710 8 8 The ASAP container for scans 9 9 """ 10 10 11 11 def __init__(self, filename, average=None, unit=None): 12 12 """ … … 27 27 (input rpfits/sdfits/ms) or replaces the value 28 28 in existing scantables 29 """ 29 """ 30 30 if average is None or type(average) is not bool: 31 average = rcParams['scantable.autoaverage'] 31 average = rcParams['scantable.autoaverage'] 32 32 33 33 varlist = vars() 34 34 self._vb = rcParams['verbose'] 35 35 self._p = None 36 36 from asap import asaplog 37 37 if isinstance(filename,sdtable): 38 sdtable.__init__(self, filename) 38 sdtable.__init__(self, filename) 39 39 if unit is not None: 40 self.set_fluxunit(unit) 40 self.set_fluxunit(unit) 41 41 else: 42 42 import os.path 43 43 if not os.path.exists(filename): 44 print "File '%s' not found." % (filename) 45 return 44 s = "File '%s' not found." % (filename) 45 if rcParams['verbose']: 46 asaplog.push(s) 47 print asaplog.pop().strip() 48 return 49 raise IOError(s) 46 50 filename = os.path.expandvars(filename) 47 51 if os.path.isdir(filename): … … 50 54 sdtable.__init__(self, filename) 51 55 if unit is not None: 52 self.set_fluxunit(unit) 56 self.set_fluxunit(unit) 53 57 else: 54 58 print "The given file '%s'is not a valid asap table." % (filename) 55 59 return 56 else: 60 else: 57 61 from asap._asap import sdreader 58 62 ifSel = -1 59 63 beamSel = -1 60 r = sdreader(filename,ifSel,beamSel) 61 print 'Importing data...' 64 r = sdreader() 65 r._setlog(asaplog) 66 r._open(filename,ifSel,beamSel) 67 asaplog.push('Importing data...') 62 68 r._read([-1]) 63 69 tbl = r._getdata() … … 66 72 if average: 67 73 from asap._asap import average as _av 68 print 'Auto averaging integrations...'74 asaplog.push('Auto averaging integrations...') 69 75 tbl2 = _av((tbl,),(),True,'none') 70 76 sdtable.__init__(self,tbl2) … … 74 80 del r,tbl 75 81 self._add_history("scantable", varlist) 82 log = asaplog.pop() 83 if len(log): print log 76 84 77 85 def save(self, name=None, format=None, stokes=False, overwrite=False): 78 86 """ 79 Store the scantable on disk. This can be an asap (aips++) Table, SDFITS, 87 Store the scantable on disk. This can be an asap (aips++) Table, SDFITS, 80 88 Image FITS or MS2 format. 81 89 Parameters: … … 88 96 Allowed are - 'ASAP' (save as ASAP [aips++] Table), 89 97 'SDFITS' (save as SDFITS file) 90 'FITS' (saves each row as a FITS Image) 98 'FITS' (saves each row as a FITS Image) 91 99 'ASCII' (saves as ascii text file) 92 100 'MS2' (saves as an aips++ … … 192 200 print "Illegal file name '%s'." % (filename) 193 201 print info 194 202 195 203 def set_cursor(self, beam=0, IF=0, pol=0): 196 204 """ … … 370 378 retval = {'axes': axes, 'data': array(statval), 'cursor':(i,j,k)} 371 379 return retval 372 380 373 381 def get_time(self, row=-1): 374 382 """ … … 409 417 Set the instrument for subsequent processing 410 418 Parameters: 411 instr: Select from 'ATPKSMB', 'ATPKSHOH', 'ATMOPRA', 419 instr: Select from 'ATPKSMB', 'ATPKSHOH', 'ATMOPRA', 412 420 'DSS-43' (Tid), 'CEDUNA', and 'HOBART' 413 421 """ … … 427 435 if self._p: self.plot() 428 436 self._add_history("set_doppler",vars()) 429 437 430 438 def set_freqframe(self, frame=None): 431 439 """ … … 450 458 else: 451 459 print "Please specify a valid freq type. Valid types are:\n",valid 452 460 453 461 def get_unit(self): 454 462 """ … … 474 482 """ 475 483 abc = self._getabcissa(rowno) 476 lbl = self._getabcissalabel(rowno) 484 lbl = self._getabcissalabel(rowno) 477 485 return abc, lbl 478 486 #return {'abcissa':abc,'label':lbl} … … 505 513 # masks the regions between 400 and 500 506 514 # and 800 and 900 in the unit 'channel' 507 515 508 516 """ 509 517 row = 0 … … 517 525 n = self.nchan() 518 526 msk = zeros(n) 519 for window in args: 527 # test if args is a 'list' or a 'normal *args - UGLY!!! 528 529 ws = (isinstance(args[-1][-1],int) or isinstance(args[-1][-1],float)) and args or args[0] 530 print ws 531 for window in ws: 532 print window 520 533 if (len(window) != 2 or window[0] > window[1] ): 521 534 print "A window needs to be defined as [min,max]" … … 527 540 if kwargs.get('invert'): 528 541 from numarray import logical_not 529 msk = logical_not(msk) 542 msk = logical_not(msk) 530 543 return msk 531 544 532 545 def get_restfreqs(self): 533 546 """ … … 558 571 a vector, then it MUST be of length the number of IFs 559 572 (and the available restfrequencies will be replaced by 560 this vector). In this case, *all* data ('source' and 561 'theif' are ignored) have the restfrequency set per IF according 562 to the corresponding value you give in the 'freqs' vector. 563 E.g. 'freqs=[1e9,2e9]' would mean IF 0 gets restfreq 1e9 and 573 this vector). In this case, *all* data ('source' and 574 'theif' are ignored) have the restfrequency set per IF according 575 to the corresponding value you give in the 'freqs' vector. 576 E.g. 'freqs=[1e9,2e9]' would mean IF 0 gets restfreq 1e9 and 564 577 IF 1 gets restfreq 2e9. 565 578 … … 596 609 sdtable._setrestfreqs(self, freqs, unit, lines, source, theif) 597 610 self._add_history("set_restfreqs", varlist) 598 611 599 612 600 613 … … 633 646 """ 634 647 print "Warning! Not fully functional. Use plotter.plot() instead" 635 648 636 649 validcol = {'Beam':self.nbeam(),'IF':self.nif(),'Pol':self.npol()} 637 650 … … 659 672 xlab,ylab,tlab = None,None,None 660 673 self._vb = False 661 sel = self.get_cursor() 674 sel = self.get_cursor() 662 675 for i in range(npan): 663 676 if npan > 1: … … 700 713 return 701 714 702 print out 715 print out 703 716 704 717 def _print_values(self, dat, label='', timestamps=[]): … … 722 735 print " ", label 723 736 print "-"*80 724 print out 737 print out 725 738 726 739 def history(self): … … 735 748 func = items[1] 736 749 items = items[2:] 737 print date 750 print date 738 751 print "Function: %s\n Parameters:" % (func) 739 752 for i in items: … … 765 778 Example: 766 779 # time average the scantable without using a mask 767 newscan = scan.average_time() 780 newscan = scan.average_time() 768 781 """ 769 782 varlist = vars() 770 783 if weight is None: weight = 'tint' 771 784 if mask is None: mask = () 772 from asap._asap import average as _av 785 from asap._asap import average as _av 773 786 s = scantable(_av((self,), mask, scanav, weight)) 774 787 s._add_history("average_time",varlist) 775 788 return s 776 789 777 790 def convert_flux(self, jyperk=None, eta=None, d=None, insitu=None, 778 791 allaxes=None): … … 873 886 self._add_history("gain_el", varlist) 874 887 return 875 888 876 889 def freq_align(self, reftime=None, method='cubic', perif=False, 877 890 insitu=None): … … 957 970 return 958 971 959 972 960 973 def resample(self, width=5, method='cubic', insitu=None): 961 974 """ … … 1111 1124 from asap.asaplinefind import linefinder 1112 1125 from asap import _is_sequence_or_number as _is_valid 1113 1126 1114 1127 if not _is_valid(edge, int): 1115 1128 raise RuntimeError, "Parameter 'edge' has to be an integer or a \ 1116 1129 pair of integers specified as a tuple" 1117 1130 1118 1131 # setup fitter 1119 1132 f = fitter() … … 1161 1174 def rotate_linpolphase(self, angle, allaxes=None): 1162 1175 """ 1163 Rotate the phase of the complex polarization O=Q+iU correlation. 1164 This is always done in situ in the raw data. So if you call this 1176 Rotate the phase of the complex polarization O=Q+iU correlation. 1177 This is always done in situ in the raw data. So if you call this 1165 1178 function more than once then each call rotates the phase further. 1166 1179 Parameters: … … 1178 1191 self._add_history("rotate_linpolphase", varlist) 1179 1192 return 1180 1193 1181 1194 1182 1195 def rotate_xyphase(self, angle, allaxes=None): … … 1266 1279 trailing '_R' (Mopra/Parkes) or 1267 1280 '_e'/'_w' (Tid) 1268 preserve: you can preserve (default) the continuum or 1269 remove it. The equations used are 1281 preserve: you can preserve (default) the continuum or 1282 remove it. The equations used are 1270 1283 preserve: Output = Toff * (on/off) - Toff 1271 1284 remove: Output = Tref * (on/off) - Ton … … 1280 1293 srcs = self.get_scan("*[^_ewR]") 1281 1294 refs = self.get_scan("*[_ewR]") 1282 return scantable(_quot(srcs,refs, preserve)) 1295 if isinstance(srcs,scantable) and isinstance(refs,scantable): 1296 ns,nr = srcs.nrow(),refs.nrow() 1297 if nr > ns: 1298 refs = refs.get_scan(range(ns)) 1299 return scantable(_quot(srcs,refs, preserve)) 1300 else: 1301 raise RuntimeError("Couldn't find any on/off pairs") 1283 1302 else: 1284 1303 print "not yet implemented" 1285 1304 return None 1286 1305 1287 1306 def quotient(self, other, isreference=True, preserve=True): 1288 1307 """ … … 1296 1315 isreference: if the 'other' scan is the reference (default) 1297 1316 or source 1298 preserve: you can preserve (default) the continuum or 1299 remove it. The equations used are 1317 preserve: you can preserve (default) the continuum or 1318 remove it. The equations used are 1300 1319 preserve: Output = Toff * (on/off) - Toff 1301 1320 remove: Output = Tref * (on/off) - Ton … … 1316 1335 s = None 1317 1336 if isinstance(other, scantable): 1318 from asap._asap import b_operate as _bop 1337 from asap._asap import b_operate as _bop 1319 1338 s = scantable(_bop(self, other, 'add', True)) 1320 1339 elif isinstance(other, float): … … 1335 1354 s = None 1336 1355 if isinstance(other, scantable): 1337 from asap._asap import b_operate as _bop 1356 from asap._asap import b_operate as _bop 1338 1357 s = scantable(_bop(self, other, 'sub', True)) 1339 1358 elif isinstance(other, float): … … 1345 1364 s._add_history("operator -", varlist) 1346 1365 return s 1347 1366 1348 1367 def __mul__(self, other): 1349 1368 """ … … 1353 1372 s = None 1354 1373 if isinstance(other, scantable): 1355 from asap._asap import b_operate as _bop 1374 from asap._asap import b_operate as _bop 1356 1375 s = scantable(_bop(self, other, 'mul', True)) 1357 1376 elif isinstance(other, float): … … 1366 1385 s._add_history("operator *", varlist) 1367 1386 return s 1368 1387 1369 1388 1370 1389 def __div__(self, other): … … 1375 1394 s = None 1376 1395 if isinstance(other, scantable): 1377 from asap._asap import b_operate as _bop 1396 from asap._asap import b_operate as _bop 1378 1397 s = scantable(_bop(self, other, 'div', True)) 1379 1398 elif isinstance(other, float): … … 1442 1461 hist = hist[:-2] # remove trailing '##' 1443 1462 self._addhistory(hist) 1444 1463 1445 1464 1446 1465 def _zip_mask(self, mask): … … 1453 1472 j = i + mask[i:].index(0) 1454 1473 else: 1455 j = len(mask) 1474 j = len(mask) 1456 1475 segments.append([i,j]) 1457 i = j 1476 i = j 1458 1477 return segments 1459 1478 def _get_ordinate_label(self): … … 1466 1485 lbl = "Flux density "+ fu 1467 1486 return lbl 1468 1487
Note:
See TracChangeset
for help on using the changeset viewer.