source: sasview/src/sans/perspectives/fitting/ftol_dialog.py @ 767514a

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 767514a was 767514a, checked in by Mathieu Doucet <doucetm@…>, 10 years ago

Re #212 Fix FTOL dialog.

  • Property mode set to 100644
File size: 3.8 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################################################################################
15import wx
16import sys
17# default ftol
18F_TOL = 1.49012e-08
19SANS_F_TOL = 5e-05
20
21if sys.platform.count("win32") > 0:
22    PANEL_WIDTH = 270
23    PANEL_HEIGHT = 265
24    FONT_VARIANT = 0
25else:
26    PANEL_WIDTH = 285
27    PANEL_HEIGHT = 265
28    FONT_VARIANT = 1
29   
30   
31class ChangeFtol(wx.Dialog):
32    """
33    Dialog to select ftol
34    """
35    def __init__(self, parent, base, id=-1, title="FTolerance"):
36        wx.Dialog.__init__(self, parent, id, title,
37                           size=(PANEL_WIDTH, PANEL_HEIGHT))
38        # font size
39        self.SetWindowVariant(variant=FONT_VARIANT)
40        # build layout
41        panel = wx.Panel(self, -1)
42        vbox = wx.BoxSizer(wx.VERTICAL)
43        wx.StaticBox(panel, -1, 'FTol selection (Leastsq)', (5, 6), (PANEL_WIDTH * 0.9, PANEL_HEIGHT * 0.7))
44        self.default_bt = wx.RadioButton(panel, -1, 'SansView Default (5e-05)', (15, 30), style=wx.RB_GROUP)
45        self.default_bt.SetValue(True)
46        self.default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
47        self.sci_default_bt = wx.RadioButton(panel, -1, 'Scipy Default (1.49012e-08)', (15, 55))
48        self.sci_default_bt.SetValue(False)
49        self.sci_default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
50        self.high_bt = wx.RadioButton(panel, -1, '1e-06', (15, 80))
51        self.high_bt.SetValue(False)
52        self.high_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
53        self.mid_bt = wx.RadioButton(panel, -1, '1e-05', (15, 105))
54        self.mid_bt.SetValue(False)
55        self.mid_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
56        self.low_bt = wx.RadioButton(panel, -1, '1e-04', (15, 130))
57        self.low_bt.SetValue(False)
58        self.low_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
59        self.custom_bt = wx.RadioButton(panel, -1, 'Custom', (15, 155))
60        self.custom_bt.SetValue(False)
61        self.custom_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection)
62        self.custombox = wx.TextCtrl(panel, -1, '', (95, 155))
63        self.custombox.Disable()
64       
65        hbox = wx.BoxSizer(wx.HORIZONTAL)
66        okButton = wx.Button(self, wx.ID_OK, 'Set', size=(70, 30))
67        closeButton = wx.Button(self,wx.ID_CANCEL, 'Cancel', size=(70, 30))
68        hbox.Add(okButton, 1, wx.RIGHT, 5)
69        hbox.Add(closeButton, 1, wx.RIGHT, 5)
70        vbox.Add(panel, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
71        vbox.Add(hbox, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
72       
73        self.SetSizer(vbox)
74
75    def OnFtolSelection(self, event=None):
76        """
77           Changes the ftol on selection of the radio button
78        """
79        self.custombox.Enable(self.custom_bt.GetValue())
80       
81    def get_ftol(self):
82        """
83            Get the ftol value
84        """
85        if self.default_bt.GetValue():
86            return SANS_F_TOL
87        elif self.sci_default_bt.GetValue():
88            return F_TOL
89        elif self.low_bt.GetValue():
90            return 1.0e-4
91        elif self.mid_bt.GetValue():
92            return 1.0e-5
93        elif self.high_bt.GetValue():
94            return 1.0e-6
95        if self.custom_bt.GetValue():
96            try:
97                return float(self.custombox.GetValue())
98            except:
99                return None
100        return SANS_F_TOL
Note: See TracBrowser for help on using the repository browser.