Ticket #1224: example_reduction_BTloop.py

File example_reduction_BTloop.py, 2.5 KB (added by Brett Tully, 10 years ago)

Testing script

Line 
1#Make the reduction module available
2from SANSReduction import *
3
4# Set a default data path where we look for raw data
5#DataPath("/home/m2d/workspace/mantid/Test/Data/SANS2D")
6DataPath("/home/dmn58364/mantidproject/repo/Test/Data/SANS2D")
7# Set a user path where we look for the mask file
8#UserPath("/home/m2d/workspace/mantid/Test/Data/SANS2D")
9UserPath("/home/dmn58364/mantidproject/repo/Test/Data/SANS2D")
10# Set instrument. SANS2D() or LOQ()
11SANS2D()
12#Set reduction to 1D (note that if this is left out, 1D is the default)
13Set1D()
14
15# Set the detector
16# Options:
17# SANS: rear-detector, front-detector
18# LOQ: main-detector-bank, HAB
19Detector("rear-detector")
20
21# Read a mask file
22MaskFile('MASKSANS2D.091A')
23
24# Change default limits if we want to
25#LimitsR(50.,170.)
26#   Here the arguments are min, max, step, step type
27#LimitsWav(4.,8.,0.125, 'LIN')
28#LimitsQXY(0, 0.1, 0.002, 'LIN')
29
30# Q limits (binning) can be specified in 2 ways
31# A simple min,delta,max and binning type
32#LimitsQ(0.02, 1.0, 0.02, 'LOG')
33
34# Or a full string that is passed directly to rebin as is
35#LimitsQ("0.02, -0.02,1.0")
36
37# Consider Gravity true/false (default off)
38Gravity(True)
39
40# Alter the trans fit type and range. First parameter can be 'OFF','LOG',LIN'
41#TransFit('LOG',3.0,8.0)
42
43for j in range(2):
44        # Assign run numbers (.nxs for nexus)
45        AssignSample('992.raw')
46        TransmissionSample('988.raw', '987.raw')
47        AssignCan('993.raw')
48        TransmissionCan('989.raw', '987.raw')
49
50        # Update the centre coordinates
51        # Arguments are rmin,rmax, niterations
52        #FindBeamCentre(50., 170., 2)
53
54        # Do the reduction
55        # WavRangeReduction runs the reduction for the specfied wavelength range
56
57        # The final argument can either be DefaultTrans or CalcTrans where
58        #  (a) DefaultTrans calculates the transmission for the whole range specified by L/WAV
59        #      and then crops it to the current range and
60        #  (b) CalcTrans calculates the transmission for the specifed range
61        #
62        # The returned value is the name of the fully reduced workspace
63        #reduced = WavRangeReduction(2.0, 14.0, NewTrans)
64        #plotSpectrum(reduced,0)
65
66        #  ... OR ...
67       
68        # Looping over other ranges
69        wav1 = 2.0
70        wav2 = wav1 + 1.0
71        reduced = WavRangeReduction(wav1, wav2, DefaultTrans)
72        ws_list = [reduced]
73        for i in range(3,14):
74            print 'j = ', j,  ', i = ', i
75            wav1 = i*1.0
76            wav2 = wav1 + 1.0
77            reduced = WavRangeReduction(wav1, wav2, DefaultTrans)
78            ws_list.append(reduced)
79        plt = plotSpectrum(ws_list, 0)
80        plt.confirmClose(False)
81        plt.close()
82       
83        # remove all of the workspaces
84        workspaces = mtd.getWorkspaceNames()
85        for w in workspaces:
86                DeleteWorkspace(w)