Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/7824_seek_centre'
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Sep 27, 2013
2 parents a32892a + cf3c982 commit 212816a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3154,12 +3154,60 @@ p, li { white-space: pre-wrap; }
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Tolerance
[um]</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="toleranceLineEdit">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>1.251</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand Down
21 changes: 19 additions & 2 deletions Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2502,13 +2502,30 @@ void SANSRunWindow::handleRunFindCentre()

if( m_uiForm.beamstart_box->currentIndex() == 0 )
{
py_code += "xstart = None, ystart = None)";
py_code += "xstart = None, ystart = None";
}
else
{
py_code += "xstart=float(" + beam_x->text() + ")/1000.,ystart=float(" + beam_y->text() + ")/1000.)";
py_code += "xstart=float(" + beam_x->text() + ")/1000.,ystart=float(" + beam_y->text() + ")/1000.";
}

// define the number of interactions and close the FindBeamCentre method call.
bool ok;
QString tolerance_str(m_uiForm.toleranceLineEdit->text());
double tolerance = tolerance_str.toDouble(&ok);
if (ok)
tolerance *= 1e-4; // transform in um
if ((!ok || tolerance < 0) && ! tolerance_str.isEmpty()){
QString info("You have chosen an invalid value for tolerance. Correct it or leave it blank to use the default value.");
QMessageBox::warning(this, "Wrong Input", info);
m_uiForm.toleranceLineEdit->setFocus(Qt::OtherFocusReason);
setProcessingState(Ready);
return;
}
py_code += ", tolerance=" + QString::number(tolerance) + ")";



g_centreFinderLog.notice("Iteration 1\n");
m_uiForm.beamstart_box->setFocus();

Expand Down
5 changes: 3 additions & 2 deletions Code/Mantid/scripts/SANS/ISISCommandInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def createColetteScript(inputdata, format, reduced, centreit , plotresults, csvf

return script

def FindBeamCentre(rlow, rupp, MaxIter = 10, xstart = None, ystart = None):
def FindBeamCentre(rlow, rupp, MaxIter = 10, xstart = None, ystart = None, tolerance=1.251e-4):
"""
Estimates the location of the effective beam centre given a good initial estimate. For more
information go to this page
Expand All @@ -1024,6 +1024,7 @@ def FindBeamCentre(rlow, rupp, MaxIter = 10, xstart = None, ystart = None):
@param MaxInter: don't calculate more than this number of iterations (default = 10)
@param xstart: initial guess for the horizontal distance of the beam centre from the detector centre in meters (default the values in the mask file)
@param ystart: initial guess for the distance of the beam centre from the detector centre vertically in metres (default the values in the mask file)
@param tolerance: define the precision of the search. If the step is smaller than the tolerance, it will be considered stop searching the centre (default=1.251e-4 or 1.251um)
@return: the best guess for the beam centre point
"""
XSTEP = ReductionSingleton().inst.cen_find_step
Expand Down Expand Up @@ -1094,7 +1095,7 @@ def FindBeamCentre(rlow, rupp, MaxIter = 10, xstart = None, ystart = None):
XSTEP = -XSTEP/2.
if resY > resY_old:
YSTEP = -YSTEP/2.
if abs(XSTEP) < 0.1251/1000. and abs(YSTEP) < 0.1251/1000. :
if abs(XSTEP) < tolerance and abs(YSTEP) < tolerance :
# this is the success criteria, we've close enough to the center
centre.logger.notice("Converged - check if stuck in local minimum!")
break
Expand Down

0 comments on commit 212816a

Please sign in to comment.