Ticket #7229: calculate_asymmetry.py

File calculate_asymmetry.py, 891 bytes (added by Arturs Bekasovs, 7 years ago)

Script which calculates asymmetry for a range of workspaces

Line 
1applyDeadTimeCorr = False
2
3prefix = "/home/hgb24396/Mantid/Develop/Source/Test/AutoTestData/MUSR000"
4
5start =  15189
6end = 15199
7
8result = WorkspaceFactory.create("Workspace2D", 1, end - start + 1, end - start + 1)
9
10mtd.remove("script_result")
11mtd.add("script_result", result)
12
13for run_no in range(start,end+1):
14        # Load the file
15        file = prefix + str(run_no) + ".nxs"
16        loaded = LoadMuonNexus(file, AutoGroup=False)
17
18        # Apply dead time correction
19        if applyDeadTimeCorr:
20                loaded = ApplyDeadTimeCorr("loaded", "dead_times")
21       
22        # Apply auto-grouping
23        loaded = ApplyGroupingFromMuonNexus("loaded", file)
24       
25        # Integrate the values
26        loaded = Integration("loaded")
27       
28        # Calculate and print assymetry
29        loaded = AsymmetryCalc("loaded")
30       
31        # Get first period
32        first = loaded.getItem(0)
33       
34        # Set result value
35        result.dataY(0)[run_no - start] = first.readY(0)[0]
36        result.dataX(0)[run_no - start] = run_no