$$\renewcommand\AA{\unicode{x212B}}$$

# Exercises¶

## Exercise 1¶

In this exercise we will fit a simple Gaussian on a linear background.

2. Plot Spectrum number 4.

3. Zoom into the peak around 5 angstroms.

1. Click on the Fit Toolbar button to open the fit property browser.

2. Adjust the fitting range, defined by the dashed lines, if needed.

3. Make sure the fitting model is empty, Clear the model if necessary.

1. Add a background function. Select LinearBackground.

1. Change peak type to Gaussian, and add a Gaussian.

2. Click at peak’s maximum point to set initial values for the centre and the height.

3. Adjust the width.

1. Run Fit.

## Exercise 2¶

1. Again, ensure that the Fit model is clear by clicking Setup >”Clear model”

2. Load the GEM63437_focussed.nxs data (different to the data in Exercise 1). Note the workspace created is a WorkspaceGroup, which has already been processed with Mantid. Click on the triangle to reveal the contained workspaces. Show the History to see how many algorithms have been applied to this dataset.

3. Plot the spectrum in GEM63437_focussed_2 by double-clicking on this workspace, and zoom in on the area of the three peaks

4. Open the Fit Property Browser and set fitting range/StartX and EndX to be between approximately 2270 and 5000 microseconds

5. Right click on plot and select “Add background”, then LinearBackground

6. Change the peak type to IkedaCarpenterPV.

Remember, this is a peak function where some parameters are set based on the relevant instrument geometry. This is evident from the starting guess of the peak width but also by inspecting this function in the Fit Function panel.

7. Add an IkedaCarpenterPV peak to each of the three peaks, remembering to change the peak width (at least for the first one!)

8. Display > “Plot guess” and what you should see is something similar to

where the orange line is the guess

1. Remove plot guess

2. Fit the data with the model, where the output should be something similar to:

where the green line here is the Calculated fit

Optionally using a similar approach try to fit the spectrum in for example GEM63437_focussed_3

## Exercise 3¶

1. Load the MUSR00015189 data set, this is a group workspace

2. Click the triangle beside this workspace

3. From the second workspace (MUSR00015189_2), plot spectrum number 64

4. Open the Fit property browser

5. As described earlier, add a UserFunction with the with Formula = h*exp(-a*x)

6. Set h = 5000 and Fix it to this value

7. Give a some positive intial value such as 1.0

8. Fit the data