Changeset 98485fe in sasview for src/sas


Ignore:
Timestamp:
Apr 17, 2018 7:42:12 AM (6 years ago)
Author:
krzywon
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
ae34d30
Parents:
318b353e
Message:

Run the P(r) batch fits in order to prevent thread interference and other code cleanup.

Location:
src/sas/qtgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    r318b353e r98485fe  
    7878 
    7979        # Calculation threads used by all data items 
    80         self.waitForEach = False 
     80        self.isBatch = False 
    8181        self.calc_thread = None 
    8282        self.estimation_thread = None 
     
    9797        self.mapper = QtWidgets.QDataWidgetMapper(self) 
    9898 
     99        # Batch fitting results 
    99100        self.grid_window = None 
     101        self.batchResults = {} 
     102        self.batchComplete = [] 
    100103 
    101104        # Add validators 
     
    376379        self.dmaxWindow.show() 
    377380 
    378     def showBatchOutput(self, output_data): 
     381    def showBatchOutput(self): 
    379382        """ 
    380383        Display the batch output in tabular form 
     
    383386        if self.grid_window is None: 
    384387            self.grid_window = BatchInversionOutputPanel( 
    385                 parent=self, output_data=output_data) 
     388                parent=self, output_data=self.batchResults) 
    386389        else: 
    387             self.grid_window.setupTable(output_data) 
     390            self.grid_window.setupTable(self.batchResults) 
    388391        self.grid_window.show() 
    389392 
     
    427430            DICT_KEYS[2]: self.data_plot 
    428431        } 
     432        # Update batch results window when finished 
     433        self.batchResults[self.logic.data.filename] = self._calculator 
     434        if self.grid_window is not None: 
     435            self.showBatchOutput() 
    429436 
    430437    def getNFunc(self): 
     
    494501                                       "{:.3g}".format( 
    495502                                           pr.get_pos_err(out, cov)))) 
     503        if self.pr_plot is not None: 
     504            title = self.pr_plot.name 
     505            GuiUtils.updateModelItemWithPlot(self._data, self.pr_plot, title) 
     506            self.communicate.plotRequestedSignal.emit([self.pr_plot]) 
     507        if self.data_plot is not None: 
     508            title = self.data_plot.name 
     509            GuiUtils.updateModelItemWithPlot(self._data, self.data_plot, title) 
     510            self.communicate.plotRequestedSignal.emit( 
     511                [self.data_plot, self.logic.data]) 
    496512        self.enableButtons() 
    497513 
     
    501517            self.dmaxWindow.close() 
    502518            self.dmaxWindow = None 
     519        if self.grid_window is not None: 
     520            self.grid_window.close() 
    503521        if not data_list: 
    504522            data_list = [self._data] 
     
    529547    ###################################################################### 
    530548    # Thread Creators 
     549 
    531550    def startThreadAll(self): 
    532         self.waitForEach = True 
    533         output = {} 
    534         for data_ref in self._data_list.keys(): 
    535             self.setCurrentData(data_ref) 
     551        self.batchComplete = [] 
     552        self.isBatch = True 
     553        self.performEstimate() 
     554        self.showBatchOutput() 
     555 
     556    def startNextBatchItem(self): 
     557        self.isBatch = False 
     558        for index in range(len(self._data_list)): 
     559            if index not in self.batchComplete: 
     560                self.dataList.setCurrentIndex(index) 
     561                self.isBatch = True 
     562                break 
     563        # If none left, end 
     564        if self.isBatch: 
    536565            self.performEstimate() 
    537             self.performEstimateNT() 
    538             self.acceptAlpha() 
    539             self.acceptNoTerms() 
    540             self.startThread() 
    541             output[self.logic.data.filename] = self._calculator 
    542         self.waitForEach = False 
    543         self.showBatchOutput(output) 
    544566 
    545567    def startThread(self): 
     
    563585        self.calc_thread.queue() 
    564586        self.calc_thread.ready(2.5) 
    565         if self.waitForEach: 
    566             if self.calc_thread.isrunning(): 
    567                 self.calc_thread.update() 
    568587 
    569588    def performEstimateNT(self): 
     
    592611        self.estimation_thread_nt.queue() 
    593612        self.estimation_thread_nt.ready(2.5) 
    594         if self.waitForEach: 
    595             if self.estimation_thread_nt.isrunning(): 
    596                 self.estimation_thread_nt.update() 
    597613 
    598614    def performEstimate(self): 
     
    613629        self.estimation_thread.queue() 
    614630        self.estimation_thread.ready(2.5) 
    615         if self.waitForEach: 
    616             if self.estimation_thread.isrunning(): 
    617                 self.estimation_thread.update() 
    618631 
    619632    ###################################################################### 
     
    635648        if message: 
    636649            logging.info(message) 
    637         if not self.waitForEach: 
    638             self.performEstimateNT() 
     650        self.performEstimateNT() 
    639651 
    640652    def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 
     
    659671        if message: 
    660672            logging.info(message) 
     673        if self.isBatch: 
     674            self.acceptAlpha() 
     675            self.acceptNoTerms() 
     676            self.startThread() 
    661677 
    662678    def _calculateCompleted(self, out, cov, pr, elapsed): 
     
    686702        self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 
    687703        self.pr_plot.filename = self.logic.data.filename 
    688         title = self.pr_plot.name 
    689         GuiUtils.updateModelItemWithPlot(self._data, self.pr_plot, title) 
    690         self.communicate.plotRequestedSignal.emit([self.pr_plot]) 
    691704        self.data_plot = self.logic.new1DPlot(out, self._calculator) 
    692705        self.data_plot.filename = self.logic.data.filename 
    693         title = self.data_plot.name 
    694         GuiUtils.updateModelItemWithPlot(self._data, self.data_plot, title) 
    695         self.communicate.plotRequestedSignal.emit([self.data_plot]) 
    696706 
    697707        # Udpate internals and GUI 
    698708        self.updateDataList(self._data) 
    699709        self.updateGuiValues() 
     710        if self.isBatch: 
     711            self.batchComplete.append(self.dataList.currentIndex()) 
     712            self.startNextBatchItem() 
    700713 
    701714    def _threadError(self, error): 
  • src/sas/qtgui/Utilities/GridPanel.py

    r318b353e r98485fe  
    349349        except webbrowser.Error as ex: 
    350350            logging.warning("Cannot display help. %s" % ex) 
     351 
     352    def closeEvent(self, event): 
     353        """Tell the parent window the window closed""" 
     354        self.parent.grid_window = None 
     355        event.accept() 
Note: See TracChangeset for help on using the changeset viewer.