Ignore:
Timestamp:
Jun 21, 2012 2:37:34 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ffdfd23
Parents:
75a6cf0
Message:

added Rg etc on fitdialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plottools/src/danse/common/plottools/fitDialog.py

    r10bfeb3 r9bab141  
    1010if sys.platform.count("win32") > 0: 
    1111    FONT_VARIANT = 0 
    12     PNL_WIDTH = 400 
     12    PNL_WIDTH = 450 
     13    PNL_HEIGHT = 500 
    1314else: 
    1415    FONT_VARIANT = 1 
    15     PNL_WIDTH = 450 
    16      
     16    PNL_WIDTH = 500 
     17    PNL_HEIGHT = 500 
     18RG_ON = True     
    1719     
    1820def format_number(value, high=False): 
     
    4042        Displays fitting parameters 
    4143        """ 
    42         wx.Dialog.__init__(self, parent, title=title, size=(PNL_WIDTH, 350)) 
     44        wx.Dialog.__init__(self, parent, title=title,  
     45                           size=(PNL_WIDTH, 350)) 
    4346        self.parent = parent 
    4447        self.transform = transform 
     
    5255        #dialog self plottable 
    5356        self.plottable = plottable 
    54          
     57        self.rg_on = False 
    5558        # Receive transformations of x and y 
    5659        self.xLabel, self.yLabel, self.Avalue, self.Bvalue,\ 
     
    104107         
    105108        # Intro 
    106         explanation = "Perform fit for y(x) = Ax + B" 
     109        explanation = "Perform fit for y(x) = ax + b" 
    107110        vbox.Add(sizer) 
    108111        ix = 0 
     
    111114                 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    112115        iy += 2 
    113         sizer.Add(wx.StaticText(self, -1, 'Parameter A'), (iy, ix), 
     116        sizer.Add(wx.StaticText(self, -1, 'Parameter a'), (iy, ix), 
    114117                 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    115118        ix += 1 
     
    123126        iy += 1 
    124127        ix = 0 
    125         sizer.Add(wx.StaticText(self, -1, 'Parameter B'), (iy, ix),(1, 1), 
     128        sizer.Add(wx.StaticText(self, -1, 'Parameter b'), (iy, ix),(1, 1), 
    126129                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    127130        ix += 1 
     
    139142        ix += 1 
    140143        sizer.Add(self.tcChi, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     144 
     145         
     146        #sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
    141147        iy += 2 
    142148        ix = 1 
     
    146152        sizer.Add(wx.StaticText(self, -1, 'Max'), (iy, ix), 
    147153                  (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     154 
    148155        iy += 1 
    149156        ix = 0 
     
    168175        ix += 2 
    169176        sizer.Add(self.xmaxFit, (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     177        if RG_ON: 
     178            if (self.yLabel == "ln(y)" or self.yLabel == "ln(y*x)") and \ 
     179                    (self.xLabel == "x^(2)"): 
     180                self.rg_on = True 
     181                self.SetSize((PNL_WIDTH, PNL_HEIGHT)) 
     182                I0_stxt = wx.StaticText(self, -1, 'I(q=0)') 
     183                self.I0_tctr = wx.TextCtrl(self, -1, '') 
     184                self.I0_tctr.SetEditable(False) 
     185                self.I0_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     186                self.I0err_tctr = wx.TextCtrl(self, -1, '') 
     187                self.I0err_tctr.SetEditable(False) 
     188                self.I0err_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     189                Rg_stxt = wx.StaticText(self, -1, 'Rg (A)') 
     190                Rg_stxt.Show(self.yLabel == "ln(y)" ) 
     191                self.Rg_tctr = wx.TextCtrl(self, -1, '') 
     192                self.Rg_tctr.SetEditable(False) 
     193                self.Rg_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     194                self.Rg_tctr.Show(self.yLabel == "ln(y)" ) 
     195                self.Rgerr_tctr = wx.TextCtrl(self, -1, '') 
     196                self.Rgerr_tctr.SetEditable(False) 
     197                self.Rgerr_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     198                self.Rgerr_tctr.Show(self.yLabel == "ln(y)" ) 
     199                Diameter_stxt = wx.StaticText(self, -1, 'Rod Diameter (A)') 
     200                Diameter_stxt.Show(self.yLabel == "ln(y*x)") 
     201                self.Diameter_tctr = wx.TextCtrl(self, -1, '') 
     202                self.Diameter_tctr.SetEditable(False) 
     203                self.Diameter_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     204                self.Diameter_tctr.Show(self.yLabel == "ln(y*x)") 
     205                self.Diametererr_tctr = wx.TextCtrl(self, -1, '') 
     206                self.Diametererr_tctr.SetEditable(False) 
     207                self.Diametererr_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     208                self.Diametererr_tctr.Show(self.yLabel == "ln(y*x)") 
     209                RgQmin_stxt = wx.StaticText(self, -1, 'Rg*Qmin') 
     210                self.RgQmin_tctr = wx.TextCtrl(self, -1, '') 
     211                self.RgQmin_tctr.SetEditable(False) 
     212                self.RgQmin_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     213                RgQmax_stxt = wx.StaticText(self, -1, 'Rg*Qmax') 
     214                self.RgQmax_tctr = wx.TextCtrl(self, -1, '') 
     215                self.RgQmax_tctr.SetEditable(False) 
     216                self.RgQmax_tctr.SetBackgroundColour(_BACKGROUND_COLOR) 
     217 
     218                #sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
     219                iy += 2 
     220                ix = 0 
     221                sizer.Add(I0_stxt, (iy, ix),(1,1), 
     222                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     223                ix += 1 
     224                sizer.Add(self.I0_tctr, (iy, ix), (1,1), 
     225                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     226         
     227                ix += 2 
     228                sizer.Add(self.I0err_tctr, (iy, ix), (1,1),  
     229                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     230                 
     231                iy += 1 
     232                ix = 0 
     233                sizer.Add(Rg_stxt, (iy, ix),(1,1), 
     234                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     235                ix += 1 
     236                sizer.Add(self.Rg_tctr, (iy, ix), (1,1), 
     237                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     238         
     239                ix += 2 
     240                sizer.Add(self.Rgerr_tctr, (iy, ix), (1,1),  
     241                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     242                iy += 1 
     243                ix = 0 
     244                sizer.Add(Diameter_stxt, (iy, ix),(1,1), 
     245                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     246                ix += 1 
     247                sizer.Add(self.Diameter_tctr, (iy, ix), (1,1), 
     248                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     249         
     250                ix += 2 
     251                sizer.Add(self.Diametererr_tctr, (iy, ix), (1,1),  
     252                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     253                iy += 1 
     254                ix = 0 
     255                sizer.Add(RgQmin_stxt, (iy, ix),(1,1), 
     256                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     257                ix += 1 
     258                sizer.Add(self.RgQmin_tctr, (iy, ix), (1,1), 
     259                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     260                iy += 1 
     261                ix = 0 
     262                sizer.Add(RgQmax_stxt, (iy, ix),(1,1), 
     263                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     264                ix += 1 
     265                sizer.Add(self.RgQmax_tctr, (iy, ix), (1,1), 
     266                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     267             
    170268        iy += 1 
    171269        ix = 1 
     
    393491        Display  the value on fit Dialog 
    394492        """ 
     493        rg = None 
    395494        self.tcA.SetValue(format_number(cstA)) 
    396495        self.tcB.SetValue(format_number(cstB)) 
     
    398497        self.tcErrB.SetValue(format_number(errB)) 
    399498        self.tcChi.SetValue(format_number(Chi)) 
    400          
     499        if self.rg_on: 
     500            if self.Rg_tctr.IsShown(): 
     501                rg = numpy.sqrt(-3 * float(cstA)) 
     502                value = format_number(rg) 
     503                self.Rg_tctr.SetValue(value) 
     504                if self.I0_tctr.IsShown(): 
     505                    val = numpy.exp(cstB) 
     506                    self.I0_tctr.SetValue(format_number(val)) 
     507            if self.Rgerr_tctr.IsShown(): 
     508                if rg != None and rg != 0: 
     509                    value = format_number(3 * float(cstA) / (2 * rg)) 
     510                else: 
     511                    value ='' 
     512                self.Rgerr_tctr.SetValue(value) 
     513                if self.I0err_tctr.IsShown(): 
     514                    val = numpy.abs(numpy.exp(cstB) - numpy.exp(cstB + errB)) 
     515                    self.I0err_tctr.SetValue(format_number(val)) 
     516            if self.Diameter_tctr.IsShown(): 
     517                rg = 4 * numpy.sqrt(-float(cstA)) 
     518                value = format_number(rg) 
     519                self.Diameter_tctr.SetValue(value) 
     520            if self.Diametererr_tctr.IsShown(): 
     521                if rg != None and rg != 0: 
     522                    value = format_number(8 * float(cstA) / rg) 
     523                else: 
     524                    value ='' 
     525                self.Diametererr_tctr.SetValue(value) 
     526            if self.RgQmin_tctr.IsShown(): 
     527                value = format_number(rg * self.mini) 
     528                self.RgQmin_tctr.SetValue(value) 
     529            if self.RgQmax_tctr.IsShown(): 
     530                value = format_number(rg * self.maxi) 
     531                self.RgQmax_tctr.SetValue(value) 
     532                 
    401533    def _ongetValues(self): 
    402534        """ 
Note: See TracChangeset for help on using the changeset viewer.