diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectDiffractionReduction.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectDiffractionReduction.cpp index b5e4846b5985deb962a055cc197d26a5e5259b85..d4e8a6def74e16390210dbb8ee81ba4be4ef408b 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectDiffractionReduction.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectDiffractionReduction.cpp @@ -192,7 +192,8 @@ void IndirectDiffractionReduction::plotResults() { const auto workspaceExists = AnalysisDataService::Instance().doesExist(it); if (workspaceExists) - pyInput += "plotSpectrum('" + QString::fromStdString(it) + "', 0)\n"; + pyInput += "plotSpectrum('" + QString::fromStdString(it) + + "', 0, error_bars = True)\n"; else showInformationBox(QString::fromStdString( "Workspace '" + it + "' not found\nUnable to plot workspace")); diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp index 75f477b38acb34ad47603db8e63dae4ce466d461..b33af6c3fd39db5a001dd29b02905114dd226c66 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp @@ -150,10 +150,7 @@ bool IndirectTab::loadFile(const QString &filename, const QString &outputName, /** * Configures the SaveNexusProcessed algorithm to save a workspace in the - *default - * save directory and adds the algorithm to the batch queue. - * - * This uses the plotSpectrum function from the Python API. + * default save directory and adds the algorithm to the batch queue. * * @param wsName Name of workspace to save * @param filename Name of file to save as (including extension) @@ -228,7 +225,7 @@ void IndirectTab::plotSpectrum(const QStringList &workspaceNames, int wsIndex) { pyInput += workspaceNames.join("','"); pyInput += "'], "; pyInput += QString::number(wsIndex); - pyInput += ")\n"; + pyInput += ", error_bars = True)\n"; m_pythonRunner.runPythonCode(pyInput); } @@ -272,7 +269,7 @@ void IndirectTab::plotSpectrum(const QStringList &workspaceNames, int specStart, pyInput += QString::number(specStart); pyInput += ","; pyInput += QString::number(specEnd + 1); - pyInput += "))\n"; + pyInput += "), error_bars = True)\n"; m_pythonRunner.runPythonCode(pyInput); } @@ -324,7 +321,7 @@ void IndirectTab::plotSpectra(const QStringList &workspaceNames, pyInput += " ,"; pyInput += QString::number(wsIndices[i]); } - pyInput += "])\n"; + pyInput += "], error_bars = True)\n"; m_pythonRunner.runPythonCode(pyInput); } @@ -387,7 +384,7 @@ void IndirectTab::plotTimeBin(const QStringList &workspaceNames, int binIndex) { pyInput += workspaceNames.join("','"); pyInput += "'], "; pyInput += QString::number(binIndex); - pyInput += ")\n"; + pyInput += ", error_bars=True)\n"; m_pythonRunner.runPythonCode(pyInput); } @@ -493,7 +490,7 @@ double IndirectTab::getEFixed(Mantid::API::MatrixWorkspace_sptr ws) { } /** - * Checks the workspace's intrument for a resolution parameter to use as + * Checks the workspace's instrument for a resolution parameter to use as * a default for the energy range on the mini plot * * @param workspace :: Name of the workspace to use @@ -509,7 +506,7 @@ bool IndirectTab::getResolutionRangeFromWs(const QString &workspace, } /** - * Checks the workspace's intrument for a resolution parameter to use as + * Checks the workspace's instrument for a resolution parameter to use as * a default for the energy range on the mini plot * * @param ws :: Pointer to the workspace to use @@ -586,7 +583,7 @@ QString IndirectTab::runPythonCode(QString code, bool no_output) { * @param workspaceName The name of the workspace to look for * @param plotting if true use plotting error message, false use saving error * message - * @return False if no workpsace found, True if workspace found + * @return False if no workspace found, True if workspace found */ bool IndirectTab::checkADSForPlotSaveWorkspace(const std::string &workspaceName, const bool &plotting) { diff --git a/docs/source/release/v3.9.0/indirect_inelastic.rst b/docs/source/release/v3.9.0/indirect_inelastic.rst index f857c7b443cde66a87e007bdde05d8a7dbd02695..e0860f5497768572b9086aed48d48454ba6ec711 100644 --- a/docs/source/release/v3.9.0/indirect_inelastic.rst +++ b/docs/source/release/v3.9.0/indirect_inelastic.rst @@ -25,6 +25,11 @@ Data Analysis - :ref:`TeixeiraWaterSQE <func-TeixeiraWaterSQE>` models translation of water-like molecules (jump diffusion). +Improvements +------------ + +- When plotting from interfaces the plots now display error bars as standard + Corrections ########### @@ -45,17 +50,19 @@ Transmission ~~~~~~~~~~~~ - Option to calculate number density from mass density - - :ref:`IsoRotDiff <func-IsoRotDiff>` models isotropic rotational diffusion of a particle tethered to the origin at a constant distance. Improvements ------------ + - Data saved in an ASCII format using the *EnergyTransfer* interface can be re-loaded into Mantid + Bugfixes -------- + - Clicking 'Save' without creating a res file in *ISISCalibration* no longer causes an error diff --git a/scripts/Inelastic/IndirectCommon.py b/scripts/Inelastic/IndirectCommon.py index ea44053e844ffbc32c11f04802e19c52c17736d0..8272143fa72b61a967d8f395a9637ba4cf5700d6 100644 --- a/scripts/Inelastic/IndirectCommon.py +++ b/scripts/Inelastic/IndirectCommon.py @@ -1,11 +1,10 @@ -#pylint: disable=invalid-name,redefined-builtin +# pylint: disable=invalid-name,redefined-builtin from __future__ import (absolute_import, division, print_function) from six.moves import range import mantid.simpleapi as s_api from mantid import config, logger -from IndirectImport import import_mantidplot import os.path import math @@ -178,15 +177,15 @@ def createQaxis(inputWS): def GetWSangles(inWS): - num_hist = s_api.mtd[inWS].getNumberHistograms() # get no. of histograms/groups + num_hist = s_api.mtd[inWS].getNumberHistograms() # get no. of histograms/groups source_pos = s_api.mtd[inWS].getInstrument().getSource().getPos() sample_pos = s_api.mtd[inWS].getInstrument().getSample().getPos() beam_pos = sample_pos - source_pos - angles = [] # will be list of angles + angles = [] # will be list of angles for index in range(0, num_hist): - detector = s_api.mtd[inWS].getDetector(index) # get index - two_theta = detector.getTwoTheta(sample_pos, beam_pos) * 180.0 / math.pi # calc angle - angles.append(two_theta) # add angle + detector = s_api.mtd[inWS].getDetector(index) # get index + two_theta = detector.getTwoTheta(sample_pos, beam_pos) * 180.0 / math.pi # calc angle + angles.append(two_theta) # add angle return angles @@ -194,7 +193,7 @@ def GetThetaQ(ws): """ Returns the theta and elastic Q for each spectrum in a given workspace. - @param ws Wotkspace to get theta and Q for + @param ws Workspace to get theta and Q for @returns A tuple containing a list of theta values and a list of Q values """ @@ -410,49 +409,6 @@ def getInstrumentParameter(ws, param_name): return param -def plotSpectra(ws, y_axis_title, indicies=None): - """ - Plot a selection of spectra given a list of indicies - - @param ws - the workspace to plot - @param y_axis_title - label for the y axis - @param indicies - list of spectrum indicies to plot - """ - if indicies is None: - indicies = [] - - if len(indicies) == 0: - num_spectra = s_api.mtd[ws].getNumberHistograms() - indicies = list(range(num_spectra)) - - try: - mtd_plot = import_mantidplot() - plot = mtd_plot.plotSpectrum(ws, indicies, True) - layer = plot.activeLayer() - layer.setAxisTitle(mtd_plot.Layer.Left, y_axis_title) - except RuntimeError: - # User clicked cancel on plot so don't do anything - return - - -def plotParameters(ws, *param_names): - """ - Plot a number of spectra given a list of parameter names - This searchs for relevent spectra using the text axis label. - - @param ws - the workspace to plot from - @param param_names - list of names to search for - """ - axis = s_api.mtd[ws].getAxis(1) - if axis.isText() and len(param_names) > 0: - num_spectra = s_api.mtd[ws].getNumberHistograms() - - for name in param_names: - indicies = [i for i in range(num_spectra) if name in axis.label(i)] - if len(indicies) > 0: - plotSpectra(ws, name, indicies) - - def convertToElasticQ(input_ws, output_ws=None): """ Helper function to convert the spectrum axis of a sample to ElasticQ. @@ -540,7 +496,7 @@ def IndentifyDataBoundaries(sample_ws): sample_ws = s_api.mtd[sample_ws] nhists = sample_ws.getNumberHistograms() - start_data_idx, end_data_idx = 0,0 + start_data_idx, end_data_idx = 0, 0 # For all spectra in the workspace for spectra in range(0, nhists): # Obtain first and last non zero values diff --git a/scripts/Inelastic/IndirectReductionCommon.py b/scripts/Inelastic/IndirectReductionCommon.py index 09994c89695a5b5378d4ee2d4415e536933f193b..df2d844c9712fbb41c84204c6b2bf2277b55d6c0 100644 --- a/scripts/Inelastic/IndirectReductionCommon.py +++ b/scripts/Inelastic/IndirectReductionCommon.py @@ -235,7 +235,7 @@ def identify_bad_detectors(workspace_name): except IndexError: masking_type = 'None' - logger.information('Masking type: %s' % (masking_type)) + logger.information('Masking type: %s' % masking_type) masked_spec = list() @@ -251,7 +251,7 @@ def identify_bad_detectors(workspace_name): # Remove the temporary masking workspace DeleteWorkspace(ws_mask) - logger.debug('Masked specta for workspace %s: %s' % (workspace_name, str(masked_spec))) + logger.debug('Masked spectra for workspace %s: %s' % (workspace_name, str(masked_spec))) return masked_spec @@ -340,7 +340,7 @@ def process_monitor_efficiency(workspace_name): raise ValueError('Cannot get monitor details form parameter file') if area == -1 or thickness == -1 or attenuation == -1: - logger.information('For workspace %s, skipping monitor efficiency' % (workspace_name)) + logger.information('For workspace %s, skipping monitor efficiency' % workspace_name) return OneMinusExponentialCor(InputWorkspace=monitor_workspace_name, @@ -407,7 +407,7 @@ def scale_detectors(workspace_name, e_mode='Indirect'): def group_spectra(workspace_name, masked_detectors, method, group_file=None, group_ws=None): """ Groups spectra in a given workspace according to the Workflow.GroupingMethod and - Workflow.GroupingFile parameters and GrpupingPolicy property. + Workflow.GroupingFile parameters and GroupingPolicy property. @param workspace_name Name of workspace to group spectra of @param masked_detectors List of spectra numbers to mask @@ -464,7 +464,7 @@ def group_spectra(workspace_name, masked_detectors, method, group_file=None, gro # If it is still not found just give up if not os.path.isfile(grouping_file): - raise RuntimeError('Cannot find grouping file: %s' % (grouping_file)) + raise RuntimeError('Cannot find grouping file: %s' % grouping_file) # Mask detectors if required if len(masked_detectors) > 0: @@ -520,7 +520,7 @@ def fold_chopped(workspace_name): for i in range(0, mtd[merged_ws].blocksize()): y_val = 0.0 for rng in ranges: - if data_x[i] >= rng[0] and data_x[i] <= rng[1]: + if rng[0] <= data_x[i] <= rng[1]: y_val += 1.0 data_y.append(y_val) @@ -623,14 +623,14 @@ def plot_reduction(workspace_name, plot_type): Plot a given workspace based on the Plot property. @param workspace_name Name of workspace to plot - @param plot_types Type of plot to create + @param plot_type Type of plot to create """ if plot_type == 'Spectra' or plot_type == 'Both': from mantidplot import plotSpectrum num_spectra = mtd[workspace_name].getNumberHistograms() try: - plotSpectrum(workspace_name, range(0, num_spectra)) + plotSpectrum(workspace_name, range(0, num_spectra), error_bars=True) except RuntimeError: logger.notice('Spectrum plotting canceled by user') @@ -650,7 +650,7 @@ def save_reduction(workspace_names, formats, x_units='DeltaE'): @param workspace_names List of workspace names to save @param formats List of formats to save in - @param Output X units + @param x_units X units """ from mantid.simpleapi import (SaveSPE, SaveNexusProcessed, SaveNXSPE, SaveAscii, Rebin, DeleteWorkspace,