|
1 |
| - |
2 | 1 | .. algorithm::
|
3 | 2 |
|
4 | 3 | .. summary::
|
|
9 | 8 |
|
10 | 9 | Description
|
11 | 10 | -----------
|
12 |
| - |
13 |
| -TODO: Enter a full rst-markup description of your algorithm here. |
14 |
| - |
| 11 | +The algorithm generates a simulated workspace by sampling from the probability |
| 12 | +distribution of input data, useful for testing of fitting functions and modeling. |
| 13 | +By generating a simulated dataset that mirrors the probability |
| 14 | +distribution of existing data. |
15 | 15 |
|
16 | 16 | Usage
|
17 | 17 | -----
|
18 |
| -.. Try not to use files in your examples, |
19 |
| - but if you cannot avoid it then the (small) files must be added to |
20 |
| - autotestdata\UsageData and the following tag unindented |
21 |
| - .. include:: ../usagedata-note.txt |
22 | 18 |
|
23 | 19 | **Example - CreateMonteCarloWorkspace**
|
24 | 20 |
|
25 |
| -.. testcode:: CreateMonteCarloWorkspaceExample |
| 21 | +.. testcode:: Create simulation and compare |
26 | 22 |
|
27 |
| - # Create a host workspace |
28 |
| - ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2)) |
29 |
| - or |
30 |
| - ws = CreateSampleWorkspace() |
| 23 | + from mantid.api import AnalysisDataService as ADS |
31 | 24 |
|
32 |
| - wsOut = CreateMonteCarloWorkspace() |
| 25 | + # Create Sample Workspace and Run Simulation |
| 26 | + ws = CreateSampleWorkspace(Random= True) |
| 27 | + wsOut = CreateMonteCarloWorkspace(InputWorkspace= 'ws', Seed= 32, OutputWorkspace= "New") |
33 | 28 |
|
34 |
| - # Print the result |
35 |
| - print "The output workspace has %%i spectra" %% wsOut.getNumberHistograms() |
| 29 | + # Plot both of the above |
| 30 | + fig, axes = plt.subplots(edgecolor='#ffffff', num='New', subplot_kw={'projection': 'mantid'}) |
| 31 | + for data, color, label in [(ADS.retrieve('New'), '#1f77b4', 'New: spec 1'), |
| 32 | + (ADS.retrieve('ws'), '#ff7f0e', 'ws: spec 1')]: |
| 33 | + axes.plot(data, color=color, label=label, wkspIndex=0) |
36 | 34 |
|
37 |
| -Output: |
| 35 | + axes.tick_params(axis='both', which='major', size=6, tickdir='out', width=1, gridOn=False, label1On=True) |
| 36 | + axes.set(title='New', xlabel='Time-of-flight ($\\mu s$)', ylabel='Counts ($\\mu s$)$^{-1}$', ylim=[-0.00225, 0.04725]) |
| 37 | + axes.legend(fontsize=8.0).set_draggable(True) |
38 | 38 |
|
39 |
| -.. testoutput:: CreateMonteCarloWorkspaceExample |
| 39 | + fig.show() |
40 | 40 |
|
41 |
| - The output workspace has ?? spectra |
| 41 | +Output: |
| 42 | + A histogram similar to the original but generated in a random way. |
| 43 | + |
| 44 | +.. image:: ../../../images/New.png |
| 45 | + :alt: Overplot of simulated data over input data |
| 46 | + :width: 500px |
| 47 | + :height: 400px |
| 48 | + :scale: 100% |
| 49 | + :align: center |
| 50 | + :class: custom-class |
42 | 51 |
|
43 | 52 | .. categories::
|
44 | 53 |
|
|
0 commit comments