MJOLNIRPackage / MJOLNIR

Neutron scattering software to be used at Multiplexing Joint Organization
Mozilla Public License 2.0
4 stars 5 forks source link

Bug when hovering mouse on QELine #53

Open henrikjacobsenfys opened 4 years ago

henrikjacobsenfys commented 4 years ago

To reproduce: run the code below, then hover the mouse over the figure. This error will appear N times

Traceback (most recent call last): File "c:\program files\python37\lib\site-packages\matplotlib\cbook__init__.py", line 216, in process func(*args, **kwargs) File "c:\program files\python37\lib\site-packages\matplotlib\backend_bases.py", line 2713, in mouse_move s = event.inaxes.format_coord(event.xdata, event.ydata) File "c:\program files\python37\lib\site-packages\MJOLNIR\Data\DataSet.py", line 1974, in ax.format_coord = lambda x,y: format_coord(x,y,edgeQDistance,centerPositionTotal,actualEnergy,DataList,rlu,offset,self)#EnergyBins File "c:\program files\python37\lib\site-packages\MJOLNIR\Data\DataSet.py", line 1901, in format_coord Intensity = DataList['Int'][np.logical_and(DataList['qCut']==segID,DataList['energyCut']==Eindex)].iloc[index] #Int[segID][Eindex][index][0] File "c:\program files\python37\lib\site-packages\pandas\core\indexing.py", line 1424, in getitem return self._getitem_axis(maybe_callable, axis=axis) File "c:\program files\python37\lib\site-packages\pandas\core\indexing.py", line 2157, in _getitem_axis self._validate_integer(key, axis) File "c:\program files\python37\lib\site-packages\pandas\core\indexing.py", line 2088, in _validate_integer raise IndexError("single positional indexer is out-of-bounds") IndexError: single positional indexer is out-of-bounds

import IPython shell = IPython.get_ipython() shell.enable_matplotlib(gui='qt')

from MJOLNIR.Data import DataSet from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np import matplotlib.pyplot as plt

plt.ion() numbers = '493-500' # String of data numbers

fileList = _tools.fileListGenerator(numbers,'rawdata/',2018) # Create file list from 2018 in specified folder

Create the data set

ds = DataSet.DataSet(fileList)

for d in ds:

d.A3Off+=0

ds.convertDataFile(binning=8,saveFile=False)

H_values=[-1.5] H_names=['-1p5'] fileList = _tools.fileListGenerator(numbers,'rawdata/',2018) # Create file list from 2018 in specified folder

Q1 = np.array([-1,0,-1]) Q2 = np.array([-1,0,1.5])

Collect them into one array

QPoints = np.array([Q1,Q2])

Define orthogonal width and minimum pixel size along Q-cut

width = 0.1 # 1/AA minPixel = 0.03 # 1/AA

Define energy bins

Energies1 = np.concatenate(ds.energy,axis=0) EnergyBins = np.linspace(np.min(Energies1),np.max(Energies1),101)

fig = plt.figure(figsize=(8,6)) ax = fig.gca() ax,DataLists,Bins,BinCenters,Offsets = \ ds.plotCutQELine(QPoints=QPoints, width=width, minPixel=minPixel, \ ax=ax, EnergyBins=EnergyBins) ax.set_clim(0,10e-6)