Ticket #2470: tik_2470.py

File tik_2470.py, 1.9 KB (added by Gesner Passos, 8 years ago)

Reproduce the error

Line 
1# -*- coding: utf-8 -*-
2"""
3Created on Fri Oct 19 09:47:13 2012
4
5@author: gesner
6"""
7
8import sys
9sys.path.insert(0,'/home/gesner/workspace/mantid_debug/bin/')
10from mantid.simpleapi import *
11from matplotlib import pyplot as plt
12import numpy
13
14#The detector is 192 x 192
15LoadNexus(Filename=r'SANS2D00002500.nxs',OutputWorkspace='2500_sans_nxs',EntryNumber='1')
16wrong_cropping = CropWorkspace(InputWorkspace='2500_sans_nxs',StartWorkspaceIndex='37064',EndWorkspaceIndex='73735')
17correct_cropping = CropWorkspace(InputWorkspace='2500_sans_nxs',StartWorkspaceIndex='36872',EndWorkspaceIndex='73735')
18#the wrong cropping happens because there was the assumption that for the minimum DetectorID 2 000 000 you would have the minimum SpectrumID number.
19
20bins = wrong_cropping.getDimension(0).getNBins() # should be 152
21wrong_data = numpy.concatenate([wrong_cropping.readY(i) for i in range(wrong_cropping.getNumberHistograms())])
22correct_data = numpy.concatenate([correct_cropping.readY(i) for i in range(correct_cropping.getNumberHistograms())])
23
24
25# Now, there is another problem, if you organize the dataset as 191x192xbins you will have the correct image
26wrong_dataset = wrong_data.reshape((191,192,bins))
27wrong_image = numpy.sum(wrong_dataset,axis=2)
28plt.imshow(wrong_image, label="Correct 191x192")
29plt.show()
30plt.plot(numpy.sum(wrong_image, axis=0))
31plt.show()
32
33#But if you organize the dataset differently: 192x191xbins you will end up with a wrong dataset
34
35wrong_dataset = wrong_data[:191*191*bins].reshape((191,191,bins))
36wrong_image = numpy.sum(wrong_dataset,axis=2)
37plt.imshow(wrong_image, label="Wrong 191x191")
38plt.show()
39plt.plot(numpy.sum(wrong_image, axis=0))
40plt.show()
41
42
43correct_dataset = correct_data.reshape((192,192,bins))
44correct_image = numpy.sum(correct_dataset, axis=2)
45plt.imshow(correct_image, label="With all the entries 192x192")
46plt.show()
47plt.plot(numpy.sum(correct_image, axis=0))
48plt.show()