Skip to content

Commit

Permalink
Refs #8792. Adding mask file saving and some docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Jan 31, 2014
1 parent 42d899b commit 4f8a6c2
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -9,6 +9,7 @@
import mantid.simpleapi as msapi
import mantid.api as api
import mantid.kernel as kernel
from mantid import config

import os

Expand Down Expand Up @@ -36,6 +37,9 @@ def name(self):
return "ConvertSnsRoiFileToMask"

def PyInit(self):
"""
Set the algorithm properties.
"""
self.declareProperty(api.FileProperty(name="SnsRoiFile",
defaultValue="",
action=api.FileAction.Load,
Expand All @@ -45,10 +49,23 @@ def PyInit(self):
self.declareProperty("Instrument", "",
validator=allowedInstruments,
doc="One of the following instruments: "+" ".join(INSTRUMENTS))
self.declareProperty("OutputFilePrefix", "",
"Overrides the default filename for the output "\
+"file (Optional). Default is <inst_name>_Mask.")
self.declareProperty(api.FileProperty(name="OutputDirectory",
defaultValue=config['defaultsave.directory'],
action=api.FileAction.Directory),
"Directory to save mask file."\
+" Default is current Mantid save directory.")

def PyExec(self):
"""
Execute the algorithm.
"""
self._roiFile = self.getProperty("SnsRoiFile").value
self._instName = self.getProperty("Instrument").value
self._filePrefix = self.getProperty("OutputFilePrefix").value
self._outputDir = self.getProperty("OutputDirectory").value

# Read in ROI file
roi_file = open(self._roiFile)
Expand Down Expand Up @@ -85,6 +102,13 @@ def PyExec(self):
# Clean up temporary file
os.remove(temp_file)

# Save mask to a file
if self._filePrefix == "":
self._filePrefix = self._instName + "_Mask"

output_file = os.path.join(self._outputDir, self._filePrefix)
msapi.SaveMask(mask_ws, OutputFile=output_file+".xml")

def __get_id(self, idx):
"""
Convert the old bankN_x_y pixel ID into a Mantid index.
Expand Down

0 comments on commit 4f8a6c2

Please sign in to comment.