diff --git a/Framework/Properties/Mantid.properties.template b/Framework/Properties/Mantid.properties.template index baec26b172e9d72f18b487f6d74432ab7b607e3d..aa98016f34e54182ce72ffdff53cd35db52ca658 100644 --- a/Framework/Properties/Mantid.properties.template +++ b/Framework/Properties/Mantid.properties.template @@ -21,7 +21,7 @@ Q.convention = Inelastic # Set of PyQt interfaces to add to the Interfaces menu, separated by a space. Interfaces are seperated from their respective categories by a "/". -mantidqt.python_interfaces = Direct/DGS_Reduction.py Direct/DGSPlanner.py Direct/PyChop.py Direct/MSlice.py SANS/ORNL_SANS.py Utility/TofConverter.py Diffraction/Engineering_Diffraction_2.py Diffraction/Powder_Diffraction_Reduction.py Utility/FilterEvents.py Diffraction/HFIR_4Circle_Reduction.py Utility/QECoverage.py SANS/ISIS_SANS.py Muon/Frequency_Domain_Analysis.py Muon/Elemental_Analysis.py Muon/Frequency_Domain_Analysis_Old.py Muon/Muon_Analysis.py +mantidqt.python_interfaces = Direct/DGS_Reduction.py Direct/DGSPlanner.py Direct/PyChop.py Direct/MSlice.py SANS/ORNL_SANS.py Utility/TofConverter.py Diffraction/Engineering_Diffraction.py Diffraction/Powder_Diffraction_Reduction.py Utility/FilterEvents.py Diffraction/HFIR_4Circle_Reduction.py Utility/QECoverage.py SANS/ISIS_SANS.py Muon/Frequency_Domain_Analysis.py Muon/Elemental_Analysis.py Muon/Frequency_Domain_Analysis_Old.py Muon/Muon_Analysis.py # Directory containing the above startup scripts mantidqt.python_interfaces_directory = @MANTID_ROOT@/scripts diff --git a/Framework/PythonInterface/mantid/plots/datafunctions.py b/Framework/PythonInterface/mantid/plots/datafunctions.py index 494e7fbcd406c564941ecabac446c4795eae2da6..74ddac5e5a00d5f113bc8d414422a8704469fb0c 100644 --- a/Framework/PythonInterface/mantid/plots/datafunctions.py +++ b/Framework/PythonInterface/mantid/plots/datafunctions.py @@ -608,7 +608,11 @@ def get_sample_log(workspace, **kwargs): if not run.hasProperty(LogName): raise ValueError('The workspace does not contain the {} sample log'.format(LogName)) tsp = run[LogName] - units = tsp.units + try: + units = tsp.units + except UnicodeDecodeError as exc: + mantid.kernel.logger.warning("Error retrieving units for log {}: {}".format(LogName, str(exc))) + units = "unknown" if not isinstance(tsp, (mantid.kernel.FloatTimeSeriesProperty, mantid.kernel.Int32TimeSeriesProperty, mantid.kernel.Int64TimeSeriesProperty)): diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py index 3658cc4a83a00c0c149201cdfe105b406e6a187c..32292f72d8e34922c17c40fb39bb4a771b92ef1f 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py @@ -218,7 +218,7 @@ class SANSBeamCentreFinder(DataProcessorAlgorithm): iter_details = "Itr {:02d}: ({:7.3f}, {:7.3f}) SX={:<8.4f}\tSY={:<8.4f}\t Points: {:3d} (Unaligned: {:2d})" \ .format(iteration, scaled_lr, scaled_tb, avg_lr_residual, avg_tb_residual, - lr_results.num_points_considered, lr_results.num_points_considered) + lr_results.num_points_considered, lr_results.mismatched_points) self.logger.notice(iter_details) diff --git a/dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffraction2TestGuide.rst b/dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffractionTestGuide.rst similarity index 94% rename from dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffraction2TestGuide.rst rename to dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffractionTestGuide.rst index 2f53943d636acbff5b2e08de6ff5c058a61d5b1f..1093176dd6ae1896a48c8a4ba084cd9f93a953b0 100644 --- a/dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffraction2TestGuide.rst +++ b/dev-docs/source/Testing/EngineeringDiffraction/EngineeringDiffractionTestGuide.rst @@ -1,6 +1,6 @@ -.. _Engineering_Diffraction_2_TestGuide-ref: +.. _Engineering_Diffraction_TestGuide-ref: -Engineering Diffraction 2 Testing +Engineering Diffraction Testing ================================= .. contents:: Table of Contents @@ -9,14 +9,14 @@ Engineering Diffraction 2 Testing Preamble ^^^^^^^^^ This document is tailored towards developers intending to test the Engineering Diffraction -interface 2. +interface. Runs can be loaded from the archive, however it is possible that different run numbers will be needed as older runs may be deleted. Overview ^^^^^^^^ -The Engineering Diffraction 2 interface allows scientists using the EnginX instrument to interactively +The Engineering Diffraction interface allows scientists using the EnginX instrument to interactively process their data. There are 3 tabs which are ordered according to the main steps performed. These are: diff --git a/docs/source/interfaces/Engineering Diffraction (Old).rst b/docs/source/interfaces/Engineering Diffraction (Old).rst new file mode 100644 index 0000000000000000000000000000000000000000..d6d9b438abc1a904c318915b277690fb00c3f8e0 --- /dev/null +++ b/docs/source/interfaces/Engineering Diffraction (Old).rst @@ -0,0 +1,603 @@ +.. _Engineering_Diffraction_(Old)-ref: + +Engineering Diffraction (Old) +============================= + +.. contents:: Table of Contents + :local: + +Overview +-------- +This interface is hidden and will likely be removed from the next release of mantid. + +This custom interface integrates several tasks related to engineering +diffraction. It provides functionality for calibration, focusing, and +pre-processing of event mode data. Further extensions can be expected +for future releases as it is under active development. Feedback is very +much welcome. The following sections describe the different tabs or +functionality areas of the interface. + +General options +^^^^^^^^^^^^^^^ +RB Number + To enable the GUI specify a RB Number (where "RB Number" usually + denotes the experiment reference number at ISIS). This reference + will be used for the output paths, so that files from different + users and/or experiments can be kept separate. + +Instrument + Select the instrument. Only ENGIN-X (ISIS) is supported in this version. + +? + Shows this documentation page. + +Close + Close the interface + +Status at the bottom of the interface + A short message will be displayed which indicates whether the last + important calculations finished successfully, and when the interface + is busy calculating (calibrating, focusing, fitting, etc.). + +* Red Star Sign + If a red star sign is displayed next to the Browse Button, it is mostly + likely because the file specified has not been found. Error message + can be viewed by hovering over the red star sign. + +.. _ui engineering calibration: + +Calibration +----------- + +This tab provides a graphical interface to calculate calibrations and +visualize them. + +It is possible to: + +- Generate a new calibration file (which becomes the new current + calibration) +- Load an existing calibration from a GSAS instrument + parameters file previously generated + +For the current calibration, the following parameters are displayed: + +- The vanadium run number +- The calibration sample run number +- The path to the output calibration file. + +This calibration file output is a GSAS instrument parameters file (IPARM/PAR/PRM). The interface +produces a calibration file containing all banks and in addition a calibration +file for every individual bank. All the calibration files are written +in the same directory. + +With the help of Cropped Calibration user can also calibrate according +to specific banks or by setting the Spectrum Numbers once the Cropped Calibration group +box has been enabled. + +The plot Calibrated Workspace check-box will enable user to plot +vanadium curves and Ceria peaks. For Ceria peaks there will be two +workspaces generated and plotted, one for each bank, whereas for a +cropped calibration there will only be one workspace generated +and plotted, depending on the selected bank or provided Spectrum +IDs. The workspace contains difa, difc and tzero data which is then +utilised to plot the Ceria peaks per bank, the graph will plot Peaks +Fitted and TOF Straight Line for comparison. More information +regarding the fit peaks can be found on the +:ref:`EnggFitPeaks<algm-EnggFitPeaks>` documentation. + +The calibration files are written into two different output +directories. First, they are written to a user specific directory +which for the ENGIN-X instrument on Windows systems is: + +`C:\\EnginX_Mantid\\<Username>\\<RBNumber>\\Calibration` + +On UNIX based platforms this path is: + +`~/EnginX_Mantid/<Username>/<RBNumber>/Calibration` + +They are also copied into a general (all) output directory: + +`C:\\EnginX_Mantid\\Calibration` on Windows or + +`~/EnginX_Mantid/Calibration` on UNIX platforms. + +The calibration parameters for each bank are made available for user +inspection in a workspace named +**engggui_calibration_banks_parameters** which is updated when new +calibrations are loaded or calculated. + +Parameters +^^^^^^^^^^ + +These parameters are required to generate new calibrations: + +Vanadium # + Number of the vanadium run used to correct calibration and experiment + runs. + +Calibration sample # + Number of the calibration sample run (for example Ceria run) used to + calibrate experiment runs. + +Bank Name: + This parameter is only required when Cropped Calibration is being + carried out. The bank name can be selected from a drop down list with + option of "North" and "South", which are equivalent to 1 and 2 + respectively. + Custom bank mappings can be created by setting the Bank Name option + to `Use spectrum numbers`. When the option *Use Spectrum Numbers* is + set a bank name must be specified in *Customise Bank Name*. + +Spectrum Numbers: + This parameter is only required when Cropped Calibration is being + carried out, the parameter will set the spectrum numbers of the + detectors, that should be considered in the calibration while all + others will be ignored. This option cannot be used together with + Bank Name, as they overlap. You may also give multiple ranges, for + example: "0-100", or "0-9", "150-750". + +Customise Bank Name: + This parameter is only required when Cropped Calibration is being + carried out with Spectrum Numbers, the parameter will set the workspace + and `.his` file name according to this Bank Name provided by the user. + However if the user does not provide a personalised name, the + interface will use "cropped" as a default bank name. + +The calibration process depends on several additional parameters and +settings which can be modified in the *Settings* tab, see :ref:`setting-Engineering_Diffraction-ref` for details. + +.. _focus-Engineering_Diffraction-ref: + +Focus +----- + +Here it is possible to focus run files, by providing a run number or a +range of run number to enable multi-run focusing, along with that the +user may also select the files with the help of Browse button. + +The focusing process uses the algorithm :ref:`EnggFocus +<algm-EnggFocus>`. In the documentation of the algorithm you can find +the details on how the input runs are focused. + +The interface will also create workspaces that can be inspected in the +workspaces window: + +1. The *engggui_focusing_input_ws workspace* for the data being focused +2. The *engggui_focusing_output_ws... workspace* for the corresponding + focused data (where the ... denotes a suffix explained below). + +Three focusing alternatives are provided: + +1. Normal focusing, which includes all the spectra from the input run. +2. Cropped focusing, where several spectra or ranges of spectra can + be specified, as a list separated by commas. +3. Texture focusing, where the *texture* group of detectors is given + in a Detector Grouping File. + +Depending on the alternative chosen, the focusing operation will +include different banks and/or combinations of spectra (detectors). +The behavior for each option is as follows: + +1. *Normal focusing* - All the selected banks and spectra present +in the input runs are considered. The output focused workspace will +be named with suffixes such as *_bank_1, _bank_2*, and so on + +2. *Cropped Focusing* - All the banks are considered in +principle but only a list of spectra provided manually are +processed. The output focused workspace will be named with +the suffix *_cropped*. + +3. *Texture Focusing* - The banks are selected by a user-defined +list of banks and corresponding spectrum numbers provided in a file. +The output workspaces will be named with suffixes such as *_texture_bank_1, +_texture_bank_2*, and so on. These suffixes are determined by the +bank IDs given in the detector grouping file. + +Cropped focusing and Texture focusing have been disabled by default to +declutter the interface, but each section can be enabled simply by +ticking the check-box next to Focus Cropped and Focus Texture. + +For texture focusing, the detector grouping file is a text (csv) file +with one line per bank. Each line must contain at least two numeric +fields, where the first one specifies the bank ID, and the second and +subsequent ones different spectrum numbers or ranges of spectrum +numbers. For example:: + + # Bank ID, spectrum numbers + 1, 205-210 + 2, 100, 102, 107 + 3, 300, 310, 320-329, 350-370 + +When a focus run process is being carried out, Focus Stop button will +be enabled. Focus Stop button will allow the user to abort once the +current focus run process has been completed. Inside the *Result Log* +a warning message will be displayed with last successful run and total +number of focus runs that could not be processed. + +The focused data files are saved in NeXus format into the user +specific and general directories (as with the calibration output +files). That is the files are written into +`C:\\EnginX_Mantid\\User\\<RBNumber>\\Calibration` and +`C:\\EnginX_Mantid\\Calibration` on Windows, or +`~/EnginX_Mantid/User/<RBNumber>/Calibration` and +`~/EnginX_Mantid/Calibration` on UNIX platforms. See below for +additional, optional outputs. + +Run Number +^^^^^^^^^^ +The run provided to focus can be for example 228061-228063, this will +run all the files within the given range as long as the file +directories are included in the +`User Directories <http://www.mantidproject.org/ManageUserDirectories>`_. +The user may also provide an input of 228061-3 or 228061, 228062, +2280623 which should work the same way. + +If a red star sign is displayed next to the Browse Button, it is mostly +likely because the file specified has not been found. Error message +can be viewed by hovering over the red star sign. + +Checking the availability of all the files can take some time, for this +reason it is also possible that a file may not have been found but the +red star sign has not been displayed. If you manage to click Focus +before red sign is displayed, the interface will process the last valid +focus run instead. + +Output +^^^^^^ + +Under the output section, the user is provided with an option of +plotting data in three different formats. + +- One Window - Replacing Plots: will replace the previous graph and plot a new graph on top. + +- One Window - Waterfall: will plot all the generated focused workspace graphs in one window + which can be useful while comparing various graphs. + +- Multiple Windows - will plot graph in separate windows. + +However, user may also change the Plot Data representation drop-down box while a run is being carried out. This +will update the interface and plot workspace according to the new given input. +For example, if a user has selected *One Window - Replacing Plots* and then decides to change it to *One Window - +Waterfall* during a run, the interface will carry on by plotting +Waterfall within the same window. + +The user also has an option of saving GSS, XYE and OpenGenie formatted +files by clicking the Output Files checkbox. This will generate three +different files for each focused output workspace in Mantid. These +files can be found with appropriate name within: + +`C:\\EnginX_Mantid\\<User>\\<RBNumber>\\Focus` on Windows or + +`~/EnginX_Mantid/Foxus` on UNIX systems. + +The files are also copied to the general (all) output directory which is + +`C:\\EnginX_Mantid\\Focus` on Windows + +`~/EnginX_Mantid/Focus` under on UNIX systems + +`The Multiple Runs Focus Mode` combo-box enables two alternative +focus modes. `Focus Individual Run Files Separately` is the default +option set, which allows user to run focus with multi-run files. +Whereas the `Focus Sum Of Files` option merges all the multi-run +number files together and applies the Focus Process to the merged +file. + +Pre-processing +-------------- + +.. warning:: This is a new capability that is currently in a very + early stage of definition and implementation. Not all + options may be supported and/or consistent at the moment. + +The focusing options can be applied directly to histogram data. For +event mode experiments, the event data (which would be loaded as event +workspaces in Mantid) need to be pre-processed. + +The simplest pre-processing option is "regular time binning" which +will produce a histogram data workspace (as a :ref:`Workspace2D +<Workspace2D>`). The only parameter required is the bin width. The +workspace will be named with the following convention: + +- *engggui_preproc_time_ws* + +When the input run file contains multiple workspaces (it would be +loaded by :ref:`Load <algm-Load>` as multiple :ref:`EventWorkspace +<EventWorkspace>` workspaces) the output workspace will be a group +with the corresponding number of histogram workspaces, binned +separately. This is the case when the input run file comes from a +multi-period experiment. Note that the time bin can be a multiple of +the pulse time. + +A different way of pre-processing event data is by rebinning +multi-period data by pulse times. In this case the input required is +the time step for the binning (the x axis of the output will be time +instead of time-of-flight). It is also possible to specify the number +of periods that will be processed (starting from the first one). This +type of pre-processing produces workspaces with the following naming +convention: + +- *engggui_preproc_by_pulse_time_ws* + +Focussing uses the algorithms :ref:`Rebin <algm-Rebin>` and :ref:`RebinByPulseTimes +<algm-RebinByPulseTimes>` to bin the data in different ways when +converting event data into histogram data. + +Fitting +------- + +.. warning:: This is a new capability that is currently in a very + early stage of definition and implementation. Not all + options may be supported and/or consistent at the moment. + +.. warning:: The input workspace must be converted into a focused file + first. The steps to complete this are found here: :ref:`focus-Engineering_Diffraction-ref` + +The Fitting tab provides a graphical interface which fits an expected +diffraction pattern and visualises them. The pattern is specified by +providing a list of peak centre values where Bragg peaks are expected. +These values can have units of either TOF of dSpacing but **not** both. +The algorithm :ref:`EnggFitPeaks<algm-EnggFitPeaks>` is used to +background fit peaks in those areas using a peak fitting function. + +To use the Fitting tab, user is required to follow these steps: + +1. Load run(s) to perform fitting on by browsing for focused nexus + files *User may click Load button to load the focused file to the + canvas* +2. List of expected peaks which can be either by browsing a (*CSV*) file, + manually selecting peaks from the canvas using peak picker tool and the "Add Peak to List" button after + loading the focused file or by entering the peaks list within the text-field +3. Next click on the *Fit* button if you would like to fit single focused + file or you can click *Fit All* button which will enable user to + batch-process all the runs and banks when several files are loaded. + *Fit All* process may also be used when a single run number is given + or a file is browsed + +.. _ExpectedPeaks-Engineering_Diffraction-ref: + +Parameters +^^^^^^^^^^ + +These parameters are required to process Fitting successfully: + +Focused Run files: + .nxs files containing focused diffraction data. These should be the result + of focusing data with the :ref:`focus-Engineering_Diffraction-ref` tab. + +Peaks: + A list of dSpacing values to be translated into TOF to find expected + peaks. These peaks can be manually written or imported by selecting a + (*CSV*) file. + +Output +^^^^^^ + +Once the Fit button has been clicked Mantid will process the data. Please wait +until the Fitting process has completed. Upon completion you should be able to +view the Fitting tab which will contain: + +- The focused workspace plotted in the background in gray crosses. +- The expected peaks plotted in various colours overlapping the + focused workspace peaks. + +Within the :ref:`Preview-Engineering_Diffraction-ref` section a user is +able to zoom-in or zoom-out as well as select, add and save peaks. + +The interface will also generate workspaces that can be inspected in the +workspaces window: + +1. The *engggui_fitting_fitpeaks_param* Table workspace + with the parameters of the peaks found and fitted. +2. The *engggui_fitting_focused_ws* Focused workspace also loaded + so the fitted data can be compared with focused data +3. The *engggui_fitting_single_peaks* workspace with each workspace + index representing individual expected peak. + +During the Fit process, :ref:`EnggSaveSinglePeakFitResultsToHDF5 +<algm-EnggSaveSinglePeakFitResultsToHDF5>` algorithm will be utilised +to save *engggui_fitting_fitpeaks_param* TableWorkspace as a `hdf5` +file. There will one file per run, indexed by bank ID, and the file +will be found in the **Runs** directory of the user's output +directory. If **Fit All** was run on multiple runs, then an additional +file for all runs will be output, which is indexed first by run number +and then by bank ID. + +In the plots, the x or abscissa axis is in d-spacing units, which are +more convenient for peak fitting than time-of-flight. However the run +files and the focus files are normally stored as time-of-flight +data. For this reason a conversion from the time-of-flight data to +d-spacing is required. The conversion is performed using the current +calibration of banks. The interface handles this internally and adds +special sample logs to the fitting workspaces +(*engggui_fitting_single_peaks* and *engggui_fitting_focused_ws*). By +inspecting the sample logs of these workspaces. The conversion is +performed using the `GSAS +<https://subversion.xray.aps.anl.gov/trac/pyGSAS>`__ equations, as +calculated by the algorithm :ref:`AlignDetectors +<algm-AlignDetectors>` + +.. _Preview-Engineering_Diffraction-ref: + +Preview +^^^^^^^ +Once the fitting process has completed and you are able to view a +focused workspace with listed expected peaks on the data plot, the *Select +Peak* button should also be enabled. If the user choose to load the focus +workspace or if fitting fails with the given peaks then the focused +workspace will be plotted so that the user can select the peaks manually. + +If you've run a fit but you can't see the reconstructed peaks, make sure +the checkbox **Plot fitted peaks** is checked - if the fit was successful, +then clicking this should show the results. Equally, if you want to hide +fitted peaks, just uncheck this box and they will disappear. + +By clicking Select Peak button the peak picker tool can be activated. +To select a peak simply hold *Shift* key and left-click on the graph +near the peak's center. + +To get help selecting the center of the peak, you may set the peak +width by left-click and drag horizontally, while holding *Ctrl* key +as well. Users may also zoom-in to the graph by holding left-click +and dragging a box on the plot, and zoom-out by left-clicking on +the plot. + +When user is happy with the center position of the peak, you may +add the selected peak to :ref:`ExpectedPeaks-Engineering_Diffraction-ref` +list by clicking Add Peak button. User may rerun Fit process by +clearing peaks list using Clear button and manually selecting peaking +using Select Peak button or instead Save the peaks list in *CSV* file +by clicking Save button. + +User may plot single peak fitting workspace in separate window by using +Plot To Separate Window button, if the *engggui_fitting_single_peaks* +is available. + +.. _gsas-Engineering_Diffraction-ref: + +GSAS Fitting +------------ + +.. warning:: This is a new capability that is currently in a very + early stage of definition and implementation. Not all + options may be supported and/or consistent at the moment. + +The GSAS tab provides a graphical interface to the Mantid algorithm +:ref:`GSASIIRefineFitPeaks <algm-GSASIIRefineFitPeaks>`. This allows +users to perform GSAS-style fitting on their data from Mantid. + +The user must input the following files: + +- **Focused run file(s)** - these must have been generated either by + the **Fitting** tab or :ref:`EnggFocus <algm-EnggFocus>`. +- **Instrument Parameter File** - contains DIFA and DIFC GSAS + constants, will probably be of ``.prm`` format +- **Phase file(s)** - contain crystallographic information about the + sample in question. Currently only ``.cif`` files are supported + +The following parameters are also required: + +- **New GSAS-II Project** - GSASIIRefineFitPeaks creates a new + ``.gpx`` project here, which can be opened and inspected from the + GSAS-II GUI + + - Note, if running **Refine All** on more than one run, the run + number and bank ID will be appended to the filename +- **GSAS-II Installation Directory** + + - This is the directory containing the GSAS-II executables and + Python libraries. In particular, it must contain + ``GSASIIscriptable.py``. This directory will normally be called + `GSASII`, if GSAS-II was installed normally + - You must have a version of GSAS-II from at least **February 2018** + to use the GUI. See :ref:`Installing_GSASII` for how to install a + compatible version +- **Refinement method** - can either be **Pawley** or + **Rietveld**. Pawley refinement is currently under development, so + Rietveld is recommended. + +Optionally, you may also supply: + +- **XMin** and **XMax** - the limits (in TOF) to perform fitting + within +- **DMin** - the minimum dSpacing to use for refinement when + performing Pawley refinement +- **Negative weight** - The weight for a penalty function applied + during a Pawley refinement on resulting negative intensities. + +To do a refinement, take the following steps: + +1. Load a run by selecting the focused NeXuS file using the + corresponding **Browse** button, then clicking **Load**. The run + number and bank ID (for example ``123456_1``) should appear in the + **Run Number** list in the **Preview** section. Click the label, + and the run will be plotted +2. Select your input files, and input any additional parameters in the + **GSASIIRefineFitPeaks Controls** section +3. Click **Run Refinement**. Once complete, fitted peaks for the run + should be overplotted in the fitting area. In addition, Rwp + (goodness of fit index), Sigma and Gamma (peak broadening + coefficients) and lattice parameters should be displayed in the + **Fit Results** section. + + - You can also click **Refine All** to run refinement on all runs + loaded into GSAS tab + +During the Fit process, :ref:`EnggSaveGSASIIFitResultsToHDF5 +<algm-EnggSaveGSASIIFitResultsToHDF5>` algorithm will be utilised to +save the fit results, and also the parameters used, as a `hdf5` +file. There will be one file per run, indexed by bank ID, and the file +will be found in the **Runs** directory of the user's output +directory. + +You can toggle the fitted peaks on and off with the **Plot Fitted +Peaks** checkbox, remove runs from the list with the **Remove Run** +button, and plot the run and fitted peaks to a larger, separate plot +using **Plot to separate window**. + +.. _setting-Engineering_Diffraction-ref: + +Settings +-------- + +Controls several settings, including the input folders where the +instrument run files can be found. Other advanced options can also be +controlled to customize the way the underlying calculations are +performed. + +Calibration Parameters +^^^^^^^^^^^^^^^^^^^^^^ + +The calibration settings are organized in three blocks: + +1. Input directories +2. Pixel (full) calibration +3. Advanced settings + +The input directories will be used when looking for run files +(Vanadium and Ceria). They effectively become part of the search path +of Mantid when using this interface. + +The pixel (full) calibration file contains the calibration details of +every pixel of all banks, as produced by the algorithm +:ref:`EnggCalibrateFull <algm-EnggCalibrateFull>`. A default pixel +calibration file is provided with Mantid packages. This calibration +has been produced for the Vanadium and calibration sample (Ceria) runs +indicated in the name of the calibration file. Note that this +calibration is currently subject to changes, as the fitting of peaks +is being refined. + +The Following advanced settings are available to customize the +behavior of this interface: + +Force recalculate all existing Vanadium files + If this is enabled, Vanadium corrections will be recalculated even + if previous correction results are available for the current Vanadium + run number. This is not required unless a modification is done to the + original Vanadium run file, or there is a change in the algorithms + that calculate the corrections + +Template .prm file + By changing this option you can Use a different template file for + the output GSAS IPAR/PAR/PRM that is generated in the Calibration + tab. + +Rebin for Calibrate + This sets a rebin width parameter that can be used by underlying + algorithms such as :ref:`EnggCalibrate <algm-EnggCalibrate>` and + :ref:`EnggFocus <algm-EnggFocus>` + +Algorithms +---------- + +Most of the functionality provided by this interface is based on the +engineering diffraction Mantid algorithms (which are named with the +prefix *Engg*). This includes :ref:`EnggCalibrate +<algm-EnggCalibrate>`, :ref:`EnggCalibrateFull +<algm-EnggCalibrateFull>`, :ref:`EnggVanadiumCorrections +<algm-EnggVanadiumCorrections>`, :ref:`EnggFocus <algm-EnggFocus>`, +:ref:`EnggFitPeaks<algm-EnggFitPeaks>` +and several other algorithms, explained in detail in the following Mantid +algorithms documentation pages. + +.. categories:: Interfaces Diffraction diff --git a/docs/source/interfaces/Engineering Diffraction 2.rst b/docs/source/interfaces/Engineering Diffraction 2.rst deleted file mode 100644 index abcd46ea6de7f44b6cc30a3b1cd46933990b991b..0000000000000000000000000000000000000000 --- a/docs/source/interfaces/Engineering Diffraction 2.rst +++ /dev/null @@ -1,171 +0,0 @@ -.. _Engineering_Diffraction_2-ref: - -Engineering Diffraction 2 -========================= - -.. contents:: Table of Contents - :local: - -Interface Overview ------------------- - -This custom interface will integrate several tasks related to engineering -diffraction. In its current state it provides functionality for creating -and loading calibration files and focusing ENGINX run files. - -Functionality for performing single peak fitting on focused run files is currently in progress. - -This interface is under active development. - -General Options -^^^^^^^^^^^^^^^ -RB Number - The reference number for the output paths (usually an experiment reference - number at ISIS). Leaving this field empty will result in no user directories - being created, and only the general directory will be used for file storage. - -Instrument - Select the instrument (ENGINX or IMAT). Currently only ENGINX is fully - supported. - -? - Show this documentation page. - -Settings - Provides a range of options that apply across the entire interface, currently - providing the option to change the default output directory and force the - recalculation of the vanadium correction files. - -Close - Close the interface. - -Red Stars - Red stars next to browse boxes and other fields indicate that the file - could not be found. Hover over the star to see more information. - -Calibration ------------ - -This tab currently provides a graphical interface to create new calibrations, using the -:ref:`EnggCalibrate<algm-EnggCalibrate>` algorithm, and visualise them. -It also allows for the loading of GSAS parameter files created by the calibration process -to load a previously created calibration into the interface. - -When loading an existing calibration, the fields for creating a new calibration will be -automatically filled, allowing the recreation of the workspaces and plots generated by -creating a new calibration. - -The "Plot Output" check-box will plot vanadium curves and ceria peaks for new calibrations. -Four plots will be generated (for ENGINX), one of each plot for each of the detector banks. - -Creating a new calibration file generates 3 GSAS instrument parameter files, -one covering all banks and separate ones for each individual bank. All 3 files are written -to the same directory: - -`<CHOSEN_OUTPUT_DIRECTORY>/Calibration/` - -If an RB number has been specified the files will also be saved to a user directory -in the base directory: - -`<CHOSEN_OUTPUT_DIRECTORY>/User/<RB_NUMBER>/Calibration/` - -Cropping -^^^^^^^^ - -The interface also provides the ability to restrict a new calibration to one of the two banks -or to a custom list of spectra. - -Parameters -^^^^^^^^^^ - -Vanadium Number - The run number or file path used to correct the calibration and experiment runs. - -Calibration Sample Number - The run number for the calibration sample run (such as ceria) used to calibrate - experiment runs. - -Path - The path to the GSAS parameter file to be loaded. - -Bank/Spectra - Select a bank to crop to or specify a custom spectra will be entered. - -Custom Spectra - A comma separated list of spectra to restrict the calibration to. Can be provided as single spectrum numbers - or ranges using hyphens (e.g. 14-150, 405, 500-600). - -Focus ------ - -This tab allows for the focusing of data files by making use of the :ref:`EnggFocus<algm-EnggFocus>` algorithm. - -Files can be selected by providing run numbers or selecting the files manually using the browse button. - -In order to use the tab, a new or existing calibration must be created or loaded (see above). - -The interface allows for two kinds of focusing: - -- **Normal Focusing:** - Run numbers can be entered and both banks will be focused for each workspace. - The output workspaces will have a prefix for the run they are for and a suffix denoting which bank they are for. - -- **Cropped Focusing:** - The entered workspace can be cropped to one of the two banks or to a user defined set of spectra. - Workspaces cropped using custom spectra lists will have the suffix "cropped". - -Ticking the "Plot Focused Workspace" checkbox will create a plot of the focused workspace when the algorithm is -complete. The number of plots that are generated is dependent on the type of focusing done. Normal focusing generates -a plot for each bank and cropped focusing generates a plot for the single bank or one for the chosen spectra. - -Clicking the focus button will begin the focusing algorithm for the selected run files. The button and plotting checkbox -will be disabled until the fitting algorithm is complete. - -The focused output files are saved in NeXus, GSS, and raw XYE format to: - -`<CHOSEN_OUTPUT_DIRECTORY>/Focus/` - -If an RB number has been specified the files will also be saved to a user directory: - -`<CHOSEN_OUTPUT_DIRECTORY>/User/<RB_NUMBER>/Focus/` - -Parameters -^^^^^^^^^^ - -Sample Run Number - The run numbers of or file paths to the data files to be focused. - -Bank/Spectra - Select which bank to restrict the focusing to or allow for the entry of custom spectra. - -Custom Spectra - A comma separated list of spectra to restrict the calibration to. Can be provided as single spectrum numbers - or ranges using hyphens (e.g. 14-150, 405, 500-600). - -Fitting -------- - -**This tab is currently a work in progress!** - -This tab will allow for single peak fitting of focused run files. - -Focused run files can be loaded from the file system into mantid from the interface, which will keep track of all the -workspaces that it has created from these files. - -The plan for the rest of the functionality is to allow for loaded workspaces to be plotted in the interface. Peaks -could then be selected by clicking on the plot or by using a text field to enter peak centres in d-spacing. -Once the peaks have been selected, they would be fitted using the :ref:`Pseudo-Voigt <func-PseudoVoigt>` and -:ref:`BackToBackExponential <func-BackToBackExponential>` fit functions. - -The output from the fitting functions will be stored in a multidimensional file format, along with the sample logs for -the runs that have been fitted. - -Parameters -^^^^^^^^^^ - -Focused Run Files - A comma separated list of files to load. Selecting files from the file system using the browse button will do this - for you. - -Peak Positions - A comma separated list of peak positions to be used when performing the fit. diff --git a/docs/source/interfaces/Engineering Diffraction.rst b/docs/source/interfaces/Engineering Diffraction.rst index ac36fe86cb58fccd8a772c72e4f28d5fd364ac7e..89477dfa73a00c494143c17a0cd66574c8f5cce2 100644 --- a/docs/source/interfaces/Engineering Diffraction.rst +++ b/docs/source/interfaces/Engineering Diffraction.rst @@ -1,605 +1,171 @@ .. _Engineering_Diffraction-ref: Engineering Diffraction -======================= +========================= .. contents:: Table of Contents - :local: - -Overview --------- -This custom interface integrates several tasks related to engineering -diffraction. It provides functionality for calibration, focusing, and -pre-processing of event mode data. Further extensions can be expected -for future releases as it is under active development. Feedback is very -much welcome. The following sections describe the different tabs or -functionality areas of the interface. - -.. interface:: Engineering Diffraction - :align: center - :width: 400 - -General options + :local: + +Interface Overview +------------------ + +This custom interface will integrate several tasks related to engineering +diffraction. In its current state it provides functionality for creating +and loading calibration files and focusing ENGINX run files. + +Functionality for performing single peak fitting on focused run files is currently in progress. + +This interface is under active development. + +General Options ^^^^^^^^^^^^^^^ RB Number - To enable the GUI specify a RB Number (where "RB Number" usually - denotes the experiment reference number at ISIS). This reference - will be used for the output paths, so that files from different - users and/or experiments can be kept separate. + The reference number for the output paths (usually an experiment reference + number at ISIS). Leaving this field empty will result in no user directories + being created, and only the general directory will be used for file storage. Instrument - Select the instrument. Only ENGIN-X (ISIS) is supported in this version. + Select the instrument (ENGINX or IMAT). Currently only ENGINX is fully + supported. ? - Shows this documentation page. - -Close - Close the interface + Show this documentation page. -Status at the bottom of the interface - A short message will be displayed which indicates whether the last - important calculations finished successfully, and when the interface - is busy calculating (calibrating, focusing, fitting, etc.). +Settings + Provides a range of options that apply across the entire interface, currently + providing the option to change the default output directory and force the + recalculation of the vanadium correction files. -* Red Star Sign - If a red star sign is displayed next to the Browse Button, it is mostly - likely because the file specified has not been found. Error message - can be viewed by hovering over the red star sign. +Close + Close the interface. -.. _ui engineering calibration: +Red Stars + Red stars next to browse boxes and other fields indicate that the file + could not be found. Hover over the star to see more information. Calibration ----------- -This tab provides a graphical interface to calculate calibrations and -visualize them. - -It is possible to: - -- Generate a new calibration file (which becomes the new current - calibration) -- Load an existing calibration from a GSAS instrument - parameters file previously generated - -For the current calibration, the following parameters are displayed: - -- The vanadium run number -- The calibration sample run number -- The path to the output calibration file. - -This calibration file output is a GSAS instrument parameters file (IPARM/PAR/PRM). The interface -produces a calibration file containing all banks and in addition a calibration -file for every individual bank. All the calibration files are written -in the same directory. - -With the help of Cropped Calibration user can also calibrate according -to specific banks or by setting the Spectrum Numbers once the Cropped Calibration group -box has been enabled. +This tab currently provides a graphical interface to create new calibrations, using the +:ref:`EnggCalibrate<algm-EnggCalibrate>` algorithm, and visualise them. +It also allows for the loading of GSAS parameter files created by the calibration process +to load a previously created calibration into the interface. -The plot Calibrated Workspace check-box will enable user to plot -vanadium curves and Ceria peaks. For Ceria peaks there will be two -workspaces generated and plotted, one for each bank, whereas for a -cropped calibration there will only be one workspace generated -and plotted, depending on the selected bank or provided Spectrum -IDs. The workspace contains difa, difc and tzero data which is then -utilised to plot the Ceria peaks per bank, the graph will plot Peaks -Fitted and TOF Straight Line for comparison. More information -regarding the fit peaks can be found on the -:ref:`EnggFitPeaks<algm-EnggFitPeaks>` documentation. +When loading an existing calibration, the fields for creating a new calibration will be +automatically filled, allowing the recreation of the workspaces and plots generated by +creating a new calibration. -The calibration files are written into two different output -directories. First, they are written to a user specific directory -which for the ENGIN-X instrument on Windows systems is: +The "Plot Output" check-box will plot vanadium curves and ceria peaks for new calibrations. +Four plots will be generated (for ENGINX), one of each plot for each of the detector banks. -`C:\\EnginX_Mantid\\<Username>\\<RBNumber>\\Calibration` +Creating a new calibration file generates 3 GSAS instrument parameter files, +one covering all banks and separate ones for each individual bank. All 3 files are written +to the same directory: -On UNIX based platforms this path is: +`<CHOSEN_OUTPUT_DIRECTORY>/Calibration/` -`~/EnginX_Mantid/<Username>/<RBNumber>/Calibration` +If an RB number has been specified the files will also be saved to a user directory +in the base directory: -They are also copied into a general (all) output directory: +`<CHOSEN_OUTPUT_DIRECTORY>/User/<RB_NUMBER>/Calibration/` -`C:\\EnginX_Mantid\\Calibration` on Windows or +Cropping +^^^^^^^^ -`~/EnginX_Mantid/Calibration` on UNIX platforms. - -The calibration parameters for each bank are made available for user -inspection in a workspace named -**engggui_calibration_banks_parameters** which is updated when new -calibrations are loaded or calculated. +The interface also provides the ability to restrict a new calibration to one of the two banks +or to a custom list of spectra. Parameters ^^^^^^^^^^ -These parameters are required to generate new calibrations: - -Vanadium # - Number of the vanadium run used to correct calibration and experiment - runs. - -Calibration sample # - Number of the calibration sample run (for example Ceria run) used to - calibrate experiment runs. - -Bank Name: - This parameter is only required when Cropped Calibration is being - carried out. The bank name can be selected from a drop down list with - option of "North" and "South", which are equivalent to 1 and 2 - respectively. - Custom bank mappings can be created by setting the Bank Name option - to `Use spectrum numbers`. When the option *Use Spectrum Numbers* is - set a bank name must be specified in *Customise Bank Name*. - -Spectrum Numbers: - This parameter is only required when Cropped Calibration is being - carried out, the parameter will set the spectrum numbers of the - detectors, that should be considered in the calibration while all - others will be ignored. This option cannot be used together with - Bank Name, as they overlap. You may also give multiple ranges, for - example: "0-100", or "0-9", "150-750". - -Customise Bank Name: - This parameter is only required when Cropped Calibration is being - carried out with Spectrum Numbers, the parameter will set the workspace - and `.his` file name according to this Bank Name provided by the user. - However if the user does not provide a personalised name, the - interface will use "cropped" as a default bank name. - -The calibration process depends on several additional parameters and -settings which can be modified in the *Settings* tab, see :ref:`setting-Engineering_Diffraction-ref` for details. - -.. _focus-Engineering_Diffraction-ref: - -Focus ------ - -Here it is possible to focus run files, by providing a run number or a -range of run number to enable multi-run focusing, along with that the -user may also select the files with the help of Browse button. - -The focusing process uses the algorithm :ref:`EnggFocus -<algm-EnggFocus>`. In the documentation of the algorithm you can find -the details on how the input runs are focused. - -The interface will also create workspaces that can be inspected in the -workspaces window: - -1. The *engggui_focusing_input_ws workspace* for the data being focused -2. The *engggui_focusing_output_ws... workspace* for the corresponding - focused data (where the ... denotes a suffix explained below). - -Three focusing alternatives are provided: - -1. Normal focusing, which includes all the spectra from the input run. -2. Cropped focusing, where several spectra or ranges of spectra can - be specified, as a list separated by commas. -3. Texture focusing, where the *texture* group of detectors is given - in a Detector Grouping File. - -Depending on the alternative chosen, the focusing operation will -include different banks and/or combinations of spectra (detectors). -The behavior for each option is as follows: - -1. *Normal focusing* - All the selected banks and spectra present -in the input runs are considered. The output focused workspace will -be named with suffixes such as *_bank_1, _bank_2*, and so on - -2. *Cropped Focusing* - All the banks are considered in -principle but only a list of spectra provided manually are -processed. The output focused workspace will be named with -the suffix *_cropped*. - -3. *Texture Focusing* - The banks are selected by a user-defined -list of banks and corresponding spectrum numbers provided in a file. -The output workspaces will be named with suffixes such as *_texture_bank_1, -_texture_bank_2*, and so on. These suffixes are determined by the -bank IDs given in the detector grouping file. - -Cropped focusing and Texture focusing have been disabled by default to -declutter the interface, but each section can be enabled simply by -ticking the check-box next to Focus Cropped and Focus Texture. - -For texture focusing, the detector grouping file is a text (csv) file -with one line per bank. Each line must contain at least two numeric -fields, where the first one specifies the bank ID, and the second and -subsequent ones different spectrum numbers or ranges of spectrum -numbers. For example:: - - # Bank ID, spectrum numbers - 1, 205-210 - 2, 100, 102, 107 - 3, 300, 310, 320-329, 350-370 - -When a focus run process is being carried out, Focus Stop button will -be enabled. Focus Stop button will allow the user to abort once the -current focus run process has been completed. Inside the *Result Log* -a warning message will be displayed with last successful run and total -number of focus runs that could not be processed. - -The focused data files are saved in NeXus format into the user -specific and general directories (as with the calibration output -files). That is the files are written into -`C:\\EnginX_Mantid\\User\\<RBNumber>\\Calibration` and -`C:\\EnginX_Mantid\\Calibration` on Windows, or -`~/EnginX_Mantid/User/<RBNumber>/Calibration` and -`~/EnginX_Mantid/Calibration` on UNIX platforms. See below for -additional, optional outputs. - -Run Number -^^^^^^^^^^ -The run provided to focus can be for example 228061-228063, this will -run all the files within the given range as long as the file -directories are included in the -`User Directories <http://www.mantidproject.org/ManageUserDirectories>`_. -The user may also provide an input of 228061-3 or 228061, 228062, -2280623 which should work the same way. +Vanadium Number + The run number or file path used to correct the calibration and experiment runs. -If a red star sign is displayed next to the Browse Button, it is mostly -likely because the file specified has not been found. Error message -can be viewed by hovering over the red star sign. +Calibration Sample Number + The run number for the calibration sample run (such as ceria) used to calibrate + experiment runs. -Checking the availability of all the files can take some time, for this -reason it is also possible that a file may not have been found but the -red star sign has not been displayed. If you manage to click Focus -before red sign is displayed, the interface will process the last valid -focus run instead. +Path + The path to the GSAS parameter file to be loaded. -Output -^^^^^^ +Bank/Spectra + Select a bank to crop to or specify a custom spectra will be entered. -Under the output section, the user is provided with an option of -plotting data in three different formats. +Custom Spectra + A comma separated list of spectra to restrict the calibration to. Can be provided as single spectrum numbers + or ranges using hyphens (e.g. 14-150, 405, 500-600). -- One Window - Replacing Plots: will replace the previous graph and plot a new graph on top. +Focus +----- -- One Window - Waterfall: will plot all the generated focused workspace graphs in one window - which can be useful while comparing various graphs. +This tab allows for the focusing of data files by making use of the :ref:`EnggFocus<algm-EnggFocus>` algorithm. -- Multiple Windows - will plot graph in separate windows. +Files can be selected by providing run numbers or selecting the files manually using the browse button. -However, user may also change the Plot Data representation drop-down box while a run is being carried out. This -will update the interface and plot workspace according to the new given input. -For example, if a user has selected *One Window - Replacing Plots* and then decides to change it to *One Window - -Waterfall* during a run, the interface will carry on by plotting -Waterfall within the same window. +In order to use the tab, a new or existing calibration must be created or loaded (see above). -The user also has an option of saving GSS, XYE and OpenGenie formatted -files by clicking the Output Files checkbox. This will generate three -different files for each focused output workspace in Mantid. These -files can be found with appropriate name within: +The interface allows for two kinds of focusing: -`C:\\EnginX_Mantid\\<User>\\<RBNumber>\\Focus` on Windows or +- **Normal Focusing:** + Run numbers can be entered and both banks will be focused for each workspace. + The output workspaces will have a prefix for the run they are for and a suffix denoting which bank they are for. -`~/EnginX_Mantid/Foxus` on UNIX systems. +- **Cropped Focusing:** + The entered workspace can be cropped to one of the two banks or to a user defined set of spectra. + Workspaces cropped using custom spectra lists will have the suffix "cropped". -The files are also copied to the general (all) output directory which is +Ticking the "Plot Focused Workspace" checkbox will create a plot of the focused workspace when the algorithm is +complete. The number of plots that are generated is dependent on the type of focusing done. Normal focusing generates +a plot for each bank and cropped focusing generates a plot for the single bank or one for the chosen spectra. -`C:\\EnginX_Mantid\\Focus` on Windows +Clicking the focus button will begin the focusing algorithm for the selected run files. The button and plotting checkbox +will be disabled until the fitting algorithm is complete. -`~/EnginX_Mantid/Focus` under on UNIX systems +The focused output files are saved in NeXus, GSS, and raw XYE format to: -`The Multiple Runs Focus Mode` combo-box enables two alternative -focus modes. `Focus Individual Run Files Separately` is the default -option set, which allows user to run focus with multi-run files. -Whereas the `Focus Sum Of Files` option merges all the multi-run -number files together and applies the Focus Process to the merged -file. +`<CHOSEN_OUTPUT_DIRECTORY>/Focus/` -Pre-processing --------------- +If an RB number has been specified the files will also be saved to a user directory: -.. warning:: This is a new capability that is currently in a very - early stage of definition and implementation. Not all - options may be supported and/or consistent at the moment. +`<CHOSEN_OUTPUT_DIRECTORY>/User/<RB_NUMBER>/Focus/` -The focusing options can be applied directly to histogram data. For -event mode experiments, the event data (which would be loaded as event -workspaces in Mantid) need to be pre-processed. +Parameters +^^^^^^^^^^ -The simplest pre-processing option is "regular time binning" which -will produce a histogram data workspace (as a :ref:`Workspace2D -<Workspace2D>`). The only parameter required is the bin width. The -workspace will be named with the following convention: +Sample Run Number + The run numbers of or file paths to the data files to be focused. + +Bank/Spectra + Select which bank to restrict the focusing to or allow for the entry of custom spectra. -- *engggui_preproc_time_ws* +Custom Spectra + A comma separated list of spectra to restrict the calibration to. Can be provided as single spectrum numbers + or ranges using hyphens (e.g. 14-150, 405, 500-600). -When the input run file contains multiple workspaces (it would be -loaded by :ref:`Load <algm-Load>` as multiple :ref:`EventWorkspace -<EventWorkspace>` workspaces) the output workspace will be a group -with the corresponding number of histogram workspaces, binned -separately. This is the case when the input run file comes from a -multi-period experiment. Note that the time bin can be a multiple of -the pulse time. +Fitting +------- -A different way of pre-processing event data is by rebinning -multi-period data by pulse times. In this case the input required is -the time step for the binning (the x axis of the output will be time -instead of time-of-flight). It is also possible to specify the number -of periods that will be processed (starting from the first one). This -type of pre-processing produces workspaces with the following naming -convention: +**This tab is currently a work in progress!** -- *engggui_preproc_by_pulse_time_ws* +This tab will allow for single peak fitting of focused run files. -Focussing uses the algorithms :ref:`Rebin <algm-Rebin>` and :ref:`RebinByPulseTimes -<algm-RebinByPulseTimes>` to bin the data in different ways when -converting event data into histogram data. +Focused run files can be loaded from the file system into mantid from the interface, which will keep track of all the +workspaces that it has created from these files. -Fitting -------- +The plan for the rest of the functionality is to allow for loaded workspaces to be plotted in the interface. Peaks +could then be selected by clicking on the plot or by using a text field to enter peak centres in d-spacing. +Once the peaks have been selected, they would be fitted using the :ref:`Pseudo-Voigt <func-PseudoVoigt>` and +:ref:`BackToBackExponential <func-BackToBackExponential>` fit functions. -.. warning:: This is a new capability that is currently in a very - early stage of definition and implementation. Not all - options may be supported and/or consistent at the moment. - -.. warning:: The input workspace must be converted into a focused file - first. The steps to complete this are found here: :ref:`focus-Engineering_Diffraction-ref` - -The Fitting tab provides a graphical interface which fits an expected -diffraction pattern and visualises them. The pattern is specified by -providing a list of peak centre values where Bragg peaks are expected. -These values can have units of either TOF of dSpacing but **not** both. -The algorithm :ref:`EnggFitPeaks<algm-EnggFitPeaks>` is used to -background fit peaks in those areas using a peak fitting function. - -To use the Fitting tab, user is required to follow these steps: - -1. Load run(s) to perform fitting on by browsing for focused nexus - files *User may click Load button to load the focused file to the - canvas* -2. List of expected peaks which can be either by browsing a (*CSV*) file, - manually selecting peaks from the canvas using peak picker tool and the "Add Peak to List" button after - loading the focused file or by entering the peaks list within the text-field -3. Next click on the *Fit* button if you would like to fit single focused - file or you can click *Fit All* button which will enable user to - batch-process all the runs and banks when several files are loaded. - *Fit All* process may also be used when a single run number is given - or a file is browsed - -.. _ExpectedPeaks-Engineering_Diffraction-ref: +The output from the fitting functions will be stored in a multidimensional file format, along with the sample logs for +the runs that have been fitted. Parameters ^^^^^^^^^^ -These parameters are required to process Fitting successfully: - -Focused Run files: - .nxs files containing focused diffraction data. These should be the result - of focusing data with the :ref:`focus-Engineering_Diffraction-ref` tab. - -Peaks: - A list of dSpacing values to be translated into TOF to find expected - peaks. These peaks can be manually written or imported by selecting a - (*CSV*) file. - -Output -^^^^^^ - -Once the Fit button has been clicked Mantid will process the data. Please wait -until the Fitting process has completed. Upon completion you should be able to -view the Fitting tab which will contain: - -- The focused workspace plotted in the background in gray crosses. -- The expected peaks plotted in various colours overlapping the - focused workspace peaks. - -Within the :ref:`Preview-Engineering_Diffraction-ref` section a user is -able to zoom-in or zoom-out as well as select, add and save peaks. - -The interface will also generate workspaces that can be inspected in the -workspaces window: - -1. The *engggui_fitting_fitpeaks_param* Table workspace - with the parameters of the peaks found and fitted. -2. The *engggui_fitting_focused_ws* Focused workspace also loaded - so the fitted data can be compared with focused data -3. The *engggui_fitting_single_peaks* workspace with each workspace - index representing individual expected peak. - -During the Fit process, :ref:`EnggSaveSinglePeakFitResultsToHDF5 -<algm-EnggSaveSinglePeakFitResultsToHDF5>` algorithm will be utilised -to save *engggui_fitting_fitpeaks_param* TableWorkspace as a `hdf5` -file. There will one file per run, indexed by bank ID, and the file -will be found in the **Runs** directory of the user's output -directory. If **Fit All** was run on multiple runs, then an additional -file for all runs will be output, which is indexed first by run number -and then by bank ID. - -In the plots, the x or abscissa axis is in d-spacing units, which are -more convenient for peak fitting than time-of-flight. However the run -files and the focus files are normally stored as time-of-flight -data. For this reason a conversion from the time-of-flight data to -d-spacing is required. The conversion is performed using the current -calibration of banks. The interface handles this internally and adds -special sample logs to the fitting workspaces -(*engggui_fitting_single_peaks* and *engggui_fitting_focused_ws*). By -inspecting the sample logs of these workspaces. The conversion is -performed using the `GSAS -<https://subversion.xray.aps.anl.gov/trac/pyGSAS>`__ equations, as -calculated by the algorithm :ref:`AlignDetectors -<algm-AlignDetectors>` - -.. _Preview-Engineering_Diffraction-ref: - -Preview -^^^^^^^ -Once the fitting process has completed and you are able to view a -focused workspace with listed expected peaks on the data plot, the *Select -Peak* button should also be enabled. If the user choose to load the focus -workspace or if fitting fails with the given peaks then the focused -workspace will be plotted so that the user can select the peaks manually. - -If you've run a fit but you can't see the reconstructed peaks, make sure -the checkbox **Plot fitted peaks** is checked - if the fit was successful, -then clicking this should show the results. Equally, if you want to hide -fitted peaks, just uncheck this box and they will disappear. - -By clicking Select Peak button the peak picker tool can be activated. -To select a peak simply hold *Shift* key and left-click on the graph -near the peak's center. - -To get help selecting the center of the peak, you may set the peak -width by left-click and drag horizontally, while holding *Ctrl* key -as well. Users may also zoom-in to the graph by holding left-click -and dragging a box on the plot, and zoom-out by left-clicking on -the plot. - -When user is happy with the center position of the peak, you may -add the selected peak to :ref:`ExpectedPeaks-Engineering_Diffraction-ref` -list by clicking Add Peak button. User may rerun Fit process by -clearing peaks list using Clear button and manually selecting peaking -using Select Peak button or instead Save the peaks list in *CSV* file -by clicking Save button. - -User may plot single peak fitting workspace in separate window by using -Plot To Separate Window button, if the *engggui_fitting_single_peaks* -is available. - -.. _gsas-Engineering_Diffraction-ref: - -GSAS Fitting ------------- - -.. warning:: This is a new capability that is currently in a very - early stage of definition and implementation. Not all - options may be supported and/or consistent at the moment. - -The GSAS tab provides a graphical interface to the Mantid algorithm -:ref:`GSASIIRefineFitPeaks <algm-GSASIIRefineFitPeaks>`. This allows -users to perform GSAS-style fitting on their data from Mantid. - -The user must input the following files: - -- **Focused run file(s)** - these must have been generated either by - the **Fitting** tab or :ref:`EnggFocus <algm-EnggFocus>`. -- **Instrument Parameter File** - contains DIFA and DIFC GSAS - constants, will probably be of ``.prm`` format -- **Phase file(s)** - contain crystallographic information about the - sample in question. Currently only ``.cif`` files are supported - -The following parameters are also required: - -- **New GSAS-II Project** - GSASIIRefineFitPeaks creates a new - ``.gpx`` project here, which can be opened and inspected from the - GSAS-II GUI - - - Note, if running **Refine All** on more than one run, the run - number and bank ID will be appended to the filename -- **GSAS-II Installation Directory** - - - This is the directory containing the GSAS-II executables and - Python libraries. In particular, it must contain - ``GSASIIscriptable.py``. This directory will normally be called - `GSASII`, if GSAS-II was installed normally - - You must have a version of GSAS-II from at least **February 2018** - to use the GUI. See :ref:`Installing_GSASII` for how to install a - compatible version -- **Refinement method** - can either be **Pawley** or - **Rietveld**. Pawley refinement is currently under development, so - Rietveld is recommended. - -Optionally, you may also supply: - -- **XMin** and **XMax** - the limits (in TOF) to perform fitting - within -- **DMin** - the minimum dSpacing to use for refinement when - performing Pawley refinement -- **Negative weight** - The weight for a penalty function applied - during a Pawley refinement on resulting negative intensities. - -To do a refinement, take the following steps: - -1. Load a run by selecting the focused NeXuS file using the - corresponding **Browse** button, then clicking **Load**. The run - number and bank ID (for example ``123456_1``) should appear in the - **Run Number** list in the **Preview** section. Click the label, - and the run will be plotted -2. Select your input files, and input any additional parameters in the - **GSASIIRefineFitPeaks Controls** section -3. Click **Run Refinement**. Once complete, fitted peaks for the run - should be overplotted in the fitting area. In addition, Rwp - (goodness of fit index), Sigma and Gamma (peak broadening - coefficients) and lattice parameters should be displayed in the - **Fit Results** section. - - - You can also click **Refine All** to run refinement on all runs - loaded into GSAS tab - -During the Fit process, :ref:`EnggSaveGSASIIFitResultsToHDF5 -<algm-EnggSaveGSASIIFitResultsToHDF5>` algorithm will be utilised to -save the fit results, and also the parameters used, as a `hdf5` -file. There will be one file per run, indexed by bank ID, and the file -will be found in the **Runs** directory of the user's output -directory. - -You can toggle the fitted peaks on and off with the **Plot Fitted -Peaks** checkbox, remove runs from the list with the **Remove Run** -button, and plot the run and fitted peaks to a larger, separate plot -using **Plot to separate window**. - -.. _setting-Engineering_Diffraction-ref: +Focused Run Files + A comma separated list of files to load. Selecting files from the file system using the browse button will do this + for you. -Settings --------- - -Controls several settings, including the input folders where the -instrument run files can be found. Other advanced options can also be -controlled to customize the way the underlying calculations are -performed. - -Calibration Parameters -^^^^^^^^^^^^^^^^^^^^^^ - -The calibration settings are organized in three blocks: - -1. Input directories -2. Pixel (full) calibration -3. Advanced settings - -The input directories will be used when looking for run files -(Vanadium and Ceria). They effectively become part of the search path -of Mantid when using this interface. - -The pixel (full) calibration file contains the calibration details of -every pixel of all banks, as produced by the algorithm -:ref:`EnggCalibrateFull <algm-EnggCalibrateFull>`. A default pixel -calibration file is provided with Mantid packages. This calibration -has been produced for the Vanadium and calibration sample (Ceria) runs -indicated in the name of the calibration file. Note that this -calibration is currently subject to changes, as the fitting of peaks -is being refined. - -The Following advanced settings are available to customize the -behavior of this interface: - -Force recalculate all existing Vanadium files - If this is enabled, Vanadium corrections will be recalculated even - if previous correction results are available for the current Vanadium - run number. This is not required unless a modification is done to the - original Vanadium run file, or there is a change in the algorithms - that calculate the corrections - -Template .prm file - By changing this option you can Use a different template file for - the output GSAS IPAR/PAR/PRM that is generated in the Calibration - tab. - -Rebin for Calibrate - This sets a rebin width parameter that can be used by underlying - algorithms such as :ref:`EnggCalibrate <algm-EnggCalibrate>` and - :ref:`EnggFocus <algm-EnggFocus>` - -Algorithms ----------- - -Most of the functionality provided by this interface is based on the -engineering diffraction Mantid algorithms (which are named with the -prefix *Engg*). This includes :ref:`EnggCalibrate -<algm-EnggCalibrate>`, :ref:`EnggCalibrateFull -<algm-EnggCalibrateFull>`, :ref:`EnggVanadiumCorrections -<algm-EnggVanadiumCorrections>`, :ref:`EnggFocus <algm-EnggFocus>`, -:ref:`EnggFitPeaks<algm-EnggFitPeaks>` -and several other algorithms, explained in detail in the following Mantid -algorithms documentation pages. - -.. categories:: Interfaces Diffraction +Peak Positions + A comma separated list of peak positions to be used when performing the fit. diff --git a/docs/source/release/v4.3.0/diffraction.rst b/docs/source/release/v4.3.0/diffraction.rst index 56f6524240f745d2d2ee9b3d11f482f6b68c61e0..7331107f9f0b761719ffc0000dff23376904162f 100644 --- a/docs/source/release/v4.3.0/diffraction.rst +++ b/docs/source/release/v4.3.0/diffraction.rst @@ -14,7 +14,7 @@ New Features Engineering Diffraction ----------------------- -- Introduction of Engineering Diffraction 2 interface. Currently supports calibration and focusing for ENGINX. +- Introduction of new Engineering Diffraction interface. Currently supports calibration and focusing for ENGINX. Improvements diff --git a/docs/source/release/v4.3.0/mantidworkbench.rst b/docs/source/release/v4.3.0/mantidworkbench.rst index eee9536525dce53ad0ccf867650b9f8beb88e17e..beb74673b85090a6a17ba74201ad794addcc9a7c 100644 --- a/docs/source/release/v4.3.0/mantidworkbench.rst +++ b/docs/source/release/v4.3.0/mantidworkbench.rst @@ -106,5 +106,6 @@ Bugfixes - Overplots will be normalized by bin width if they are overplotting a curve from a workspace which is a distribution. - Several bugs in the way Python scripts were parsed and executed, including blank lines after a colon and tabs in strings, have been fixed. - Axes limits of a plot no longer automatically rescale when errorbars are on/off +- Fixed a crash in the TOFConverter interface when leaving input fields blank or using invalid characters. :ref:`Release 4.3.0 <v4.3.0>` diff --git a/docs/source/release/v4.3.0/sans.rst b/docs/source/release/v4.3.0/sans.rst index 8378b6edec8ed8ca9b23b30095bc74baf544a6b2..74e1808d81e67c4f27a622e58c341c91aba78041 100644 --- a/docs/source/release/v4.3.0/sans.rst +++ b/docs/source/release/v4.3.0/sans.rst @@ -48,6 +48,7 @@ Fixed radius limits, which previously summed the difference across different numbers of points. - Bug fixed affecting SANS > ORNL_SANS interface - only facilities with applicable instruments can now be selected. +- Bug fixed causing ORNL_SANS interface to crash when selecting HFIR instruments :ref:`Release 4.3.0 <v4.3.0>` diff --git a/qt/applications/workbench/workbench/plugins/workspacewidget.py b/qt/applications/workbench/workbench/plugins/workspacewidget.py index 67a398ad1a5acfff35d6d06bd13a4c73f1d23d23..4af40c31a6002720ab813e5021c68c3972e0cc97 100644 --- a/qt/applications/workbench/workbench/plugins/workspacewidget.py +++ b/qt/applications/workbench/workbench/plugins/workspacewidget.py @@ -138,8 +138,8 @@ class WorkspaceWidget(PluginWidget): except Exception as exception: logger.warning("Could not open sample logs for workspace '{}'." "".format(ws.name())) - logger.debug("{}: {}".format(type(exception).__name__, - exception)) + logger.warning("{}: {}".format(type(exception).__name__, + exception)) def _do_slice_viewer(self, names): """ diff --git a/qt/python/mantidqt/widgets/samplelogs/model.py b/qt/python/mantidqt/widgets/samplelogs/model.py index d08316773dcb30ea6383a116d5510f20125258b8..d69c98a12e92e661e9f1f9c0f67adcdf4e2fb7af 100644 --- a/qt/python/mantidqt/widgets/samplelogs/model.py +++ b/qt/python/mantidqt/widgets/samplelogs/model.py @@ -10,7 +10,7 @@ from __future__ import (absolute_import, division, print_function) from mantid.kernel import (BoolTimeSeriesProperty, FloatTimeSeriesProperty, Int32TimeSeriesProperty, - Int64TimeSeriesProperty, StringTimeSeriesProperty) + Int64TimeSeriesProperty, StringTimeSeriesProperty, logger) from mantid.api import MultipleExperimentInfos from qtpy.QtGui import QStandardItemModel, QStandardItem @@ -55,6 +55,7 @@ class SampleLogsModel(object): """This class stores the workspace object and return log values when requested """ + def __init__(self, ws): """Stores three thing:, the workspace, which experiment info number to use, and the run object. @@ -126,23 +127,27 @@ class SampleLogsModel(object): """Return a QModel made from the current workspace. This should be set onto a QTableView """ + + def create_table_item(column, itemname, callable, *args): + item = QStandardItem() + item.setEditable(False) + try: + item.setText(callable(*args)) + except Exception as exc: + logger.warning("Error setting column {} for log {}: {}".format(column, itemname, str(exc))) + + return item + model = QStandardItemModel() model.setHorizontalHeaderLabels(["Name", "Type", "Value", "Units"]) model.setColumnCount(4) for key in self.get_log_names(): log = self.run.getLogData(key) - name = QStandardItem() - name.setText(log.name) - name.setEditable(False) - log_type = QStandardItem() - log_type.setText(get_type(log)) - log_type.setEditable(False) - value = QStandardItem() - value.setText(str(get_value(log))) - value.setEditable(False) - unit = QStandardItem() - unit.setText(log.units) - unit.setEditable(False) + name = create_table_item("Name", key, lambda: log.name) + log_type = create_table_item("Type", key, get_type, log) + value = create_table_item("Value", key, lambda log: str(get_value(log)), log) + unit = create_table_item("Units", key, lambda: log.units) model.appendRow((name, log_type, value, unit)) + model.sort(0) return model diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index 5a5e210361df42860f3599012f3c5d622ecc97b9..4e7f9c954af3d60c33c028697d811475f93c80c4 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -28,7 +28,8 @@ namespace MantidQt { namespace CustomInterfaces { // Add this class to the list of specialised dialogs in this namespace -DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI) +// Hidden for release of 5.0 to be removed as a maintainance issue. +// DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI) const double EnggDiffractionViewQtGUI::g_defaultRebinWidth = -0.0005; diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h index e9b0aeee81022ef6ccae356b92ca56f9f3d1d32b..53dc26e1855ce6bb3040aa639d6048e63105e784 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h @@ -49,7 +49,7 @@ public: /// Default Constructor EnggDiffractionViewQtGUI(QWidget *parent = nullptr); /// Interface name - static std::string name() { return "Engineering Diffraction"; } + static std::string name() { return "Engineering Diffraction (Old)"; } /// This interface's categories. static QString categoryInfo() { return "Diffraction"; } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp index 665dee88a8ae31de40a8a0eda70f2bc66350e032..afb03025396c258b6f84288baa6fa2fcd9a96946 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp @@ -263,7 +263,8 @@ QString IndirectFitAnalysisTab::selectedFitType() const { */ size_t IndirectFitAnalysisTab::numberOfCustomFunctions( const std::string &functionName) const { - if (auto fittingFunction = m_fittingModel->getFittingFunction()) + auto fittingFunction = m_fittingModel->getFittingFunction(); + if (fittingFunction->nFunctions() > 0) return getNumberOfSpecificFunctionContained( functionName, fittingFunction->getFunction(0).get()); else diff --git a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py index 518b615fedbc06ea225f1f4804a3d223f5aed02d..4627ee476a7577b1f1256252fb8fb69afe71a63d 100644 --- a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py +++ b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py @@ -29,14 +29,14 @@ Ui_main_window, _ = load_ui(__file__, "main_window.ui") class EngineeringDiffractionGui(QtWidgets.QMainWindow, Ui_main_window): """ - The engineering diffraction interface v2.0 + The engineering diffraction interface """ def __init__(self, parent=None): super(EngineeringDiffractionGui, self).__init__(parent) # Main Window self.setupUi(self) - self.doc = "Engineering Diffraction 2" + self.doc = "Engineering Diffraction" self.tabs = self.tab_main self.setFocusPolicy(QtCore.Qt.StrongFocus) self.calibration_presenter = None diff --git a/scripts/Engineering_Diffraction_2.py b/scripts/Engineering_Diffraction.py similarity index 100% rename from scripts/Engineering_Diffraction_2.py rename to scripts/Engineering_Diffraction.py diff --git a/scripts/ExternalInterfaces/CMakeLists.txt b/scripts/ExternalInterfaces/CMakeLists.txt index 89e7ec8cffb18c8dcc8b69975777d2bffc4bdf42..487df63307b067d397d75f86d3d607a5953d2c36 100644 --- a/scripts/ExternalInterfaces/CMakeLists.txt +++ b/scripts/ExternalInterfaces/CMakeLists.txt @@ -8,7 +8,7 @@ externalproject_add(mslice GIT_REPOSITORY "https://github.com/mantidproject/mslice.git" GIT_TAG - 98510b984f4efd0e8fbadac60d813e825aad01ae + 186173f5b6f14bf43b708a662e7c5544cfcbf2ea EXCLUDE_FROM_ALL 1 CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py b/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py index b8115d4e78adbb33dd6ea5ba6c9bb63de7fefac6..5e23eb7689c3676e14fe36bb8f3b0e8ebbfc96af 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py +++ b/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py @@ -61,7 +61,7 @@ class DirectBeam(BaseWidget): self._content.sample_plot.clicked.connect(self._sample_plot_clicked) self._content.direct_plot.clicked.connect(self._direct_plot_clicked) - if not self._has_instrumentview: + if not self._has_instrument_view: self._content.sample_plot.hide() self._content.direct_plot.hide() diff --git a/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py b/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py index 3555cf034ea480fc6467b7b1f3f8ca2f0bcc6c0b..29a7fdab3b9dbedc98628a9df15c0d10a93472b1 100644 --- a/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py +++ b/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py @@ -1660,7 +1660,7 @@ class SANSDataProcessorGui(QMainWindow, # Hedge for trying to read out try: return RangeStepType(q_1d_step_type_as_string) - except RuntimeError: + except ValueError: return None @q_1d_step_type.setter diff --git a/scripts/SANS/sans/gui_logic/models/batch_process_runner.py b/scripts/SANS/sans/gui_logic/models/batch_process_runner.py index c3df6ebd075390dd856c2103a77499f055584894..7cde807935f03f663c2616f765611b4b07fed658 100644 --- a/scripts/SANS/sans/gui_logic/models/batch_process_runner.py +++ b/scripts/SANS/sans/gui_logic/models/batch_process_runner.py @@ -4,9 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + +import traceback + +import six from qtpy.QtCore import Slot, QThreadPool, Signal, QObject from six import itervalues +from mantid.kernel import Logger from sans.algorithm_detail.batch_execution import load_workspaces_from_states from sans.common.enums import ReductionMode from sans.sans_batch import SANSBatchReduction @@ -23,6 +27,7 @@ class BatchProcessRunner(QObject): self.row_failed_signal.connect(notify_error) self.notify_done = notify_done self.batch_processor = SANSBatchReduction() + self._logger = Logger("SANS") self._worker = None @Slot() @@ -62,7 +67,7 @@ class BatchProcessRunner(QObject): try: states, errors = get_states_func(row_entries=[row]) except Exception as e: - self.row_failed_signal.emit(index, str(e)) + self._handle_err(index, e) continue assert len(states) + len(errors) == 1, \ @@ -76,7 +81,7 @@ class BatchProcessRunner(QObject): out_scale_factors, out_shift_factors = \ self.batch_processor([state], use_optimizations, output_mode, plot_results, output_graph, save_can) except Exception as e: - self.row_failed_signal.emit(index, str(e)) + self._handle_err(index, e) continue if state.reduction.reduction_mode == ReductionMode.MERGED: @@ -92,7 +97,7 @@ class BatchProcessRunner(QObject): try: states, errors = get_states_func(row_entries=[row]) except Exception as e: - self.row_failed_signal.emit(index, str(e)) + self._handle_err(index, e) continue for error in itervalues(errors): @@ -103,4 +108,12 @@ class BatchProcessRunner(QObject): load_workspaces_from_states(state) self.row_processed_signal.emit(index, [], []) except Exception as e: - self.row_failed_signal.emit(index, str(e)) + self._handle_err(index, e) + continue + + def _handle_err(self, index, e): + # We manually have to extract out the traceback, since going to a str for Qt signals will strip this + if six.PY3: + self._logger.error(''.join(traceback.format_tb(e.__traceback__))) + self._logger.error(str(e)) + self.row_failed_signal.emit(index, str(e)) diff --git a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py index 0ac9475eaf97e7ab208207a442178f3b2f421b79..d8933facb197d2dacb90317010615b4c04dee58c 100644 --- a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py @@ -631,7 +631,6 @@ class RunTabPresenter(PresenterCommon): row = self._table_model.get_row(row_index) row.state = RowState.ERROR row.tool_tip = error_msg - self.sans_logger.error(error_msg) self.update_view_from_table_model() def on_processing_finished(self, result): diff --git a/scripts/TofConverter/converterGUI.py b/scripts/TofConverter/converterGUI.py index 68bb6209cbbf7ddab33f331fb35cd4c92f049359..9729ea93523bfd9cbf87612e73a466178954dec4 100644 --- a/scripts/TofConverter/converterGUI.py +++ b/scripts/TofConverter/converterGUI.py @@ -15,7 +15,6 @@ from mantidqt.gui_helper import show_interface_help import math import TofConverter.convertUnits - try: from mantidqt.utils.qt import load_ui except ImportError: @@ -29,24 +28,24 @@ class MainWindow(QMainWindow): needsFlightPathInputList = ['Time of flight (microseconds)'] needsFlightPathOutputList = ['Time of flight (microseconds)'] - def thetaEnable (self, enabled): + def thetaEnable(self, enabled): self.ui.scatteringAngleInput.setEnabled(enabled) - if not enabled: + if not enabled: self.ui.scatteringAngleInput.clear() - def flightPathEnable (self, enabled): + def flightPathEnable(self, enabled): self.ui.totalFlightPathInput.setEnabled(enabled) - if not enabled: + if not enabled: self.ui.totalFlightPathInput.clear() - def setInstrumentInputs (self): + def setInstrumentInputs(self): #disable both self.thetaEnable(False) self.flightPathEnable(False) #get the values of the two unit strings - inOption=self.ui.inputUnits.currentText() - outOption=self.ui.outputUnits.currentText() + inOption = self.ui.inputUnits.currentText() + outOption = self.ui.outputUnits.currentText() #for theta: enable if input or output unit requires it if inOption in self.needsThetaInputList: @@ -63,7 +62,7 @@ class MainWindow(QMainWindow): self.flightPathEnable(True) def __init__(self, parent=None): - QMainWindow.__init__(self,parent) + QMainWindow.__init__(self, parent) self.ui = load_ui(__file__, 'converter.ui', baseinstance=self) self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal)) self.ui.totalFlightPathInput.setValidator(QDoubleValidator(self.ui.totalFlightPathInput)) @@ -83,7 +82,7 @@ class MainWindow(QMainWindow): self.assistant_process = QtCore.QProcess(self) # pylint: disable=protected-access import mantid - self.mantidplot_name='TOF Converter' + self.mantidplot_name = 'TOF Converter' self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc') version = ".".join(mantid.__version__.split(".")[:2]) self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/TOF Converter.html' @@ -92,16 +91,14 @@ class MainWindow(QMainWindow): try: import mantid #register startup - mantid.UsageService.registerFeatureUsage(mantid.kernel.FeatureType.Interface,"TofConverter",False) + mantid.UsageService.registerFeatureUsage(mantid.kernel.FeatureType.Interface, + "TofConverter", False) except ImportError: pass def helpClicked(self): - show_interface_help(self.mantidplot_name, - self.assistant_process, - self.collection_file, - self.qt_url, - self.external_url) + show_interface_help(self.mantidplot_name, self.assistant_process, self.collection_file, + self.qt_url, self.external_url) def closeEvent(self, event): self.assistant_process.close() @@ -119,23 +116,24 @@ class MainWindow(QMainWindow): raise RuntimeError("Input value must be greater than 0 for conversion") inOption = self.ui.inputUnits.currentText() outOption = self.ui.outputUnits.currentText() - if self.ui.totalFlightPathInput.text() !='': + if self.ui.totalFlightPathInput.text(): self.flightpath = float(self.ui.totalFlightPathInput.text()) else: self.flightpath = -1.0 - if self.ui.scatteringAngleInput.text() !='': + if self.ui.scatteringAngleInput.text(): self.Theta = float(self.ui.scatteringAngleInput.text()) * math.pi / 360.0 + else: + self.Theta = -1.0 - self.output = TofConverter.convertUnits.doConversion(self.ui.InputVal.text(), inOption, outOption, self.Theta, self.flightpath) + self.output = TofConverter.convertUnits.doConversion(self.ui.InputVal.text(), inOption, + outOption, self.Theta, + self.flightpath) self.ui.convertedVal.clear() self.ui.convertedVal.insert(str(self.output)) - except UnboundLocalError as ule: - QMessageBox.warning(self, "TofConverter", str(ule)) - return - except ArithmeticError as ae: - QMessageBox.warning(self, "TofConverter", str(ae)) + except (UnboundLocalError, ArithmeticError, ValueError, RuntimeError) as err: + QMessageBox.warning(self, "TofConverter", str(err)) return - except RuntimeError as re: - QMessageBox.warning(self, "TofConverter", str(re)) + except Exception as exc: + Logger.error(exc) return