-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement powder data reduction GUI. Refs #6555.
Add powder reduction GUI to MantidPolot.
- Loading branch information
Showing
23 changed files
with
5,704 additions
and
2 deletions.
There are no files selected for viewing
742 changes: 742 additions & 0 deletions
742
Code/Mantid/Framework/PythonInterface/PythonAlgorithms/SNSPowderReductionPlus.py
Large diffs are not rendered by default.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
Code/Mantid/scripts/Interface/reduction_gui/instruments/diffraction_interface_dev.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from interface import InstrumentInterface | ||
|
||
from reduction_gui.widgets.diffraction.diffraction_run_setup import RunSetupWidget | ||
from reduction_gui.widgets.diffraction.diffraction_van_setup import VanadiumSetupWidget | ||
from reduction_gui.widgets.diffraction.diffraction_filter_setup import FilterSetupWidget | ||
|
||
# from reduction_gui.widgets.inelastic.dgs_data_corrections import DataCorrectionsWidget | ||
# from reduction_gui.widgets.inelastic.dgs_diagnose_detectors import DiagnoseDetectorsWidget | ||
# from reduction_gui.widgets.inelastic.dgs_absolute_units import AbsoluteUnitsWidget | ||
# from reduction_gui.widgets.inelastic.dgs_pd_sc_conversion import PdAndScConversionWidget | ||
|
||
from reduction_gui.reduction.diffraction.diffraction_reduction_script import DiffractionReductionScripter | ||
|
||
class DiffractionInterface(InstrumentInterface): | ||
""" | ||
Defines the widgets for direct geometry spectrometer reduction | ||
""" | ||
# Allowed extensions for loading data files | ||
data_type = "Data files *.* (*.*)" | ||
|
||
|
||
def __init__(self, name, settings): | ||
super(DiffractionInterface, self).__init__(name, settings) | ||
|
||
self.ERROR_REPORT_NAME = "diffraction_error_report.xml" | ||
|
||
# Scripter object to interface with Mantid | ||
self.scripter = DiffractionReductionScripter(name=name, facility=settings.facility_name) | ||
|
||
# Tab Test: Sample run setup (Test case. Will be removed later) | ||
# self.attach(SampleSetupWidget(settings = self._settings, data_type = self.data_type)) | ||
|
||
# Tab 1: Run number setup (Will be the first one) | ||
self.attach(RunSetupWidget(settings = self._settings, data_type = self.data_type)) | ||
|
||
# Tab 2: Advanced and Vanadium number setup | ||
self.attach(VanadiumSetupWidget(settings = self._settings, data_type = self.data_type)) | ||
|
||
# Tab 3: Event filters setup | ||
self.attach(FilterSetupWidget(settings = self._settings, data_type = self.data_type)) | ||
|
||
# Data corrections | ||
# self.attach(DataCorrectionsWidget(settings = self._settings, | ||
# data_type = self.data_type)) | ||
|
||
# Diagnose detectors | ||
# self.attach(DiagnoseDetectorsWidget(settings = self._settings, | ||
# data_type = self.data_type)) | ||
|
||
# Absolute units normalisation | ||
# self.attach(AbsoluteUnitsWidget(settings = self._settings, | ||
# data_type = self.data_type)) | ||
|
||
# Powder and Single Crystal conversion | ||
#self.attach(PdAndScConversionWidget(settings = self._settings, | ||
# data_type = self.data_type)) | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
228 changes: 228 additions & 0 deletions
228
.../scripts/Interface/reduction_gui/reduction/diffraction/diffraction_filter_setup_script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
""" | ||
Classes for each reduction step. Those are kept separately | ||
from the the interface class so that the DgsReduction class could | ||
be used independently of the interface implementation | ||
""" | ||
import os | ||
import time | ||
import xml.dom.minidom | ||
|
||
from reduction_gui.reduction.scripter import BaseScriptElement | ||
|
||
class FilterSetupScript(BaseScriptElement): | ||
""" Run setup script for tab 'Run Setup' | ||
""" | ||
|
||
# Class static variables | ||
starttime = "" | ||
stoptime = "" | ||
timeinterval = 1 | ||
unitoftime = "Seconds" | ||
logname = "" | ||
minimumlogvalue = "" | ||
maximumlogvalue = "" | ||
logvalueinterval = "" | ||
filterlogvaluebychangingdirection = "Both" | ||
timetolerance = "" | ||
logboundary = "" | ||
logvaluetolerance = "" | ||
logvaluetimesections = 1 | ||
titleofsplitters = "" | ||
|
||
def __init__(self, inst_name): | ||
""" Initialization | ||
""" | ||
super(FilterSetupScript, self).__init__() | ||
self.createParametersList() | ||
|
||
self.set_default_pars(inst_name) | ||
self.reset() | ||
|
||
return | ||
|
||
def createParametersList(self): | ||
""" Create a list of parameter names for SNSPowderReductionPlus() | ||
""" | ||
self.parnamelist = [] | ||
self.parnamelist.append("FilterByTimeMin") | ||
self.parnamelist.append("FilterByTimeMax") | ||
self.parnamelist.append("TimeInterval") | ||
self.parnamelist.append("UnitOfTime") | ||
self.parnamelist.append("LogName") | ||
self.parnamelist.append("MinimumLogValue") | ||
self.parnamelist.append("MaximumLogValue") | ||
self.parnamelist.append("LogValueInterval") | ||
self.parnamelist.append("FilterLogValueByChangingDirection") | ||
self.parnamelist.append("TimeTolerance") | ||
self.parnamelist.append("LogBoundary") | ||
self.parnamelist.append("LogValueTolerance") | ||
self.parnamelist.append("LogValueTimeSections") | ||
self.parnamelist.append("TitleOfSplitters") | ||
|
||
return | ||
|
||
def set_default_pars(self, inst_name): | ||
|
||
# import dgs_utils | ||
# ip = dgs_utils.InstrumentParameters(inst_name) | ||
# RunSetupScript.monitor1_specid = int(ip.get_parameter("ei-mon1-spec")) | ||
# RunSetupScript.monitor2_specid = int(ip.get_parameter("ei-mon2-spec")) | ||
|
||
return | ||
|
||
def to_script(self): | ||
""" 'Public' method to save the current GUI to string via str() and general class ReductionScript | ||
""" | ||
# 1. Check inputs | ||
|
||
|
||
# 2. Output values | ||
parnamevaluedict = self.buildParameterDict() | ||
script = "" | ||
for parname in self.parnamelist: | ||
parvalue = parnamevaluedict[parname] | ||
if parvalue != "": | ||
script += "%-10s = \"%s\"" % (parname, parvalue) | ||
if parname != self.parnamelist[-1]: | ||
script += ",\n" | ||
#ENDFOR | ||
|
||
return script | ||
|
||
|
||
def buildParameterDict(self): | ||
""" Create a dictionary for parameter and parameter values for SNSPowderReductionPlus() | ||
""" | ||
pardict = {} | ||
|
||
pardict["FilterByTimeMin"] = self.starttime | ||
pardict["FilterByTimeMax"] = self.stoptime | ||
pardict["TimeInterval"] = self.timeinterval | ||
pardict["UnitOfTime"] = self.unitoftime | ||
pardict["LogName"] = self.logname | ||
pardict["MinimumLogValue"] = self.minimumlogvalue | ||
pardict["MaximumLogValue"] = self.maximumlogvalue | ||
pardict["LogValueInterval"] = self.logvalueinterval | ||
pardict["FilterLogValueByChangingDirection"] = self.filterlogvaluebychangingdirection | ||
pardict["TimeTolerance"] = self.timetolerance | ||
pardict["LogBoundary"] = self.logboundary | ||
pardict["LogValueTolerance"] = self.logvaluetolerance | ||
pardict["LogValueTimeSections"] = self.logvaluetimesections | ||
pardict["TitleOfSplitters"] = self.titleofsplitters | ||
|
||
return pardict | ||
|
||
def to_xml(self): | ||
""" 'Public' method to create XML from the current data. | ||
""" | ||
pardict = self.buildParameterDict() | ||
|
||
xml = "<FilterSetup>\n" | ||
for parname in self.parnamelist: | ||
keyname = parname.lower() | ||
parvalue = pardict[parname] | ||
xml += " <%s>%s</%s>\n" % (keyname, str(parvalue), keyname) | ||
xml += "</FilterSetup>\n" | ||
# xml += " <sample_input_file>%s</sample_input_file>\n" % self.sample_file | ||
# xml += " <output_wsname>%s</output_wsname>\n" % self.output_wsname | ||
# xml += " <detcal_file>%s</detcal_file>\n" % self.detcal_file | ||
# xml += " <relocate_dets>%s</relocate_dets>\n" % str(self.relocate_dets) | ||
# xml += " <incident_energy_guess>%s</incident_energy_guess>\n" % str(self.incident_energy_guess) | ||
# xml += " <use_ei_guess>%s</use_ei_guess>\n" % str(self.use_ei_guess) | ||
# xml += " <tzero_guess>%s</tzero_guess>\n" % str(self.tzero_guess) | ||
# xml += " <monitor1_specid>%s</monitor1_specid>\n" % self.monitor1_specid | ||
# xml += " <monitor2_specid>%s</monitor2_specid>\n" % self.monitor2_specid | ||
# xml += " <et_range>\n" | ||
# xml += " <low>%s</low>\n" % self.et_range_low | ||
# xml += " <width>%s</width>\n" % self.et_range_width | ||
# xml += " <high>%s</high>\n" % self.et_range_high | ||
# xml += " </et_range>\n" | ||
# xml += " <sofphie_is_distribution>%s</sofphie_is_distribution>\n" % str(self.et_is_distribution) | ||
# xml += " <hardmask_file>%s</hardmask_file>\n" % self.hardmask_file | ||
# xml += " <grouping_file>%s</grouping_file>\n" % self.grouping_file | ||
# xml += " <show_workspaces>%s</show_workspaces>\n" % self.show_workspaces | ||
|
||
return xml | ||
|
||
def from_xml(self, xml_str): | ||
""" 'Public' method to read in data from XML | ||
@param xml_str: text to read the data from | ||
""" | ||
dom = xml.dom.minidom.parseString(xml_str) | ||
element_list = dom.getElementsByTagName("FilterSetup") | ||
if len(element_list)>0: | ||
instrument_dom = element_list[0] | ||
# self.sample_file = BaseScriptElement.getStringElement(instrument_dom, | ||
# "sample_input_file", | ||
# default=VanadiumSetupScript.sample_file) | ||
# self.output_wsname = BaseScriptElement.getStringElement(instrument_dom, | ||
# "output_wsname", | ||
# default=VanadiumSetupScript.output_wsname) | ||
# self.detcal_file = BaseScriptElement.getStringElement(instrument_dom, | ||
# "detcal_file", | ||
# default=VanadiumSetupScript.detcal_file) | ||
# self.relocate_dets = BaseScriptElement.getBoolElement(instrument_dom, | ||
# "relocate_dets", | ||
# default=VanadiumSetupScript.relocate_dets) | ||
# self.incident_energy_guess = BaseScriptElement.getStringElement(instrument_dom, | ||
# "incident_energy_guess", | ||
# default=RunSetupScript.incident_energy_guess) | ||
# self.use_ei_guess = BaseScriptElement.getBoolElement(instrument_dom, | ||
# "use_ei_guess", | ||
# default=RunSetupScript.use_ei_guess) | ||
# self.tzero_guess = BaseScriptElement.getFloatElement(instrument_dom, | ||
# "tzero_guess", | ||
# default=RunSetupScript.tzero_guess) | ||
# # self.monitor1_specid = BaseScriptElement.getIntElement(instrument_dom, | ||
# # "monitor1_specid", | ||
# # default=RunSetupScript.monitor1_specid) | ||
# # self.monitor2_specid = BaseScriptElement.getIntElement(instrument_dom, | ||
# # "monitor2_specid", | ||
# # default=RunSetupScript.monitor2_specid) | ||
# self.et_range_low = BaseScriptElement.getStringElement(instrument_dom, | ||
# "et_range/low", | ||
# default=RunSetupScript.et_range_low) | ||
# self.et_range_width = BaseScriptElement.getStringElement(instrument_dom, | ||
# "et_range/width", | ||
# default=RunSetupScript.et_range_width) | ||
# self.et_range_high = BaseScriptElement.getStringElement(instrument_dom, | ||
# "et_range/high", | ||
# default=RunSetupScript.et_range_high) | ||
# self.et_is_distribution = BaseScriptElement.getBoolElement(instrument_dom, | ||
# "sofphie_is_distribution", | ||
# default=RunSetupScript.et_is_distribution) | ||
# self.hardmask_file = BaseScriptElement.getStringElement(instrument_dom, | ||
# "hardmask_file", | ||
# default=RunSetupScript.hardmask_file) | ||
# self.grouping_file = BaseScriptElement.getStringElement(instrument_dom, | ||
# "grouping_file", | ||
# default=RunSetupScript.grouping_file) | ||
# self.show_workspaces = BaseScriptElement.getBoolElement(instrument_dom, | ||
# "show_workspaces", | ||
# default=RunSetupScript.show_workspaces) | ||
|
||
return | ||
|
||
def reset(self): | ||
""" 'Public' method to reset state | ||
""" | ||
# self.sample_file = RunSetupScript.sample_file | ||
# self.output_wsname = RunSetupScript.output_wsname | ||
# self.detcal_file = RunSetupScript.detcal_file | ||
# self.relocate_dets = RunSetupScript.relocate_dets | ||
# self.incident_energy_guess = RunSetupScript.incident_energy_guess | ||
# self.use_ei_guess = RunSetupScript.use_ei_guess | ||
# self.tzero_guess = RunSetupScript.tzero_guess | ||
# self.monitor1_specid = RunSetupScript.monitor1_specid | ||
# # self.monitor2_specid = RunSetupScript.monitor2_specid | ||
# self.rebin_et = RunSetupScript.rebin_et | ||
# self.et_range_low = RunSetupScript.et_range_low | ||
# self.et_range_width = RunSetupScript.et_range_width | ||
# self.et_range_high = RunSetupScript.et_range_high | ||
# self.et_is_distribution = RunSetupScript.et_is_distribution | ||
# self.hardmask_file = RunSetupScript.hardmask_file | ||
# self.grouping_file = RunSetupScript.grouping_file | ||
# self.show_workspaces = RunSetupScript.show_workspaces | ||
|
||
return | ||
|
Oops, something went wrong.