-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #705 from mantidproject/vision-load-detector-pars
Python algorithm to load VISION detector parameters
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Code/Mantid/Framework/PythonInterface/plugins/algorithms/VisionLoadDetectorTable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pylint: disable=no-init,invalid-name | ||
from mantid.api import * | ||
from mantid.simpleapi import * | ||
from mantid.kernel import * | ||
import numpy as np | ||
|
||
|
||
class VisionLoadDetectorTable(PythonAlgorithm): | ||
|
||
def category(self): | ||
return "Utility\\Development;PythonAlgorithms" | ||
|
||
def summary(self): | ||
return "Warning - This is under development - Algorithm to load detector parameters for VISION." | ||
|
||
def PyInit(self): | ||
self.declareProperty(WorkspaceProperty("OutputWorkspace", "", Direction.Output), | ||
doc="Name of Output Workspace") | ||
|
||
self.declareProperty(FileProperty("DetectorFile", "", action=FileAction.Load, extensions=['csv']), | ||
doc="Name of detector file to load.") | ||
|
||
def PyExec(self): | ||
filename = self.getPropertyValue("DetectorFile") | ||
output_ws_name = self.getPropertyValue("OutputWorkspace") | ||
|
||
# Open File and read parameters | ||
spectra,l1,l2,twotheta,efixed,emode = np.genfromtxt(filename, delimiter=',', unpack=True) | ||
|
||
# Setup the output table | ||
output_workspace = CreateEmptyTableWorkspace(OutputWorkspace=output_ws_name) | ||
output_workspace.addColumn("int", "spectra") | ||
output_workspace.addColumn("double", "l1") | ||
output_workspace.addColumn("double", "l2") | ||
output_workspace.addColumn("double", "twotheta") | ||
output_workspace.addColumn("double", "efixed") | ||
output_workspace.addColumn("int", "emode") | ||
|
||
# Write the values | ||
for i in range(len(spectra)): | ||
output_workspace.addRow([int(spectra[i]),float(l1[i]),float(l2[i]), | ||
float(twotheta[i]),float(efixed[i]),int(emode[i])]) | ||
|
||
# Set the output workspace | ||
self.setProperty("OutputWorkspace", output_workspace) | ||
|
||
AlgorithmFactory.subscribe(VisionLoadDetectorTable) |
21 changes: 21 additions & 0 deletions
21
Code/Mantid/docs/source/algorithms/VisionLoadDetectorTable-v1.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.. algorithm:: | ||
|
||
.. summary:: | ||
|
||
.. alias:: | ||
|
||
.. properties:: | ||
|
||
Description | ||
----------- | ||
|
||
This algorithm is used to load the detector parameters for VISION | ||
from a CSV file into a TableWorkspace. | ||
|
||
.. Note:: | ||
|
||
Do not use this algortithm, it is just for VISION commissioning | ||
|
||
|
||
.. categories:: | ||
|