source: sasview/sansview/perspectives/fitting/fitpage2D.py @ ca88b2e

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 ca88b2e was 26bf293, checked in by Gervaise Alina <gervyh@…>, 16 years ago

redesign the model1D and madel page

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[d89f09b]1import sys
2import wx
3import wx.lib
[442895f]4import numpy,math
[d89f09b]5import copy
6
7from sans.guicomm.events import StatusEvent   
8(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
9_BOX_WIDTH = 80
10
[d23544dc]11from modelpage import format_number
12from fitpage1D import FitPage1D
[d89f09b]13   
[d23544dc]14class FitPage2D(FitPage1D):
[d89f09b]15    """
16        FitPanel class contains fields allowing to display results when
17        fitting  a model and one data
18        @note: For Fit to be performed the user should check at least one parameter
19        on fit Panel window.
20 
21    """
22    ## Internal name for the AUI manager
23    window_name = "Fit page"
24    ## Title to appear on top of the window
25    window_caption = "Fit Page"
26   
27   
[9d31a8b]28    def __init__(self, parent,data, *args, **kwargs):
[26bf293]29        FitPage1D.__init__(self, parent, *args, **kwargs)
[d89f09b]30        """
31            Initialization of the Panel
32        """
[9d31a8b]33       
[6f73a08]34       
[442895f]35    def compute_chisqr(self):
36        """ @param fn: function that return model value
37            @return residuals
38        """
39        flag=self.checkFitRange()
[9d31a8b]40        res=[]
[442895f]41        if flag== True:
[948add7]42            try:
[9d31a8b]43                xmin = float(self.xmin.GetValue())
44                xmax = float(self.xmax.GetValue())
45                ymin = float(self.ymin.GetValue())
46                ymax = float(self.ymax.GetValue())
[d23544dc]47                for i in range(len(self.data.x_bins)):
48                    if self.data.x_bins[i]>= xmin and self.data.x_bins[i]<= xmax:
49                        for j in range(len(self.data.y_bins)):
50                            if self.data.y_bins[j]>= ymin and self.data.y_bins[j]<= ymax:
[57668f8]51                                res.append( (self.data.data[j][i]- self.model.runXY(\
[d23544dc]52                                 [self.data.x_bins[i],self.data.y_bins[j]]))\
[57668f8]53                                    /self.data.err_data[j][i] )
[948add7]54                sum=0
[9d31a8b]55               
[948add7]56                for item in res:
57                    if numpy.isfinite(item):
58                        sum +=item
[e9b4cc4]59                #print "chisqr : sum 2D", xmin, xmax, ymin, ymax,sum
[d23544dc]60                #print res
[948add7]61                self.tcChi.SetValue(format_number(math.fabs(sum)))
62            except:
63                wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
64                            "Chisqr cannot be compute: %s"% sys.exc_value))
[d89f09b]65       
[d23544dc]66 
Note: See TracBrowser for help on using the repository browser.