\(\renewcommand\AA{\unicode{x212B}}\)

Python in Mantid: Exercise 1

The aim of this exercise is to show some simple examples of data exploration

A - ISIS Data

The HRPD data contains a spike (pulse) every 20 milliseconds. While this is nicely localized in time-of-flight, it is not the case upon conversion to d-spacing.

The aim of this exercise is to use Mantid to write a script, which excludes this contribution from the pulse.

  1. Load v1 - Load the given HRPD data set, HRP39182.RAW into a workspace called ‘HRP39182’

  2. MaskBins v1 - Mask out the bins corresponding to the pulse with XMin=19990 and XMax=20040

  3. Repeat the previous step for the other 4 pulses, each of which is 20000 microseconds after the previous. All MaskBins executions should happen on the same InputWorkspace so that all 5 pulses are masked from the same workspace. Hint: A loop might be useful.

  4. ApplyDiffCal v1- Correct the masked workspace for small variations in detector position, using the calibration file hrpd_new_072_01_corr.cal.

  5. ConvertUnits v1 - Convert unit to dSpacing

  6. DiffractionFocussing v2 - Focus the data in the masked workspace using the same cal file as the previous step (called a grouping file here)

Bonus: Can you run the Align-Focus process on the original, unmasked data and Minus v1 the final workspace processed without the pulse from the final workspace processed with the pulse? Plot the difference workspace with the final processed data to compare.

B - SNS Data

Filter, process and compress event data.

  1. LoadEventNexus v1 - Load the given POWGEN data set, PG3_4871. If you need to reduce the number of events loaded, select only the first 4000 seconds of the run.

  2. Log the number of events in the Messages Box with the command logger.notice(“message”) (The function to get the number of events from a workspace called ws is ws.getNumberEvents().

  3. FilterBadPulses v1 - Remove events that occurred while the accelerator was resetting, by setting the LowerCutoff to 99.5 % of the average beam proton charge.

  4. ApplyDiffCal v1- Correct the masked workspace for small variations in detector position, using the calibration file PG3_golden.cal.

  5. ConvertUnits v1 - Convert unit to dSpacing.

  6. Rebin v1 - Bin the data in d-spacing from 1.4 to 8 angstroms using logarithmic binning of .0004.

  7. DiffractionFocussing v2 - Focus the data in the workspace using the same cal file as the previous step (PG3_golden.cal).

  8. CompressEvents v1 - Saves some memory. Again, extract and log the number of events.

C - ILL Data

Merge, mask, correct and compare.

  1. Load v1 - Load the given IN6 data sets, ‘164198.nxs’, ‘164199.nxs’ and ‘164200.nxs’ into workspaces named after the filename.

  2. MergeRuns v1 - Merge all the previously loaded data sets into a single workspaced called ‘data_merged’.

  3. MaskDetectors v1 - Remove bad spectra indices : 1,2,3,4,5,6,11,14,30,69,90,93,95,97,175,184,190,215,216,217,251,252,253,255,289,317,335 and 337.

  4. MultiplyRange v1 - Calculate sample transmission of 95%.

  5. ConvertUnits v1 - Convert the data from TOF to Delta Energy. (Find the Efixed value as Ei in the Sample Logs for the workspace)

  6. DetectorEfficiencyCorUser v1 - Correct the data with the detector efficiency for this instrument.

  7. Compare the corrected with the unccorrected data, say bin 4 of spectrum number 7 (workspace index 6).

Solutions