Commit 1dd622f5 authored by Zhang, Chen's avatar Zhang, Chen
Browse files

add demo figs for P1 and P1+2

parent 321ee7aa
......@@ -109,7 +109,7 @@ It is worth points out that the derivative of the detector efficiency is compute
The detailed explanation can be found in [2]_ .
.. plot:: CalculatePlaczekPlotP1.py
.. plot:: algorithms/CalculatePlaczekPlotP1.py
The second order Placzek correction, :math:`P_2` is similar to the first order, just with some new components
......@@ -170,9 +170,11 @@ If no detector efficiency is measured, :math:`\epsilon_2` can also be approximat
where :math:`x = -\lambda / \lambda_d`.
.. plot:: algorithms/CalculatePlaczekPlotP2.py
Usage
-----
.. Try not to use files in your examples,
.. Example ddd
but if you cannot avoid it then the (small) files must be added to
autotestdata\UsageData and the following tag unindented
.. include:: ../usagedata-note.txt
......
......@@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
# Load incident flux
Load(
......@@ -11,7 +12,7 @@ Load(
CropWorkspace(InputWorkspace='influx', OutputWorkspace='influx', XMin=0.1, XMax=2.9)
# Load 6 summed spectrum from NOM as input workspace
Load(Filename='inputwsNOM_164109', OutputWorkspace='NOM_164109')
Load(Filename='inputwsNOM_164109.nxs', OutputWorkspace='NOM_164109')
SetSampleMaterial(InputWorkspace='NOM_164109', ChemicalFormula='Cs-Cl', SampleMassDensity=3.99)
CalculatePlaczek(
InputWorkspace="NOM_164109",
......@@ -23,12 +24,20 @@ CalculatePlaczek(
CrystalDensity=0.01,
OutputWorkspace="NOM_P1",
)
# convert to q
ConvertUnits(InputWorkspace='NOM_P1', OutputWorkspace='NOM_P1', Target='MomentumTransfer')
# plot
outws = mtd["NOM_P1"]
x = np.array(outws.readX(0))
fig, ax = plt.subplots(1)
x = 0.5 * (x[1:] + x[:-1])
fig, ax1 = plt.subplots(1)
for i in range(6):
y = np.array(outws.readY(i))
ax.plot(x, y, label=f"P1_Spec{i}")
ax.set_ylabel("P1 Factor")
ax1.plot(x, y, label=f"P1:Spec{i}")
ax1.set_xlabel(r"q($\AA^{-1}$)")
ax1.set_xlim([0.1, 15])
ax1.legend()
ax1.set_ylabel("P1")
ax1.set_title("First Order Placzek correction factor")
......@@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
# Load incident flux
Load(
......@@ -11,7 +12,7 @@ Load(
CropWorkspace(InputWorkspace='influx', OutputWorkspace='influx', XMin=0.1, XMax=2.9)
# Load 6 summed spectrum from NOM as input workspace
Load(Filename='inputwsNOM_164109', OutputWorkspace='NOM_164109')
Load(Filename='inputwsNOM_164109.nxs', OutputWorkspace='NOM_164109')
SetSampleMaterial(InputWorkspace='NOM_164109', ChemicalFormula='Cs-Cl', SampleMassDensity=3.99)
CalculatePlaczek(
InputWorkspace="NOM_164109",
......@@ -23,12 +24,19 @@ CalculatePlaczek(
CrystalDensity=0.01,
OutputWorkspace="NOM_P2",
)
# convert to q
ConvertUnits(InputWorkspace='NOM_P2', OutputWorkspace='NOM_P2', Target='MomentumTransfer')
# plot
outws = mtd["NOM_P2"]
x = np.array(outws.readX(0))
fig, ax = plt.subplots(1)
x = 0.5 * (x[1:] + x[:-1])
fig, ax1 = plt.subplots(1)
for i in range(6):
y = np.array(outws.readY(i))
ax.plot(x, y, label=f"P2_Spec{i}")
ax.set_ylabel("P2 Factor")
ax1.plot(x, y, label=f"P1+P2:Spec{i}")
ax1.set_xlabel(r"q($\AA^{-1}$)")
ax1.set_xlim([0.1, 15])
ax1.legend()
ax1.set_ylabel("P2")
ax1.set_title("Full Placzek correction factor (P1+P2)")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment