Ticket #10182: verify10182.py

File verify10182.py, 2.3 KB (added by Wenduo Zhou, 6 years ago)
Line 
1# Script is used to convert the Mantid binned VULCAN data to V-DRIVE binned GSAS data
2# in order to compare the final result
3#
4# Version   2.0
5# Date      2014.08.14
6
7
8calibrationfilename = "vulcan_foc_all_2bank_11p.cal"
9characterfilename   =  "VULCAN_Characterization_2Banks_v2.txt"
10#logbinfilename      = "vdrive_log_bin.dat"
11
12def reduceVulcanRun(runnumber):
13    """ Reduce a powder diffraction run with proper
14    """ 
15    SNSPowderReduction( 
16            Instrument  = "VULCAN",
17            RunNumber   = runnumber,
18            Extension   = "_event.nxs",
19            PreserveEvents  = True,
20            CalibrationFile = calibrationfilename,
21            CharacterizationRunsFile = characterfilename,
22            Binning = "-0.001",
23            SaveAS  = "",
24            OutputDirectory = "/home/wzz/Projects/MantidTests/Vulcan/Reduction/Generate_GSAS/temp", 
25            NormalizeByCurrent = False,
26            FilterBadPulses=0,
27            CompressTOFTolerance = 0.)
28
29    newrun = ConvertUnits(InputWorkspace="VULCAN_%d"%(runnumber), OutputWorkspace="VULCAN_%d_SNSReduc"%(runnumber), 
30            Target="TOF", EMode="Elastic", AlignBins=False)
31           
32    return newrun
33
34
35
36def getRunNumber(nexusfilename):
37    """ Run number
38    """
39    filename = nexusfilename.split(".")[0]
40    terms = filename.split("/")
41    for t in terms:
42        if t.count("IPTS") == 1:
43            ipts = int(t.split("-")[1])
44        elif t.count("event") == 1:
45            run = int(t.split("_")[1])
46    # ENDFOR
47
48    return (ipts, run)
49
50
51def main(nexusfilename, refxfilename):
52    """ main
53    """
54    ipts, runnumber = getRunNumber(nexusfilename)
55
56    vulcanws = reduceVulcanRun(runnumber)
57
58    outfilename = "/tmp/mtd%s.gda" % (str(runnumber))
59    SaveVulcanGSS(InputWorkspace=vulcanws, BinFilename=refxfilename, 
60            OutputWorkspace="Proto2Bank", GSSFilename=outfilename, 
61            IPTS = ipts, GSSParmFilename="xxx.iparm")
62
63    mtdgss = LoadGSS(Filename="/tmp/mtd%s.gda" % (str(runnumber)))
64    vdrgss = LoadGSS(Filename="26299.gda")
65    Minus(LHSWorkspace=vdrgss, RHSWorkspace=mtdgss, OutputWorkspace="diff_mv", AllowDifferentNumberSpectra=True)
66
67    return
68
69
70if __name__ == "__main__":
71    nexusfilename = "/SNS/VULCAN/IPTS-9846/0/26299/NeXus/VULCAN_26299_event.nxs"
72    vdrivebinfname = "vdrive_log_bin.dat"
73    main(nexusfilename, vdrivebinfname)