Opened 16 years ago

Closed 16 years ago

#140 closed defect (fixed)

Plotter unable to plot scans that have been averaged together with the align=True option

Reported by: slbreen@… Owned by: Malte Marquarding
Priority: normal Milestone: ASAP 2.2
Component: General Version: 2.0
Severity: normal Keywords:
Cc: slbreen@…

Description

The plotter is unable to plot scans that have been averaged together with the command

avtime = final.average_time(align=True)

the error when trying to plot 'avtime' with plotter.plot(avtime) is

Warning: invalid value encountered in reduce Warning: invalid value encountered in reduce


Traceback (most recent call last):

File "<ipython console>", line 1, in ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/asap/asapplotter.py", line 97, in plot

self._plotter.release()

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/asap/asaplotbase.py", line 381, in release

self.show()

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/asap/asaplotgui.py", line 187, in show

self.canvas.show()

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 154, in draw

FigureCanvasAgg.draw(self)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 392, in draw

self.figure.draw(renderer)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/figure.py", line 544, in draw

for a in self.axes: a.draw(renderer)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axes.py", line 1063, in draw

a.draw(renderer)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axis.py", line 547, in draw

self.major.formatter.set_locs(majorLocs)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/ticker.py", line 315, in set_locs

self._set_format()

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/ticker.py", line 356, in _set_format

sigfigs = [len(str('%1.3f'% loc).split('.')[1].rstrip('0')) \

IndexError: list index out of range

This only occurs with the align=True option, as if this creates some nan values that plotter cannot cope with. Plotter is able to plot these scans if you manually set the range the plotter should plot.

Change History (3)

comment:1 by Malte Marquarding, 16 years ago

Owner: changed from Malte Marquarding to Malte Marquarding
Status: newassigned

Hi,

again could you provide the 'final' scantable. in asap

final.save("final.sdfits","SDFITS")

and then attach it to this ticket (if it isn't too big)

If possible also attach the script/commands you used.

Cheers, Malte

comment:2 by Malte Marquarding, 16 years ago

Hi,

the problem lies indeed with NaNs. In the latest version of matplotlib (0.98) I don't see the error, the plotter panel remains empty though. To work around this use

def flag_nans(scan):
  import numpy
  basesel = scan.get_selection()
  for i in range(scan.nrow()):
    sel = selector()+basesel
    sel.set_scans(scan.getscan(i))
    sel.set_beams(scan.getbeam(i))
    sel.set_ifs(scan.getif(i))
    sel.set_polarisations(scan.getpol(i))
    scan.set_selection(sel)
    nans = numpy.isnan(scan._getspectrum(0))
    if numpy.any(nans):
      print i
      bnans = [ bool(i) for i in nans]
      scan.flag(bnans)
    scan.set_selection(basesel)

This will flag all NaNs in the scan channels. I might add thsi function to the next asap release.

comment:3 by Malte Marquarding, 16 years ago

Resolution: fixed
Status: assignedclosed

I have added this function as scantable.flag_nans

Note: See TracTickets for help on using tickets.