Skip to content

Commit

Permalink
Re #5042 simplify angle inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Mar 29, 2012
1 parent 6dbaf86 commit a4c2520
Show file tree
Hide file tree
Showing 7 changed files with 6,123 additions and 20 deletions.
14 changes: 10 additions & 4 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/RefReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void RefReduction::init()
declareProperty("TOFMax", EMPTY_DBL());

declareProperty("Theta", EMPTY_DBL());
declareProperty("NBins", 40);
//declareProperty("LogScale", true);
declareProperty("TOFStep", 400.0);
declareProperty("NBins", EMPTY_INT());

declareProperty("ReflectivityPixel", EMPTY_DBL());
declareProperty("DetectorAngle", EMPTY_DBL());
Expand Down Expand Up @@ -430,17 +430,23 @@ IEventWorkspace_sptr RefReduction::loadData(const std::string dataRun,
// Crop TOF as needed and set binning
double tofMin = getProperty("TOFMin");
double tofMax = getProperty("TOFMax");
const int nBins = getProperty("NBins");
if (isEmpty(tofMin) || isEmpty(tofMax))
{
const MantidVec& x = rawWS->readX(0);
if (isEmpty(tofMin)) tofMin = *std::min_element(x.begin(), x.end());
if (isEmpty(tofMax)) tofMax = *std::max_element(x.begin(), x.end());
}

int nBins = getProperty("NBins");
double tofStep = getProperty("TOFStep");
if (!isEmpty(nBins))
tofStep = (tofMax-tofMin)/nBins;
else
nBins = (int)floor( (tofMax-tofMin)/tofStep );

std::vector<double> params;
params.push_back(tofMin);
params.push_back((tofMax-tofMin)/nBins);
params.push_back(tofStep);
params.push_back(tofMax);

IAlgorithm_sptr rebinAlg = createSubAlgorithm("Rebin", 0.25, 0.3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from interface import InstrumentInterface
from reduction_gui.widgets.reflectometer.refl_data_simple import DataReflWidget
from reduction_gui.widgets.reflectometer.refm_reduction import DataReflWidget
try:
from reduction_gui.widgets.reflectometer.stitcher import StitcherWidget
HAS_STITCHER = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DataSets(BaseScriptElement):
DataBackgroundRoi = [115, 137, 123, 137]
DataTofRange = [10700., 24500.]
crop_TOF_range = True
TOFstep = 400.0

data_x_range_flag = False
data_x_range = [115, 210]
Expand All @@ -37,8 +38,7 @@ class DataSets(BaseScriptElement):

# scattering angle
theta = 0.0
center_pixel = 220
use_center_pixel = False
use_center_pixel = True

# Sample log overwrites
set_detector_angle = False
Expand Down Expand Up @@ -86,11 +86,12 @@ def to_script(self, for_automated_reduction=False):
if self.crop_TOF_range:
script += " TOFMin=%s,\n" % str(self.DataTofRange[0])
script += " TOFMax=%s,\n" % str(self.DataTofRange[1])
script += " NBins=%s,\n" % str(self.q_bins)
script += " TOFStep=%s,\n" % str(self.TOFstep)
else:
script += " NBins=%s,\n" % str(self.q_bins)

# Scattering angle options
if self.use_center_pixel:
script += " ReflectivityPixel=%s,\n" % str(self.center_pixel)
if self.set_detector_angle:
script += " DetectorAngle=%s\n" % str(self.detector_angle)
if self.set_detector_angle_offset:
Expand Down Expand Up @@ -155,8 +156,6 @@ def _automated_reduction(self):
if self.norm_x_range_flag:
script += " LowResNormAxisPixelRange=%s,\n" % str(self.norm_x_range)

script += " ReflectivityPixel=ref_pixel,\n"

# The output should be slightly different if we are generating
# a script for the automated reduction
script += " OutputWorkspacePrefix='reflectivity_'+%s)\n" % str(self.data_files[0])
Expand Down Expand Up @@ -184,6 +183,7 @@ def to_xml(self):
xml += "<crop_tof>%s</crop_tof>\n" % str(self.crop_TOF_range)
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 += "<tof_step>%s</tof_step>\n" % str(self.TOFstep)
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.data_x_range[0])
xml += "<x_max_pixel>%s</x_max_pixel>\n" % str(self.data_x_range[1])
Expand All @@ -209,7 +209,6 @@ def to_xml(self):

# Scattering angle
xml += "<theta>%s</theta>\n" % str(self.theta)
xml += "<center_pixel>%s</center_pixel>\n" % str(self.center_pixel)
xml += "<use_center_pixel>%s</use_center_pixel>\n" % str(self.use_center_pixel)

# Sample log overwrites
Expand Down Expand Up @@ -272,11 +271,13 @@ def from_xml_element(self, instrument_dom):
BaseScriptElement.getIntElement(instrument_dom, "back_roi2_to")]

#from TOF and to TOF
self.crop_TOF_range = BaseScriptElement.getBoolElement(instrument_dom, "crop_tof",
default=DataSets.crop_TOF_range)
#self.crop_TOF_range = BaseScriptElement.getBoolElement(instrument_dom, "crop_tof",
# default=DataSets.crop_TOF_range)
self.DataTofRange = [BaseScriptElement.getFloatElement(instrument_dom, "from_tof_range"),
BaseScriptElement.getFloatElement(instrument_dom, "to_tof_range")]

self.TOFstep = BaseScriptElement.getFloatElement(instrument_dom, "tof_step",
default = DataSets.TOFstep)

self.data_files = BaseScriptElement.getIntList(instrument_dom, "data_sets")

#with or without norm
Expand Down Expand Up @@ -306,10 +307,9 @@ def from_xml_element(self, instrument_dom):

# scattering angle
self.theta = BaseScriptElement.getFloatElement(instrument_dom, "theta", default=DataSets.theta)
self.center_pixel = BaseScriptElement.getFloatElement(instrument_dom, "center_pixel", default=DataSets.center_pixel)
self.use_center_pixel = BaseScriptElement.getBoolElement(instrument_dom,
"use_center_pixel",
default=DataSets.use_center_pixel)
#self.use_center_pixel = BaseScriptElement.getBoolElement(instrument_dom,
# "use_center_pixel",
# default=DataSets.use_center_pixel)

# Sample log overwrites
self.set_detector_angle = BaseScriptElement.getBoolElement(instrument_dom,
Expand Down Expand Up @@ -343,6 +343,7 @@ def reset(self):
self.DataBackgroundRoi = DataSets.DataBackgroundRoi
self.DataPeakPixels = DataSets.DataPeakPixels
self.DataTofRange = DataSets.DataTofRange
self.TOFstep = DataSets.TOFstep
self.crop_TOF_range = DataSets.crop_TOF_range
self.data_files = DataSets.data_files

Expand All @@ -364,7 +365,6 @@ def reset(self):

# Scattering angle
self.theta = DataSets.theta
self.center_pixel = DataSets.center_pixel
self.use_center_pixel = DataSets.use_center_pixel

# Sample log overwrites
Expand Down

0 comments on commit a4c2520

Please sign in to comment.