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 changing binning #51

Closed henrikjacobsenfys closed 4 years ago

henrikjacobsenfys commented 4 years ago

numbers='276-278' SelectedFilenames = _tools.fileListGenerator(numbers,'rawdata/',2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(SelectedFilenames)

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

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

V=ds.View3D(0.05,0.05,0.05)

This produces the following error. Upon inspection, there are 6 instead fo 3 converted data files in ds.

runfile('C:/Users/jacobsen_h/Dropbox/MJOLINRfun/bug4.py', wdir='C:/Users/jacobsen_h/Dropbox/MJOLINRfun') Traceback (most recent call last):

File "C:\Users\jacobsen_h\Dropbox\MJOLINRfun\bug4.py", line 26, in V=ds.View3D(0.05,0.05,0.05)

File "c:\program files\python37\lib\site-packages\MJOLNIR_tools.py", line 58, in newFunc returnval = func(*args,**kwargs)

File "c:\program files\python37\lib\site-packages\MJOLNIR\Data\DataSet.py", line 2520, in View3D Data,bins = self.binData3D(dx=dQx,dy=dQy,dz=dE,rlu=rlu)

File "c:\program files\python37\lib\site-packages\MJOLNIR_tools.py", line 58, in newFunc returnval = func(*args,**kwargs)

File "c:\program files\python37\lib\site-packages\MJOLNIR\Data\DataSet.py", line 400, in binData3D returnData,bins = binData3D(dx=dx,dy=dy,dz=dz,pos=pos,data=I,norm=Norm,mon=Monitor)

File "c:\program files\python37\lib\site-packages\MJOLNIR_tools.py", line 58, in newFunc returnval = func(*args,**kwargs)

File "c:\program files\python37\lib\site-packages\MJOLNIR\Data\DataSet.py", line 4148, in binData3D intensity = np.histogramdd(np.array(pos).T,bins=HistBins,weights=data.flatten())[0].astype(data.dtype)

File "<__array_function__ internals>", line 6, in histogramdd

File "c:\program files\python37\lib\site-packages\numpy\lib\histograms.py", line 1034, in histogramdd 'The dimension of bins must be equal to the dimension of the '

ValueError: The dimension of bins must be equal to the dimension of the sample x.

henrikjacobsenfys commented 4 years ago

I've since discovered that adding

ds = DataSet.DataSet(SelectedFilenames)

before the second call to convertDataFile seems to fix the problem. So it might not be a bug, but just an error 40?

Jakob-Lass commented 4 years ago

Converting the data files in a data set twice results in double the amount of converted data files. What is the behaviour expected/wanted? As I see it, it could either be to remove previously converted files or extend the DataSet object to work with multiple converted data sets.

henrikjacobsenfys commented 4 years ago

I would say that the expected behaviour is the first option, removing previously converted files.

Jakob-Lass commented 4 years ago

The behaviour of overwriting preciously converted data files has been introduced in 2ee32cbba7bb8fd5872f7eb918ac0b3364f307e1.