Ticket #5858 (closed: fixed)

Opened 8 years ago

Last modified 5 years ago

Improve performance of LeBailFit

Reported by: Wenduo Zhou Owned by: Wenduo Zhou
Priority: major Milestone: Release 2.4
Component: Mantid Keywords:
Cc: petersonpf@… Blocked By:
Blocking: Tester: Alex Buts

Description (last modified by Wenduo Zhou) (diff)

Some functionality of LeBailFit should be enhanced according to its performance in real application.

Here are a list of tasks to do in this ticket.

  1. Add more minimizes;
  2. Add constraint on the parameters to fit
  3. Refactor the codes;
  4. Improve message output;

Test Instruction

Testing of this ticket is combined with the test to other tickets related to Le Bail Fit. Please read the testing instruction of ticket 6083 for how to test this ticket.

Change History

comment:1 Changed 8 years ago by Wenduo Zhou

  • Status changed from new to accepted

comment:2 Changed 8 years ago by Wenduo Zhou

Refactor code and fix some exception. Refs #5858.

Changeset: 56edbf92697224ffc44f91d69cb5f246c9763b79

comment:3 Changed 8 years ago by Wenduo Zhou

Modification for better LeBailFit. Refs #5858.

  • Refactor and enhance LeBailFit. Add parameter validity check.

Framework/CurveFitting/CMakeLists.txt Framework/CurveFitting/inc/MantidCurveFitting/LeBailFit.h Framework/CurveFitting/src/LeBailFit.cpp Framework/CurveFitting/test/LeBailFitTest.h

  • An alternative method to determine parameters related to instrument geometry

Framework/CurveFitting/inc/MantidCurveFitting/RefinePowderInstrumentParameters.h Framework/CurveFitting/test/RefinePowderInstrumentParametersTest.h Framework/CurveFitting/src/RefinePowderInstrumentParameters.cpp

  • Refactor peak function.

Framework/CurveFitting/inc/MantidCurveFitting/ThermalNeutronBk2BkExpConvPV.h Framework/CurveFitting/src/ThermalNeutronBk2BkExpConvPV.cpp

Changeset: 42a4bb49e67feea038a2f982efb128b3a16afdac

comment:4 Changed 8 years ago by Wenduo Zhou

Fix the test. Refs #5858.

Changeset: 657adbce527794c397de42d55bff4e49ad9223e1

comment:5 Changed 8 years ago by Wenduo Zhou

Fix the test. Refs #5858.

Changeset: 2eb8a15378251fb2c58a5d93c358d79c3efa9702

comment:6 Changed 8 years ago by Wenduo Zhou

Try to fix windows build. Refs #5858.

Changeset: bce90a31546b871707836e6e7c85f718c6f9c111

comment:7 Changed 8 years ago by Wenduo Zhou

Fix the windows build error. Refs #5858.

Changeset: e8b11c96c4ba69ad20239b48ff5d95a2fa43e636

comment:8 Changed 8 years ago by Wenduo Zhou

Clean the output. Refs #5858.

Changeset: 86be50f98e70732079f54715390294c4202f9ca0

comment:9 Changed 8 years ago by Wenduo Zhou

Elimiate warnings. Refs #5858.

Changeset: 0e77b79868eabbd9ea1ade785aed1d554e3db881

comment:10 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 3a65090d241c1979a160e17919d30ce5f0bcadaf

comment:11 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 3afe26df0ef5119ddeb04a56f9d960f8278493ab

comment:12 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 7608cb551590d944976c6c34adef0c7a6f8276c5

comment:13 Changed 8 years ago by Wenduo Zhou

Fix a typo. Refs #5858.

Changeset: 15159294c8dd61e79afb307de6744baf166a1417

comment:14 Changed 8 years ago by Wenduo Zhou

Fix Windows build. Refs #5858.

Changeset: 3b2eb301ebf28dc6d99733957579380489591165

comment:15 Changed 8 years ago by Wenduo Zhou

Add Zscore to output. Refs #5858.

Changeset: 720b6bcbbd34523c1a53a8fbbbe18433a80bb77d

comment:16 Changed 8 years ago by Wenduo Zhou

Modify the property names. Refs #5858.

Changeset: 6877e45849648434e6ce2569a84ce5337410d77e

comment:17 Changed 8 years ago by Wenduo Zhou

Fix unit tests. Refs #5858.

Changeset: d01fca8f6270987b8b22885aef2a6016b4f73bb1

comment:18 Changed 8 years ago by Wenduo Zhou

Start to implement an alg to select peaks for refine. Refs #5858.

Changeset: 623682ca3a43df1a00818165047391911d5ed757

comment:19 Changed 8 years ago by Wenduo Zhou

Update python scripts. Refs #5858.

Changeset: e8fd1fd0797b7587b7bc40cac4aa3c806566b080

comment:20 Changed 8 years ago by Wenduo Zhou

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:21 Changed 8 years ago by Alex Buts

  • Status changed from verify to verifying
  • Tester set to Alex Buts

comment:22 Changed 8 years ago by Wenduo Zhou

  • Description modified (diff)

comment:23 Changed 8 years ago by Wenduo Zhou

  • Description modified (diff)

comment:24 Changed 8 years ago by Wenduo Zhou

Add test data. Refs #5858.

Changeset: 5f927edf35c75ec736d74f1348578db9379b0e53

comment:25 Changed 8 years ago by Wenduo Zhou

  • Description modified (diff)

comment:26 Changed 8 years ago by Alex Buts

  • Status changed from verifying to reopened
  • Priority changed from critical to major
  • type changed from enhancement to defect
  • Resolution fixed deleted
  • Milestone changed from Release 2.3 to Release 2.4

It is difficult to judge this ticket properly. I've generating Tickets #6083 and #6087 which request better description and would help to test and understand this work better.

In addition to that, if I try to run first script from ticket #5306, (provided below #1) second script from header of this ticket (provider below #2) and then row:

LeBailFit(InputWorkspace='4844b1',OutputWorkspace='4844b1_fitalph1',InputParameterWorkspace='Peak4844',OutputParameterWorkspace='Peak4844X',InputHKLWorkspace='HKL4844',OutputPeaksWorkspace='HKL4844X',BackgroundFunctionOrder='6',BackgroundParametersWorkspace='4844b_polybkgd_Parameters',UseInputPeakHeights='0',PeakRadius='8',Minimizer='SteepestDescent')

in the script interpreter, the Mantid seems freezes (at least at win 7, 64bit)

May be it just runs too slowly, but I waited for 20min and rather suspect a bug. This is why I am reopening this ticket for the next release.

Step #1, set workspaces and fit good behaving data:

# Import data
LoadAscii(Filename='4844b1.inp',OutputWorkspace='4844b1',Unit='TOF')

# Create some table workspaces for staring values
CreateLeBailFitInput(Instrument='NOMAD',ReflectionsFile='LB4844b1.hkl',
   FullprofParameterFile='2011B_HR60b1.irf',LatticeConstant='4.1568899999999998',
   InstrumentParameterWorkspace='Peak4844',BraggPeakParameterWorkspace='HKL4844')

# Fit for background of the diffraction pattern
ProcessBackground(InputWorkspace='4844b1',OutputWorkspace='4844b1_bkgd',
    Options='SelectBackgroundPoints',LowerBound='5053',UpperBound='49387',
    BackgroundType='Chebyshev',
    BackgroundPoints='5000,6500,8951,10670,15231,16943,24887,33527,40200,45110,49725',
    NoiseTolerance='20')

Fit(Function='name=Polynomial,n=6,A0=0,A1=0,A2=0,A3=0,A4=0,A5=0,A6=0',
    InputWorkspace='4844b1_bkgd',MaxIterations='1000',
    Minimizer='Levenberg-MarquardtMD',
    CreateOutput='1',Output='4844b_polybkgd',
    StartX='2277.27',EndX='49988.900000000001')

# Calculate peak heights with Le Bail algorithm
LeBailFit(InputWorkspace='4844b1',OutputWorkspace='4844b1_cal',
    InputParameterWorkspace='Peak4844',OutputParameterWorkspace='Temp1',
    InputHKLWorkspace='HKL4844',OutputPeaksWorkspace='Temp2',Function='Calculation',
    BackgroundFunctionOrder='6',BackgroundParametersWorkspace='4844b_polybkgd_Parameters',
    UseInputPeakHeights='0',PeakRadius='8')

Step #2, modify data:

# Fix all the parameters
UpdatePeakParameterTableValue(InputWorkspace='Peak4844',Column='FitOrTie',NewStringValue='t')
# Change value of Alph1
UpdatePeakParameterTableValue(InputWorkspace='Peak4844',ParameterNames='Alph1',NewFloatValue='6')
# Flag Alph1 to be fit
UpdatePeakParameterTableValue(InputWorkspace='Peak4844',Column='FitOrTie',ParameterNames='Alph1',NewStringValue='f')

comment:27 Changed 8 years ago by Wenduo Zhou

Refactor code and fix some exception. Refs #5858.

Changeset: 56edbf92697224ffc44f91d69cb5f246c9763b79

comment:28 Changed 8 years ago by Wenduo Zhou

Modification for better LeBailFit. Refs #5858.

  • Refactor and enhance LeBailFit. Add parameter validity check.

Framework/CurveFitting/CMakeLists.txt Framework/CurveFitting/inc/MantidCurveFitting/LeBailFit.h Framework/CurveFitting/src/LeBailFit.cpp Framework/CurveFitting/test/LeBailFitTest.h

  • An alternative method to determine parameters related to instrument geometry

Framework/CurveFitting/inc/MantidCurveFitting/RefinePowderInstrumentParameters.h Framework/CurveFitting/test/RefinePowderInstrumentParametersTest.h Framework/CurveFitting/src/RefinePowderInstrumentParameters.cpp

  • Refactor peak function.

Framework/CurveFitting/inc/MantidCurveFitting/ThermalNeutronBk2BkExpConvPV.h Framework/CurveFitting/src/ThermalNeutronBk2BkExpConvPV.cpp

Changeset: 42a4bb49e67feea038a2f982efb128b3a16afdac

comment:29 Changed 8 years ago by Wenduo Zhou

Fix the test. Refs #5858.

Changeset: 657adbce527794c397de42d55bff4e49ad9223e1

comment:30 Changed 8 years ago by Wenduo Zhou

Fix the test. Refs #5858.

Changeset: 2eb8a15378251fb2c58a5d93c358d79c3efa9702

comment:31 Changed 8 years ago by Wenduo Zhou

Try to fix windows build. Refs #5858.

Changeset: bce90a31546b871707836e6e7c85f718c6f9c111

comment:32 Changed 8 years ago by Wenduo Zhou

Fix the windows build error. Refs #5858.

Changeset: e8b11c96c4ba69ad20239b48ff5d95a2fa43e636

comment:33 Changed 8 years ago by Wenduo Zhou

Clean the output. Refs #5858.

Changeset: 86be50f98e70732079f54715390294c4202f9ca0

comment:34 Changed 8 years ago by Wenduo Zhou

Elimiate warnings. Refs #5858.

Changeset: 0e77b79868eabbd9ea1ade785aed1d554e3db881

comment:35 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 3a65090d241c1979a160e17919d30ce5f0bcadaf

comment:36 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 3afe26df0ef5119ddeb04a56f9d960f8278493ab

comment:37 Changed 8 years ago by Wenduo Zhou

Fix the build. Refs #5858.

Changeset: 7608cb551590d944976c6c34adef0c7a6f8276c5

comment:38 Changed 8 years ago by Wenduo Zhou

Fix a typo. Refs #5858.

Changeset: 15159294c8dd61e79afb307de6744baf166a1417

comment:39 Changed 8 years ago by Wenduo Zhou

Fix Windows build. Refs #5858.

Changeset: 3b2eb301ebf28dc6d99733957579380489591165

comment:40 Changed 8 years ago by Wenduo Zhou

Add Zscore to output. Refs #5858.

Changeset: 720b6bcbbd34523c1a53a8fbbbe18433a80bb77d

comment:41 Changed 8 years ago by Wenduo Zhou

Modify the property names. Refs #5858.

Changeset: 6877e45849648434e6ce2569a84ce5337410d77e

comment:42 Changed 8 years ago by Wenduo Zhou

Fix unit tests. Refs #5858.

Changeset: d01fca8f6270987b8b22885aef2a6016b4f73bb1

comment:43 Changed 8 years ago by Wenduo Zhou

Start to implement an alg to select peaks for refine. Refs #5858.

Changeset: 623682ca3a43df1a00818165047391911d5ed757

comment:44 Changed 8 years ago by Wenduo Zhou

Update python scripts. Refs #5858.

Changeset: e8fd1fd0797b7587b7bc40cac4aa3c806566b080

comment:45 Changed 8 years ago by Wenduo Zhou

  • Status changed from reopened to accepted

comment:46 Changed 8 years ago by Wenduo Zhou

Improve output information. Refs #5858.

Changeset: 783cc4e0507c61ae14812ff9d90d8b78ffea996e

comment:47 Changed 8 years ago by Wenduo Zhou

Improve output information. Refs #5858.

Changeset: 5df1b57a970d347fe71145bed8b18522760bcfa2

comment:48 Changed 8 years ago by Wenduo Zhou

  • Description modified (diff)

comment:49 Changed 8 years ago by Wenduo Zhou

Improve warning message. Refs #5858.

Changeset: 04f3d3e614ad9d9ca70ea2b58baed6fb69defb6f

comment:50 Changed 8 years ago by Wenduo Zhou

Enhance robustness. Refs #5858.

Add input property to tolerate input peaks (HKL) to have duplicate (HKL)2 value.

Changeset: 18c3af2f644e1b7213b2edd6f05eed5d07bcdeb2

comment:51 Changed 8 years ago by Wenduo Zhou

  • Description modified (diff)
  • Summary changed from Improve the fitting in LeBailFit to Improve performance of LeBailFit

comment:52 Changed 8 years ago by Wenduo Zhou

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:53 Changed 8 years ago by Alex Buts

  • Status changed from verify to verifying

comment:54 Changed 8 years ago by Alex Buts

  • Status changed from verifying to closed

It looks like it works much better now and I am not an expert to verify it further.

comment:55 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 6704

Note: See TracTickets for help on using tickets.