source: branches/Release-2-fixes/python/asapplotter.py@ 3037

Last change on this file since 3037 was 693, checked in by mar637, 19 years ago

added user customisable color and linestyles

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.2 KB
Line 
1from asap.asaplot import ASAPlot
2from asap import rcParams
3
4class asapplotter:
5 """
6 The ASAP plotter.
7 By default the plotter is set up to plot polarisations
8 'colour stacked' and scantables across panels.
9 Note:
10 Currenly it only plots 'spectra' not Tsys or
11 other variables.
12 """
13 def __init__(self):
14 self._plotter = ASAPlot()
15
16 self._tdict = {'Time':'t','time':'t','t':'t','T':'t'}
17 self._bdict = {'Beam':'b','beam':'b','b':'b','B':'b'}
18 self._idict = {'IF':'i','if':'i','i':'i','I':'i'}
19 self._pdict = {'Pol':'p','pol':'p','p':'p'}
20 self._sdict = {'scan':'s','Scan':'s','s':'s','S':'s'}
21 self._cdict = {'t':'len(self._cursor["t"])',
22 'b':'len(self._cursor["b"])',
23 'i':'len(self._cursor["i"])',
24 'p':'len(self._cursor["p"])',
25 's':'len(scans)'}
26 self._ldict = {'b':'Beam',
27 'i':'IF',
28 'p':'Pol',
29 's':'Scan'}
30 self._dicts = [self._tdict,self._bdict,
31 self._idict,self._pdict,
32 self._sdict]
33 self._panelling = None
34 self._stacking = None
35 self.set_panelling()
36 self.set_stacking()
37 self._rows = None
38 self._cols = None
39 self._autoplot = False
40 self._minmaxx = None
41 self._minmaxy = None
42 self._data = None
43 self._lmap = None
44 self._title = None
45 self._ordinate = None
46 self._abcissa = None
47 self._abcunit = None
48 self._cursor = {'t':None, 'b':None,
49 'i':None, 'p':None
50 }
51
52 def _translate(self, name):
53 for d in self._dicts:
54 if d.has_key(name):
55 return d[name]
56 return None
57
58 def plot(self, *args):
59 """
60 Plot a (list of) scantables.
61 Parameters:
62 one or more comma separated scantables
63 Note:
64 If a (list) of scantables was specified in a previous call
65 to plot, no argument has to be given to 'replot'
66 NO checking is done that the abcissas of the scantables
67 are consistent e.g. all 'channel' or all 'velocity' etc.
68 """
69 if self._plotter.is_dead:
70 self._plotter = ASAPlot()
71 self._plotter.hold()
72 self._plotter.clear()
73 if len(args) > 0:
74 if self._data is not None:
75 if list(args) != self._data:
76 self._data = list(args)
77 # reset cursor
78 self.set_cursor(refresh=False)
79 else:
80 self._data = list(args)
81 self.set_cursor(refresh=False)
82 # ranges become invalid when unit changes
83 if self._abcunit != self._data[0].get_unit():
84 self._minmaxx = None
85 self._minmaxy = None
86 self._abcunit = self._data[0].get_unit()
87 if self._panelling == 't':
88 maxrows = 25
89 if self._data[0].nrow() > maxrows:
90 if self._cursor["t"] is None or \
91 (isinstance(self._cursor["t"],list) and \
92 len(self._cursor["t"]) > maxrows ):
93 print "Scan to be plotted contains more than %d rows.\n" \
94 "Selecting first %d rows..." % (maxrows,maxrows)
95 self._cursor["t"] = range(maxrows)
96 self._plot_time(self._data[0], self._stacking)
97 elif self._panelling == 's':
98 self._plot_scans(self._data, self._stacking)
99 else:
100 self._plot_other(self._data, self._stacking)
101 if self._minmaxy is not None:
102 self._plotter.set_limits(ylim=self._minmaxy)
103 self._plotter.release()
104 return
105
106 def _plot_time(self, scan, colmode):
107 if colmode == 't':
108 return
109 n = len(self._cursor["t"])
110 cdict = {'b':'scan.setbeam(j)',
111 'i':'scan.setif(j)',
112 'p':'scan.setpol(j)'}
113 cdict2 = {'b':'self._cursor["b"]',
114 'i':'self._cursor["i"]',
115 'p':'self._cursor["p"]'}
116 ncol = 1
117 if self._stacking is not None:
118 ncol = eval(self._cdict.get(colmode))
119 if n > 1:
120 if self._rows and self._cols:
121 n = min(n,self._rows*self._cols)
122 self._plotter.set_panels(rows=self._rows,cols=self._cols,
123 nplots=n)
124 else:
125 self._plotter.set_panels(rows=n,cols=0,nplots=n)
126 else:
127 self._plotter.set_panels()
128 rows = self._cursor["t"]
129 self._plotter.palette(0)
130 for rowsel in rows:
131 i = self._cursor["t"].index(rowsel)
132 if n > 1:
133 self._plotter.palette(0)
134 self._plotter.subplot(i)
135 colvals = eval(cdict2.get(colmode))
136 for j in colvals:
137 polmode = "raw"
138 jj = colvals.index(j)
139 savej = j
140 for k in cdict.keys():
141 sel = eval(cdict2.get(k))
142 j = sel[0]
143 if k == "p":
144 which = self._cursor["p"].index(j)
145 polmode = self._polmode[which]
146 j = which
147 eval(cdict.get(k))
148 j = savej
149 if colmode == "p":
150 polmode = self._polmode[self._cursor["p"].index(j)]
151 #j = jj
152 eval(cdict.get(colmode))
153 x = None
154 y = None
155 m = None
156 if self._title is None:
157 tlab = scan._getsourcename(rowsel)
158 else:
159 if len(self._title) >= n:
160 tlab = self._title[rowsel]
161 else:
162 tlab = scan._getsourcename(rowsel)
163 x,xlab = scan.get_abcissa(rowsel)
164 if self._abcissa: xlab = self._abcissa
165 y = None
166 if polmode == "stokes":
167 y = scan._getstokesspectrum(rowsel)
168 elif polmode == "stokes2":
169 y = scan._getstokesspectrum(rowsel,True)
170 elif polmode == "circular":
171 y = scan._stokestopolspectrum(rowsel,False,-1)
172 else:
173 y = scan._getspectrum(rowsel)
174 if self._ordinate:
175 ylab = self._ordinate
176 else:
177 ylab = scan._get_ordinate_label()
178 m = scan._getmask(rowsel)
179 if self._lmap and len(self._lmap) > 0:
180 llab = self._lmap[jj]
181 else:
182 if colmode == 'p':
183 llab = self._get_pollabel(scan, polmode)
184 else:
185 llab = self._ldict.get(colmode)+' '+str(j)
186 self._plotter.set_line(label=llab)
187 if self._minmaxx is not None:
188 s,e = self._slice_indeces(x)
189 x = x[s:e]
190 y = y[s:e]
191 m = m[s:e]
192 self._plotter.plot(x,y,m)
193
194 xlim=[min(x),max(x)]
195 if self._minmaxx is not None:
196 xlim = self._minmaxx
197 self._plotter.axes.set_xlim(xlim)
198 self._plotter.set_axes('xlabel',xlab)
199 self._plotter.set_axes('ylabel',ylab)
200 self._plotter.set_axes('title',tlab)
201 return
202
203 def _plot_scans(self, scans, colmode):
204 print "Plotting mode is scans across panels. Can only plot one row per scan."
205 if colmode == 's':
206 return
207 cdict = {'b':'scan.setbeam(j)',
208 'i':'scan.setif(j)',
209 'p':'scan.setpol(j)'}
210 cdict2 = {'b':'self._cursor["b"]',
211 'i':'self._cursor["i"]',
212 'p':'self._cursor["p"]'}
213
214 n = len(scans)
215 ncol = 1
216 if self._stacking is not None:
217 scan = scans[0]
218 ncol = eval(self._cdict.get(colmode))
219 if n > 1:
220 if self._rows and self._cols:
221 n = min(n,self._rows*self._cols)
222 self._plotter.set_panels(rows=self._rows,cols=self._cols,
223 nplots=n)
224 else:
225 self._plotter.set_panels(rows=n,cols=0,nplots=n)
226 else:
227 self._plotter.set_panels()
228
229 for scan in scans:
230 self._plotter.palette(0)
231 if n > 1:
232 self._plotter.subplot(scans.index(scan))
233 colvals = eval(cdict2.get(colmode))
234 rowsel = self._cursor["t"][0]
235 for j in colvals:
236 polmode = "raw"
237 jj = colvals.index(j)
238 savej = j
239 for k in cdict.keys():
240 sel = eval(cdict2.get(k))
241 j = sel[0]
242 eval(cdict.get(k))
243 if k == "p":
244 which = self._cursor["p"].index(j)
245 polmode = self._polmode[which]
246 j = which
247 j = savej
248 if colmode == "p":
249 polmode = self._polmode[self._cursor["p"].index(j)]
250 #j = jj
251 eval(cdict.get(colmode))
252 x = None
253 y = None
254 m = None
255 tlab = self._title
256 if not self._title:
257 tlab = scan._getsourcename(rowsel)
258 x,xlab = scan.get_abcissa(rowsel)
259 if self._abcissa: xlab = self._abcissa
260 if polmode == "stokes":
261 y = scan._getstokesspectrum(rowsel)
262 elif polmode == "stokes2":
263 y = scan._getstokesspectrum(rowsel,True)
264 elif polmode == "circular":
265 y = scan._stokestopolspectrum(rowsel,False,-1)
266 else:
267 y = scan._getspectrum(rowsel)
268 if self._ordinate:
269 ylab = self._ordinate
270 else:
271 ylab = scan._get_ordinate_label()
272 m = scan._getmask(rowsel)
273 if self._lmap and len(self._lmap) > 0:
274 llab = self._lmap[jj]
275 else:
276 if colmode == 'p':
277 llab = self._get_pollabel(scan, polmode)
278 else:
279 llab = self._ldict.get(colmode)+' '+str(j)
280 self._plotter.set_line(label=llab)
281 if self._minmaxx is not None:
282 s,e = self._slice_indeces(x)
283 x = x[s:e]
284 y = y[s:e]
285 m = m[s:e]
286
287 self._plotter.plot(x,y,m)
288 xlim=[min(x),max(x)]
289 if self._minmaxx is not None:
290 xlim = self._minmaxx
291 self._plotter.axes.set_xlim(xlim)
292
293 self._plotter.set_axes('xlabel',xlab)
294 self._plotter.set_axes('ylabel',ylab)
295 self._plotter.set_axes('title',tlab)
296 return
297
298 def _plot_other(self,scans,colmode):
299 if colmode == self._panelling:
300 return
301 cdict = {'b':'scan.setbeam(i)',
302 'i':'scan.setif(i)',
303 'p':'scan.setpol(i)'}
304 cdict2 = {'b':'self._cursor["b"]',
305 'i':'self._cursor["i"]',
306 'p':'self._cursor["p"]',
307 's': 'scans',
308 't': 'self._cursor["t"]'}
309 scan = scans[0]
310 n = eval(self._cdict.get(self._panelling))
311 ncol=1
312 if self._stacking is not None:
313 ncol = eval(self._cdict.get(colmode))
314 if n > 1:
315 if self._rows and self._cols:
316 n = min(n,self._rows*self._cols)
317 self._plotter.set_panels(rows=self._rows,cols=self._cols,
318 nplots=n)
319 else:
320 self._plotter.set_panels(rows=n,cols=0,nplots=n)
321 else:
322 self._plotter.set_panels()
323 panels = self._cursor[self._panelling]
324 for i in panels:
325 self._plotter.palette(0)
326 polmode = "raw"
327 ii = self._cursor[self._panelling].index(i)
328 if n>1:
329 self._plotter.subplot(ii)
330 if self._panelling == "p":
331 polmode = self._polmode[ii]
332 eval(cdict.get(self._panelling))
333 else:
334 eval(cdict.get(self._panelling))
335 colvals = eval(cdict2.get(colmode))
336 for j in colvals:
337 rowsel = self._cursor["t"][0]
338 jj = colvals.index(j)
339 savei = i
340 for k in cdict.keys():
341 if k != self._panelling:
342 sel = eval(cdict2.get(k))
343 i = sel[0]
344 if k == "p":
345 which = self._cursor["p"].index(i)
346 polmode = self._polmode[which]
347 i = which
348 eval(cdict.get(k))
349 i = savei
350 if colmode == 's':
351 scan = j
352 elif colmode == 't':
353 rowsel = j
354 else:
355 savei = i
356 if colmode == 'p':
357 polmode = self._polmode[self._cursor["p"].index(j)]
358 i = j
359 eval(cdict.get(colmode))
360 i = savei
361 x = None
362 y = None
363 m = None
364 x,xlab = scan.get_abcissa(rowsel)
365 if self._abcissa: xlab = self._abcissa
366 if polmode == "stokes":
367 y = scan._getstokesspectrum(rowsel)
368 elif polmode == "stokes2":
369 y = scan._getstokesspectrum(rowsel,True)
370 elif polmode == "circular":
371 y = scan._stokestopolspectrum(rowsel,False,-1)
372 else:
373 y = scan._getspectrum(rowsel)
374
375 if self._ordinate:
376 ylab = self._ordinate
377 else:
378 ylab = scan._get_ordinate_label()
379 m = scan._getmask(rowsel)
380 if colmode == 's' or colmode == 't':
381 if self._title and len(self._title) > 0:
382 tlab = self._title[ii]
383 else:
384 if self._panelling == 'p':
385 tlab = self._get_pollabel(scan, polmode)
386 else:
387 tlab = self._ldict.get(self._panelling)+' '+str(i)
388 if self._lmap and len(self._lmap) > 0:
389 llab = self._lmap[jj]
390 else:
391 llab = scan._getsourcename(rowsel)
392 else:
393 if self._title and len(self._title) > 0:
394 tlab = self._title[ii]
395 else:
396 if self._panelling == 'p':
397 tlab = self._get_pollabel(scan, polmode)
398 else:
399 tlab = self._ldict.get(self._panelling)+' '+str(i)
400 if self._lmap and len(self._lmap) > 0:
401 llab = self._lmap[jj]
402 else:
403 if colmode == 'p':
404 llab = self._get_pollabel(scan, polmode)
405 else:
406 llab = self._ldict.get(colmode)+' '+str(j)
407 self._plotter.set_line(label=llab)
408 if self._minmaxx is not None:
409 s,e = self._slice_indeces(x)
410 x = x[s:e]
411 y = y[s:e]
412 m = m[s:e]
413
414 self._plotter.plot(x,y,m)
415 xlim=[min(x),max(x)]
416 if self._minmaxx is not None:
417 xlim = self._minmaxx
418 self._plotter.axes.set_xlim(xlim)
419
420 self._plotter.set_axes('xlabel',xlab)
421 self._plotter.set_axes('ylabel',ylab)
422 self._plotter.set_axes('title',tlab)
423
424 return
425
426
427 def set_mode(self, stacking=None, panelling=None):
428 """
429 Set the plots look and feel, i.e. what you want to see on the plot.
430 Parameters:
431 stacking: tell the plotter which variable to plot
432 as line color overlays (default 'pol')
433 panelling: tell the plotter which variable to plot
434 across multiple panels (default 'scan'
435 Note:
436 Valid modes are:
437 'beam' 'Beam' 'b': Beams
438 'if' 'IF' 'i': IFs
439 'pol' 'Pol' 'p': Polarisations
440 'scan' 'Scan' 's': Scans
441 'time' 'Time' 't': Times
442 """
443 if not self.set_panelling(panelling):
444 print "Invalid mode"
445 return
446 if not self.set_stacking(stacking):
447 print "Invalid mode"
448 return
449 if self._data: self.plot()
450 return
451
452 def set_panelling(self, what=None):
453 mode = what
454 if mode is None:
455 mode = rcParams['plotter.panelling']
456 md = self._translate(mode)
457 if md:
458 self._panelling = md
459 self._title = None
460 return True
461 return False
462
463 def set_layout(self,rows=None,cols=None):
464 """
465 Set the multi-panel layout, i.e. how many rows and columns plots
466 are visible.
467 Parameters:
468 rows: The number of rows of plots
469 cols: The number of columns of plots
470 Note:
471 If no argument is given, the potter reverts to its auto-plot
472 behaviour.
473 """
474 self._rows = rows
475 self._cols = cols
476 if self._data: self.plot()
477 return
478
479 def set_stacking(self, what=None):
480 mode = what
481 if mode is None:
482 mode = rcParams['plotter.stacking']
483 md = self._translate(mode)
484 if md:
485 self._stacking = md
486 self._lmap = None
487 return True
488 return False
489
490 def set_range(self,xstart=None,xend=None,ystart=None,yend=None):
491 """
492 Set the range of interest on the abcissa of the plot
493 Parameters:
494 [x,y]start,[x,y]end: The start and end points of the 'zoom' window
495 Note:
496 These become non-sensical when the unit changes.
497 use plotter.set_range() without parameters to reset
498
499 """
500 if xstart is None and xend is None:
501 self._minmaxx = None
502 else:
503 self._minmaxx = [xstart,xend]
504 if ystart is None and yend is None:
505 self._minmaxy = None
506 else:
507 self._minmaxy = [ystart,yend]
508 if self._data: self.plot()
509 return
510
511 def set_legend(self, mp=None):
512 """
513 Specify a mapping for the legend instead of using the default
514 indices:
515 Parameters:
516 mp: a list of 'strings'. This should have the same length
517 as the number of elements on the legend and then maps
518 to the indeces in order. It is possible to uses latex
519 math expression. These have to be enclosed in r'', e.g. r'$x^{2}$'
520
521 Example:
522 If the data has two IFs/rest frequencies with index 0 and 1
523 for CO and SiO:
524 plotter.set_stacking('i')
525 plotter.set_legend(['CO','SiO'])
526 plotter.plot()
527 plotter.set_legend([r'$^{12}CO$', r'SiO'])
528 """
529 self._lmap = mp
530 if self._data: self.plot()
531 return
532
533 def set_title(self, title=None):
534 """
535 Set the title of the plot. If multiple panels are plotted,
536 multiple titles have to be specified.
537 Example:
538 # two panels are visible on the plotter
539 plotter.set_title(["First Panel","Second Panel"])
540 """
541 self._title = title
542 if self._data: self.plot()
543 return
544
545 def set_ordinate(self, ordinate=None):
546 """
547 Set the y-axis label of the plot. If multiple panels are plotted,
548 multiple labels have to be specified.
549 Example:
550 # two panels are visible on the plotter
551 plotter.set_ordinate(["First Y-Axis","Second Y-Axis"])
552 """
553 self._ordinate = ordinate
554 if self._data: self.plot()
555 return
556
557 def set_abcissa(self, abcissa=None):
558 """
559 Set the x-axis label of the plot. If multiple panels are plotted,
560 multiple labels have to be specified.
561 Example:
562 # two panels are visible on the plotter
563 plotter.set_ordinate(["First X-Axis","Second X-Axis"])
564 """
565 self._abcissa = abcissa
566 if self._data: self.plot()
567 return
568
569 def set_colors(self, colormap):
570 """
571 Set the colors to be used. The plotter will cycle through
572 these colors when lines are overlaid (stacking mode).
573 Example:
574 plotter.set_colors("red green blue")
575 # If for example four lines are overlaid e.g I Q U V
576 # 'I' will be 'red', 'Q' will be 'green', U will be 'blue'
577 # and 'V' will be 'red' again.
578 """
579 self._plotter.palette(0,colormap=colormap)
580 if self._data: self.plot()
581
582 def set_linestyles(self, linestyles):
583 """
584 Parameters:
585 linestyles: a list of linestyles to use.
586 'line', 'dashed', 'dotted', 'dashdot',
587 'dashdotdot' and 'dashdashdot' are
588 possible
589
590 Set the linestyles to be used. The plotter will cycle through
591 these linestyles when lines are overlaid (stacking mode) AND
592 only one color has been set.
593 Example:
594 plotter.set_colors("black")
595 plotter.set_linestyles("line dashed dotted dashdot")
596 # If for example four lines are overlaid e.g I Q U V
597 # 'I' will be 'solid', 'Q' will be 'dashed',
598 # U will be 'dotted' and 'V' will be 'dashdot'.
599 """
600 self._plotter.palette(color=0,linestyle=0,linestyles=linestyles)
601 if self._data: self.plot()
602
603 def save(self, filename=None, orientation=None):
604 """
605 Save the plot to a file. The know formats are 'png', 'ps', 'eps'.
606 Parameters:
607 filename: The name of the output file. This is optional
608 and autodetects the image format from the file
609 suffix. If non filename is specified a file
610 called 'yyyymmdd_hhmmss.png' is created in the
611 current directory.
612 orientation: optional parameter for postscript only (not eps).
613 'landscape', 'portrait' or None (default) are valid.
614 If None is choosen for 'ps' output, the plot is
615 automatically oriented to fill the page.
616 """
617 self._plotter.save(filename,orientation)
618 return
619
620 def set_cursor(self, row=None,beam=None,IF=None,pol=None, refresh=True):
621 """
622 Specify a 'cursor' for plotting selected spectra. Time (rows),
623 Beam, IF, Polarisation ranges can be specified.
624 Parameters:
625 Default for all paramaters is to select all available
626 row: selects the rows (time stamps) to be plotted, this has
627 to be a vector of row indices, e.g. row=[0,2,5] or row=[2]
628 beam: select a range of beams
629 IF: select a range of IFs
630 pol: select Polarisations for plotting these can be by index
631 (raw polarisations (default)) or by names any of:
632 ["I", "Q", "U", "V"] or
633 ["I", "Plinear", "Pangle", "V"] or
634 ["XX", "YY", "Real(XY)", "Imag(XY)"] or
635 ["RR", "LL"]
636 Example:
637 plotter.set_mode('pol','time')
638 plotter.plot(myscan) # plots all raw polarisations colour stacked
639 plotter.set_cursor(pol=["I"]) # plot "I" only for all rows
640 # plot "I" only for two time stamps row=0 and row=2
641 plotter.set_cursor(row=[0,2],pol=["I"])
642
643 Note:
644 Be careful to select only exisiting polarisations.
645 """
646 if not self._data:
647 print "Can only set cursor after a first call to plot()"
648 return
649
650 n = self._data[0].nrow()
651 if row is None:
652 self._cursor["t"] = range(n)
653 else:
654 for i in row:
655 if i < 0 or i >= n:
656 print "Row index '%d' out of range" % i
657 return
658 self._cursor["t"] = row
659
660 n = self._data[0].nbeam()
661 if beam is None:
662 self._cursor["b"] = range(n)
663 else:
664 for i in beam:
665 if i < 0 or i >= n:
666 print "Beam index '%d' out of range" % i
667 return
668 self._cursor["b"] = beam
669
670 n = self._data[0].nif()
671 if IF is None:
672 self._cursor["i"] = range(n)
673 else:
674 for i in IF:
675 if i < 0 or i >= n:
676 print "IF index '%d' out of range" %i
677 return
678 self._cursor["i"] = IF
679
680 n = self._data[0].npol()
681 dstokes = {"I":0,"Q":1,"U":2,"V":3}
682 dstokes2 = {"I":0,"Plinear":1,"Pangle":2,"V":3}
683 draw = {"XX":0, "YY":1,"Real(XY)":2, "Imag(XY)":3}
684 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag(RL)":3}
685
686 if pol is None:
687 self._cursor["p"] = range(n)
688 self._polmode = ["raw" for i in range(n)]
689 else:
690 if isinstance(pol,str):
691 pol = pol.split()
692 polmode = []
693 pols = []
694 for i in pol:
695 if isinstance(i,str):
696 if draw.has_key(i):
697 pols.append(draw.get(i))
698 polmode.append("raw")
699 elif dstokes.has_key(i):
700 pols.append(dstokes.get(i))
701 polmode.append("stokes")
702 elif dstokes2.has_key(i):
703 pols.append(dstokes2.get(i))
704 polmode.append("stokes2")
705 elif dcirc.has_key(i):
706 pols.append(dcirc.get(i))
707 polmode.append("circular")
708 else:
709 print "Pol type '%s' not valid" %i
710 return
711 elif 0 > i >= n:
712 print "Pol index '%d' out of range" %i
713 return
714 else:
715 pols.append(i)
716 polmode.append("raw")
717 self._cursor["p"] = pols
718 self._polmode = polmode
719 if self._data and refresh: self.plot()
720
721 def _get_pollabel(self, scan, polmode):
722 tlab = ""
723 if polmode == "stokes":
724 tlab = scan._getpolarizationlabel(0,1,0)
725 elif polmode == "stokes2":
726 tlab = scan._getpolarizationlabel(0,1,1)
727 elif polmode == "circular":
728 tlab = scan._getpolarizationlabel(0,0,0)
729 else:
730 tlab = scan._getpolarizationlabel(1,0,0)
731 return tlab
732
733 def _slice_indeces(self, data):
734 mn = self._minmaxx[0]
735 mx = self._minmaxx[1]
736 asc = data[0] < data[-1]
737 start=0
738 end = len(data)-1
739 inc = 1
740 if not asc:
741 start = len(data)-1
742 end = 0
743 inc = -1
744 # find min index
745 while data[start] < mn:
746 start+= inc
747 # find max index
748 while data[end] > mx:
749 end-=inc
750 end +=1
751 if start > end:
752 return end,start
753 return start,end
754
755if __name__ == '__main__':
756 plotter = asapplotter()
Note: See TracBrowser for help on using the repository browser.