source: sasview/src/sas/perspectives/fitting/ftol_dialog.py @ 386ffe1

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 386ffe1 was 386ffe1, checked in by pkienzle, 9 years ago

remove scipy levenburg marquardt and park from ui

  • Property mode set to 100644
File size: 4.1 KB
Line 
1"""
2Dialog to set ftol for Scipy
3
4    ftol(float): Relative error desired in the sum of squares.
5"""
6################################################################################
7#This software was developed by the University of Tennessee as part of the
8#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
9#project funded by the US National Science Foundation.
10#
11#See the license text in license.txt
12#
13#copyright 2009, University of Tennessee
14################################################################################
15_ = """
16import wx
17import sys
18# default ftol
19F_TOL = 1.49012e-08
20SAS_F_TOL = 5e-05
21
22PANEL_WIDTH = 270
23FONT_VARIANT = 0
24if sys.platform.count("win32") > 0:
25    PANEL_HEIGHT = 265
26else:
27    PANEL_HEIGHT = 245
28   
29class ChangeFtol(wx.Dialog):
30    """
31    Dialog to select ftol
32    """
33    def __init__(self, parent, base, id=-1, title="FTolerance"):
34        wx.Dialog.__init__(self, parent, id, title,
35                           size=(PANEL_WIDTH, PANEL_HEIGHT))
36        # font size
37        self.SetWindowVariant(variant=FONT_VARIANT)
38        # build layout
39        vbox = wx.BoxSizer(wx.VERTICAL)
40        title_text = wx.StaticText(self, id=wx.NewId(), label='FTol selection (Leastsq)')
41        self.default_bt = wx.RadioButton(self, -1, 'SasView Default (5e-05)', (15, 30), style=wx.RB_GROUP)
42        self.default_bt.SetValue(True)
43        self.default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
44        self.sci_default_bt = wx.RadioButton(self, -1, 'Scipy Default (1.49012e-08)', (15, 55))
45        self.sci_default_bt.SetValue(False)
46        self.sci_default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
47        self.high_bt = wx.RadioButton(self, -1, '1e-06', (15, 80))
48        self.high_bt.SetValue(False)
49        self.high_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
50        self.mid_bt = wx.RadioButton(self, -1, '1e-05', (15, 105))
51        self.mid_bt.SetValue(False)
52        self.mid_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
53        self.low_bt = wx.RadioButton(self, -1, '1e-04', (15, 130))
54        self.low_bt.SetValue(False)
55        self.low_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
56        self.custom_bt = wx.RadioButton(self, -1, 'Custom', (15, 155))
57        self.custom_bt.SetValue(False)
58        self.custom_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
59        self.custombox = wx.TextCtrl(self, -1, '', (95, 155))
60        self.custombox.Disable()
61       
62        hbox = wx.BoxSizer(wx.HORIZONTAL)
63        okButton = wx.Button(self, wx.ID_OK, 'Set', size=(70, 30))
64        closeButton = wx.Button(self,wx.ID_CANCEL, 'Cancel', size=(70, 30))
65        hbox.Add(okButton, 1, wx.RIGHT, 5)
66        hbox.Add(closeButton, 1, wx.RIGHT, 5)
67       
68        vbox.Add(title_text, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
69        vbox.Add(self.default_bt, 0, wx.LEFT, 20)
70        vbox.Add(self.sci_default_bt, 0, wx.LEFT, 20)
71        vbox.Add(self.high_bt, 0, wx.LEFT, 20)
72        vbox.Add(self.mid_bt, 0, wx.LEFT, 20)
73        vbox.Add(self.low_bt, 0, wx.LEFT, 20)
74        vbox.Add(self.custom_bt, 0, wx.LEFT, 20)
75        vbox.Add(self.custombox, 0, wx.LEFT, 60)
76        vbox.Add(hbox, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
77       
78        self.SetSizer(vbox)
79
80    def OnFtolSelection(self, event=None):
81        """
82           Changes the ftol on selection of the radio button
83        """
84        self.custombox.Enable(self.custom_bt.GetValue())
85       
86    def get_ftol(self):
87        """
88            Get the ftol value
89        """
90        if self.default_bt.GetValue():
91            return SAS_F_TOL
92        elif self.sci_default_bt.GetValue():
93            return F_TOL
94        elif self.low_bt.GetValue():
95            return 1.0e-4
96        elif self.mid_bt.GetValue():
97            return 1.0e-5
98        elif self.high_bt.GetValue():
99            return 1.0e-6
100        if self.custom_bt.GetValue():
101            try:
102                return float(self.custombox.GetValue())
103            except:
104                return None
105        return SAS_F_TOL
106"""
Note: See TracBrowser for help on using the repository browser.