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