Ticket #7199 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Investigate & fix differences between vesuvio reduction in Mantid & Matlab

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Release 2.6
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester: Alex Buts

Description

The VESUVIO group have found some differences in the results of the fitting in Mantid vs MATLAB. Investigate & fix them.

Change History

comment:1 Changed 7 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:2 Changed 7 years ago by Martyn Gigg

Fix value of angular width parameter on VESUVIO. Refs #7199

Changeset: 9e5a6a9c37b7360f67ad8b4161eb19c78dadd2ad

comment:3 Changed 7 years ago by Martyn Gigg

Add logging to ComptonProfile. Refs #7199

Changeset: 01b3c217d7e107f989dbaf243e32c82d07ccf636

comment:4 Changed 7 years ago by Martyn Gigg

Allow the absolute error to be specified in SimplexMinimizer.

Refs #7199

Changeset: 180bfba419563ef8b26f6882ca3ec2f41a2938b9

comment:5 Changed 7 years ago by Martyn Gigg

Add a specialized CostFunction to minimize a set of linear eqns ...

that includes equality & inequality constraints. The simplex minizer eventually gets to a good answer after restarting with updated values a few times. Refs #7199

Changeset: e5c50acf28b0d73ac6ce90e65566b9924d34eff4

comment:6 Changed 7 years ago by Martyn Gigg

Refactor ComptonProfile to calculate resolution & Y-space once.

Refs #7199

Changeset: beb7b89f971038b2d74836f2bbb13ada60a0fab8

comment:7 Changed 7 years ago by Martyn Gigg

ComptonProfile functions can now populate a constraint matrix

This can be used by a composite of the functions to compute the mass profile for various parameters. Refs #7199

Changeset: db7b5cf902eaefd3fa9c92a621691312962a4e51

comment:8 Changed 7 years ago by Martyn Gigg

Significant caching in GramCharlierComptonProfile.

Leads to a roughly 400% speed increase (of the system test) as it currently is. The Voigt function was expensive to compute and identical with each function iteration. It is now cached when the workspace is set. Refs #7199

Changeset: f73586cb963b70e3fe9602f8ba2bdca191c166d6

comment:9 Changed 7 years ago by Martyn Gigg

Refactor GramCharlierComptonProfile to allow calculation of

each contribution separately. Refs #7199

Changeset: 6822152f6f1c386505f90416fcd9476884b64e22

comment:10 Changed 7 years ago by Martyn Gigg

Pass errors through to fill constraint matrix in ComptonProfile.

Refs #7199

Changeset: 2bb501a450e2122bad7fc943318b82769bfa47d3

comment:11 Changed 7 years ago by Martyn Gigg

Fix value of angular width parameter on VESUVIO. Refs #7199

Changeset: 9e5a6a9c37b7360f67ad8b4161eb19c78dadd2ad

comment:12 Changed 7 years ago by Martyn Gigg

Add logging to ComptonProfile. Refs #7199

Changeset: 01b3c217d7e107f989dbaf243e32c82d07ccf636

comment:13 Changed 7 years ago by Martyn Gigg

Allow the absolute error to be specified in SimplexMinimizer.

Refs #7199

Changeset: 180bfba419563ef8b26f6882ca3ec2f41a2938b9

comment:14 Changed 7 years ago by Martyn Gigg

Refactor ComptonProfile to calculate resolution & Y-space once.

Refs #7199

Changeset: c29f961da252b25009ef748c9c9799072c7b29a8

comment:15 Changed 7 years ago by Martyn Gigg

ComptonProfile functions can now populate a constraint matrix

This can be used by a composite of the functions to compute the mass profile for various parameters. Refs #7199

Changeset: 6baa8fc2416c58a766b8c28e35baf7b82462fa7f

comment:16 Changed 7 years ago by Martyn Gigg

Significant caching in GramCharlierComptonProfile.

Leads to a roughly 400% speed increase (of the system test) as it currently is. The Voigt function was expensive to compute and identical with each function iteration. It is now cached when the workspace is set. Refs #7199

Changeset: 9b24229966e3831156b26261ec7d1075958f09af

comment:17 Changed 7 years ago by Martyn Gigg

Refactor GramCharlierComptonProfile to allow calculation of

each contribution separately. Refs #7199

Changeset: b2af3c162e7fb3e06b0d2ab092dc72689d896d89

comment:18 Changed 7 years ago by Martyn Gigg

Pass errors through to fill constraint matrix in ComptonProfile.

Refs #7199

Changeset: 12cb61c574c053e2651d363552af115b4ebaf171

comment:19 Changed 7 years ago by Martyn Gigg

Added class to perform least-square minimzation on eqn set.

It uses the same implementation that scipy uses for slsqp. Refs #7199

Changeset: 2fb44fd46c4ba89ac91c5b4cd14eaea2c0769778

comment:20 Changed 7 years ago by Martyn Gigg

Fix doxygen comment. Refs #7199

Changeset: ac60c5692781ae4c4b4e3800c7455725ac99b702

comment:21 Changed 7 years ago by Martyn Gigg

Remove dead-time correction from Vesuvio loader

Refs #7199

Changeset: a26728a3b487f7ebe90830dfa5f67952b43450b3

comment:22 Changed 7 years ago by Martyn Gigg

Output a non-histogram workspace from LoadVesuvio in difference mode

Refs #7199

Changeset: 64d9d30a5a3d12f6156cba9d84c06cc715a3a263

comment:23 Changed 7 years ago by Martyn Gigg

Fix error calculation in LoadVesuvio. Refs #7199

The errors should have be computed from the data itself and not the errors computed by LoadRaw. There was also a bug with how the tof values were calculated.

Changeset: 7f5f010011088d38dc122c342037f480fa72f6ee

comment:24 Changed 7 years ago by Martyn Gigg

Fix intensity parameters in ComptonScatteringCountRate

This allows them to be computed based on the current profile values and taken out of the main fit. Refs #7199

Changeset: 77f7c05392001459c0d0653d8c69f6f66cfc3f38

comment:25 Changed 7 years ago by Martyn Gigg

Fix value of angular width parameter on VESUVIO. Refs #7199

Changeset: 98ee33590eeef355f5b79bb56a17692de93f5756

comment:26 Changed 7 years ago by Martyn Gigg

Add logging to ComptonProfile. Refs #7199

Changeset: 099377a338bd48371a6918984dfb865e608620e5

comment:27 Changed 7 years ago by Martyn Gigg

Allow the absolute error to be specified in SimplexMinimizer.

Refs #7199

Changeset: cbf364377c98c50f6be9d905dfae267fd3c640c4

comment:28 Changed 7 years ago by Martyn Gigg

Refactor ComptonProfile to calculate resolution & Y-space once.

Refs #7199

Changeset: 11bca6c63ceab2d0f2246028dcbf9f2797fd7aee

comment:29 Changed 7 years ago by Martyn Gigg

ComptonProfile functions can now populate a constraint matrix

This can be used by a composite of the functions to compute the mass profile for various parameters. Refs #7199

Changeset: fc37cefc25d95e5d84fde9d0545e197d6b1aa170

comment:30 Changed 7 years ago by Martyn Gigg

Significant caching in GramCharlierComptonProfile.

Leads to a roughly 400% speed increase (of the system test) as it currently is. The Voigt function was expensive to compute and identical with each function iteration. It is now cached when the workspace is set. Refs #7199

Changeset: c2f18fb8c3ad1b360b63eb17e38ebc586a7e778f

comment:31 Changed 7 years ago by Martyn Gigg

Refactor GramCharlierComptonProfile to allow calculation of

each contribution separately. Refs #7199

Changeset: 54c7b39bb76560f5eb912b37414a04a0a7bc886d

comment:32 Changed 7 years ago by Martyn Gigg

Pass errors through to fill constraint matrix in ComptonProfile.

Refs #7199

Changeset: 4117bcabdf02f94701be8b5bd9749edc0b01822c

comment:33 Changed 7 years ago by Martyn Gigg

Added class to perform least-square minimzation on eqn set.

It uses the same implementation that scipy uses for slsqp. Refs #7199

Changeset: cf07d4b4e4e5c3633d65830f2c3201f06f587391

comment:34 Changed 7 years ago by Martyn Gigg

Fix doxygen comment. Refs #7199

Changeset: 050bc09459a7812069180e876e01d9683bed0118

comment:35 Changed 7 years ago by Martyn Gigg

Remove dead-time correction from Vesuvio loader

Refs #7199

Changeset: f98bf8cd79a2a35d9888ae3fbde1c9bcf6af0d06

comment:36 Changed 7 years ago by Martyn Gigg

Output a non-histogram workspace from LoadVesuvio in difference mode

Refs #7199

Changeset: eb5b5bf22a67569c7aa81a8e7174864bb7630cf2

comment:37 Changed 7 years ago by Martyn Gigg

Fix error calculation in LoadVesuvio. Refs #7199

The errors should have be computed from the data itself and not the errors computed by LoadRaw. There was also a bug with how the tof values were calculated.

Changeset: d1a10d7f7a4ac26a75a8562b5af38dedd57443bd

comment:38 Changed 7 years ago by Martyn Gigg

Fix intensity parameters in ComptonScatteringCountRate

This allows them to be computed based on the current profile values and taken out of the main fit. Refs #7199

Changeset: 0b784475466ab50719d98b486911dd97ecfec965

comment:39 Changed 7 years ago by Martyn Gigg

Allow custom delimiter when reading/writing matrices from streams.

The stream operators still use commas as before but the free functions now allows users to specify the delimiter. Refs #7199

Changeset: 158712d262d3668655a8c845ad7f804f9c613298

comment:40 Changed 7 years ago by Martyn Gigg

Add intensity constraint matrix as attr on ComptonScatteringCountRate

Refs #7199

Changeset: a18f90074795abfde5235b8816310b7ad95e7312

comment:41 Changed 7 years ago by Martyn Gigg

Include FSE parameter in intensity coeffs when free. Refs #7199

Changeset: 630d2d6ebb283ac84a73a2392d854024a3d1a445

comment:42 Changed 7 years ago by Martyn Gigg

Check fixing of FSE coefficient in the correct place. Refs #7199

Changeset: 17f399aa59b9c4765059b181a33f35ed3f567d22

comment:43 Changed 7 years ago by Martyn Gigg

Add tests for concrete ComptonProfile result values. Refs #7199

Also includes a separate test helper method to create a similar workspace for the tests to use as they share a large amount of setup

Changeset: 974f0df8dac945c5d56921b69022a26bbb8016f5

comment:44 Changed 7 years ago by Martyn Gigg

Add test for ComptonScatteringCountRate values. Refs #7199

Changeset: 2edc35454672500f7e3adc1fe6b1cc781ebd6a57

comment:45 Changed 7 years ago by Martyn Gigg

Fix bug with empty equality constraints. Refs #7199

They are now allowed by just not setting the attribute value.

Changeset: 52a5dcb78318c58cee79c26afb992a1019a3c28c

comment:46 Changed 7 years ago by Martyn Gigg

Fix memory error bug in filling equality matrix

It was writing to memory that it shouldn't have been. Refs #7199

Changeset: 2e53e0a302c2734863514a3be5181de1cf45735a

comment:47 Changed 7 years ago by Martyn Gigg

Allow absolute & relative errors to be specifed in LM minimizer

Gives more flexibility rather than being stuck with the hard-coded 1e-4. The default is set to replicate the old behaviour. Refs #7199

Changeset: 6e75e81e417db026f509a8f6c2a32b448736ccab

comment:48 Changed 7 years ago by Martyn Gigg

Added more detail to Fit at information log level. Refs #7199

  • The value of the cost function is printed after each iteration
  • The Covariance & Hessian matrix are output at the end of the fit

Changeset: 87521c32079a1221088ab6c3db8239eafd56c221

comment:49 Changed 7 years ago by Martyn Gigg

Update VesuvioFittingTest

Now uses ComptonScatteringCountRate instead of basic CompositeFunction to give a better overall fit. Refs #7199

Changeset: 59774490bea0bfedc33f8388604086f8592d3682

comment:50 Changed 7 years ago by Martyn Gigg

Update values for LoadVesuvio test.

The output is now a point data set in the difference case and the errors were being calculated incorrectly before. Refs #7199

Changeset: 46f936ecafd7b033a017e0a2be3d7acc4bc53caa

comment:51 Changed 7 years ago by Martyn Gigg

Remove local extern qualifiers in SLSQPMinimzer Refs #7199

Changeset: 95424ae831e7d75b2ed94e17b48212bd67f8165e

comment:52 Changed 7 years ago by Martyn Gigg

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

Branch: bugfix/7199_vesuvio_fitting_diffs

Repositories: Main code & System test

Tester: This is difficult to test as it is work that must ultimately be verified by the users.

The fit to some Vesuvio data can be run with the following scripts. Make sure the system test data directory is in your data search path. The output from Fit, which can be plotted by plotting the data vs calculated, should give a reasonable match to the data.

LoadVesuvio(Filename='14188-14190',OutputWorkspace='raw_ws',SpectrumList='135',Mode='SingleDifference',
                    InstrumentParFile=r'IP0005.dat')
        CropWorkspace(InputWorkspace='raw_ws',OutputWorkspace='raw_ws',XMin=50,XMax=562)

        function_str = \
            "composite=ComptonScatteringCountRate,NumDeriv=1,IntensityConstraints=\"Matrix(1|3)0|-1|3\";"\
            "name=GramCharlierComptonProfile,WorkspaceIndex=0,Mass=1.007940,HermiteCoeffs=1 0 1;"\
            "name=GaussianComptonProfile,WorkspaceIndex=0,Mass=27.000000;"\
            "name=GaussianComptonProfile,WorkspaceIndex=0,Mass=91.000000"

        ties_str = "f1.Width=10.000000,f2.Width=25.000000,f0.FSECoeff=f0.Width*sqrt(2)/12"
        constraints_str = "2.000000 < f0.Width < 7.000000"

        ws_prefix = "fit"
        Fit(InputWorkspace='raw_ws',Function=function_str,Ties=ties_str,Constraints=constraints_str,
            Output=ws_prefix, CreateOutput=True,OutputCompositeMembers=True,MaxIterations=5000,
            Minimizer="Levenberg-Marquardt,AbsError=1e-08,RelError=1e-08")

comment:53 Changed 7 years ago by Martyn Gigg

Move local struct to namespace level. Refs #7199

Some older compilers can't deal with a function call where the template type is only defined locally within the function.

Changeset: 2feb5151d660b52297577e957b60c33d76b93dbf

comment:54 Changed 7 years ago by Martyn Gigg

Fix std::pow call for unsigned types on OS X. Refs #7199

Changeset: b3fcc3412ea5db92180c1b46069862f4266eb3e6

comment:55 Changed 7 years ago by Martyn Gigg

Relax tolerance for test slightly for intel compiler on OS X.

Refs #7199

Changeset: af3a7489b1d9780ad41616121893905811d4bf11

comment:56 Changed 7 years ago by Martyn Gigg

Relax tolerance for GaussianComptonProfileTest for Intel on OSX 10.8

Refs #7199

Changeset: baf2fb1d77eba944a29100f881de10c5bc83de12

comment:57 Changed 7 years ago by Martyn Gigg

Relax tolerancance for GaussianComptonProfileTest for Intel on OSX

even more...Refs #7199

Changeset: 5099daab4aafdef32a03f334154db0a89a71ac5e

comment:58 Changed 7 years ago by Martyn Gigg

Relax VesuvioFittingTest tolerance (slightly) to account for OS X

Refs #7199

Changeset: 2cebf40e98f36d6068a43d27d7712bd9f6f5ba0f

comment:59 Changed 7 years ago by Alex Buts

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

comment:60 Changed 7 years ago by Alex Buts

  • Status changed from verifying to closed

It works and it indeed up to the users to check if it work correctly

comment:61 Changed 7 years ago by Alex Buts

refs #7199 Merge branch 'master' into

bugfix/7189_ConvertToMD_V2_inSysTests Conflicts:

SystemTests/AnalysisTests/MDWorkspaceTests.py

Changeset: d64e7162ffc3fe7e9c77c5f3f377554e0d924232

comment:62 Changed 7 years ago by Nick Draper

  • Component changed from Mantid to Framework

comment:63 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 8045

Note: See TracTickets for help on using tickets.