FXIhub / hummingbird

Monitoring and Analysing flash X-ray imaging experiments
http://fxihub.github.io/hummingbird
BSD 2-Clause "Simplified" License
16 stars 14 forks source link

Error when showing plotMeanMap with Python 3 #138

Closed FilipeMaia closed 2 years ago

FilipeMaia commented 2 years ago

When trying the example examples/basic/correlation.py I get an error when trying to display the result of the plotMeanMap on the frontend. The traceback is:


Traceback (most recent call last):
  File "/Users/filipe/src/hummingbird/src/interface/gui.py", line 222, in _replot
    p.replot()
  File "/Users/filipe/src/hummingbird/src/interface/ui/image_window.py", line 488, in replot
    img, transform, x, y = self._fill_meanmap(times, triples,
  File "/Users/filipe/src/hummingbird/src/interface/ui/image_window.py", line 356, in _fill_meanmap
    self.meanmap[0,iy,ix] += z
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices```
andyofmelbourne commented 2 years ago

That is because numpy.round returns a float, at least in python 3 (not sure about 2).

solution (src/interface/ui/image_window.py:344):

            ix = numpy.round((x - (self.mm_xmin+self.mm_dx/2.))/self.mm_dx).astype(numpy.int)
            iy = numpy.round((y - (self.mm_ymin+self.mm_dy/2.))/self.mm_dy).astype(numpy.int)

I do get further errors downsteam of this by the way.

FilipeMaia commented 2 years ago

44b91ac fixes some of the problems.

andyofmelbourne commented 2 years ago

I'm pretty sure that the axes should not be set as it is in this call to setImage. 't' is set to zero, so this precludes 2D images from being displayed, which is clearly not the intent. Letting setImage decide what the axes are solves the problem for me. My only hesitation here is that I couldn't really figure out where hummingbird intends to set the axes in a definitive way.

hummingbird/src/interface/ui/image_window.py:replot.py

                self.plot.setImage(img,
                                   transform=transform,
                                   autoRange=auto_range, autoLevels=auto_levels,
                                   autoHistogramRange=auto_histogram)#, axes={'t': 0, 'x': 1, 'y': 2, 'c': None})