Skip to content

Commit

Permalink
Remove Verbose options from scripts
Browse files Browse the repository at this point in the history
Refs #10850
  • Loading branch information
DanNixon committed Jan 20, 2015
1 parent fcbd61e commit 4bfe073
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 406 deletions.
Expand Up @@ -191,7 +191,7 @@ def _fury(self):
from IndirectCommon import CheckHistZero, CheckHistSame, CheckAnalysers

# Process resolution data
CheckAnalysers(self._sample, self._resolution, True)
CheckAnalysers(self._sample, self._resolution)
num_res_hist = CheckHistZero(self._resolution)[0]
if num_res_hist > 1:
CheckHistSame(self._sample, 'Sample', self._resolution, 'Resolution')
Expand Down
Expand Up @@ -475,7 +475,7 @@ def _ascii_import(self, data, name):
refl = '4'

InstrParas(self._out_ws, instr, ana, refl)
efixed = RunParas(self._out_ws, instr, name, name, True)
efixed = RunParas(self._out_ws, instr, name, name)
logger.information('Qmax = ' + str(Qmax) + ' ; efixed = ' + str(efixed))
pi4 = 4.0 * math.pi
wave = 1.8 * math.sqrt(25.2429 / efixed)
Expand All @@ -485,7 +485,7 @@ def _ascii_import(self, data, name):
ang = 2.0 * math.degrees(math.asin(qw))
theta.append(ang)

ChangeAngles(self._out_ws, instr, theta, True)
ChangeAngles(self._out_ws, instr, theta)


def _create_res_ws(self, num_sample_hist):
Expand Down
20 changes: 9 additions & 11 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ApplyCorr.cpp
Expand Up @@ -17,7 +17,7 @@ namespace CustomInterfaces
{
namespace IDA
{
ApplyCorr::ApplyCorr(QWidget * parent) :
ApplyCorr::ApplyCorr(QWidget * parent) :
IDATab(parent)
{
}
Expand Down Expand Up @@ -187,22 +187,20 @@ namespace IDA
return;
}
}

QString ScalingFactor = "1.0\n";
QString ScaleOrNot = "False\n";

pyInput += uiForm().abscor_ckScaleMultiplier->isChecked() ? "True\n" : "False\n";

if ( uiForm().abscor_ckScaleMultiplier->isChecked() )
{
ScalingFactor = uiForm().abscor_leScaleMultiplier->text();
ScalingFactor = uiForm().abscor_leScaleMultiplier->text();
ScaleOrNot = "True\n";
}

pyInput += "scale = " + ScaleOrNot + "\n";
pyInput += "scaleFactor = " + ScalingFactor + "\n";

pyInput += "verbose = True\n";
pyInput += "scaleFactor = " + ScalingFactor + "\n";

if ( uiForm().abscor_ckSave->isChecked() ) pyInput += "save = True\n";
else pyInput += "save = False\n";
Expand All @@ -220,9 +218,9 @@ namespace IDA
{
plotResult = "Both";
}

pyInput += "plotResult = '" + plotResult + "'\n";
pyInput += "print abscorFeeder(sample, container, geom, useCor, corrections, Verbose=verbose, RebinCan=rebin_can, ScaleOrNotToScale=scale, factor=scaleFactor, Save=save, PlotResult=plotResult)\n";
pyInput += "print abscorFeeder(sample, container, geom, useCor, corrections, RebinCan=rebin_can, ScaleOrNotToScale=scale, factor=scaleFactor, Save=save, PlotResult=plotResult)\n";

QString pyOutput = runPythonCode(pyInput).trimmed();

Expand All @@ -241,7 +239,7 @@ namespace IDA
{
QString message = "The sample and can energy ranges do not match, this is not recommended."
"\n\n Click OK to rebin the can to match the sample and continue or Cancel to abort applying corrections.";
QMessageBox::StandardButton reply = QMessageBox::warning(m_parentWidget, "Energy Ranges Do Not Match",
QMessageBox::StandardButton reply = QMessageBox::warning(m_parentWidget, "Energy Ranges Do Not Match",
message, QMessageBox::Ok|QMessageBox::Cancel);
return (reply == QMessageBox::Ok);
}
Expand Down Expand Up @@ -279,7 +277,7 @@ namespace IDA

/**
* Handles when the type of geometry changes
*
*
* Updates the file extension to search for
*/
void ApplyCorr::handleGeometryChange(int index)
Expand All @@ -301,7 +299,7 @@ namespace IDA
break;
}
}

/**
* Replots the preview plot.
*
Expand Down
4 changes: 1 addition & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/CalcCorr.cpp
Expand Up @@ -269,8 +269,6 @@ namespace IDA
"canws = None\n";
}

pyInput += "verbose = True\n";

if ( uiForm().absp_ckSave->isChecked() ) pyInput += "save = True\n";
else pyInput += "save = False\n";

Expand All @@ -282,7 +280,7 @@ namespace IDA
"plotOpt = '" + uiForm().absp_cbPlotOutput->currentText() + "'\n"
"sampleFormula = " + sampleFormula + "\n"
"canFormula = " + canFormula + "\n"
"print IndirectAbsCor.AbsRunFeeder(inputws, canws, geom, ncan, size, avar, density, beam, sampleFormula, canFormula, sigs, siga, plot_opt=plotOpt, save=save, verbose=verbose)\n";
"print IndirectAbsCor.AbsRunFeeder(inputws, canws, geom, ncan, size, avar, density, beam, sampleFormula, canFormula, sigs, siga, plot_opt=plotOpt, save=save)\n";

QString pyOutput = runPythonCode(pyInput);

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp
Expand Up @@ -197,7 +197,7 @@ namespace IDA
pyInput +=
"bg = '" + bgType + "'\n"
"ftype = '" + fitType + "'\n"
"confitSeq(input, func, startx, endx, ftype, bg, temp, specMin, specMax, convolve, Verbose=True, Plot=plot, Save=save)\n";
"confitSeq(input, func, startx, endx, ftype, bg, temp, specMin, specMax, convolve, Plot=plot, Save=save)\n";

QString pyOutput = runPythonCode(pyInput);

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidQt/CustomInterfaces/src/FuryFit.cpp
Expand Up @@ -164,11 +164,11 @@ namespace IDA

if( !constrainBeta )
{
pyInput += "furyfitSeq(input, func, ftype, startx, endx, spec_min=spec_min, spec_max=spec_max, intensities_constrained=constrain_intens, Save=save, Plot=plot, Verbose=True)\n";
pyInput += "furyfitSeq(input, func, ftype, startx, endx, spec_min=spec_min, spec_max=spec_max, intensities_constrained=constrain_intens, Save=save, Plot=plot)\n";
}
else
{
pyInput += "furyfitMult(input, func, ftype, startx, endx, spec_min=spec_min, spec_max=spec_max, intensities_constrained=constrain_intens, Save=save, Plot=plot, Verbose=True)\n";
pyInput += "furyfitMult(input, func, ftype, startx, endx, spec_min=spec_min, spec_max=spec_max, intensities_constrained=constrain_intens, Save=save, Plot=plot)\n";
}

QString pyOutput = runPythonCode(pyInput);
Expand Down
Expand Up @@ -116,7 +116,7 @@ namespace MantidQt

pyInput += "from IndirectNeutron import "+pyFunc+"\n";
pyInput += pyFunc + "('"+instrument+"','"+filename+"','"+analyser+"','"+reflection+"',"+rejectZero+","+useMap+",'"+mapPath+"'"
",True,'"+plot+"',"+save+")";
",'"+plot+"',"+save+")";

}
runPythonScript(pyInput);
Expand Down
8 changes: 2 additions & 6 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MSDFit.cpp
Expand Up @@ -75,16 +75,14 @@ namespace IDA
"specMax = " + uiForm().msd_spSpectraMax->text() + "\n"
"input = '" + uiForm().msd_dsSampleInput->getCurrentDataName() + "'\n";

pyInput += "verbose = True\n";

if ( uiForm().msd_ckPlot->isChecked() ) pyInput += "plot = True\n";
else pyInput += "plot = False\n";

if ( uiForm().msd_ckSave->isChecked() ) pyInput += "save = True\n";
else pyInput += "save = False\n";

pyInput +=
"msdfit(input, startX, endX, spec_min=specMin, spec_max=specMax, Save=save, Verbose=verbose, Plot=plot)\n";
"msdfit(input, startX, endX, spec_min=specMin, spec_max=specMax, Save=save, Plot=plot)\n";

QString pyOutput = runPythonCode(pyInput);
UNUSED_ARG(pyOutput);
Expand All @@ -107,10 +105,8 @@ namespace IDA
"specMax = " + uiForm().msd_spPlotSpectrum->text() + "\n"
"input = '" + uiForm().msd_dsSampleInput->getCurrentDataName() + "'\n";

pyInput += "verbose = True\n";

pyInput +=
"output = msdfit(input, startX, endX, spec_min=specMin, spec_max=specMax, Save=False, Verbose=verbose, Plot=False)\n"
"output = msdfit(input, startX, endX, spec_min=specMin, spec_max=specMax, Save=False, Plot=False)\n"
"print output \n";

QString pyOutput = runPythonCode(pyInput).trimmed();
Expand Down
60 changes: 25 additions & 35 deletions Code/Mantid/scripts/Inelastic/IndirectAbsCor.py
Expand Up @@ -39,34 +39,30 @@ def WaveRange(inWS, efixed):
DeleteWorkspace(oWS)
return wave

def CheckSize(size, geom, ncan, Verbose):
def CheckSize(size, geom, ncan):
if geom == 'cyl':
if (size[1] - size[0]) < 1e-4:
raise ValueError('Sample outer radius not > inner radius')
else:
if Verbose:
message = 'Sam : inner radius = ' + str(size[0]) + ' ; outer radius = ' + str(size[1])
logger.notice(message)
message = 'Sam : inner radius = ' + str(size[0]) + ' ; outer radius = ' + str(size[1])
logger.information(message)
if geom == 'flt':
if size[0] < 1e-4:
raise ValueError('Sample thickness is zero')
else:
if Verbose:
logger.notice('Sam : thickness = ' + str(size[0]))
logger.information('Sam : thickness = ' + str(size[0]))
if ncan == 2:
if geom == 'cyl':
if (size[2] - size[1]) < 1e-4:
raise ValueError('Can inner radius not > sample outer radius')
else:
if Verbose:
message = 'Can : inner radius = ' + str(size[1]) + ' ; outer radius = ' + str(size[2])
logger.notice(message)
message = 'Can : inner radius = ' + str(size[1]) + ' ; outer radius = ' + str(size[2])
logger.information(message)
if geom == 'flt':
if size[1] < 1e-4:
raise ValueError('Can thickness is zero')
else:
if Verbose:
logger.notice('Can : thickness = ' + str(size[1]))
logger.information('Can : thickness = ' + str(size[1]))

def CheckDensity(density, ncan):
if density[0] < 1e-5:
Expand All @@ -76,22 +72,21 @@ def CheckDensity(density, ncan):
if density[1] < 1e-5:
raise ValueError('Can density is zero')

def AbsRun(inputWS, geom, beam, ncan, size, density, sigs, siga, avar, Verbose, Save):
def AbsRun(inputWS, geom, beam, ncan, size, density, sigs, siga, avar, Save):
workdir = getDefaultWorkingDirectory()

if Verbose:
logger.notice('Sample run : ' + inputWS)
logger.information('Sample run : ' + inputWS)

# check that there is data
Xin = mtd[inputWS].readX(0)
if len(Xin) == 0:
raise ValueError('Sample file has no data')

CheckSize(size, geom, ncan, Verbose)
CheckSize(size, geom, ncan)
CheckDensity(density,ncan)

diffraction_run = checkUnitIs(inputWS, 'dSpacing')
logger.notice('Is diffraction run: %s' % str(diffraction_run))
logger.information('Is diffraction run: %s' % str(diffraction_run))

if diffraction_run:
det = GetWSangles(inputWS)
Expand All @@ -111,21 +106,20 @@ def AbsRun(inputWS, geom, beam, ncan, size, density, sigs, siga, avar, Verbose,

run_name = getWSprefix(inputWS)

if Verbose:
message = 'Sam : sigt = ' + str(sigs[0]) + ' ; siga = ' + str(siga[0]) + ' ; rho = ' + str(density[0])
logger.notice(message)
message = 'Sam : sigt = ' + str(sigs[0]) + ' ; siga = ' + str(siga[0]) + ' ; rho = ' + str(density[0])
logger.information(message)

if ncan == 2:
message = 'Can : sigt = ' + str(sigs[1]) + ' ; siga = ' + str(siga[1]) + ' ; rho = ' + str(density[1])
logger.notice(message)
if ncan == 2:
message = 'Can : sigt = ' + str(sigs[1]) + ' ; siga = ' + str(siga[1]) + ' ; rho = ' + str(density[1])
logger.information(message)

logger.notice('Elastic lambda : ' + str(wavelas))
logger.information('Elastic lambda : ' + str(wavelas))

message = 'Lambda : ' + str(nw) + ' values from ' + str(waves[0]) + ' to ' + str(waves[nw - 1])
logger.notice(message)
message = 'Lambda : ' + str(nw) + ' values from ' + str(waves[0]) + ' to ' + str(waves[nw - 1])
logger.information(message)

message = 'Detector angles : ' + str(ndet) + ' from ' + str(det[0]) + ' to ' + str(det[ndet - 1])
logger.notice(message)
message = 'Detector angles : ' + str(ndet) + ' from ' + str(det[0]) + ' to ' + str(det[ndet - 1])
logger.information(message)

name = run_name + geom
wrk = workdir + run_name
Expand Down Expand Up @@ -169,8 +163,7 @@ def AbsRun(inputWS, geom, beam, ncan, size, density, sigs, siga, avar, Verbose,
density, sigs, siga, angle, wavelas, waves, n, wrk, 0)

if kill == 0:
if Verbose:
logger.notice('Detector ' + str(n) + ' at angle : ' + str(det[n]) + ' * successful')
logger.information('Detector ' + str(n) + ' at angle : ' + str(det[n]) + ' * successful')

dataA1 = np.append(dataA1, A1)
dataA2 = np.append(dataA2, A2)
Expand Down Expand Up @@ -222,9 +215,7 @@ def AbsRun(inputWS, geom, beam, ncan, size, density, sigs, siga, avar, Verbose,
if Save:
opath = os.path.join(workdir, fname + '.nxs')
SaveNexusProcessed(InputWorkspace=fname, Filename=opath)

if Verbose:
logger.notice('Output file created : ' + opath)
logger.information('Output file created : ' + opath)

if ncan > 1:
return [fname, assWS, asscWS, acscWS, accWS]
Expand All @@ -244,7 +235,7 @@ def plotAbs(workspaces, plotOpt):


def AbsRunFeeder(input_ws, can_ws, geom, ncan, size, avar, density, beam_width=None, sample_formula=None, can_formula=None, sigs=None, siga=None,
plot_opt='None', verbose=False, save=False):
plot_opt='None', save=False):
"""
Handles the feeding of input and plotting of output for the F2PY
absorption correction routine.
Expand All @@ -261,7 +252,6 @@ def AbsRunFeeder(input_ws, can_ws, geom, ncan, size, avar, density, beam_width=N
@param siga - absorption for sample and can(s)
@param avar - sample angle
@param plot_opt - whether to plot output
@param verbose - whether to show extra verbose output
@param save - whether to save the output to file
@return The result workspace group
"""
Expand Down Expand Up @@ -319,7 +309,7 @@ def AbsRunFeeder(input_ws, can_ws, geom, ncan, size, avar, density, beam_width=N
siga[2] = can_mat.absorbXSection()

workspaces = AbsRun(input_ws, geom, beam, ncan, size, density,
sigs, siga, avar, verbose, save)
sigs, siga, avar, save)

EndTime('CalculateCorrections')
plotAbs(workspaces[1:], plot_opt)
Expand Down

0 comments on commit 4bfe073

Please sign in to comment.