Skip to content
Snippets Groups Projects
Commit 5704ef35 authored by Savici, Andrei T.'s avatar Savici, Andrei T. Committed by GitHub
Browse files

Merge pull request #20791 from mganeva/20775_toftof_gui

TOFTOF GUI minor issues fix
parents 143513ec 0d98496c
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ Spectroscopy Changes ...@@ -12,6 +12,8 @@ Spectroscopy Changes
Direct Geometry Direct Geometry
--------------- ---------------
- TOFTOF data reduction GUI has been improved. In the new version it has options to delete intermediate workspaces, to replace NaNs in S(Q,W), to create diffractograms and to save the reduced data in NXSPE and NeXus format.
Indirect Geometry Indirect Geometry
----------------- -----------------
......
...@@ -340,9 +340,9 @@ class TOFTOFScriptElement(BaseScriptElement): ...@@ -340,9 +340,9 @@ class TOFTOFScriptElement(BaseScriptElement):
self.l("for ws in {}:".format(wsgroup)) self.l("for ws in {}:".format(wsgroup))
self.l(" name = ws.getComment() + {}".format(suffix)) self.l(" name = ws.getComment() + {}".format(suffix))
if self.saveNXSPE and self.binEon: if self.saveNXSPE and self.binEon:
self.l(" SaveNXSPE(ws, join('{}', name + '.nxspe'), Efixed=Ei)".format(self.saveDir)) self.l(" SaveNXSPE(ws, join(r'{}', name + '.nxspe'), Efixed=Ei)".format(self.saveDir))
if self.saveNexus: if self.saveNexus:
self.l(" SaveNexus(ws, join('{}', name + '.nxs'))".format(self.saveDir)) self.l(" SaveNexus(ws, join(r'{}', name + '.nxs'))".format(self.saveDir))
self.l() self.l()
def normalize_data(self, gPrefix, gDataRuns, wsEC='', wsVan=''): def normalize_data(self, gPrefix, gDataRuns, wsEC='', wsVan=''):
...@@ -393,7 +393,10 @@ class TOFTOFScriptElement(BaseScriptElement): ...@@ -393,7 +393,10 @@ class TOFTOFScriptElement(BaseScriptElement):
if self.CORR_TOF_VAN == self.correctTof: if self.CORR_TOF_VAN == self.correctTof:
self.l("# apply vanadium TOF correction") self.l("# apply vanadium TOF correction")
self.l("{} = CorrectTOF({}, {})".format(gData2, gDataCleanFrame, eppTable)) self.l("{} = CorrectTOF({}, {})".format(gData2, gDataCleanFrame, eppTable))
self.delete_workspaces([gDataCleanFrame, gData, eppTable]) if self.ecRuns:
self.delete_workspaces([gDataCleanFrame, gData, eppTable])
return True
self.delete_workspaces([gDataCleanFrame, eppTable])
return True return True
elif self.CORR_TOF_SAMPLE == self.correctTof: elif self.CORR_TOF_SAMPLE == self.correctTof:
...@@ -401,12 +404,17 @@ class TOFTOFScriptElement(BaseScriptElement): ...@@ -401,12 +404,17 @@ class TOFTOFScriptElement(BaseScriptElement):
self.l("# apply sample TOF correction") self.l("# apply sample TOF correction")
self.l("{} = FindEPP({})".format(eppTables, gData)) self.l("{} = FindEPP({})".format(eppTables, gData))
self.l("{} = CorrectTOF({}, {})".format(gData2, gDataCleanFrame, eppTables)) self.l("{} = CorrectTOF({}, {})".format(gData2, gDataCleanFrame, eppTables))
self.delete_workspaces([gDataCleanFrame, gData, eppTables]) if self.ecRuns:
self.delete_workspaces([gDataCleanFrame, gData, eppTables])
return True
self.delete_workspaces([gDataCleanFrame, eppTables])
return True return True
if self.vanRuns: if self.vanRuns and self.ecRuns:
self.delete_workspaces([eppTable, gData]) self.delete_workspaces([eppTable, gData])
else: elif self.vanRuns:
self.delete_workspaces([eppTable])
elif self.ecRuns:
self.delete_workspaces([gData]) self.delete_workspaces([gData])
return False return False
...@@ -522,8 +530,15 @@ class TOFTOFScriptElement(BaseScriptElement): ...@@ -522,8 +530,15 @@ class TOFTOFScriptElement(BaseScriptElement):
if self.ecRuns: if self.ecRuns:
wsECNorm2 = wsECNorm + '2' wsECNorm2 = wsECNorm + '2'
self.l("{} = CloneWorkspace({})".format(wsECNorm2, wsECNorm)) self.l("{} = CloneWorkspace({})".format(wsECNorm2, wsECNorm))
if self.vanRuns: if self.vanRuns:
wsVanNorm = wsVanSubEC if self.subtractECVan else wsVanNorm if self.subtractECVan:
wsVanNorm = wsVanSubEC
else:
wsVanNorm2 = wsVanNorm + '2'
self.l("{} = CloneWorkspace({})".format(wsVanNorm2, wsVanNorm))
wsVanNorm = wsVanNorm2
if self.ecRuns: if self.ecRuns:
self.l("{} = GroupWorkspaces({}list({}.getNames()))" self.l("{} = GroupWorkspaces({}list({}.getNames()))"
.format(gData, self.group_list([wsVanNorm, wsECNorm2], ' + '), gDataSource)) .format(gData, self.group_list([wsVanNorm, wsECNorm2], ' + '), gDataSource))
...@@ -583,7 +598,7 @@ class TOFTOFScriptElement(BaseScriptElement): ...@@ -583,7 +598,7 @@ class TOFTOFScriptElement(BaseScriptElement):
self.l("for ws in {}:" .format(gLast)) self.l("for ws in {}:" .format(gLast))
self.l(" step1 = RemoveMaskedSpectra(ws)") self.l(" step1 = RemoveMaskedSpectra(ws)")
self.l(" step2 = IntegrateByComponent(step1)") self.l(" step2 = IntegrateByComponent(step1)")
self.l(" step3 = ConvertSpectrumAxis(step2, Target='Theta', EMode='Direct', EFixed=Ei, OrderAxis=True)") self.l(" step3 = ConvertSpectrumAxis(step2, Target='Theta', EMode='Direct', EFixed=Ei)")
self.l(" Transpose(step3, OutputWorkspace='{}_D_' + ws.getComment())" self.l(" Transpose(step3, OutputWorkspace='{}_D_' + ws.getComment())"
.format(self.prefix)) .format(self.prefix))
self.l("{} = GroupWorkspaces(['{}_D_'+ ws.getComment() for ws in {}])" self.l("{} = GroupWorkspaces(['{}_D_'+ ws.getComment() for ws in {}])"
......
...@@ -188,6 +188,14 @@ class TOFTOFSetupWidget(BaseWidget): ...@@ -188,6 +188,14 @@ class TOFTOFSetupWidget(BaseWidget):
TIP_rbtCorrectTOFVan = '' TIP_rbtCorrectTOFVan = ''
TIP_rbtCorrectTOFSample = '' TIP_rbtCorrectTOFSample = ''
def dir_browse_dialog(self, default_dir=''):
"""
Pop up a directory dialog box.
"""
dirname = str(QFileDialog.getExistingDirectory(self, "Select Directory", default_dir, QFileDialog.DontUseNativeDialog))
return dirname
def __init__(self, settings): def __init__(self, settings):
BaseWidget.__init__(self, settings = settings) BaseWidget.__init__(self, settings = settings)
...@@ -396,12 +404,12 @@ class TOFTOFSetupWidget(BaseWidget): ...@@ -396,12 +404,12 @@ class TOFTOFSetupWidget(BaseWidget):
self.runDataModel.selectCell.connect(self._onSelectedCell) self.runDataModel.selectCell.connect(self._onSelectedCell)
def _onDataDir(self): def _onDataDir(self):
dirname = self.dir_browse_dialog() dirname = self.dir_browse_dialog(self.dataDir.text())
if dirname: if dirname:
self.dataDir.setText(dirname) self.dataDir.setText(dirname)
def _onSaveDir(self): def _onSaveDir(self):
dirname = self.dir_browse_dialog() dirname = self.dir_browse_dialog(self.saveDir.text())
if dirname: if dirname:
self.saveDir.setText(dirname) self.saveDir.setText(dirname)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment