Changeset a0e6b1b in sasview for src/sas/sasgui/perspectives/pr


Ignore:
Timestamp:
Aug 3, 2017 2:27:25 AM (7 years ago)
Author:
lewis
Branches:
master, 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
cb62bd5
Parents:
5c3c310
Message:

Esnure background value is saved/loaded when analysis is saved/loaded

Location:
src/sas/sasgui/perspectives/pr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/pr/inversion_panel.py

    r5c3c310 ra0e6b1b  
    316316        # Read the panel's parameters 
    317317        flag, alpha, dmax, nfunc, qmin, \ 
    318         qmax, height, width = self._read_pars() 
     318        qmax, height, width, bck = self._read_pars() 
    319319 
    320320        state.nfunc = nfunc 
     
    330330 
    331331        # Background evaluation checkbox 
    332         state.estimate_bck = self.bck_est_ctl.GetValue() 
     332        state.estimate_bck = self.has_bck 
     333        state.bck_value = bck 
    333334 
    334335        # Estimates 
     
    375376        self.plot_data.SetValue(str(state.file)) 
    376377 
    377         # Background evaluation checkbox 
    378         self.bck_man_ctl.SetValue(state.estimate_bck) 
     378        # Background value 
     379        self.bck_est_ctl.SetValue(state.estimate_bck) 
     380        self.bck_man_ctl.SetValue(not state.estimate_bck) 
     381        if not state.estimate_bck: 
     382            self.bck_input.Enable() 
     383            self.bck_input.SetValue(str(state.bck_value)) 
     384        self.has_bck = state.estimate_bck 
     385        self.bck_value = state.bck_value 
    379386 
    380387        # Estimates 
     
    456463            size=(60, 20), value="0.0") 
    457464        self.bck_input.Disable() 
     465        self.bck_input.Bind(wx.EVT_TEXT, self._read_pars) 
    458466        background_units = wx.StaticText(self, -1, "[A^(-1)]", size=(55, 20)) 
    459467        iy += 1 
     
    808816        scenes. 
    809817        """ 
    810         flag, alpha, dmax, nfunc, qmin, qmax, height, width = self._read_pars() 
     818        flag, alpha, dmax, nfunc, qmin, qmax, height, width, bck = self._read_pars() 
    811819 
    812820        # If the pars are valid, estimate alpha 
     
    834842        height = 0 
    835843        width = 0 
     844        background = 0 
    836845        flag = True 
    837846        # Read slit height 
     
    927936            self.qmax_ctl.Refresh() 
    928937 
    929         return flag, alpha, dmax, nfunc, qmin, qmax, height, width 
     938        # Read background 
     939        if not self.has_bck: 
     940            try: 
     941                bck_str = self.bck_input.GetValue() 
     942                if len(bck_str.strip()) == 0: 
     943                    background = 0.0 
     944                else: 
     945                    background = float(bck_str) 
     946                    self.bck_input.SetBackgroundColour(wx.WHITE) 
     947            except ValueError: 
     948                background = 0.0 
     949                self.bck_input.SetBackgroundColour("pink") 
     950            self.bck_input.Refresh() 
     951 
     952        return flag, alpha, dmax, nfunc, qmin, qmax, height, width, background 
    930953 
    931954    def _on_explore(self, evt): 
     
    952975        # Push it to the manager 
    953976 
    954         flag, alpha, dmax, nfunc, qmin, qmax, height, width = self._read_pars() 
     977        flag, alpha, dmax, nfunc, qmin, qmax, height, width, bck = self._read_pars() 
    955978 
    956979        if flag: 
  • src/sas/sasgui/perspectives/pr/inversion_state.py

    r7432acb ra0e6b1b  
    3636           ["qmin", "qmin"], 
    3737           ["qmax", "qmax"], 
    38            ["estimate_bck", "estimate_bck"]] 
     38           ["estimate_bck", "estimate_bck"], 
     39           ["bck_value", "bck_value"]] 
    3940 
    4041## List of P(r) inversion outputs 
     
    6263        self.estimate_bck = False 
    6364        self.timestamp = time.time() 
     65        self.bck_value = 0.0 
    6466 
    6567        # Inversion parameters 
     
    109111        state += "Timestamp:    %s\n" % self.timestamp 
    110112        state += "Estimate bck: %s\n" % str(self.estimate_bck) 
     113        state += "Bck Value:    %s\n" % str(self.bck_value) 
    111114        state += "No. terms:    %s\n" % str(self.nfunc) 
    112115        state += "D_max:        %s\n" % str(self.d_max) 
     
    296299                            self.coefficients.append(float(c)) 
    297300                        except: 
    298                             # Bad data, skip. We will count the number of  
    299                             # coefficients at the very end and deal with  
     301                            # Bad data, skip. We will count the number of 
     302                            # coefficients at the very end and deal with 
    300303                            # inconsistencies then. 
    301304                            pass 
     
    329332                                cov_row.append(float(c)) 
    330333                            except: 
    331                                 # Bad data, skip. We will count the number of  
    332                                 # coefficients at the very end and deal with  
     334                                # Bad data, skip. We will count the number of 
     335                                # coefficients at the very end and deal with 
    333336                                # inconsistencies then. 
    334337                                pass 
     
    461464                tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 
    462465                # Check the format version number 
    463                 # Specifying the namespace will take care of the file  
    464                 #format version  
     466                # Specifying the namespace will take care of the file 
     467                #format version 
    465468                root = tree.getroot() 
    466469 
Note: See TracChangeset for help on using the changeset viewer.