| 1 | ###################################################################### |
|---|
| 2 | #Python Script Generated by GeneratePythonScript Algorithm |
|---|
| 3 | ###################################################################### |
|---|
| 4 | |
|---|
| 5 | # Load data |
|---|
| 6 | LoadAscii(Filename=r'PG3_11485-1.dat',OutputWorkspace='PG3_11485',Unit='TOF') |
|---|
| 7 | |
|---|
| 8 | # Create input workspaces for Le Bail fit |
|---|
| 9 | CreateLeBailFitInput(ReflectionsFile=r'LB4844b1.hkl', |
|---|
| 10 | FullprofParameterFile=r'2011B_HR60b1.irf', |
|---|
| 11 | LatticeConstant='4.1568899999999998', |
|---|
| 12 | InstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
|---|
| 13 | BraggPeakParameterWorkspace='BraggPeakParameterTable1') |
|---|
| 14 | |
|---|
| 15 | # Initial Le Bail fit in calculation mode to see how far the starting parameters are off |
|---|
| 16 | LeBailFit(InputWorkspace='PG3_11485', |
|---|
| 17 | OutputWorkspace='PG3_11485_Calculated_0', |
|---|
| 18 | InputParameterWorkspace='Bank1InstrumentParameterTable1', |
|---|
| 19 | OutputParameterWorkspace='TempTable', |
|---|
| 20 | InputHKLWorkspace='BraggPeakParameterTable1', |
|---|
| 21 | OutputPeaksWorkspace='BraggPeakParameterTable2', |
|---|
| 22 | Function='Calculation', |
|---|
| 23 | BackgroundType='Chebyshev', |
|---|
| 24 | BackgroundParameters='0,0,0', # No background at first |
|---|
| 25 | UseInputPeakHeights='0', |
|---|
| 26 | PeakRadius='8', |
|---|
| 27 | Minimizer='Levenberg-Marquardt') |
|---|
| 28 | |
|---|
| 29 | # Fit the instrumental geometry-related parameters. Dtt1, Dtt1t, Dtt2, Zero, Zerot, |
|---|
| 30 | # Step 1: Fit single diffraction peaks |
|---|
| 31 | FitPowderDiffPeaks(InputWorkspace='PG3_11485', |
|---|
| 32 | OutputWorkspace='Bank1FittedPeaks', |
|---|
| 33 | BraggPeakParameterWorkspace='BraggPeakParameterTable2', |
|---|
| 34 | InstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
|---|
| 35 | OutputBraggPeakParameterWorkspace='BraggPeakParameterTable2_0', |
|---|
| 36 | OutputBraggPeakParameterDataWorkspace='BraggPeakParameterTable2_P', |
|---|
| 37 | OutputZscoreWorkspace='BraggPeakParameterTable2_Zscore', |
|---|
| 38 | MinTOF='15000',MaxTOF='49387',UseGivenPeakCentreTOF='0', |
|---|
| 39 | MinimumPeakHeight='0.29999999999999999', |
|---|
| 40 | PeaksCorrelated='1', |
|---|
| 41 | MinimumHKL='12,12,12', |
|---|
| 42 | RightMostPeakHKL='2,0,0', |
|---|
| 43 | RightMostPeakLeftBound='46000', |
|---|
| 44 | RightMostPeakRightBound='48000') |
|---|
| 45 | |
|---|
| 46 | # Step 2: Refine geometry-related parameters. Dtt1, Dtt1t, Dtt2, Zero, Zerot, |
|---|
| 47 | RefinePowderInstrumentParameters(InputPeakPositionWorkspace='BraggPeakParameterTable2_P', |
|---|
| 48 | OutputPeakPositionWorkspace='PG3_11485_PeakPositions', |
|---|
| 49 | InputInstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
|---|
| 50 | OutputInstrumentParameterWorkspace='Bank1InstrumentParameterTable1_01', |
|---|
| 51 | RefinementAlgorithm='OneStepFit') |
|---|
| 52 | |
|---|
| 53 | # Create a workspace containing background of diffraction data to fit background polynomial |
|---|
| 54 | ProcessBackground(InputWorkspace='PG3_11485', |
|---|
| 55 | OutputWorkspace='PG3_11485_Background', |
|---|
| 56 | Options='SelectBackgroundPoints', |
|---|
| 57 | LowerBound='5053', |
|---|
| 58 | UpperBound='49387', |
|---|
| 59 | BackgroundPoints='5243,8910,11165,12153,13731,15060,16511,17767,19650,21874,23167,24519,36000,44282,49000', |
|---|
| 60 | NoiseTolerance='0.10000000000000001') |
|---|
| 61 | |
|---|
| 62 | # Fit background function |
|---|
| 63 | Fit(Function='name=Polynomial,n=6,A0=0.558765,A1=-3.36699e-05,A2=-9.89997e-10,A3=2.29598e-13,A4=-1.07727e-17,A5=2.10058e-22,A6=-1.49446e-27', |
|---|
| 64 | InputWorkspace='PG3_11485_Background', |
|---|
| 65 | MaxIterations='1000', |
|---|
| 66 | Minimizer='Levenberg-MarquardtMD', |
|---|
| 67 | CreateOutput='1', |
|---|
| 68 | Output='PG3_11485_Background', |
|---|
| 69 | StartX='5053',EndX='49387') |
|---|
| 70 | |
|---|
| 71 | # Use LeBailFit to calculate the diffraction pattern to see whether the refined geometry-related parameters are good as starting value |
|---|
| 72 | LeBailFit(InputWorkspace='PG3_11485', |
|---|
| 73 | OutputWorkspace='CalculatedPattern0', |
|---|
| 74 | InputParameterWorkspace='Bank1InstrumentParameterTable1_01', |
|---|
| 75 | OutputParameterWorkspace='Bank1InstrumentParameterTable1_0', |
|---|
| 76 | InputHKLWorkspace='BraggPeakParameterTable1', |
|---|
| 77 | OutputPeaksWorkspace='BraggPeakParameterTable2_0', |
|---|
| 78 | Function='Calculation', |
|---|
| 79 | BackgroundParametersWorkspace='PG3_11485_Background_Parameters', |
|---|
| 80 | UseInputPeakHeights='0',PeakRadius='8',Minimizer='Levenberg-Marquardt') |
|---|
| 81 | |
|---|
| 82 | # Use LeBailFit to refine POWGEN's instrument profile parameters by Monte Carlo algorithm |
|---|
| 83 | LeBailFit(InputWorkspace='PG3_11485', |
|---|
| 84 | OutputWorkspace='PG3_11485_MC_1000', |
|---|
| 85 | InputParameterWorkspace='Bank1InstrumentParameterTable1_0', |
|---|
| 86 | OutputParameterWorkspace='Bank1InstrumentParameterTable_MC', |
|---|
| 87 | InputHKLWorkspace='BraggPeakParameterTable1', |
|---|
| 88 | OutputPeaksWorkspace='BraggPeakParameterTable3', |
|---|
| 89 | FitRegion='5053,49387', |
|---|
| 90 | Function='MonteCarlo', |
|---|
| 91 | BackgroundParametersWorkspace='PG3_11485_Background_Parameters', |
|---|
| 92 | UseInputPeakHeights='0', |
|---|
| 93 | PeakRadius='8', |
|---|
| 94 | Minimizer='Levenberg-Marquardt', |
|---|
| 95 | Damping='0.90000000000000002', |
|---|
| 96 | NumberMinimizeSteps='1000', |
|---|
| 97 | FitGeometryParameter='1', |
|---|
| 98 | RandomSeed='1000', |
|---|
| 99 | AnnealingTemperature='10', |
|---|
| 100 | DrunkenWalk='1') |
|---|