Skip to content

Commit

Permalink
Merge pull request #705 from mantidproject/vision-load-detector-pars
Browse files Browse the repository at this point in the history
Python algorithm to load VISION detector parameters
  • Loading branch information
AndreiSavici committed May 6, 2015
2 parents 22a7def + 51dcd63 commit 3c49726
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
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 Code/Mantid/docs/source/algorithms/VisionLoadDetectorTable-v1.rst
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::

0 comments on commit 3c49726

Please sign in to comment.