Large diffs are not rendered by default.

@@ -1875,19 +1875,27 @@ void MuonAnalysis::createPlotWS(const std::string& groupName, const std::string&
}

// rebin data if option set in Plot Options
if (m_uiForm.rebinComboBox->currentText() == "Fixed")
if (m_uiForm.rebinComboBox->currentIndex() != 0)
{
try
{
Mantid::API::MatrixWorkspace_sptr tempWs = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(Mantid::API::AnalysisDataService::Instance().retrieve(wsname));
std::string rebinParams("");
double binSize = tempWs->dataX(0)[1]-tempWs->dataX(0)[0];
double bunchedBinSize = binSize*m_uiForm.optionStepSizeText->text().toDouble();

if(m_uiForm.rebinComboBox->currentIndex() == 1) // Fixed
{
double bunchedBinSize = binSize*m_uiForm.optionStepSizeText->text().toDouble();
rebinParams = boost::lexical_cast<std::string>(bunchedBinSize);
}
else // Variable
{
rebinParams = m_uiForm.binBoundaries->text().toStdString();
}
// bunch data
Mantid::API::IAlgorithm_sptr rebinAlg = Mantid::API::AlgorithmManager::Instance().create("Rebin");
rebinAlg->setPropertyValue("InputWorkspace", wsname);
rebinAlg->setPropertyValue("OutputWorkspace", wsname);
rebinAlg->setPropertyValue("Params", boost::lexical_cast<std::string>(bunchedBinSize));
rebinAlg->setPropertyValue("Params", rebinParams);
rebinAlg->execute();

// however muon group don't want last bin if shorter than previous bins
@@ -2977,8 +2985,9 @@ void MuonAnalysis::loadAutoSavedValues(const QString& group)
// Load Plot Binning Options
QSettings prevPlotBinning;
prevPlotBinning.beginGroup(group + "BinningOptions");
int constStepSize = prevPlotBinning.value("constStepSize", 1).toInt();
m_uiForm.optionStepSizeText->setText(QString::number(constStepSize));
int rebinFixed = prevPlotBinning.value("rebinFixed", 1).toInt();
m_uiForm.optionStepSizeText->setText(QString::number(rebinFixed));
m_uiForm.binBoundaries->setText(prevPlotBinning.value("rebinVariable", 1).toCString());

int rebinComboBoxIndex = prevPlotBinning.value("rebinComboBoxIndex", 0).toInt();
m_uiForm.rebinComboBox->setCurrentIndex(rebinComboBoxIndex);
@@ -71,6 +71,8 @@ void MuonAnalysisOptionTab::initLayout()
SLOT(runRebinComboBox(int)));
connect(m_uiForm.optionStepSizeText, SIGNAL(lostFocus()), this,
SLOT(runOptionStepSizeText()));
connect(m_uiForm.binBoundaries, SIGNAL(lostFocus()), this,
SLOT(runBinBoundaries()));

////////////// Auto Update /////////////////
connect(m_uiForm.connectPlotType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(settingsTabUpdatePlot()));
@@ -86,6 +88,7 @@ void MuonAnalysisOptionTab::initLayout()
connect(m_uiForm.yAxisMinimumInput, SIGNAL(returnPressed ()), this, SLOT(validateYMin()));
connect(m_uiForm.yAxisMaximumInput, SIGNAL(returnPressed ()), this, SLOT(validateYMax()));
connect(m_uiForm.optionStepSizeText, SIGNAL(returnPressed ()), this, SIGNAL(settingsTabUpdatePlot()));
connect(m_uiForm.binBoundaries, SIGNAL(returnPressed ()), this, SIGNAL(settingsTabUpdatePlot()));
connect(m_uiForm.rebinComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(settingsTabUpdatePlot()));
connect(m_uiForm.showErrorBars, SIGNAL(clicked()), this, SIGNAL(settingsTabUpdatePlot()));
connect(m_uiForm.yAxisAutoscale, SIGNAL(clicked()), this, SIGNAL(settingsTabUpdatePlot()));
@@ -151,6 +154,18 @@ void MuonAnalysisOptionTab::runOptionStepSizeText()
}
}


/**
*
*/
void MuonAnalysisOptionTab::runBinBoundaries()
{
QSettings group;
group.beginGroup(m_settingsGroup + "BinningOptions");
group.setValue("rebinVariable", m_uiForm.binBoundaries->text());
}


////////////// Default Plot Style slots ///////////////

/**
@@ -375,6 +375,9 @@ void SANSRunWindow::connectAnalysDetSignals()
connect(m_uiForm.transFit_ck, SIGNAL(stateChanged(int)), this, SLOT(updateTransInfo(int)));
updateTransInfo(m_uiForm.transFit_ck->state());

connect(m_uiForm.frontDetQrangeOnOff, SIGNAL(stateChanged(int)), this, SLOT(updateFrontDetQrange(int)));
updateFrontDetQrange(m_uiForm.frontDetQrangeOnOff->state());

connect(m_uiForm.enableFlood_ck, SIGNAL(stateChanged(int)), this, SLOT(prepareFlood(int)));

connect(m_uiForm.wavRanges, SIGNAL(editingFinished()),
@@ -738,6 +741,38 @@ bool SANSRunWindow::loadUserFile()
else
m_uiForm.transFitOnOff->setChecked(true);

// The front rescale/shift section
m_uiForm.frontDetRescale->setText(runReduceScriptFunction(
"print i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.scale").trimmed());
m_uiForm.frontDetShift->setText(runReduceScriptFunction(
"print i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.shift").trimmed());

QString fitScale = runReduceScriptFunction("i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.fitScale");
QString fitShift = runReduceScriptFunction("i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.fitShift");

if ( fitScale == "True" )
m_uiForm.frontDetRescaleCB->setChecked(true);
else
m_uiForm.frontDetRescaleCB->setChecked(false);

if ( fitShift == "True" )
m_uiForm.frontDetShiftCB->setChecked(true);
else
m_uiForm.frontDetShiftCB->setChecked(false);

QString qRangeUserSelected = runReduceScriptFunction("i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.qRangeUserSelected");
if ( qRangeUserSelected == "True" )
{
m_uiForm.frontDetQrangeOnOff->setChecked(true);
m_uiForm.frontDetQmin->setText(runReduceScriptFunction(
"print i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.qMin").trimmed());
m_uiForm.frontDetQmin->setText(runReduceScriptFunction(
"print i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.qMax").trimmed());
}
else
m_uiForm.frontDetQrangeOnOff->setChecked(false);


//Monitor spectra
m_uiForm.monitor_spec->setText(runReduceScriptFunction(
"print i.ReductionSingleton().instrument.get_incident_mon()").trimmed());
@@ -1938,6 +1973,22 @@ QString SANSRunWindow::readUserFileGUIChanges(const States type)
exec_reduce += "i.TransFit('Off')\n";
}

// Set the Front detector Rescale and Shift
QString fdArguments = "scale=" + m_uiForm.frontDetRescale->text().trimmed() + ","
+ "shift=" + m_uiForm.frontDetShift->text().trimmed();
if ( m_uiForm.frontDetRescaleCB->isChecked() )
fdArguments += ", fitScale=True";
if ( m_uiForm.frontDetShiftCB->isChecked() )
fdArguments += ", fitShift=True";
if ( m_uiForm.frontDetQrangeOnOff->isChecked() && !m_uiForm.frontDetQmin->text().isEmpty()
&& !m_uiForm.frontDetQmax->text().isEmpty() )
{
fdArguments += ", qMin=" + m_uiForm.frontDetQmin->text().trimmed();
fdArguments += ", qMax=" + m_uiForm.frontDetQmax->text().trimmed();
}

exec_reduce += "i.SetFrontDetRescaleShift(" + fdArguments + ")\n";

//Gravity correction
exec_reduce += "i.Gravity(";
if( m_uiForm.gravity_check->isChecked() )
@@ -2681,6 +2732,26 @@ void SANSRunWindow::clearLogger()
m_uiForm.logging_field->clear();
m_uiForm.tabWidget->setTabText(4, "Logging");
}

/**Respond to the Front detector Q range check box.
* @param state :: equal to Qt::Checked or not
*/
void SANSRunWindow::updateFrontDetQrange(int state)
{
if( state == Qt::Checked )
{
m_uiForm.frontDetQmin->setEnabled(true);
m_uiForm.frontDetQmax->setEnabled(true);
runReduceScriptFunction("i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.qRangeUserSelected=True");
}
else
{
m_uiForm.frontDetQmin->setEnabled(false);
m_uiForm.frontDetQmax->setEnabled(false);
runReduceScriptFunction("i.ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift.qRangeUserSelected=False");
}
}

/**Respond to the "Use default transmission" check box being clicked. If
* the box is checked the transmission fit wavelength maximum and minimum
* boxs with be set to the defaults for the instrument and disabled.
@@ -2709,6 +2780,7 @@ void SANSRunWindow::updateTransInfo(int state)
m_uiForm.trans_max->setText("");
}
}

/** A slot to validate entries for Python lists and tupples
*/
void SANSRunWindow::checkList()
@@ -159,6 +159,21 @@ def Gravity(flag):
_printMessage('Gravity(' + str(flag) + ')')
ReductionSingleton().to_Q.set_gravity(flag)

def SetFrontDetRescaleShift(scale=1.0, shift=0.0, fitScale=False, fitShift=False, qMin=None, qMax=None):
"""
Stores property about the detector which is used to rescale and shift
data in the bank after data have been reduced
@param scale: Default to 1.0. Value to multiply data with
@param shift: Default to 0.0. Value to add to data
@param fitScale: Default is False. Whether or not to try and fit this param
@param fitShift: Default is False. Whether or not to try and fit this param
@param qMin: When set to None (default) then for fitting use the overlapping q region of front and rear detectors
@param qMax: When set to None (default) then for fitting use the overlapping q region of front and rear detectors
"""
ReductionSingleton().instrument.getDetector('FRONT').rescaleAndShift = ReductionSingleton().instrument.getDetector('FRONT')._RescaleAndShift(
scale, shift, fitScale, fitShift, qMin, qMax)
_printMessage('#Set front detector rescale/shift values')

def TransFit(mode,lambdamin=None,lambdamax=None):
"""
Sets the fit method to calculate the transmission fit and the wavelength range
@@ -53,57 +53,82 @@ class _RescaleAndShift:
collected on front and rear bank on the same 'level' before e.g. merging
such data
"""
def __init__(self, scale=1.0, shift=0.0, fitScale = False, fitShift = False, qMin = None, qMax = None):
def __init__(self, scale=1.0, shift=0.0, fitScale=False, fitShift=False, qMin=None, qMax=None):
"""
@param scale: Default to 1.0. Value to multiply data with
@param shift: Default to 0.0. Value to add to data
@param fitScale: Default is False. Whether or not to try and fit this param
@param fitShift: Default is False. Whether or not to try and fit this param
@param qMin: When set to None (default) then for fit use min value of the overlapping q range of front and rear
@param qMax: When set to None (default) then for fit use max value of the overlapping q range of front and rear
@param qMin: When set to None (default) then for fitting use the overlapping q region of front and rear detectors
@param qMax: When set to None (default) then for fitting use the overlapping q region of front and rear detectors
"""
self._scale = scale
self.scale = scale
self._shift = shift
self._fitScale = bool(fitScale)
self._fitShift = bool(fitShift)
self._qMin = qMin
self._qMax = qMax

if self._qMin == None or self._qMax == None:
self._qRangeUserSelected = False
else:
self._qRangeUserSelected = True

def get_scale(self):
return self._scale

def set_scale(self, scale):
self._scale = scale
def set_scale(self, val):
self._scale = val

scale = property(get_scale, set_scale, None, None)

def get_shift(self):
return self._shift

def set_shift(self, shift):
self._shift = shift
def set_shift(self, val):
self._shift = val

shift = property(get_shift, set_shift, None, None)

def get_qRangeUserSelected(self):
return self._qRangeUserSelected

def set_qRangeUserSelected(self, val):
self._qRangeUserSelected = bool(val)

qRangeUserSelected = property(get_qRangeUserSelected, set_qRangeUserSelected, None, None)

def get_fitScale(self):
return self._fitScale

def set_fitScale(self, fitScale):
self._fitScale = bool(fitScale)
def set_fitScale(self, val):
self._fitScale = bool(val)

fitScale = property(get_fitScale, set_fitScale, None, None)

def get_fitShift(self):
return self._fitShift

def set_fitShift(self, fitShift):
self._fitShift = bool(fitShift)
def set_fitShift(self, val):
self._fitShift = bool(val)

fitShift = property(get_fitShift, set_fitShift, None, None)

def get_qMin(self):
return self._qMin

def set_qMin(self, qMin):
self._qMin = qMin
def set_qMin(self, val):
self._qMin = val

qMin = property(get_qMin, set_qMin, None, None)

def get_qMax(self):
return self._qMax

def set_qMax(self, qMax):
self._qMax = qMax
def set_qMax(self, val):
self._qMax = val

qMax = property(get_qMax, set_qMax, None, None)

def __init__(self, instr, det_type):
#detectors are known by many names, the 'uni' name is an instrument independent alias the 'long' name is the instrument view name and 'short' name often used for convenience
@@ -162,7 +187,7 @@ def __init__(self, instr, det_type):
self._side_corr =0.0

# hold rescale and shift object _RescaleAndShift
self._rescaleAndShift = self._RescaleAndShift()
self.rescaleAndShift = self._RescaleAndShift()

#in the empty instrument detectors are laid out as below on loading a run the orientation becomes run dependent
self._orientation = 'HorizontalFlipped'
@@ -177,9 +202,6 @@ def disable_y_and_rot_corrs(self):
self._radius_corr = None
self._side_corr = None

def get_rescaleAndShift(self):
return self._rescaleAndShift

def get_y_corr(self):
if not self._y_corr is None:
return self._y_corr
@@ -1933,6 +1933,7 @@ def _readFrontRescaleShiftSetup(self, details, reducer):
"""
values = details.split()
rAnds = reducer.instrument.getDetector('FRONT').rescaleAndShift
rAnds.qRangeUserSelected = False
if details.startwith('RESCALE'):
if 'FIT' in details:
if len(values) == 1:
@@ -1941,6 +1942,7 @@ def _readFrontRescaleShiftSetup(self, details, reducer):
rAnds.fitRescale = True
rAnds.qMin = float(values[1])
rAnds.qMax = float(values[2])
rAnds.qRangeUserSelected = True
else:
_issueWarning("Command: \"DET/" + details + "\" not valid. Expected format is /DET/RESCALE/FIT [q1 q2]")
else:
@@ -1956,6 +1958,7 @@ def _readFrontRescaleShiftSetup(self, details, reducer):
rAnds.fitShift = True
rAnds.qMin = float(values[1])
rAnds.qMax = float(values[2])
rAnds.qRangeUserSelected = True
else:
_issueWarning("Command: \"DET/" + details + "\" not valid. Expected format is /DET/SHIFT/FIT [q1 q2]")
else: