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
Line 
1import sys
2import wx
3import wx.lib
4import numpy,math
5import copy
6
7from sans.guicomm.events import StatusEvent   
8(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
9_BOX_WIDTH = 80
10
11from modelpage import format_number
12from fitpage1D import FitPage1D
13   
14class FitPage2D(FitPage1D):
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   
28    def __init__(self, parent,data, *args, **kwargs):
29        FitPage1D.__init__(self, parent, *args, **kwargs)
30        """
31            Initialization of the Panel
32        """
33       
34       
35    def compute_chisqr(self):
36        """ @param fn: function that return model value
37            @return residuals
38        """
39        flag=self.checkFitRange()
40        res=[]
41        if flag== True:
42            try:
43                xmin = float(self.xmin.GetValue())
44                xmax = float(self.xmax.GetValue())
45                ymin = float(self.ymin.GetValue())
46                ymax = float(self.ymax.GetValue())
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:
51                                res.append( (self.data.data[j][i]- self.model.runXY(\
52                                 [self.data.x_bins[i],self.data.y_bins[j]]))\
53                                    /self.data.err_data[j][i] )
54                sum=0
55               
56                for item in res:
57                    if numpy.isfinite(item):
58                        sum +=item
59                #print "chisqr : sum 2D", xmin, xmax, ymin, ymax,sum
60                #print res
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))
65       
66 
Note: See TracBrowser for help on using the repository browser.