Skip to content
Snippets Groups Projects
Commit 2f39c00f authored by Owen Arnold's avatar Owen Arnold
Browse files

Merge remote-tracking branch 'origin/feature/9627_Doc_Martyn'

parents 4aa765d7 f7a518af
No related branches found
No related tags found
No related merge requests found
Showing
with 461 additions and 58 deletions
......@@ -18,8 +18,10 @@ void IdentifyNoisyDetectors::init()
wsVal->add<HistogramValidator>();
wsVal->add<SpectraAxisValidator>();
wsVal->add<InstrumentValidator>();
declareProperty(new WorkspaceProperty<>("InputWorkspace", "", Direction::Input,wsVal));
declareProperty(new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output));
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", "", Direction::Input/*,wsVal*/));
declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace", "", Direction::Output));
declareProperty("RangeLower", 2000.0,"The lower integration range");
declareProperty("RangeUpper", 19000.0,"The upper integration range");
}
void IdentifyNoisyDetectors::exec()
......@@ -29,8 +31,8 @@ void IdentifyNoisyDetectors::exec()
MatrixWorkspace_sptr inputWs = getProperty("InputWorkspace");
const int nHist = static_cast<int>(inputWS->getNumberHistograms());
const double rangeLower = 2000;
const double rangeUpper = 19000;
const double rangeLower = getProperty("RangeLower");
const double rangeUpper = getProperty("RangeUpper");
const double steps = rangeUpper - rangeLower;
// Create the output workspace a single value for each spectra.
......
......@@ -45,7 +45,6 @@ class LoadLogPropertyTable(PythonAlgorithm):
possibleLogs = ws.getRun().keys()
possibleLogs.insert(0,'comment')
message = "The log name '" + name + "' was not found, possible choices are: " + str(possibleLogs)
print message
raise ValueError(message)
try:
times2=[]
......@@ -101,7 +100,6 @@ class LoadLogPropertyTable(PythonAlgorithm):
try:
returnTuple=Load(Filename=thispath,OutputWorkspace="__CopyLogsTmp",SpectrumMin=1, SpectrumMax=1)
except:
print "Cannot load file " + thispath + " - skipping"
continue
#check if the return type is atuple
......@@ -113,7 +111,6 @@ class LoadLogPropertyTable(PythonAlgorithm):
#check if the ws is a group
ws = loadedWs
if (ws.id() == 'WorkspaceGroup'):
print "Multiperiod File: Logs will be from the first period, but unfiltered. ",
ws=ws[0]
begin=datetime.datetime(*(time.strptime(ws.getRun().getProperty("run_start").value,"%Y-%m-%dT%H:%M:%S")[0:6])) # start of day
......@@ -135,7 +132,6 @@ class LoadLogPropertyTable(PythonAlgorithm):
if(lval>ows.cell(cc,ff-firstnum-1)):
ows.setCell(cc,ff-firstnum-1,lval)
ows.addRow(vallist)
print "Finished file ",thispath
DeleteWorkspace(loadedWs)
......
......@@ -42,4 +42,16 @@ The pixel efficiency and incident spectrum correction are NOT CURRENTLY
USED. The absorption correction, trans, depends on both lamda and the
pixel, Which is a fairly expensive calulation when done for each event.
Usage
-----
**Example:**
.. testcode:: AnvredCorrection
ws = CreateSampleWorkspace("Event",XMin=5000)
wsOut = AnvredCorrection(ws,LinearScatteringCoef=1.302,
LinearAbsorptionCoef=1.686,Radius=0.170,PowerLambda=3)
.. categories::
......@@ -17,4 +17,34 @@ This workspace can serve as a starting point for modifying the
`PeaksWorkspace <PeaksWorkspace>`__, using the GUI or python scripting,
for example.
Usage
-----
**Example: An empty table, not tied to an instrument**
.. testcode:: ExEmptyTable
ws = CreatePeaksWorkspace()
print "Created a %s with %i rows" % (ws.id(), ws.rowCount())
Output:
.. testoutput:: ExEmptyTable
Created a PeaksWorkspace with 0 rows
**Example: With a few peaks in place**
.. testcode:: ExTableWithRows
sampleWs = CreateSampleWorkspace()
ws = CreatePeaksWorkspace(InstrumentWorkspace=sampleWs,NumberOfPeaks=3)
print "Created a %s with %i rows" % (ws.id(), ws.rowCount())
Output:
.. testoutput:: ExTableWithRows
Created a PeaksWorkspace with 3 rows
.. categories::
......@@ -18,4 +18,31 @@ reflected line, the second is taken to be from the transmission line.
This algorithm outputs a TableWorkspace containing the spectrum number
of interest.
Usage
-----
**Example:**
.. testcode:: ExFindReflectometryLines
# a simple workspace
dataX = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
dataY = [0.1, 1, 0.1, 0.2, 0.1, 2, 0.1] # Real peaks with values 1, 2, false peak with value 0.2
dataE = [0, 0, 0, 0, 0, 0, 0]
nSpec = 7
ws = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=nSpec, UnitX="Wavelength",
VerticalAxisUnit="SpectraNumber")
wsOut = FindReflectometryLines(ws)
for i in range(wsOut.columnCount()):
print wsOut.getColumnNames()[i], wsOut.column(i)[0]
Output:
.. testoutput:: ExFindReflectometryLines
Reflected Spectrum Number 6
Transmission Spectrum Number 2
.. categories::
......@@ -26,4 +26,31 @@ accurate and belong to a single crystal, this method should produce some
UB matrix that indexes the peaks. However, other software will usually
be needed to adjust this UB to match a desired conventional cell.
Usage
-----
**Example:**
.. testcode:: ExFindUBUsingMinMaxD
ws=LoadIsawPeaks("TOPAZ_3007.peaks")
print "After LoadIsawPeaks does the workspace have an orientedLattice: %s" % ws.sample().hasOrientedLattice()
FindUBUsingMinMaxD(ws,MinD=8.0,MaxD=13.0)
print "After FindUBUsingMinMaxD does the workspace have an orientedLattice: %s" % ws.sample().hasOrientedLattice()
print ws.sample().getOrientedLattice().getUB()
Output:
.. testoutput:: ExFindUBUsingMinMaxD
After LoadIsawPeaks does the workspace have an orientedLattice: False
After FindUBUsingMinMaxD does the workspace have an orientedLattice: True
[[ 0.01223576 0.00480107 0.08604016]
[-0.11654506 0.00178069 -0.00458823]
[-0.02737294 -0.08973552 -0.02525994]]
.. categories::
......@@ -16,14 +16,12 @@ The process for this algorithm is:
- The mean value and standard deviation of these standard deviation
values is calculated.
- Any detector/pixel for which it's standard deviation value satisfied
the following conditions:
the following conditions is considered to be "noisy":
- sdev(pixel) < mean(sdevs) - 3 \* sdev(sdevs)
- sdev(pixel) > mean(sdevs) + 3 \* sdev(sdevs)
- sdev(pixel) < mean(sdevs) \* 0.0001
- (cont) is considered to be "noisy".
This is repeated three times from the second step.
This uses the :ref:`algm-Integration`, :ref:`algm-Power` and
......@@ -33,4 +31,43 @@ The lower bound for the integration is currently fixed to 2000.
The upper bound for the integration is currently fixed to 19000.
Usage
-----
**Example: A clean run no noisy detectors**
.. testcode:: ExClearRun
ws = CreateSampleWorkspace()
wsOut = IdentifyNoisyDetectors(ws)
print "The output workspace is filled with %i for good detectors and 0 for noisy ones." % wsOut.readY(0)[0]
sum = SumSpectra(wsOut)
print "%i good spectra left" % sum.readY(0)[0]
Output:
.. testoutput:: ExClearRun
The output workspace is filled with 1 for good detectors and 0 for noisy ones.
200 good spectra left
**Example: With lots of noisy detectors**
.. testcode:: ExNoisy
ws = CreateSampleWorkspace()
#make the spectra vary
for i in range(ws.getNumberHistograms()):
ws.setY(i, ws.readY(i)*2**i)
wsOut = IdentifyNoisyDetectors(ws)
sum = SumSpectra(wsOut)
print "%i good spectra left from an original %i." % (sum.readY(0)[0], wsOut.getNumberHistograms())
Output:
.. testoutput:: ExNoisy
15 good spectra left from an original 200.
.. categories::
......@@ -33,4 +33,48 @@ It should:
#. Use a hidden workspace for the temporary loaded workspaces, and clean
up after itself.
Usage
-----
**Example:**
.. testcode:: Exlogtable
def print_table_workspace(wsOut):
for i in range(wsOut.columnCount()):
print wsOut.getColumnNames()[i],
print
for rowIndex in range(wsOut.columnCount()):
for i in range(wsOut.columnCount()):
print wsOut.column(i)[rowIndex],
print
wsComment = LoadLogPropertyTable(FirstFile = "MUSR00015189.nxs",
LastFile = "MUSR00015193.nxs", LogNames="comment")
print "The comments of all the files"
print_table_workspace(wsComment)
wsMultiple = LoadLogPropertyTable(FirstFile = "MUSR00015189.nxs",
LastFile = "MUSR00015193.nxs", LogNames="Temp_Sample,dur")
print "\nThe Temp_Sample and dur logs"
print_table_workspace(wsMultiple)
Output:
.. testoutput:: Exlogtable
The comments of all the files
RunNumber comment
15189 18.95MHz 100W
15190 18.95MHz 100W
The Temp_Sample and dur logs
RunNumber Temp_Sample dur
15189 0.0 100
15190 0.0 100
15191 0.0 101
.. categories::
......@@ -12,34 +12,41 @@ Description
The SPB struct within an ISIS raw file defines 4 fields that describe
the basic geometry of the sample:
- e\_geom;
- e\_thick;
- e\_height;
- e\_width.
- e_geom;
- e_thick;
- e_height;
- e_width.
The meaning of the last three are dependent on the flag value *e\_geom*,
The meaning of the last three are dependent on the flag value *e_geom*,
which defines the sample shape as one of 4 basic shapes:
- 1 = cylinder: radius = e\_thick = e\_width, height = e\_height;
- 1 = cylinder: radius = e_thick = e_width, height = e_height;
- 2 = flat plate: as named;
- 3 = disc: radius = e\_width, thickness = e\_thick;
- 3 = disc: radius = e_width, thickness = e_thick;
- 4 = single crystal.
The values are stored on the
`sample <http://doxygen.mantidproject.org/classMantid_1_1API_1_1Sample.html#a07df5ce7be639c3cb67f33f5e1c7493f>`__
object.
The values are stored on the sample object within the workspace.
Access in Python
----------------
Usage
-----
To access these values in Python:
**Example:**
| ``sampleInfo = wksp.getSampleInfo()``
| ``print sampleInfo.getGeometryFlag()``
| ``print sampleInfo.getThickness()``
| ``print sampleInfo.getHeight()``
| ``print sampleInfo.getWidth()``
.. testcode:: ExLoadDetails
where wksp is a handle to a Mantid workspace.
filename = "HRP39180.RAW"
ws = Load(filename)
LoadSampleDetailsFromRaw(ws,filename)
s = ws.sample()
print "Geometry flag %.0f" % s.getGeometryFlag()
print "Dimensions H,W,D %.0f,%.0f,%.0f" % (s.getHeight(),s.getWidth(),s.getThickness())
Output:
.. testoutput:: ExLoadDetails
Geometry flag 2
Dimensions H,W,D 20,15,11
.. categories::
......@@ -14,4 +14,25 @@ PeaksWorkspace. Peaks could come from ISAW diamond stripping routine for
SNAP data. Only works on Workspaces and for instruments with
RectangularDetector's.
Usage
-----
**Example:**
.. comment::
To usage test this properly you need a matching dataset and peaks workspace,
the unit tests do this, but that functionality is not available in algorithms.
You could load files, but the basic data would be too big to download sensisbly.
Therefore this is an untested code block just showing usage
.. code:: python
#the files for this example are not available for download
#This is to illustrate usage only
ws = Load("TOPAZ_3007.nxs")
wsPeaks=LoadIsawPeaks("TOPAZ_3007.peaks")
#This will mask out the data in the event workspace relating to the peaks
MaskPeaksWorkspace(ws,wsPeaks)
.. categories::
......@@ -41,4 +41,47 @@ defined because detector, source & sample position are needed.
At a minimum, the input workspace must have a sample shape defined.
Usage
-----
**Example: A simple spherical sample**
.. testcode:: ExMonteSimpleSample
#setup the sample shape
sphere = '''<sphere id="sample-sphere">
<centre x="0" y="0" z="0"/>
<radius val="0.1" />
</sphere>'''
ws = CreateSampleWorkspace("Histogram",NumBanks=1)
ws = ConvertUnits(ws,"Wavelength")
CreateSampleShape(ws,sphere)
SetSampleMaterial(ws,ChemicalFormula="V")
#Note: this is a quick and dirty evaluation, in reality you would need more than 300 events per point
wsOut = MonteCarloAbsorption(ws,EventsPerPoint=300)
print "The created workspace has one entry for each spectra: %i" % ws.getNumberHistograms()
print "Just divide your data by the correction to correct for absorption."
Output:
.. testoutput:: ExMonteSimpleSample
The created workspace has one entry for each spectra: 100
Just divide your data by the correction to correct for absorption.
**Example: A simple spherical sample in a cylindrical container**
.. Ticket 9644 is in place to improve the python exports and expand this example
.. code:: python
# The algorithm does allow you to set a complex sample environment
# of different materials and shapes, but some of the required methods
# are not exported to python yet. This will come.
.. categories::
......@@ -23,4 +23,30 @@ This correction is applied to a copy of the input workpace and put into
output workspace. If the input and output workspaces have the same name,
the operation is applied to the workspace of that name.
Usage
-----
**Example:**
.. testcode:: ExOneMinusExp
ws=CreateWorkspace([1,2,3],[1,1,1])
print "You can divide the data by the factor"
wsOut=OneMinusExponentialCor(ws,2,3,"Divide")
print wsOut.readY(0)
print "Or multiply"
wsOut=OneMinusExponentialCor(ws,2,3,"Multiply")
print wsOut.readY(0)
Output:
.. testoutput:: ExOneMinusExp
You can divide the data by the factor
[ 0.38550588 0.33955245 0.33416164]
Or multiply
[ 2.59399415 2.94505308 2.99256374]
.. categories::
......@@ -13,28 +13,28 @@ This algorithm basically optimizes h,k, and l offsets from an integer by
varying the parameters sample positions, sample orientations ( chi,phi,
and omega), and/or the tilt of the goniometer for an experiment.
-If the crystal orientation matrix, UB, was created from one run, that
If the crystal orientation matrix, UB, was created from one run, that
run may not need to have its goniometer settings optimized. There is a
property to list the run numbers to NOT have their goniometer settings
changed. This entry is IGNORED if the tilt or sample positions are
included in the optimization. In this case NONE of the goniometer
angles, relative to any tilt, will be changed.
-The goniometer angles displayed are relative to the tilt,i,e, phi is
The goniometer angles displayed are relative to the tilt,i,e, phi is
the rotation around the axis perpendicular to the tilted plane. The
resultant PeaksWorkspace has the goniometer angles relative to the Y and
Z axes at that time.
-The crystal orientation matrix, UB, from the PeaksWorkspace should
The crystal orientation matrix, UB, from the PeaksWorkspace should
index all the runs "very well". Otherwise iterations that slowly build a
UB with corrected sample orientations may be needed.
-The parameters for the tilt are GonRotx, GonRoty, and GonRotz in
The parameters for the tilt are GonRotx, GonRoty, and GonRotz in
degrees. The usage for this information is as follows:
`` rotate('x',GonRotx)*rotate('y',GonRoty)*rotate('z',GonRotz)* SampleOrientation( i.e. omegaRot*chiRot*phiRot)).``
-Note: To optimize by the tilt in the goniometer and then by the angles
Note: To optimize by the tilt in the goniometer and then by the angles
or by the sample position, it is possible to run with one optimization,
then using the resultant PeaksWorkspace for input, run another
optimization.
......@@ -44,4 +44,23 @@ the first guess is very close, the optimize algorithm does try cases far
away and may not get back to the best value. Check the chisquared
values. If they increase, that optimization should probably not be used.
Usage
-----
**Example:**
.. testcode:: ExOptimizeCrystalPlacement
ws=LoadIsawPeaks("TOPAZ_3007.peaks")
LoadIsawUB(ws,"ls5637.mat")
wsd = OptimizeCrystalPlacement(ws)
(wsPeakOut,fitInfoTable,chi2overDoF,nPeaks,nParams,nIndexed,covrianceInfoTable) = OptimizeCrystalPlacement(ws)
print "Chi2: %.4f" % chi2overDoF
Output:
.. testoutput:: ExOptimizeCrystalPlacement
Chi2: 0.0203
.. categories::
......@@ -20,4 +20,34 @@ calculate a sequence of approximations for each parameter, with delta
ranging over 10 orders of magnitude and keep the value in the sequence
with the smallest relative change.
Usage
-----
**Example:**
.. testcode:: ExOptimizeForCellType
ws=LoadIsawPeaks("TOPAZ_3007.peaks")
FindUBUsingFFT(ws,MinD=8.0,MaxD=13.0)
print "Before Optimization:"
print ws.sample().getOrientedLattice().getUB()
OptimizeLatticeForCellType(ws,CellType="Monoclinic ( a unique )")
print "\nAfter Optimization:"
print ws.sample().getOrientedLattice().getUB()
Output:
.. testoutput:: ExOptimizeForCellType
Before Optimization:
[[ 0.01223576 0.00480107 0.08604016]
[-0.11654506 0.00178069 -0.00458823]
[-0.02737294 -0.08973552 -0.02525994]]
After Optimization:
[[-0.04772517 0.04134355 -0.00058175]
[-0.0055954 -0.00905383 0.12507404]
[ 0.06103109 0.03149982 0.01101201]]
.. categories::
......@@ -21,17 +21,23 @@ The input PeaksWorkspace must contain an orientation matrix and have
been INDEXED by THIS MATRIX when the new peaks are not created from a
range of h ,k, and l values
Example usage
#############
from mantidsimple import \* PeaksWrkSpace=mtd["PeaksQa"]
Usage
-----
#. Can be created via PredictPeaks( then do NOT use next line)
**Example:**
FindUBUsingFFT(PeaksWrkSpace,3,15,.12) IndexPeaks(PeaksWrkSpace,.12,1)
PredictFractionalPeaks(PeaksWrkSpace,"FracPeaks","-.5,0,.5","-.5,.5","0")
.. This test is not run at the moment as it creates an exception in python. Ticket 9642 is in place to fix this and reinstate the test
#. NOTE: There are editing options on PeaksWorkspaces, like combining 2
PeaksWorkspaces.
.. code:: Python
ws=LoadIsawPeaks("TOPAZ_3007.peaks")
LoadIsawUB(ws,"ls5637.mat")
IndexPeaks(ws)
PredictFractionalPeaks(ws,FracPeaks='wsPeaksOut',HOffset=[-0.5,0,0.5],KOffset=0,LOffset=0.2)
.. categories::
.. algorithm::
.. summary::
.. alias::
.. properties::
Description
-----------
.. categories::
......@@ -27,4 +27,28 @@ Description
- The values between the average regions are replaced with the
interpolated linear background drawn as a straight line.
Usage
-----
.. include:: ../usagedata-note.txt
**Example:**
.. testcode:: ExStripPeak
ws = Load("PG3_733.nxs")
wsOut = StripVanadiumPeaks(ws,WorkspaceIndex=2,PeakWidthPercent=3,Version=1)
i = 1529
print "This peak at %.4f Angstroms has been reduced from %.0f to a background level of %.0f" % (wsOut.readX(2)[i],ws.readY(2)[i], wsOut.readY(2)[i])
Output:
.. testoutput:: ExStripPeak
This peak at 0.8116 Angstroms has been reduced from 11569 to a background level of 10869
.. categories::
......@@ -19,4 +19,26 @@ Description
- The vanadium peaks are fit to a function combined from Gaussian and
linear/quadratic background.
Usage
-----
.. include:: ../usagedata-note.txt
**Example:**
.. testcode:: ExStripPeak
ws = Load("PG3_733.nxs")
wsOut = StripVanadiumPeaks(ws,BackgroundType="Linear",WorkspaceIndex=2)
i = 1529
print "This peak at %.4f Angstroms has been reduced from %.0f to a background level of %.0f" % (wsOut.readX(2)[i],ws.readY(2)[i], wsOut.readY(2)[i])
Output:
.. testoutput:: ExStripPeak
This peak at 0.8116 Angstroms has been reduced from 11569 to a background level of 10771
.. categories::
......@@ -16,4 +16,26 @@ microseconds before the neutrons arrive at the sample, and TibMin is
pulse is in this interval, or it goes below the TOF frame minimum, or it
can be reduced to 2400 microseconds.
Usage
-----
**Example:**
.. testcode:: ExSuggestTibCNCS
incidentEnergy = 3
(tibMin,tibMax) = SuggestTibCNCS(incidentEnergy)
print "Incident Energy = %i, tibMin = %.2f, tibMax = %.2f" % (incidentEnergy,tibMin,tibMax)
incidentEnergy = 1
(tibMin,tibMax) = SuggestTibCNCS(incidentEnergy)
print "Incident Energy = %i, tibMin = %.2f, tibMax = %.2f" % (incidentEnergy,tibMin,tibMax)
Output:
.. testoutput:: ExSuggestTibCNCS
Incident Energy = 3, tibMin = 44914.92, tibMax = 47314.92
Incident Energy = 1, tibMin = 95621.15, tibMax = 99021.15
.. categories::
......@@ -12,4 +12,26 @@ Description
Suggest possible time independent background range for HYSPEC. It works
for incident energy range from 3 to 100 meV.
Usage
-----
**Example:**
.. testcode:: ExSuggestTibHYSPEC
incidentEnergy = 5
(tibMin,tibMax) = SuggestTibHYSPEC(incidentEnergy)
print "Incident Energy = %i, tibMin = %.2f, tibMax = %.2f" % (incidentEnergy,tibMin,tibMax)
incidentEnergy = 40
(tibMin,tibMax) = SuggestTibHYSPEC(incidentEnergy)
print "Incident Energy = %i, tibMin = %.2f, tibMax = %.2f" % (incidentEnergy,tibMin,tibMax)
Output:
.. testoutput:: ExSuggestTibHYSPEC
Incident Energy = 5, tibMin = 39515.88, tibMax = 41515.88
Incident Energy = 40, tibMin = 11898.11, tibMax = 13898.11
.. categories::
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment