Skip to content

Commit

Permalink
Re #4303 Shiny REFL_L UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jan 19, 2012
1 parent 73ed7df commit dd763d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DataSets(BaseScriptElement):
DataPeakDiscreteSelection = 'N/A'
DataBackgroundFlag = False
DataBackgroundRoi = [123, 137,123, 137]
DataTofRange = [9000., 23600.]
DataTofRange = [9600., 21600.]

x_range = [115,210]

Expand All @@ -37,13 +37,8 @@ def to_script(self):
Generate reduction script
@param execute: if true, the script will be executed
"""
script = "# REF_L reduction script\n"
script += "# Script automatically generated on %s\n\n" % time.ctime(time.time())

script += "from MantidFramework import *\n"
script += "mtd.initialise(False)\n"
script += "from mantidsimple import *\n\n"
script += "RefLReduction(RunNumbers=%s,\n" % ','.join([str(i) for i in self.data_files])

script = "RefLReduction(RunNumbers=%s,\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRunNumber=%d,\n" % self.norm_file
script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels)
script += " SignalBackgroundPixelRange=%s,\n" % str(self.DataBackgroundRoi[:2])
Expand All @@ -52,7 +47,7 @@ def to_script(self):
script += " LowResAxisPixelRange=%s,\n" % str(self.x_range)
script += " TOFRange=%s,\n" % str(self.DataTofRange)
script += " Binning=[0,200,200000],\n"
script += " OutputWorkspace=\"Reflectivity\")"
script += " OutputWorkspace='reflectivity_%s')" % str(self.data_files[0])
script += "\n"

return script
Expand All @@ -75,22 +70,22 @@ def to_xml(self):
xml += "<to_peak_pixels>%s</to_peak_pixels>\n" % str(self.DataPeakPixels[1])
xml += "<peak_discrete_selection>%s</peak_discrete_selection>\n" % self.DataPeakDiscreteSelection
xml += "<background_flag>%s</background_flag>\n" % str(self.DataBackgroundFlag)
xml += "<back_roi1_from>%s</back_roi1_from>\n" % self.DataBackgroundRoi[0]
xml += "<back_roi1_to>%s</back_roi1_to>\n" % self.DataBackgroundRoi[1]
xml += "<back_roi2_from>%s</back_roi2_from>\n" % self.DataBackgroundRoi[2]
xml += "<back_roi2_to>%s</back_roi2_to>\n" % self.DataBackgroundRoi[3]
xml += "<back_roi1_from>%s</back_roi1_from>\n" % str(self.DataBackgroundRoi[0])
xml += "<back_roi1_to>%s</back_roi1_to>\n" % str(self.DataBackgroundRoi[1])
xml += "<back_roi2_from>%s</back_roi2_from>\n" % str(self.DataBackgroundRoi[2])
xml += "<back_roi2_to>%s</back_roi2_to>\n" % str(self.DataBackgroundRoi[3])
xml += "<from_tof_range>%s</from_tof_range>\n" % str(self.DataTofRange[0])
xml += "<to_tof_range>%s</to_tof_range>\n" % str(self.DataTofRange[1])
xml += "<data_sets>%s</data_sets>\n" % ','.join([str(i) for i in self.data_files])
xml += "<x_min_pixel>%s</x_min_pixel>\n" % str(self.x_range[0])
xml += "<x_max_pixel>%s</x_max_pixel>\n" % str(self.x_range[1])


xml += "<norm_from_peak_pixels>%s</norm_from_peak_pixels>\n" % self.NormPeakPixels[0]
xml += "<norm_to_peak_pixels>%s</norm_to_peak_pixels>\n" % self.NormPeakPixels[1]
xml += "<norm_background_flag>%s</norm_background_flag>\n" % self.NormBackgroundFlag
xml += "<norm_from_back_pixels>%s</norm_from_back_pixels>\n" % self.NormBackgroundRoi[0]
xml += "<norm_to_back_pixels>%s</norm_to_back_pixels>\n" % self.NormBackgroundRoi[1]
xml += "<norm_from_peak_pixels>%s</norm_from_peak_pixels>\n" % str(self.NormPeakPixels[0])
xml += "<norm_to_peak_pixels>%s</norm_to_peak_pixels>\n" % str(self.NormPeakPixels[1])
xml += "<norm_background_flag>%s</norm_background_flag>\n" % str(self.NormBackgroundFlag)
xml += "<norm_from_back_pixels>%s</norm_from_back_pixels>\n" % str(self.NormBackgroundRoi[0])
xml += "<norm_to_back_pixels>%s</norm_to_back_pixels>\n" % str(self.NormBackgroundRoi[1])
xml += "<norm_dataset>%s</norm_dataset>\n" % str(self.norm_file)
xml += "</Data>\n"

Expand Down Expand Up @@ -126,10 +121,10 @@ def from_xml_element(self, instrument_dom):
self.DataBackgroundFlag = BaseScriptElement.getBoolElement(instrument_dom, "background_flag")

#background from/to pixels
self.DataBackgroundRoi = [BaseScriptElement.getStringElement(instrument_dom, "back_roi1_from"),
BaseScriptElement.getStringElement(instrument_dom, "back_roi1_to"),
BaseScriptElement.getStringElement(instrument_dom, "back_roi2_from"),
BaseScriptElement.getStringElement(instrument_dom, "back_roi2_to")]
self.DataBackgroundRoi = [BaseScriptElement.getIntElement(instrument_dom, "back_roi1_from"),
BaseScriptElement.getIntElement(instrument_dom, "back_roi1_to"),
BaseScriptElement.getIntElement(instrument_dom, "back_roi2_from"),
BaseScriptElement.getIntElement(instrument_dom, "back_roi2_to")]

#from TOF and to TOF
self.DataTofRange = [BaseScriptElement.getFloatElement(instrument_dom, "from_tof_range"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ def set_state(self, state):
@param state: data object
"""
if IS_IN_MANTIDPLOT:
ws_name = "Reflectivity"
ws_name = "reflectivity"
ws_list = [n for n in mtd.keys() if n.startswith(ws_name)]
g = _qti.app.graph(ws_name)
if g is None and mtd.workspaceExists(ws_name):
g = _qti.app.mantidUI.pyPlotSpectraList([ws_name],[0],True)
if g is None and len(ws_list)>0:
g = _qti.app.mantidUI.pyPlotSpectraList(ws_list,[0],True)
g.setName(ws_name)

self._summary.angle_list.clear()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from numpy import zeros, arctan2
from numpy import zeros, arctan2, arange
from mantidsimple import *
import math

Expand Down Expand Up @@ -118,7 +118,7 @@ def createIntegratedWorkspace(mt1, outputWorkspace,
_y_error_axis[y, :] += ((mt1.readE(_index)[:]) * (mt1.readE(_index)[:]))

_y_axis = _y_axis.flatten()
_y_error_axis = sqrt(_y_error_axis)
_y_error_axis = numpy.sqrt(_y_error_axis)
#plot_y_error_axis = _y_error_axis #for output testing only -> plt.imshow(plot_y_error_axis, aspect='auto', origin='lower')
_y_error_axis = _y_error_axis.flatten()

Expand Down Expand Up @@ -234,13 +234,13 @@ def convertToRvsQ(dMD=-1,theta=-1,tof=None):
theta: angle of detector
"""
_const = float(4) * math.pi * m * dMD / h
sz_tof = shape(tof)[0]
sz_tof = numpy.shape(tof)[0]
q_array = zeros(sz_tof-1)
for t in range(sz_tof-1):
tof1 = tof[t]
tof2 = tof[t+1]
tofm = (tof1+tof2)/2.
_Q = _const * sin(theta) / (tofm*1e-6)
_Q = _const * math.sin(theta) / (tofm*1e-6)
q_array[t] = _Q*1e-10

return q_array

0 comments on commit dd763d7

Please sign in to comment.