Changeset 5789654 in sasview


Ignore:
Timestamp:
Apr 7, 2008 6:31:09 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
8742751
Parents:
fcaada5
Message:

modied fitdialog property dialog added fittings , modified plottables

Location:
guitools
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • guitools/PropertyDialog.py

    re2914b1 r5789654  
    2626        iy += 1 
    2727        ix = 1 
    28         self.xvalue = wx.ComboBox(panel, -1, size=(60, -1)) 
     28        self.xvalue = wx.ComboBox(panel, -1) 
    2929        sizer.Add(self.xvalue,(iy,ix)) 
    3030        ix +=2 
    31         self.yvalue = wx.ComboBox(panel, -1, size=(60, -1)) 
     31        self.yvalue = wx.ComboBox(panel, -1) 
    3232        sizer.Add( self.yvalue,(iy, ix)) 
    3333        ix +=2 
     
    5353        self.yvalue.Insert("Log(y)",1) 
    5454        self.yvalue.Insert("y^(2)",2) 
     55        self.yvalue.Insert("1/y",3) 
     56        self.yvalue.Insert("1/sqrt(y)",4) 
     57        self.yvalue.Insert("Log(y*x)",5) 
     58        self.yvalue.Insert("Log(y*x^(2))",6) 
    5559         
    5660        panel.SetSizer(sizer) 
  • guitools/fitDialog.py

    r1bde57a r5789654  
    8989        # new data for the fit  
    9090        self.file_data1 = Theory1D(x=[], y=[], dy=None) 
    91         self.file_data1.name = "y= exp(A + bx**2)" 
     91        self.file_data1.name = "Fit" 
    9292         
    9393    def _onFit(self ,event): 
     
    9595        print "we are on fit" 
    9696        temp =[] 
    97         tempdx =[] 
    98         tempdy =[] 
    9997        xmin = self._checkVal(self.tcXmin.GetValue()) 
    10098        xmax = self._checkVal(self.tcXmax.GetValue()) 
    101         #x= self.plottable.view.x 
    102         x=self.plottable.returnXvalueOfView() 
    103         print "x value :" ,x 
     99         
     100        #store the values of View in x,y, dx,dy 
     101        x,y,dx,dy=self.plottable.returnValuesOfView() 
     102        
    104103        if x != []: 
    105104            if xmin !=None  and xmax != None: 
     
    107106                    if x[j]>xmin and x[j]<xmax: 
    108107                        temp.append(self.model.run(x[j])) 
    109                         #tempdx.append(math.sqrt(x[j])) 
     108                     
    110109                        for y_i in temp: 
    111110                            tempdy.append(math.sqrt(y_i))  
     
    114113                for x_i in x: 
    115114                    temp.append(self.model.run(x_i)) 
    116                     tempdx.append(math.sqrt(x_i)) 
    117                 for y_i in temp: 
    118                     tempdy.append(math.sqrt(y_i)) 
     115         
    119116                    self.tcXmin.SetValue(str(min(x))) 
    120117                    self.tcXmax.SetValue(str(max(x))) 
     
    124121            self.file_data1.x =x 
    125122            self.file_data1.y =temp 
    126             #self.file_data1.dx=tempdx 
     123           
    127124            self.file_data1.dx=None 
    128             #self.file_data1.dy=tempdy 
    129125            self.file_data1.dy=None 
    130              
     126            self.file_data1.reset_view() 
    131127         
    132128            # Display the fittings values 
     
    136132            cstB  = fittings.Parameter(self.model, 'B', default_B)         
    137133            chisqr, out, cov = fittings.sansfit(self.model,  
    138                 [cstA, cstB], self.plottable.view.x,  
    139                 self.plottable.view.y, self.plottable.view.dy,xmin,xmax) 
    140             # Create new data plottable with result 
     134               [cstA, cstB],x, y,dy,min(x),max(x)) 
    141135             
    142             self.file_data1.y = [] 
    143             #for x_i in self.file_data1.x: 
    144             for x_i in self.file_data1.x: 
    145                 self.file_data1.y.append(self.model.run(x_i)) 
    146                  
    147             self.push_data(self.file_data1) 
     136            
     137            #Check that cov and out are iterable before displaying them 
    148138            if cov ==None: 
    149139                errA =str(0.0) 
     
    158148                cstA=str(out[0]) 
    159149                cstB=str(out[1]) 
     150            
     151            self.model.setParam('A', float(cstA)) 
     152            self.model.setParam('B', float(cstB)) 
     153             # Create new data plottable with result 
     154            self.file_data1.y = [] 
     155            
     156            for x_i in x: 
     157                self.file_data1.y.append(self.model.run(x_i)) 
     158            #Send the data to display to the PlotPanel 
     159            self.file_data1.reset_view() 
     160            self.push_data(self.file_data1) 
     161            # Display the fitting value on the Fit Dialog 
    160162            self._onsetValues(cstA, cstB, errA,errB,str(chisqr)) 
    161163        
  • guitools/plottables.py

    rf63f5ff r5789654  
    174174        if plottable in self.plottables: 
    175175            del self.plottables[plottable] 
     176        if self.color > 0: 
     177            self.color =  self.color -1 
     178        else: 
     179            self.color =0  
    176180 
    177181    def reset(self): 
     
    312316        self._yaxis = name 
    313317        self._yunit = units 
     318    def get_xaxis(self): 
     319        return self._xaxis, self._xunit 
     320    def get_yaxis(self): 
     321        return self._yaxis, self._yunit 
    314322 
    315323    @classmethod 
     
    336344    def __init__(self): 
    337345        self.view = View() 
     346        self._xaxis = "" 
     347        self._xunit = "" 
     348        self._yaxis = "" 
     349        self._yunit = ""  
     350         
    338351    def set_View(self,x,y): 
    339352        """ Load View  """ 
     
    345358        """ Reload view with new value to plot""" 
    346359        self.view = self.View(self.x, self.y, self.dx, self.dy) 
    347         print "the value of view x",self.view.x 
    348         print "the value of view y",self.view.y 
     360        
    349361        
    350362     
     
    379391        self.view.transform_y(func, errfunc, self.y, self.dy) 
    380392         
    381     def returnXvalueOfView(self): 
     393    def returnValuesOfView(self): 
    382394        return self.view.returnXview() 
    383395         
     
    449461                      
    450462        def returnXview(self): 
    451             return self.x 
     463            return self.x,self.y,self.dx,self.dy 
     464            
    452465      
    453466class Data1D(Plottable): 
     
    468481        self.dx = dx 
    469482        self.dy = dy 
    470          
     483        self.xaxis( 'q', 'A') 
     484        self.yaxis( 'intensity', 'cm') 
    471485        self.view = self.View(self.x, self.y, self.dx, self.dy) 
    472486         
     
    497511        The title is the name that will show up on the legend. 
    498512        """ 
     513        self.name= "theo" 
    499514        self.x = x 
    500515        self.y = y 
    501516        self.dy = dy 
    502         #Alina:added 
     517        
    503518        self.view = self.View(self.x, self.y, None, self.dy) 
    504519    def render(self,plot,**kw): 
     
    508523    def changed(self): 
    509524        return False 
    510  
     525    @classmethod 
     526    def labels(cls, collection): 
     527        """Build a label mostly unique within a collection""" 
     528        map = {} 
     529        for item in collection: 
     530            #map[item] = label(item, collection) 
     531            map[item] = r"$\rm{%s}$" % item.name 
     532        return map 
     533    
    511534 
    512535 
  • guitools/requirements.txt

    rfcaada5 r5789654  
    33  1- [DONE] After fitting, the fit panel is not updated with the output values of the fit.  
    44   
    5   2- Do this: 
     5  2- [DONE] Do this: 
    66      a) load the file line_in_x2_y.txt 
    77      b) fit a straight line, close the Fit Dialog 
     
    99      You will see an exception that should be fixed. 
    1010 
    11   3- [DONE] Load the file line_in_x2_y.txt in miniView. Select x^2 and y for the scales. Fit it.  
     11  3-  [DONE] Load the file line_in_x2_y.txt in miniView. Select x^2 and y for the scales. Fit it.  
    1212      a) The fit range is wrong, it's not update for the X^2 view. 
    1313      b) the fit result is wrong 
    1414      c) Even if you update the range, the fit and the plots are wrong. 
    1515       
    16   4- At the python command prompt, try: 
     16  4- [DONE]At the python command prompt, try: 
    1717       from sans.guitools.PlotPanel import PlotPanel 
    1818        
     
    2121     Guitools should not depend on your miniView code. 
    2222      
    23   5- Each time you open and close the Fit Dialog, a new label "Theory1D" is created in the 
     23  5- [QUESTION] Each time you open and close the Fit Dialog, a new label "Theory1D" is created in the 
    2424     legend. There should always be only one, for the _last_ fit, and the name should be "Fit". 
     25     [alina] is it fine if I delete the fit line from the graph 
     26      and remove  it when I close the Fit Dialog window? 
    2527      
    26   6- Do this: 
     28  6-[QUESTION ] Do this: 
    2729                a) Load the file 'line_in_logy_x.txt' 
    2830                b) Fit a straight line 
    2931                c) The fit shown does not start from the first point and it's not a straight line.  
     32        [ALINA] then for transformation to log Do I have to transform x to log and set x linear? 
    3033       
    3134- NOTES that might help for bugs 
     
    3437                the axis is in log will NOT be a straight line 
    3538  3- Make sure that you are filling the View of the fit result correctly. 
    36    
     39  [ALINA] not using the log of matplotlib anymore but the axis are never in the log scale by the value are in log10 x 
    3740 
    3841- NEEDED IMPROVEMENTS 
    39   1- After loading a new file or changing the scale using the "Properties" menu, remove any previously displayed fit from the graph. 
     42  1-[DONE] After loading a new file or changing the scale using the "Properties" menu, remove any previously displayed fit from the graph. 
    4043   
    4144  2- There are additional y scales we need: y, y^2, log(y), 1/y, 1/sqrt(y), log(y * x), log(y * x^2) 
Note: See TracChangeset for help on using the changeset viewer.