Ticket #1051: Fourier.py

File Fourier.py, 2.2 KB (added by Russell Taylor, 11 years ago)

Script from Spencer Howells

Line 
1#Fury - version for individual spectra
2import os.path as op
3
4prefix = 'irs'
5ana_dict = {'xtal' : 'PG', 'refl' : '002', 'code' : 1, 'efix' : 0.1}
6prog = 'FURY'
7
8inWS = 'In'
9s_load = LoadNexusProcessedDialog(OutputWorkspace=inWS,Message="Sample file")
10s_path = s_load.getPropertyValue("Filename")
11s_file = op.basename(s_path)
12print 'Sample file : ' + s_file
13tmp = mantid.getMatrixWorkspace(inWS)
14s_hist = tmp.getNumberHistograms()
15e_range = "-0.5,0.005,0.5"
16samWS = 'Sam'
17sqtWS = 'Sqt'
18sam_list = []
19# loop over all histograms/groups
20for n in range(0, s_hist):
21        n1=str(n)
22        stmpWS = sqtWS + str(n)
23# get individual group into temp WS
24        ExtractSingleSpectrum(inWS,samWS,n1)
25# rebin to constant delta-e
26        Rebin(samWS,samWS,e_range)
27# perform FFT
28        FFT(samWS, stmpWS)
29# get modulus - index 2
30        ExtractSingleSpectrum(stmpWS,stmpWS,2)
31        sam_list.append(stmpWS)
32#       if n == 0:
33# for first time, rename tempWS as output WS
34#               RenameWorkspace(stmpWS,sqtWS)
35#       else:
36# subsequent times, add tempWS to output WS
37#               ConjoinWorkspaces(sqtWS,stmpWS)
38s_graph=plotSpectrum(sam_list,0)
39# delete temp WS
40mantid.deleteWorkspace(inWS)
41mantid.deleteWorkspace(samWS)
42
43r_load = LoadNexusProcessedDialog(OutputWorkspace=inWS,Message="Resolution file")
44r_path = r_load.getPropertyValue("Filename")
45r_file = op.basename(r_path)
46print 'Resolution file : ' + r_file
47tmp = mantid.getMatrixWorkspace(inWS)
48r_hist = tmp.getNumberHistograms()
49
50# check that no. groups are the same
51if s_hist == r_hist:
52        resWS = 'Res'
53        rqtWS = 'Rqt'
54        iqtWS = 'Iqt'
55        res_list = []
56        iqt_list = []
57        for n in range(0, s_hist):
58                n1=str(n)
59                rtmpWS = rqtWS + str(n)
60                itmpWS = iqtWS + str(n)
61# get individual group into temp WS
62                ExtractSingleSpectrum(inWS,resWS,n1)
63# rebin to constant delta-e
64                Rebin(resWS,resWS,e_range)
65# perform FFT
66                FFT(resWS, rtmpWS)
67# get modulus - index 2
68                ExtractSingleSpectrum(rtmpWS,rtmpWS,2)
69                res_list.append(rtmpWS)
70                Divide(stmpWS,rtmpWS,itmpWS)
71#               if n == 0:
72# for first time, rename tempWS as output WS
73#                       RenameWorkspace(tmpWS,sqtWS)
74#               else:
75# subsequent times, add tempWS to output WS
76#                       ConjoinWorkspaces(sqtWS,tmpWS)
77        r_graph=plotSpectrum(res_list,0)
78
79else:
80# error message
81        print 'Vanadium histograms (' +v_hist + ') not = Sample (' + s_hist +')'
82