Ticket #5591 (closed: fixed)

Opened 8 years ago

Last modified 5 years ago

[Indirect] - Cubic spline algorithms

Reported by: Peter Parker Owned by: Samuel Jackson
Priority: major Milestone: Release 2.6
Component: Indirect Inelastic Keywords: Indirect, Student First
Cc: spencer.howells@… Blocked By:
Blocking: #7565 Tester: Owen Arnold

Description (last modified by Nick Draper) (diff)

Requested ticket from Spencer:

Could you add another ticket for me:

GSL has routines for doing cubic spline interpolation. This is useful for:

  • interpolation : where the number of intyerpolation points is much greater than input and/or the x-increment for interpolation is much smaller that input.
  • smoothing : using interpolation range same as input. Good for sharp peaks.
  • derivatives : these come as by-product of the prodecure. Advantages as above.

Implement on Genie and tried & tested.

Attachments

g-ZnCl2_ND_Stheta.nxs (128.0 KB) - added by Samuel Jackson 7 years ago.
Example data for SplineInterpolation
l-ZnCl2_ND_Mome.nxs (65.5 KB) - added by Samuel Jackson 7 years ago.
Example data for SplineInterpolation
ZnCl2_Stheta.nxs (128.7 KB) - added by Samuel Jackson 7 years ago.
Example data for SplineSmoothing

Change History

comment:1 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.2 to Release 2.3

Moved at the end of release 2.2

comment:2 Changed 8 years ago by Peter Parker

Update:

Talk to Spencer for more info, but Nick also seemed keen to add some comments about how best to proceed with this.

comment:3 Changed 8 years ago by Peter Parker

  • Keywords Indirect added
  • Summary changed from Cubic spline algorithms to [Indirect] - Cubic spline algorithms

comment:4 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.3 to Release 2.4

Moved to milestone 2.4

comment:5 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.4 to Release 2.5

Moved at the code freeze for release 2.4

comment:6 Changed 7 years ago by Nick Draper

  • Milestone changed from Release 2.5 to Release 2.6

Moved to r2.6 at the end of r2.5

comment:7 Changed 7 years ago by Nick Draper

  • Owner changed from Peter Parker to Anyone
  • Keywords Indirect, Student added; Indirect removed
  • Status changed from new to assigned

comment:8 Changed 7 years ago by Nick Draper

  • Keywords First added

comment:9 Changed 7 years ago by Nick Draper

  • Owner changed from Anyone to Samuel Jackson

comment:10 Changed 7 years ago by Samuel Jackson

  • Status changed from assigned to accepted

comment:11 Changed 7 years ago by Samuel Jackson

Initial files stored before starting testing. Not yet working.

Refs #5591

Changeset: d7e654346a139309bdc2cba867528e4c6b20d45d

comment:12 Changed 7 years ago by Samuel Jackson

Working on CubicSpline test class.

Refactored CubicSpline to remove reallocating the spline on every run of the function.

Refs #5591

Changeset: b4fd004d5347fa404d8b2dd7360643e27b63cf34

comment:13 Changed 7 years ago by Samuel Jackson

Added tests for a selection of known and unknown data set points.

Refs #5591

Changeset: d10d4975adb21be6aa95bf4b46d1d0ff2788ae33

comment:14 Changed 7 years ago by Samuel Jackson

Finished writing unit tests for basic CubicSpline.

Refs #5591

Changeset: 3ef6a42a6e1e7450b41268fc8072d0ff78f5855a

comment:15 Changed 7 years ago by Samuel Jackson

Updated algorithm with a function to calculate derivatives.

Algorithm should now be able to calculate both the first and second derivatives.

Refs #5591

Changeset: d48cda0ebfd4e56f5d04d5f2d47507ad60cd4d4d

comment:16 Changed 7 years ago by Samuel Jackson

Finishing up derivatives implementation.

Added correction for x points being out of order.

Refs #5591

Changeset: edb46705c48865c6f718541c8f3606d62aae3e3f

comment:17 Changed 7 years ago by Samuel Jackson

Fixing exception checking.

Refs #5591

Changeset: 18d8de0c1cfe066440d2c215cb31e3d50c0003b7

comment:18 Changed 7 years ago by Samuel Jackson

Swapping arrays to boost scoped arrays.

Also changing test to run correctly on mac build server.

Refs #5591

Changeset: f5ad3d7205ed8719f454dfbfae9651e12b15ec53

comment:19 Changed 7 years ago by Samuel Jackson

Fixing arrays issue in CubicSplineTest

Refs #5591

Changeset: 4f3657d762134dbeefc48c71b6736e0f209febb8

comment:20 Changed 7 years ago by Russell Taylor

Heads up on a few gcc compiler warnings (IFunction1D.cpp line 55): http://download.mantidproject.org/jenkins/job/is_inc_rhel6_develop/1248/warnings14Result/NORMAL/?

comment:21 Changed 7 years ago by Samuel Jackson

Created Spline algorithm as wrapper to CubicSpline

Spline calculates smoothing of noisy data from an input workspace.

Refs #5591

Changeset: 72b2941558438c514df0bc5bec88dc01e23d632d

comment:22 Changed 7 years ago by Samuel Jackson

Creating new algorithm for SplineInterpolation.

Renaming Spline to SplineSmoothing.

Refs #5591

Changeset: bf598468094f73bce922f629e2b1a4fde5873c04

comment:23 Changed 7 years ago by Samuel Jackson

SplineInterpolation algorithm written.

Improved error handling in CubicSpline. Fixed Attribute setting bug in SplineSmoothing. Suppressed unused function variables warning in unimplemented method derivative1D in IFunction1D.

Refs #5591

Changeset: 8c66d3982a41af48ce7a44eb20680e60fe8fa1cf

comment:24 Changed 7 years ago by Samuel Jackson

Touching up failed tests.

Refs #5591

Changeset: 19a12bb178b5d29613b8e17d81cde077546cbf86

comment:25 Changed 7 years ago by Samuel Jackson

Refs #5591 Algorithms now support both binned and point data.

Changeset: f0bf22040d7d946f5f61bd0b89e27f3ab8ac8910

comment:26 Changed 7 years ago by Samuel Jackson

  • Cc spencer.howells@… added

comment:27 Changed 7 years ago by Samuel Jackson

SplineSmoothing now works with all histograms.

Better range checking added to CubicSpline. Both algorithms should now return histogram data rather than point data. Changed "Order" property to "DerivOrder"

Refs #5591

Changeset: b11cf720a064aa4a3462d26b2a224306685e4f29

comment:28 Changed 7 years ago by Samuel Jackson

Forgot to change "order" to "DerivOrder" in SplineInterpolation.

Refs #5591

Changeset: 46dc3e7e4f8230c1c6d2edb7431ded2204c75af6

comment:29 Changed 7 years ago by Samuel Jackson

Missed changing a parameter

Refs #5591

Changeset: ae7617c37e3882aac06a3b4a17ab9bd442355cde

comment:30 Changed 7 years ago by Nick Draper

  • Status changed from accepted to assigned

comment:31 Changed 7 years ago by Nick Draper

  • Status changed from assigned to new

comment:32 Changed 7 years ago by Samuel Jackson

Swapping raw pointers to boost shared pointers

And general refactoring.

Refs #5591

Changeset: 97a67af5a14183618482f2ed941e40334b3eaa63

comment:33 Changed 7 years ago by Samuel Jackson

Tidying up with typedefs to CubicSpline.

Refs #5591

Changeset: dfe9b80de0d43708155de380d407e79074bfb6cd

comment:34 Changed 7 years ago by Samuel Jackson

Refactoring, updating documentation, updating unit tests

Refs #5591

Changeset: ea3b30e8a6aebdbe65d24ac1d76dfa07e3d5c91d

comment:35 Changed 7 years ago by Samuel Jackson

Adding support for histogram data in SplineInterpolation.

Refs #5591

Changeset: 8094c0c0c53470c67792d967de80a4bd5e44f142

comment:36 Changed 7 years ago by Samuel Jackson

Fixing support for GSL library function not present in Windows.

Refs #5591

Changeset: af435cd9fd076624696cd80c5d8a753de4fb5946

comment:37 Changed 7 years ago by Samuel Jackson

  • Status changed from new to inprogress

Working on derivatives with higher orders than 2.

Refs #5591

Changeset: 3359aa7a5000b7a879df41ec6b7a2bc7c2084375

comment:38 Changed 7 years ago by Samuel Jackson

Implemented new approach to smoothing.

Removed property "SplineSize" Added property "Error"

Refs #5591

Changeset: d3476410cf407bfc0f0c14653f0b6c1656d2863f

comment:39 Changed 7 years ago by Nick Draper

  • Component changed from Mantid to Framework

comment:40 Changed 7 years ago by Samuel Jackson

Implemented better output workspace structure.

Changed SplineInterpolation to all histograms against first reference histogram in a similar way to RebinToWorkspace. Updated unit tests on both algorithms to reflect workspace changes.

Refs #5591

Changeset: 59fe8831bdc5f0d3b0a74b8723144f159b40f533

comment:41 Changed 7 years ago by Samuel Jackson

Added additional fitting.

Updated documentation and wiki descriptions.

Refs #5591

Changeset: 439829f13cff0646893480434f580b26482c7200

comment:42 Changed 7 years ago by Samuel Jackson

Updating to pass unit tests.

Refs #5591

Changeset: 4ae51a42947d4ae3f39eab7486d35dd743ef1b3a

comment:43 Changed 7 years ago by Nick Draper

  • Component changed from Framework to Indirect Inelastic
  • Description modified (diff)

comment:44 Changed 7 years ago by Samuel Jackson

Updated with better unit tests.

Refs #5591

Changeset: 4d28df37b7b5715da66155e4efc7664f20fdeaf0

comment:45 Changed 7 years ago by Samuel Jackson

Last minute bugfix to catch values outside of spline.

Refs #5591

Changeset: e022505d00e7556a2525fd26732d8d1f15851b18

comment:46 Changed 7 years ago by Samuel Jackson

Adding more intelligent range overflow handling.

Refs #5591

Changeset: 03c155d9835e85b092c1cbde0495d22b6e41897a

comment:47 Changed 7 years ago by Samuel Jackson

Fixing workspaces being the wrong way round.

Refs #5591

Changeset: 84467e788a4fef46e05052ee75e439a37d996004

Changed 7 years ago by Samuel Jackson

Example data for SplineInterpolation

Changed 7 years ago by Samuel Jackson

Example data for SplineInterpolation

Changed 7 years ago by Samuel Jackson

Example data for SplineSmoothing

comment:48 Changed 7 years ago by Samuel Jackson

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

To Test:

There have been two new algorithms added for this ticket. SplineInterpolation and SplineSmoothing both of which need to be tested. I have attached some sample files to help with this.

Testing SplineSmoothing:

The algorithm should take a 2D matrix workspace of either point or histogram data (e.g. ZnCl2_Stheta.nxs) and the following properties:

  • DerivOrder: order of derivatives to calculate (0-2)
  • Error: The error tolerance allowed between the spline and the input data

And produce the following:

1) A workspace containing the smoothed version of the input workspace in the same format (e.g. histogram data)

2) A grouped workspace containing a set of workspaces (one per input histogram) containing the derivatives of the output data to the order specified by the DerivOrder property (entering zero for this should not produce a grouped workspace at all).

Testing SplineInterpolation:

The algorithm should take two matrix workspaces (either point or histogram data):

  • WorkspaceToMatch: A workspace containing a data set to match against. This can have multiple spectra, but only the first set of values will be used. (e.g. g-ZnCl_ND_Stheta.nxs)
  • WorkspaceToInterpolate: A workspace containing a set of data to be interpolated. (e.g. l-ZnCl2_ND_Mome.nxs)

It also takes the following property:

  • DerivOrder: order of the derivatives to calculate (0-2)

The following output should be produced:

1) A workspace containing the interpolated version of the input workspace in the same format (e.g. histogram data)

2) A grouped workspace containing a set of workspaces (one per input histogram) containing the derivatives of the output data to the order specified by the DerivOrder property (entering zero for this should not produce a grouped workspace at all).

comment:49 Changed 7 years ago by Owen Arnold

  • Status changed from verify to verifying
  • Tester set to Owen Arnold

comment:50 Changed 7 years ago by Owen Arnold

  • Blocking 7565 added

comment:51 Changed 7 years ago by Owen Arnold

  • Status changed from verifying to reopened
  • Resolution fixed deleted

The zero default on SplineSmoothing is not a good default.

comment:52 Changed 7 years ago by Samuel Jackson

  • Status changed from reopened to inprogress

Changed validator property to be something more sensible than zero.

Refs #5591

Changeset: 20399ef60b32c38bdb122f03c83fafca31d4b90b

comment:53 Changed 7 years ago by Owen Arnold

Tester Code Review:

I don't see any problems with this ticket given a code review. Lots of units tests used, which is good to see. For future reference, it's good to try and weight more of your unit tests to be destructive rather than happy-path. Algorithms can also make use of the performance tests framework, which you might find useful.

comment:54 Changed 7 years ago by Samuel Jackson

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

comment:55 Changed 7 years ago by Owen Arnold

  • Status changed from verify to verifying

comment:56 Changed 7 years ago by Owen Arnold

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/5591_cubic_spline_algorithms'

comment:57 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 6437

Note: See TracTickets for help on using tickets.