Changeset 5062bbf in sasview for sansview/perspectives


Ignore:
Timestamp:
Jun 7, 2010 8:26:43 AM (14 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:
b94945d
Parents:
79ac6f8
Message:

working on documentation

Location:
sansview/perspectives/fitting
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/basepage.py

    rbb70474 r5062bbf  
    3131class BasicPage(wx.ScrolledWindow): 
    3232    """ 
    33         This class provide general structure of  fitpanel page 
     33    This class provide general structure of  fitpanel page 
    3434    """ 
    3535     ## Internal name for the AUI manager 
     
    3939     
    4040    def __init__(self,parent, page_info): 
     41        """ 
     42        """ 
    4143        wx.ScrolledWindow.__init__(self, parent, 
    4244                 style= wx.FULL_REPAINT_ON_RESIZE ) 
     
    149151    class ModelTextCtrl(wx.TextCtrl): 
    150152        """ 
    151             Text control for model and fit parameters. 
    152             Binds the appropriate events for user interactions. 
    153             Default callback methods can be overwritten on initialization 
    154              
    155             @param kill_focus_callback: callback method for EVT_KILL_FOCUS event 
    156             @param set_focus_callback:  callback method for EVT_SET_FOCUS event 
    157             @param mouse_up_callback:   callback method for EVT_LEFT_UP event 
    158             @param text_enter_callback: callback method for EVT_TEXT_ENTER event 
     153        Text control for model and fit parameters. 
     154        Binds the appropriate events for user interactions. 
     155        Default callback methods can be overwritten on initialization 
     156         
     157        :param kill_focus_callback: callback method for EVT_KILL_FOCUS event 
     158        :param set_focus_callback:  callback method for EVT_SET_FOCUS event 
     159        :param mouse_up_callback:   callback method for EVT_LEFT_UP event 
     160        :param text_enter_callback: callback method for EVT_TEXT_ENTER event 
     161         
    159162        """ 
    160163        ## Set to True when the mouse is clicked while the whole string is selected 
     
    184187        def _on_set_focus(self, event): 
    185188            """ 
    186                 Catch when the text control is set in focus to highlight the whole 
    187                 text if necessary 
    188                 @param event: mouse event 
     189            Catch when the text control is set in focus to highlight the whole 
     190            text if necessary 
     191             
     192            :param event: mouse event 
     193             
    189194            """ 
    190195             
     
    197202        def _highlight_text(self, event): 
    198203            """ 
    199                 Highlight text of a TextCtrl only of no text has be selected 
    200                 @param event: mouse event 
     204            Highlight text of a TextCtrl only of no text has be selected 
     205             
     206            :param event: mouse event 
     207             
    201208            """ 
    202209            # Make sure the mouse event is available to other listeners 
     
    215222        def _silent_kill_focus(self,event): 
    216223            """ 
    217                do nothing to kill focus 
     224            do nothing to kill focus 
    218225            """ 
    219226            event.Skip() 
     
    222229    def set_page_info(self, page_info): 
    223230        """ 
    224             set some page important information at once 
     231        set some page important information at once 
    225232        """ 
    226233       ##window_name 
     
    243250    def onContextMenu(self, event):  
    244251        """ 
    245             Retrieve the state selected state 
     252        Retrieve the state selected state 
    246253        """ 
    247254        # Skipping the save state functionality for release 0.9.0 
     
    256263    def onUndo(self, event): 
    257264        """ 
    258             Cancel the previous action 
     265        Cancel the previous action 
    259266        """ 
    260267        #print "enable undo" 
     
    262269        wx.PostEvent(self.parent, event) 
    263270         
    264          
    265271    def onRedo(self, event): 
    266272        """ 
    267             Restore the previous action cancelled  
     273        Restore the previous action cancelled  
    268274        """ 
    269275        #print "enable redo" 
    270276        event = NextStateEvent(page= self) 
    271277        wx.PostEvent(self.parent, event) 
    272          
    273          
     278     
    274279    def define_page_structure(self): 
    275280        """ 
    276             Create empty sizer for a panel 
     281        Create empty sizer for a panel 
    277282        """ 
    278283        self.vbox  = wx.BoxSizer(wx.VERTICAL) 
     
    303308    def set_layout(self): 
    304309        """ 
    305              layout 
     310        layout 
    306311        """ 
    307312        self.vbox.Layout() 
     
    311316        self.set_scroll() 
    312317        self.Centre() 
    313          
    314          
     318     
    315319    def set_scroll(self): 
     320        """ 
     321        """ 
    316322        self.SetScrollbars(20,20,25,65) 
    317323        self.Layout()    
    318324        self.SetAutoLayout(True) 
    319325          
    320           
    321326    def set_owner(self,owner): 
    322327        """  
    323             set owner of fitpage 
    324             @param owner: the class responsible of plotting 
     328        set owner of fitpage 
     329         
     330        :param owner: the class responsible of plotting 
     331         
    325332        """ 
    326333        self.event_owner = owner     
     
    329336    def get_data(self): 
    330337        """ 
    331             return the current data  
     338        return the current data  
    332339        """ 
    333340        return self.data   
     
    335342    def set_manager(self, manager): 
    336343        """ 
    337              set panel manager 
    338              @param manager: instance of plugin fitting 
     344        set panel manager 
     345         
     346        :param manager: instance of plugin fitting 
     347         
    339348        """ 
    340349        self.manager = manager   
     
    343352    def populate_box(self, dict): 
    344353        """ 
    345              Store list of model 
    346              @param dict: dictionary containing list of models 
     354        Store list of model 
     355         
     356        :param dict: dictionary containing list of models 
     357         
    347358        """ 
    348359        self.model_list_box = dict 
     
    351362    def initialize_combox(self):  
    352363        """ 
    353             put default value in the combobox  
     364        put default value in the combobox  
    354365        """   
    355366        ## fill combox box 
     
    377388    def set_dispers_sizer(self): 
    378389        """ 
    379             fill sizer containing dispersity info 
     390        fill sizer containing dispersity info 
    380391        """ 
    381392        self.sizer4.Clear(True) 
     
    439450        self.state.enable_disp= self.enable_disp.GetValue() 
    440451        self.state.disable_disp= self.disable_disp.GetValue() 
    441      
    442      
     452 
    443453    def select_disp_angle(self, event):  
    444454        """ 
    445             Event for when a user select a parameter to average over. 
    446             @param event: radiobutton event 
     455        Event for when a user select a parameter to average over. 
     456         
     457        :param event: radiobutton event 
     458         
    447459        """ 
    448460        self.values=[] 
     
    533545    def onResetModel(self, event): 
    534546        """ 
    535             Reset model state 
     547        Reset model state 
    536548        """ 
    537549        ## post help message for the selected model  
     
    550562    def on_save_state(self, event):    
    551563        """ 
    552             Save the current state into file 
     564        Save the current state into file 
    553565        """   
    554566        self.save_current_state() 
     
    569581    def on_bookmark(self, event): 
    570582        """ 
    571             save history of the data and model 
     583        save history of the data and model 
    572584        """ 
    573585        if self.model==None: 
     
    616628    def onSetFocus(self, evt): 
    617629        """ 
    618             highlight the current textcrtl and hide the error text control shown  
    619             after fitting 
    620             :Not implemented. 
     630        highlight the current textcrtl and hide the error text control shown  
     631        after fitting 
    621632        """ 
    622633        return 
     
    624635    def read_file(self, path): 
    625636        """ 
    626             Read two columns file 
    627             @param path: the path to the file to read 
     637        Read two columns file 
     638         
     639        :param path: the path to the file to read 
     640         
    628641        """ 
    629642        try: 
     
    651664        except: 
    652665            raise  
    653      
    654      
     666 
    655667    def createMemento(self): 
    656668        """ 
    657             return the current state of the page 
     669        return the current state of the page 
    658670        """ 
    659671        return self.state.clone() 
     
    662674    def save_current_state(self): 
    663675        """ 
    664             Store current state 
     676        Store current state 
    665677        """ 
    666678        ## save model option 
     
    743755    def save_current_state_fit(self): 
    744756        """ 
    745             Store current state for fit_page 
     757        Store current state for fit_page 
    746758        """ 
    747759        ## save model option 
     
    820832    def check_invalid_panel(self):   
    821833        """ 
    822             check if the user can already perform some action with this panel 
     834        check if the user can already perform some action with this panel 
    823835        """  
    824836        flag = False 
     
    829841            wx.MessageBox(msg, 'Info') 
    830842            return  True 
     843         
    831844    def reset_page_helper(self, state): 
    832845        """ 
    833             Use page_state and change the state of existing page 
    834             @precondition: the page is already drawn or created 
    835             @postcondition: the state of the underlying data change as well as the 
     846        Use page_state and change the state of existing page 
     847         
     848        :precondition: the page is already drawn or created 
     849         
     850        :postcondition: the state of the underlying data change as well as the 
    836851            state of the graphic interface 
    837852        """ 
     
    958973    def _selectDlg(self): 
    959974        """ 
    960             open a dialog file to selected the customized dispersity  
     975        open a dialog file to selected the customized dispersity  
    961976        """ 
    962977        import os 
     
    968983        dlg.Destroy() 
    969984        return path 
    970      
    971      
     985 
    972986    def _reset_context_menu(self): 
    973987        """ 
    974             reset the context menu 
     988        reset the context menu 
    975989        """ 
    976990        for name, state in self.state.saved_states.iteritems(): 
     
    981995            wx.EVT_MENU(self, id, self.onResetModel) 
    982996     
    983      
    984997    def _reset_plotting_range(self, state): 
    985998        """ 
    986             Reset the plotting range to a given state 
     999        Reset the plotting range to a given state 
    9871000        """ 
    9881001        if self.check_invalid_panel(): 
     
    9931006            self.npts.SetValue(str(state.npts))  
    9941007             
    995              
    9961008    def _save_typeOfmodel(self): 
    9971009        """ 
    998             save radiobutton containing the type model that can be selected 
     1010        save radiobutton containing the type model that can be selected 
    9991011        """ 
    10001012        self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     
    10101022        wx.PostEvent(self.parent, event) 
    10111023         
    1012          
    10131024    def _save_plotting_range(self ): 
    10141025        """ 
    1015             save the state of plotting range  
     1026        save the state of plotting range  
    10161027        """ 
    10171028        self.state.qmin = self.qmin_x 
     
    10231034    def _onparamEnter_helper(self): 
    10241035        """ 
    1025              check if values entered by the user are changed and valid to replot  
    1026              model 
    1027              use : _check_value_enter  
     1036        check if values entered by the user are changed and valid to replot  
     1037        model 
    10281038        """ 
    10291039        # Flag to register when a parameter has changed.    
     
    10801090    def _update_paramv_on_fit(self): 
    10811091        """ 
    1082              make sure that update param values just before the fitting 
     1092        make sure that update param values just before the fitting 
    10831093        """ 
    10841094        #flag for qmin qmax check values 
     
    11451155            if self._is_2D():self.btEditMask.Enable(True) 
    11461156 
    1147          
    11481157        if not flag: 
    11491158            msg= "Cannot Plot or Fit :Must select a model or Fitting range is not valid!!!  " 
     
    11561165    def _is_modified(self, is_modified): 
    11571166        """ 
    1158             return to self._is_modified 
     1167        return to self._is_modified 
    11591168        """ 
    11601169        return is_modified 
     
    11621171    def _reset_parameters_state(self, listtorestore,statelist): 
    11631172        """ 
    1164             Reset the parameters at the given state 
     1173        Reset the parameters at the given state 
    11651174        """ 
    11661175        if len(statelist)==0 or  len(listtorestore)==0 : 
     
    12071216                else: 
    12081217                    item_page[6].Hide() 
    1209                              
    1210                              
     1218                                       
    12111219    def _copy_parameters_state(self, listtocopy, statelist): 
    12121220        """ 
    1213             copy the state of button  
    1214             @param listtocopy: the list of check button to copy 
    1215             @param statelist: list of state object to store the current state 
     1221        copy the state of button  
     1222         
     1223        :param listtocopy: the list of check button to copy 
     1224        :param statelist: list of state object to store the current state 
     1225         
    12161226        """ 
    12171227        if len(listtocopy)==0: 
     
    12551265                                [min_state,min_value],[max_state , max_value],unit]) 
    12561266            
    1257          
    1258     
    12591267    def _set_model_sizer_selection(self, model): 
    12601268        """ 
    1261             Display the sizer according to the type of the current model 
    1262         """ 
    1263         if model ==None: 
     1269        Display the sizer according to the type of the current model 
     1270        """ 
     1271        if model == None: 
    12641272            return 
    12651273        if hasattr(model ,"s_model"): 
     
    13681376                    break 
    13691377     
    1370      
    13711378    def _draw_model(self): 
    13721379        """ 
    1373             Method to draw or refresh a plotted model. 
    1374             The method will use the data member from the model page 
    1375             to build a call to the fitting perspective manager. 
    1376              
    1377             [Note to coder: This way future changes will be done in only one place.]  
     1380        Method to draw or refresh a plotted model. 
     1381        The method will use the data member from the model page 
     1382        to build a call to the fitting perspective manager. 
    13781383        """ 
    13791384        if self.check_invalid_panel(): 
     
    13951400    def _set_model_sizer(self,sizer, box_sizer, title="", object=None): 
    13961401        """ 
    1397             Use lists to fill a sizer for model info 
     1402        Use lists to fill a sizer for model info 
    13981403        """ 
    13991404        
     
    14721477        self.SetScrollbars(20,20,25,65) 
    14731478         
    1474          
    14751479    def _show_combox(self, event): 
    14761480        """ 
    1477             Show combox box associate with type of model selected 
     1481        Show combox box associate with type of model selected 
    14781482        """ 
    14791483        if self.check_invalid_panel(): 
     
    15271531    def _populate_box(self, combobox, list): 
    15281532        """ 
    1529             fill combox box with dict item 
    1530             @param list: contains item to fill the combox 
     1533        fill combox box with dict item 
     1534         
     1535        :param list: contains item to fill the combox 
    15311536            item must model class 
    15321537        """ 
     
    15391544                    name = model.name 
    15401545                combobox.Append(name,models) 
    1541  
    15421546        return 0 
    15431547 
    1544     #def _onparamEnter(self,event): 
    1545         """  
    1546         #when enter value on panel redraw model according to changed 
    1547         """ 
    1548         """ 
    1549         tcrtl= event.GetEventObject() 
    1550          
    1551         #Clear msg if previously shown. 
    1552         msg= "" 
    1553         wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 
    1554          
    1555         ## save current state 
    1556         self.save_current_state() 
    1557         if event !=None: 
    1558             #self._undo.Enable(True) 
    1559             event = PageInfoEvent(page = self) 
    1560             wx.PostEvent(self.parent, event) 
    1561                
    1562         if check_float(tcrtl): 
    1563              
    1564             self._onparamEnter_helper() 
    1565             #event.Skip() 
    1566         else: 
    1567             msg= "Cannot Plot :Must enter a number!!!  " 
    1568             wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 
    1569             #event.Skip() 
    1570             return  
    1571        """ 
    15721548    def _onQrangeEnter(self, event): 
    15731549        """ 
    1574             Check validity of value enter in the Q range field 
     1550        Check validity of value enter in the Q range field 
    15751551        """ 
    15761552         
     
    16311607    def _on_select_model_helper(self):  
    16321608        """ 
    1633              call back for model selection 
     1609        call back for model selection 
    16341610        """ 
    16351611        ## reset dictionary containing reference to dispersion 
     
    16801656    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    16811657        """ 
    1682             Verify that the Q range controls have valid values 
    1683             and that Qmin < Qmax. 
    1684              
    1685             @param qmin_ctrl: text control for Qmin 
    1686             @param qmax_ctrl: text control for Qmax 
    1687             @return: True is the Q range is value, False otherwise  
     1658        Verify that the Q range controls have valid values 
     1659        and that Qmin < Qmax. 
     1660         
     1661        :param qmin_ctrl: text control for Qmin 
     1662        :param qmax_ctrl: text control for Qmax 
     1663         
     1664        :return: True is the Q range is value, False otherwise  
     1665         
    16881666        """ 
    16891667        qmin_validity = check_float(qmin_ctrl) 
     
    17121690    def _validate_Npts(self):   
    17131691        """ 
    1714             Validate the number of points for fitting is more than 10 points. 
    1715             If valid, setvalues Npts_fit otherwise post msg. 
     1692        Validate the number of points for fitting is more than 10 points. 
     1693        If valid, setvalues Npts_fit otherwise post msg. 
    17161694        """ 
    17171695        #default flag 
     
    17431721    def _check_value_enter(self, list, modified): 
    17441722        """ 
    1745             @param list: model parameter and panel info 
    1746             each item of the list should be as follow: 
    1747             item=[cb state, name, value, "+/-", error of fit, min, max , units] 
     1723        :param list: model parameter and panel info 
     1724        :Note: each item of the list should be as follow: 
     1725            item=[check button state, parameter's name, 
     1726                paramater's value, string="+/-",  
     1727                parameter's error of fit,  
     1728                parameter's minimum value,  
     1729                parrameter's maximum value ,  
     1730                parameter's units] 
    17481731        """   
    17491732        is_modified =  modified 
     
    18291812    def _set_dipers_Param(self, event): 
    18301813        """ 
    1831             respond to self.enable_disp and self.disable_disp radio box. 
    1832             The dispersity object is reset inside the model into Gaussian.  
    1833             When the user select yes , this method display a combo box for more selection 
    1834             when the user selects No,the combo box disappears. 
    1835             Redraw the model with the default dispersity (Gaussian) 
     1814        respond to self.enable_disp and self.disable_disp radio box. 
     1815        The dispersity object is reset inside the model into Gaussian.  
     1816        When the user select yes , this method display a combo box for more selection 
     1817        when the user selects No,the combo box disappears. 
     1818        Redraw the model with the default dispersity (Gaussian) 
    18361819        """ 
    18371820        if self.check_invalid_panel(): 
     
    18881871    def _layout_sizer_noDipers(self): 
    18891872        """ 
    1890             Draw a sizer with no dispersity info 
     1873        Draw a sizer with no dispersity info 
    18911874        """ 
    18921875        ix=0 
     
    19081891    def _reset_dispersity(self): 
    19091892        """ 
    1910              put gaussian dispersity into current model 
     1893        put gaussian dispersity into current model 
    19111894        """ 
    19121895        if len(self.param_toFit)>0: 
     
    19501933        self.Refresh() 
    19511934                   
    1952              
    19531935    def _on_select_Disp(self,event): 
    19541936        """ 
    1955              allow selecting different dispersion 
    1956              self.disp_list should change type later .now only gaussian 
     1937        allow selecting different dispersion 
     1938        self.disp_list should change type later .now only gaussian 
    19571939        """ 
    19581940        n = self.disp_box.GetCurrentSelection() 
     
    19791961    def _set_sizer_arraydispersion(self): 
    19801962        """ 
    1981             draw sizer with array dispersity  parameters 
     1963        draw sizer with array dispersity  parameters 
    19821964        """ 
    19831965         
     
    20632045        wx.PostEvent(self.parent, event) 
    20642046         
    2065                  
    2066          
    2067         
    2068  
    20692047    def _set_range_sizer(self, title, box_sizer=None, object1=None,object=None): 
    20702048        """ 
    2071             Fill the Q range sizer 
     2049        Fill the Q range sizer 
    20722050        """ 
    20732051        #2D data? default 
     
    21442122    def _fill_save_sizer(self): 
    21452123        """ 
    2146             Draw the layout for saving option 
     2124        Draw the layout for saving option 
    21472125        """ 
    21482126        self.sizer6.Clear(True) 
     
    21662144    def _lay_out(self): 
    21672145        """ 
    2168             returns self.Layout 
    2169             Note: Mac seems to like this better when self.Layout is called after fitting. 
     2146        returns self.Layout 
     2147         
     2148        :Note: Mac seems to like this better when self. 
     2149            Layout is called after fitting. 
    21702150        """ 
    21712151        self._sleep4sec() 
     
    21832163    def on_reset_clicked(self,event): 
    21842164        """ 
    2185         #On 'Reset' button  for Q range clicked 
     2165        On 'Reset' button  for Q range clicked 
    21862166        """ 
    21872167        flag = True 
     
    22342214            self._onparamEnter_helper() 
    22352215 
    2236              
    22372216        self.save_current_state() 
    22382217        self.state.qmin = self.qmin_x 
     
    22472226    def on_model_help_clicked(self,event): 
    22482227        """ 
    2249         #On 'More details' button 
     2228        on 'More details' button 
    22502229        """ 
    22512230        from help_panel import  HelpWindow 
  • sansview/perspectives/fitting/console.py

    re54d2c32 r5062bbf  
    2222        If quiet is true, only print out final summary, not progress and 
    2323        improvements. 
     24         
     25        :attr parent: the object that handle the messages 
     26         
    2427        """ 
    2528        self.parent= parent 
     
    9699             
    97100    def finalize(self): 
     101        """ 
     102        """ 
    98103        if self.isbetter: 
    99104            self.result.print_summary() 
    100105 
    101106    def abort(self): 
     107        """ 
     108        """ 
    102109        if self.isbetter: 
    103110            self.result.print_summary() 
    104111             
    105112    def update_fit(self, msg=""): 
     113        """ 
     114        """ 
    106115        self.elapsed_time = time.time() - self.elapsed_time 
    107116        msg = " Updating fit ...\n result:\n %s \n"%self.result.__str__() 
     
    110119         
    111120    def starting_fit(self): 
     121        """ 
     122        """ 
    112123        wx.PostEvent(self.parent, StatusEvent(status="Starting the Fit...", 
    113124                                        info="info",type="progress")) 
    114125         
    115126    def set_result(self, result): 
     127        """ 
     128        """ 
    116129        self.result = result 
    117130         
  • sansview/perspectives/fitting/fit_thread.py

    re54d2c32 r5062bbf  
    3030    def isquit(self): 
    3131        """ 
    32              @raise KeyboardInterrupt: when the thread is interrupted 
     32        :raise KeyboardInterrupt: when the thread is interrupted 
     33         
    3334        """ 
    3435        try: 
     
    3940    def compute(self): 
    4041        """ 
    41             Perform a fit  
     42        Perform a fit  
    4243        """ 
    4344        try:  
     
    5859            self.handler.error(msg=msg) 
    5960         
    60              
    61           
    62              
    63      
  • sansview/perspectives/fitting/fitpage.py

    rcb190a19 r5062bbf  
    3333class FitPage(BasicPage): 
    3434    """ 
    35         FitPanel class contains fields allowing to display results when 
    36         fitting  a model and one data 
    37         @note: For Fit to be performed the user should check at least one parameter 
     35    FitPanel class contains fields allowing to display results when 
     36    fitting  a model and one data 
     37     
     38    :note: For Fit to be performed the user should check at least one parameter 
    3839        on fit Panel window. 
    39    
    4040    """ 
    4141     
    4242    def __init__(self,parent, page_info): 
     43        """  
     44        Initialization of the Panel 
     45        """ 
    4346        BasicPage.__init__(self, parent, page_info) 
    44  
    45         """  
    46             Initialization of the Panel 
    47         """ 
    4847        ## total number of point: float 
    4948        self.npts=None 
     
    9897    def _on_fit_complete(self, event): 
    9998        """ 
    100             When fit is complete ,reset the fit button label. 
     99        When fit is complete ,reset the fit button label. 
    101100        """ 
    102101        #self.btFit.SetLabel("Fit") 
     
    107106    def _is_2D(self): 
    108107        """ 
    109             Check if data_name is Data2D 
    110             @return: True or False 
     108        Check if data_name is Data2D 
     109         
     110        :return: True or False 
     111         
    111112        """ 
    112113         
     
    117118    def _on_engine_change(self, event): 
    118119        """ 
    119             get an event containing the current name of the fit engine type 
    120             @param event: FitterTypeEvent containing  the name of the current engine 
     120        get an event containing the current name of the fit engine type 
     121         
     122        :param event: FitterTypeEvent containing  the name of the current engine 
     123         
    121124        """ 
    122125        self.engine_type = event.type 
     
    186189    def _fill_range_sizer(self): 
    187190        """ 
    188             Fill the sizer containing the plotting range 
    189             add  access to npts 
     191        Fill the sizer containing the plotting range 
     192        add  access to npts 
    190193        """ 
    191194        is_2Ddata = False 
     
    231234        self.smear_accuracy.SetToolTipString("'Higher' uses more Gaussian points for smearing computation.") 
    232235                    
    233          
    234               
    235236        wx.EVT_COMBOBOX(self.smear_accuracy,-1, self._on_select_accuracy) 
    236237 
     
    390391    def _fill_datainfo_sizer(self): 
    391392        """ 
    392             fill sizer 0 with data info 
     393        fill sizer 0 with data info 
    393394        """ 
    394395        ## no loaded data , don't fill the sizer 
     
    455456    def _fill_model_sizer(self, sizer): 
    456457        """ 
    457             fill sizer containing model info 
     458        fill sizer containing model info 
    458459        """ 
    459460        ##Add model function Details button in fitpanel. 
     
    470471        ## class base method  to add view 2d button     
    471472        self._set_model_sizer(sizer=sizer, box_sizer=boxsizer1, title="Model",object=self.model_help )    
    472  
    473      
     473         
    474474    def _set_sizer_dispersion(self, dispersity): 
    475475        """ 
    476             draw sizer with gaussian dispersity parameters 
     476        draw sizer with gaussian dispersity parameters 
    477477        """ 
    478478        self.fittable_param=[] 
     
    749749                                                     ,None,None, None, None,None]) 
    750750        
    751  
    752751        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)   
    753752           
     
    769768        self.Layout() 
    770769 
    771  
    772770    def _onFit(self, event):      
    773771        """ 
    774             Allow to fit 
     772        Allow to fit 
    775773        """ 
    776774        #make sure all parameter values are updated. 
     
    796794            return  
    797795       
    798  
    799796        self.select_param(event =None) 
    800797         
     
    820817        #    self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) 
    821818            
    822  
    823          
    824819    def _StopFit(self, event): 
    825820        """ 
    826             Stop fit  
     821        Stop fit  
    827822        """ 
    828823        self.btFit.SetLabel("Fit") 
     
    835830    def _on_select_model(self, event):  
    836831        """ 
    837              call back for model selection 
     832        call back for model selection 
    838833        """   
    839834        self._on_select_model_helper()  
     
    879874            event = PageInfoEvent(page = self) 
    880875            wx.PostEvent(self.parent, event)  
    881       
    882                  
     876       
    883877    def _onparamEnter(self,event): 
    884878        """  
    885             when enter value on panel redraw model according to changed 
     879        when enter value on panel redraw model according to changed 
    886880        """ 
    887881        if self.model ==None: 
     
    941935    def _onparamRangeEnter(self, event): 
    942936        """ 
    943             Check validity of value enter in the parameters range field 
     937        Check validity of value enter in the parameters range field 
    944938        """ 
    945939        if self.check_invalid_panel(): 
     
    974968    def _onQrangeEnter(self, event): 
    975969        """ 
    976             Check validity of value enter in the Q range field 
     970        Check validity of value enter in the Q range field 
    977971        """ 
    978972        if self.check_invalid_panel(): 
     
    10401034        wx.PostEvent(self.parent, event) 
    10411035        self.state_change= False 
    1042  
    10431036        return 
     1037     
    10441038    def _clear_Err_on_Fit(self): 
    10451039        """ 
    1046             hide the error text control shown  
    1047             after fitting 
     1040        hide the error text control shown  
     1041        after fitting 
    10481042        """ 
    10491043         
     
    10841078    def _get_defult_custom_smear(self): 
    10851079        """ 
    1086            Get the defult values for custum smearing. 
    1087         """ 
    1088  
     1080        Get the defult values for custum smearing. 
     1081        """ 
    10891082        # get the default values 
    10901083        if self.dxl == None: self.dxl = 0.0 
     
    10951088    def _get_smear_info(self): 
    10961089        """ 
    1097            Get the smear info from data. 
    1098            @return: self.smear_type, self.dq_l and self.dq_r,  
     1090        Get the smear info from data. 
     1091        
     1092        :return: self.smear_type, self.dq_l and self.dq_r,  
    10991093            respectively the type of the smear, dq_min and dq_max for pinhole smear data  
    11001094            while dxl and dxw for slit smear 
     1095             
    11011096        """ 
    11021097 
     
    11181113            else:  
    11191114                return 
    1120  
    1121         
    1122  
    11231115        # check if it is pinhole smear and get min max if it is. 
    11241116        if data.dx != None and all(data.dx !=0):  
     
    11331125                self.dq_l = data.dxl[0] 
    11341126            if data.dxw != None and all(data.dxw !=0):  
    1135                 self.dq_r = data.dxw[0] 
    1136                  
     1127                self.dq_r = data.dxw[0]     
    11371128        #return self.smear_type,self.dq_l,self.dq_r        
    11381129     
    11391130    def _show_smear_sizer(self):     
    11401131        """ 
    1141             Show only the sizers depending on smear selection 
     1132        Show only the sizers depending on smear selection 
    11421133        """ 
    11431134        # smear disabled 
     
    11901181    def _hide_all_smear_info(self): 
    11911182        """ 
    1192            Hide all smearing messages in the set_smearer sizer 
     1183        Hide all smearing messages in the set_smearer sizer 
    11931184        """ 
    11941185        self.smear_description_none.Hide() 
     
    12171208    def _set_accuracy_list(self): 
    12181209        """ 
    1219             Set the list of an accuracy in 2D custum smear: Xhigh, High, Med, or Low 
     1210        Set the list of an accuracy in 2D custum smear: Xhigh, High, Med, or Low 
    12201211        """ 
    12211212        # list of accuracy choices 
     
    12261217    def _on_select_accuracy(self,event): 
    12271218        """ 
    1228             Select an accuracy in 2D custom smear: Xhigh, High, Med, or Low 
     1219        Select an accuracy in 2D custom smear: Xhigh, High, Med, or Low 
    12291220        """ 
    12301221        #event.Skip() 
    1231          
    12321222        # Check if the accuracy is same as before 
    1233          
    12341223        #self.smear2d_accuracy = event.GetEventObject().GetValue() 
    12351224        self.smear2d_accuracy = self.smear_accuracy.GetValue() 
     
    12391228            self.onSmear(event=None) 
    12401229            if self.current_smearer != None: 
    1241                 self.current_smearer.set_accuracy(accuracy = self.smear2d_accuracy) 
    1242                 
     1230                self.current_smearer.set_accuracy(accuracy = self.smear2d_accuracy)  
    12431231        event.Skip() 
    12441232         
    12451233    def _onMask(self, event):      
    12461234        """ 
    1247             Build a panel to allow to edit Mask 
     1235        Build a panel to allow to edit Mask 
    12481236        """ 
    12491237         
     
    12791267    def set_data(self, data): 
    12801268        """ 
    1281             reset the current data  
     1269        reset the current data  
    12821270        """ 
    12831271        self.data = data 
    1284  
    1285          
    12861272        if self.data is None: 
    12871273            data_min = "" 
     
    13021288                self.slit_smearer.Disable() 
    13031289                self.default_mask = copy.deepcopy(self.data.mask) 
    1304                  
    13051290                 
    13061291            self.formfactorbox.Enable() 
     
    13321317                self.btEditMask.Enable()   
    13331318                self.EditMask_title.Enable()  
    1334  
    1335              
    13361319        self.dataSource.SetValue(data_name) 
    13371320        self.qmin_x = data_min 
     
    13471330        self.state.qmax = self.qmax_x 
    13481331         
    1349  
    13501332    def reset_page(self, state,first=False): 
    13511333        """ 
    1352             reset the state 
     1334        reset the state 
    13531335        """ 
    13541336        self.reset_page_helper(state) 
     
    13681350    def get_range(self): 
    13691351        """ 
    1370             return the fitting range 
     1352        return the fitting range 
    13711353        """ 
    13721354        return float(self.qmin_x) , float(self.qmax_x) 
     
    13741356    def get_npts2fit(self): 
    13751357        """ 
    1376             return numbers of data points within qrange 
    1377             Note: This is for Park where chi2 is not normalized by Npts of fit 
     1358        return numbers of data points within qrange 
     1359         
     1360        :Note: This is for Park where chi2 is not normalized by Npts of fit 
     1361         
    13781362        """ 
    13791363        npts2fit = 0 
     
    13931377    def set_npts2fit(self): 
    13941378        """ 
    1395             setValue Npts for fitting  
     1379        setValue Npts for fitting  
    13961380        """ 
    13971381        self.Npts_fit.SetValue(str(self.get_npts2fit())) 
    13981382         
    1399          
    14001383    def get_chi2(self): 
    14011384        """ 
    1402             return the current chi2 
     1385        return the current chi2 
    14031386        """ 
    14041387        return self.tcChi.GetValue() 
     
    14061389    def get_param_list(self): 
    14071390        """ 
    1408             @return self.param_toFit: list containing  references to TextCtrl 
     1391        :return self.param_toFit: list containing  references to TextCtrl 
    14091392            checked.Theses TextCtrl will allow reference to parameters to fit. 
    1410             @raise: if return an empty list of parameter fit will nnote work  
     1393         
     1394        :raise: if return an empty list of parameter fit will nnote work  
    14111395            properly so raise ValueError,"missing parameter to fit" 
    14121396        """ 
     
    14181402    def onsetValues(self,chisqr,p_name, out,cov): 
    14191403        """ 
    1420             Build the panel from the fit result 
    1421             @param chisqr:Value of the goodness of fit metric 
    1422             @p_name: the name of parameters 
    1423             @param out:list of parameter with the best value found during fitting 
    1424             @param cov:Covariance matrix 
    1425         
     1404        Build the panel from the fit result 
     1405         
     1406        :param chisqr: Value of the goodness of fit metric 
     1407        :param p_name: the name of parameters 
     1408        :param out: list of parameter with the best value found during fitting 
     1409        :param cov: Covariance matrix 
     1410    
    14261411        """ 
    14271412        if out == None or not numpy.isfinite(chisqr): 
     
    15451530    def onPinholeSmear(self, event): 
    15461531        """ 
    1547             Create a custom pinhole smear object that will change the way residuals 
    1548             are compute when fitting 
    1549             @ accuracy: given by strings'High','Med', 'Low' FOR 2d,  None for 1D 
     1532        Create a custom pinhole smear object that will change the way residuals 
     1533        are compute when fitting 
     1534         
     1535        :Note: accuracy is given by strings'High','Med', 'Low' FOR 2d, 
     1536                     None for 1D 
     1537                      
    15501538        """ 
    15511539 
     
    16011589    def _is_changed_pinhole(self):   
    16021590        """ 
    1603             check if any of pinhole smear is changed 
    1604             return: True or False 
     1591        check if any of pinhole smear is changed 
     1592         
     1593        :return: True or False 
     1594         
    16051595        """ 
    16061596        # get the values 
     
    16271617    def _set_pinhole_smear(self): 
    16281618        """ 
    1629             Set custom pinhole smear 
    1630             return: msg 
     1619        Set custom pinhole smear 
     1620         
     1621        :return: msg 
     1622         
    16311623        """ 
    16321624        # copy data 
     
    16951687    def update_pinhole_smear(self): 
    16961688        """ 
    1697             called by kill_focus on pinhole TextCntrl 
    1698             to update the changes  
    1699             return: msg: False when wrong value was entered 
     1689        called by kill_focus on pinhole TextCntrl 
     1690        to update the changes  
     1691         
     1692        :return: False when wrong value was entered 
     1693         
    17001694        """ 
    17011695        # msg default 
     
    17141708    def onSlitSmear(self, event): 
    17151709        """ 
    1716             Create a custom slit smear object that will change the way residuals 
    1717             are compute when fitting 
     1710        Create a custom slit smear object that will change the way residuals 
     1711        are compute when fitting 
    17181712        """ 
    17191713  
     
    17701764            wx.PostEvent(self.manager.parent, StatusEvent(status = msg)) 
    17711765 
    1772  
    17731766    def _is_changed_slit(self):   
    17741767        """ 
    1775             check if any of slit lengths is changed 
    1776             return: True or False 
    1777         """ 
    1778          
     1768        check if any of slit lengths is changed 
     1769         
     1770        :return: True or False 
     1771         
     1772        """ 
    17791773        # get the values 
    17801774        width = self.smear_slit_width.GetValue() 
     
    18141808    def _set_slit_smear(self): 
    18151809        """ 
    1816             Set custom slit smear 
    1817             return: msg 
     1810        Set custom slit smear 
     1811         
     1812        :return: message to inform the user about the validity 
     1813            of the values entered for slit smear 
    18181814        """ 
    18191815        temp_smearer = None 
     
    18531849        ## set smearing value whether or not the data contain the smearing info 
    18541850        self.manager.set_smearer(smearer=self.current_smearer, qmin= float(self.qmin_x), qmax= float(self.qmax_x))  
    1855  
    18561851        return msg 
    18571852     
    1858      
    18591853    def update_slit_smear(self): 
    18601854        """ 
    1861             called by kill_focus on pinhole TextCntrl 
    1862             to update the changes  
    1863             return: msg: False when wrong value was entered 
     1855        called by kill_focus on pinhole TextCntrl 
     1856        to update the changes  
     1857         
     1858        :return: False when wrong value was entered 
     1859         
    18641860        """              
    18651861        # msg default 
     
    18761872            return True 
    18771873                             
    1878      
    18791874    def onSmear(self, event): 
    18801875        """ 
    1881             Create a smear object that will change the way residuals 
    1882             are compute when fitting 
     1876        Create a smear object that will change the way residuals 
     1877        are compute when fitting 
    18831878        """ 
    18841879        if event != None:  
     
    19501945    def on_complete_chisqr(self, event):   
    19511946        """ 
    1952             print result chisqr  
    1953             @event: activated by fitting/ complete after draw 
     1947        print result chisqr  
     1948         
     1949        :event: activated by fitting/ complete after draw 
     1950         
    19541951        """ 
    19551952        try: 
     
    19641961            pass   
    19651962             
    1966      
     1963 
    19671964    def select_all_param(self,event):  
    19681965        """ 
    1969              set to true or false all checkBox given the main checkbox value cb1 
     1966        set to true or false all checkBox given the main checkbox value cb1 
    19701967        """             
    1971  
    19721968        self.param_toFit=[] 
    19731969        if  self.parameters !=[]: 
     
    20082004            wx.PostEvent(self.parent, event)  
    20092005      
    2010                  
    2011                  
    20122006    def select_param(self,event): 
    20132007        """  
    2014             Select TextCtrl  checked for fitting purpose and stores them 
    2015             in  self.param_toFit=[] list 
     2008        Select TextCtrl  checked for fitting purpose and stores them 
     2009        in  self.param_toFit=[] list 
    20162010        """ 
    20172011        self.param_toFit=[] 
     
    20632057            event = PageInfoEvent(page = self) 
    20642058            wx.PostEvent(self.parent, event)  
    2065       
    20662059     
    2067          
    20682060    def set_model_param_sizer(self, model): 
    20692061        """ 
    2070             Build the panel from the model content 
    2071             @param model: the model selected in combo box for fitting purpose 
     2062        Build the panel from the model content 
     2063         
     2064        :param model: the model selected in combo box for fitting purpose 
     2065         
    20722066        """ 
    20732067        self.sizer3.Clear(True) 
     
    20872081            self.engine_type= self.manager._return_engine_type() 
    20882082 
    2089              
    20902083        box_description= wx.StaticBox(self, -1,str("Model Parameters")) 
    20912084        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
     
    23262319        self.Refresh() 
    23272320        self.SetScrollbars(20,20,25,65) 
     2321         
    23282322 
    23292323class BGTextCtrl(wx.TextCtrl): 
    23302324    """ 
    2331         Text control used to display outputs. 
    2332         No editing allowed. The background is  
    2333         grayed out. User can't select text. 
     2325    Text control used to display outputs. 
     2326    No editing allowed. The background is  
     2327    grayed out. User can't select text. 
    23342328    """ 
    23352329    def __init__(self, *args, **kwds): 
     
    23452339    def _click(self, event): 
    23462340        """ 
    2347             Prevent further handling of the mouse event 
    2348             by not calling Skip(). 
     2341        Prevent further handling of the mouse event 
     2342        by not calling Skip(). 
    23492343        """  
    23502344        pass 
    2351          
    2352 class HelpWindow(wx.Frame): 
    2353     def __init__(self, parent, id, title): 
    2354         wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 
    2355         
    2356         from sans.models.CylinderModel import CylinderModel 
    2357         model = CylinderModel() 
    2358         
    2359         from danse.common.plottools.plottables import Data1D 
    2360         data= Data1D(x=[1,2], y=[3,4], dy=[0.1, 0,1]) 
     2345  
     2346""" 
     2347Example: ::    
    23612348     
    2362         from fitpanel import PageInfo 
    2363         myinfo = PageInfo(self,  model, data=data ) 
    2364          
    2365         ## add data 
    2366          
    2367         from models import ModelList 
    2368         mylist= ModelList() 
    2369  
    2370         from sans.models.SphereModel import SphereModel 
    2371         from sans.models.SquareWellStructure import SquareWellStructure 
    2372         from sans.models.DebyeModel import DebyeModel 
    2373         from sans.models.LineModel import LineModel 
    2374         name= "shapes" 
    2375         list1= [SphereModel] 
    2376         mylist.set_list( name, list1) 
    2377          
    2378         name= "Shape-independent" 
    2379         list1= [DebyeModel] 
    2380         mylist.set_list( name, list1) 
    2381          
    2382         name= "Structure Factors" 
    2383         list1= [SquareWellStructure] 
    2384         mylist.set_list( name, list1) 
    2385          
    2386         name= "Added models" 
    2387         list1= [LineModel] 
    2388         mylist.set_list( name, list1) 
    2389          
    2390         myinfo.model_list_box = mylist.get_list() 
    2391          
    2392         self.page = FitPage(self, myinfo)  
    2393          
    2394         self.Centre() 
    2395         self.Show(True) 
    2396   
    2397 if __name__=="__main__": 
    2398     app = wx.App() 
    2399     HelpWindow(None, -1, 'HelpWindow') 
    2400     app.MainLoop() 
    2401                  
     2349    class HelpWindow(wx.Frame): 
     2350        def __init__(self, parent, id, title): 
     2351            wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 
     2352            
     2353            from sans.models.CylinderModel import CylinderModel 
     2354            model = CylinderModel() 
     2355            
     2356            from danse.common.plottools.plottables import Data1D 
     2357            data= Data1D(x=[1,2], y=[3,4], dy=[0.1, 0,1]) 
     2358         
     2359            from fitpanel import PageInfo 
     2360            myinfo = PageInfo(self,  model, data=data ) 
     2361             
     2362            ## add data 
     2363             
     2364            from models import ModelList 
     2365            mylist= ModelList() 
     2366     
     2367            from sans.models.SphereModel import SphereModel 
     2368            from sans.models.SquareWellStructure import SquareWellStructure 
     2369            from sans.models.DebyeModel import DebyeModel 
     2370            from sans.models.LineModel import LineModel 
     2371            name= "shapes" 
     2372            list1= [SphereModel] 
     2373            mylist.set_list( name, list1) 
     2374             
     2375            name= "Shape-independent" 
     2376            list1= [DebyeModel] 
     2377            mylist.set_list( name, list1) 
     2378             
     2379            name= "Structure Factors" 
     2380            list1= [SquareWellStructure] 
     2381            mylist.set_list( name, list1) 
     2382             
     2383            name= "Added models" 
     2384            list1= [LineModel] 
     2385            mylist.set_list( name, list1) 
     2386             
     2387            myinfo.model_list_box = mylist.get_list() 
     2388             
     2389            self.page = FitPage(self, myinfo)  
     2390             
     2391            self.Centre() 
     2392            self.Show(True) 
     2393      
     2394    if __name__=="__main__": 
     2395        app = wx.App() 
     2396        HelpWindow(None, -1, 'HelpWindow') 
     2397        app.MainLoop() 
     2398""" 
     2399             
  • sansview/perspectives/fitting/fitpanel.py

    r31b0c47 r5062bbf  
    1212class StateIterator(object): 
    1313    """ 
    14         Contains all saved state of a given page. 
    15         Provide position of the current state of a page, the first save state 
    16         and the last state for a given page.  
    17         Allow easy undo or redo for a given page   
     14    Contains all saved state of a given page. 
     15    Provide position of the current state of a page, the first save state 
     16    and the last state for a given page.  
     17    Allow easy undo or redo for a given page   
    1818    """ 
    1919    def __init__(self): 
     20        """ 
     21        """ 
    2022        self._current=0 
    2123        
    22      
    2324    def __iter__(self): 
     25        """ 
     26        """ 
    2427        return self 
    2528     
    26      
    2729    def first(self): 
     30        """ 
     31        """ 
    2832        self._current =0 
    2933        return self._current 
    3034     
    3135    def next(self, max ): 
     36        """ 
     37        """ 
    3238        if self._current < max: 
    3339            self._current += 1 
     
    3541     
    3642    def previous(self): 
     43        """ 
     44        """ 
    3745        if self._current > 0: 
    3846            self._current = self._current -1 
     
    4048     
    4149    def currentPosition(self): 
     50        """ 
     51        """ 
    4252        return self._current 
    4353     
    4454    def setPosition(self, value): 
     55        """ 
     56        """ 
    4557        if value >=0: 
    4658            self._current = int(value) 
    4759         
    4860     
    49 class ListOfState(list):      
     61class ListOfState(list):     
     62    """ 
     63    """  
    5064    def __init__(self, *args, **kw): 
    5165        list.__init__(self, *args, **kw) 
     
    5367         
    5468    def appendItem(self, x): 
     69        """ 
     70        """ 
    5571        self.append(x) 
    5672        self.iterator.setPosition(value= len(self)-1) 
    5773         
    5874    def removeItem(self, x): 
     75        """ 
     76        """ 
    5977        self.iterator.previous() 
    6078        self.remove(x) 
    6179         
    6280    def getPreviousItem(self): 
     81        """ 
     82        """ 
    6383        position = self.iterator.previous() 
    6484         
     
    6989         
    7090    def getNextItem(self): 
     91        """ 
     92        """ 
    7193        position = self.iterator.next(max= len(self)-1) 
    7294        if position >= len(self): 
     
    7698         
    7799    def getCurrentItem(self): 
     100        """ 
     101        """ 
    78102        postion = self.iterator.currentPosition() 
    79103        if postion >= 0 and position < len(self): 
     
    83107         
    84108    def getCurrentPosition(self): 
     109        """ 
     110        """ 
    85111        return self.iterator.currentPosition() 
    86112           
     
    88114class PageInfo(object): 
    89115    """ 
    90         this class contains the minimum numbers of data members 
    91         a fitpage or model page need to be initialized. 
     116    this class contains the minimum numbers of data members 
     117    a fitpage or model page need to be initialized. 
    92118    """ 
    93119    data = None 
     
    106132                  event_owner=None, model_list_box=None, name=None): 
    107133        """ 
    108             Initialize data members 
     134        Initialize data members 
    109135        """ 
    110136        self.data = data 
     
    121147 
    122148    """ 
    123         FitPanel class contains fields allowing to fit  models and  data 
    124         @note: For Fit to be performed the user should check at least one parameter 
     149    FitPanel class contains fields allowing to fit  models and  data 
     150     
     151    :note: For Fit to be performed the user should check at least one parameter 
    125152        on fit Panel window. 
    126153        
     
    133160     
    134161    def __init__(self, parent, *args, **kwargs): 
     162        """ 
     163        """ 
    135164        wx.aui.AuiNotebook.__init__(self, parent, -1, 
    136165                    style= wx.aui.AUI_NB_WINDOWLIST_BUTTON| 
     
    173202    def set_state(self, state): 
    174203        """ 
    175             Restore state of the panel 
     204        Restore state of the panel 
    176205        """ 
    177206        page_is_opened = False 
     
    193222    def on_close_page(self, event): 
    194223        """ 
    195              close page and remove all references to the closed page 
     224        close page and remove all references to the closed page 
    196225        """ 
    197226        nbr_page = self.GetPageCount() 
     
    204233    def close_page_with_data(self, deleted_data): 
    205234        """ 
    206             close a fit page when its data is completely remove from the graph 
     235        close a fit page when its data is completely remove from the graph 
    207236        """ 
    208237        if deleted_data is None: 
     
    223252    def set_manager(self, manager): 
    224253        """ 
    225              set panel manager 
    226              @param manager: instance of plugin fitting 
     254        set panel manager 
     255         
     256        :param manager: instance of plugin fitting 
     257         
    227258        """ 
    228259        self.manager = manager 
     
    231262    def set_owner(self,owner): 
    232263        """  
    233             set and owner for fitpanel 
    234             @param owner: the class responsible of plotting 
     264        set and owner for fitpanel 
     265         
     266        :param owner: the class responsible of plotting 
     267         
    235268        """ 
    236269        self.event_owner = owner 
     
    238271    def set_model_list(self, dict): 
    239272         """  
    240              copy a dictionary of model into its own dictionary 
    241              @param dict: dictionnary made of model name as key and model class 
     273         copy a dictionary of model into its own dictionary 
     274          
     275         :param dict: dictionnary made of model name as key and model class 
    242276             as value 
    243277         """ 
    244278         self.model_list_box = dict 
    245279         
    246    
    247280    def get_current_page(self): 
    248281        """ 
    249             @return the current page selected 
     282        :return: the current page selected 
     283         
    250284        """ 
    251285        return self.GetPage(self.GetSelection() ) 
     
    253287    def add_sim_page(self): 
    254288        """ 
    255             Add the simultaneous fit page 
     289        Add the simultaneous fit page 
    256290        """ 
    257291        from simfitpage import SimultaneousFitPage 
     
    265299    def get_page_info(self, data=None): 
    266300        """ 
    267             fill information required to add a page in the fit panel 
     301        fill information required to add a page in the fit panel 
    268302        """ 
    269303        name = "Fit Page" 
     
    290324    def add_empty_page(self): 
    291325        """ 
    292             add an empty page 
     326        add an empty page 
    293327        """ 
    294328        page_info = self.get_page_info() 
     
    301335    def add_page(self, page_info): 
    302336        """ 
    303             add a new page 
     337        add a new page 
    304338        """ 
    305339        from fitpage import FitPage 
     
    312346    def change_page_content(self, data, index): 
    313347        """ 
    314             replace the contains of an existing page 
     348        replace the contains of an existing page 
    315349        """ 
    316350        page_info = self.get_page_info(data=data) 
     
    328362    def replace_page(self, index, page_info, type): 
    329363        """ 
    330             replace an existing page 
     364        replace an existing page 
    331365        """ 
    332366        self.DeletePage(index) 
     
    336370    def add_fit_page(self, data, reset=False): 
    337371        """  
    338             Add a fitting page on the notebook contained by fitpanel 
    339             @param data: data to fit 
    340             @return panel : page just added for further used. is used by fitting module 
     372        Add a fitting page on the notebook contained by fitpanel 
     373         
     374        :param data: data to fit 
     375         
     376        :return panel : page just added for further used. is used by fitting module 
     377         
    341378        """ 
    342379        if data is None: 
     
    381418    def  _onGetstate(self, event): 
    382419        """ 
    383             copy the state of a page 
     420        copy the state of a page 
    384421        """ 
    385422        page= event.page 
     
    389426    def _onUndo(self, event ): 
    390427        """ 
    391             return the previous state of a given page is available 
     428        return the previous state of a given page is available 
    392429        """ 
    393430        page = event.page  
     
    402439    def _onRedo(self, event):  
    403440        """ 
    404             return the next state available 
     441        return the next state available 
    405442        """        
    406443        page = event.page  
     
    417454    def _close_helper(self, selected_page): 
    418455        """ 
    419             Delete the given page from the notebook 
     456        Delete the given page from the notebook 
    420457        """ 
    421458        #remove hint page 
  • sansview/perspectives/fitting/fitproblem.py

    r2f189dc r5062bbf  
    22class FitProblem: 
    33    """   
    4         FitProblem class allows to link a model with the new name created in _on_model, 
    5         a name theory created with that model  and the data fitted with the model. 
    6         FitProblem is mostly used  as value of the dictionary by fitting module. 
     4    FitProblem class allows to link a model with the new name created in _on_model, 
     5    a name theory created with that model  and the data fitted with the model. 
     6    FitProblem is mostly used  as value of the dictionary by fitting module. 
    77    """ 
    8      
    98    def __init__(self): 
    10          
    119        """ 
    12            contains information about data and model to fit 
     10        contains information about data and model to fit 
    1311        """ 
    1412        ## data used for fitting 
     
    3331    def clone(self): 
    3432        """ 
    35             copy fitproblem 
     33        copy fitproblem 
    3634        """ 
    3735        import copy  
     
    4947        obj.qmin = copy.deepcopy(self.qmin) 
    5048        obj.qmax = copy.deepcopy(self.qmax) 
    51          
    5249        return obj 
    53          
    5450         
    5551    def set_smearer(self, smearer): 
    5652        """ 
    57           save reference of  smear object on fitdata 
    58           @param smear : smear object from DataLoader 
     53        save reference of  smear object on fitdata 
     54         
     55        :param smear: smear object from DataLoader 
     56         
    5957        """ 
    6058        self.smearer= smearer 
     
    6260    def get_smearer(self): 
    6361        """ 
    64             return smear object 
     62        return smear object 
    6563        """ 
    6664        return self.smearer 
    6765     
    68     def save_model_name(self, name):   
     66    def save_model_name(self, name): 
     67        """ 
     68        """   
    6969        self.name_per_page= name 
    7070         
    71          
    7271    def get_name(self): 
     72        """ 
     73        """ 
    7374        return self.name_per_page 
    7475     
    7576    def set_model(self,model): 
    7677        """  
    77              associates each model with its new created name 
    78              @param model: model selected 
    79              @param name: name created for model 
     78        associates each model with its new created name 
     79         
     80        :param model: model selected 
     81        :param name: name created for model 
     82         
    8083        """ 
    8184        self.model= model 
    8285         
     86    def get_model(self): 
     87        """ 
     88        :return: saved model 
    8389         
    84     def get_model(self): 
    85         """ @return: saved model """ 
     90        """ 
    8691        return self.model 
    8792   
    8893    def set_index(self, index): 
    8994        """ 
    90             set index of the model name 
     95        set index of the model name 
    9196        """ 
    9297        self.model_index = index 
     
    9499    def get_index(self): 
    95100        """ 
    96             get index of the model name 
     101        get index of the model name 
    97102        """ 
    98103        return self.model_index 
     
    100105    def add_plotted_data(self,data): 
    101106        """  
    102             save a copy of the data select to fit 
    103             @param data: data selected 
     107        save a copy of the data select to fit 
     108         
     109        :param data: data selected 
     110         
    104111        """ 
    105112        self.plotted_data = data 
     
    107114 
    108115    def get_plotted_data(self): 
    109         """ @return:  list of data dList""" 
     116        """ 
     117        :return: list of data dList 
     118         
     119        """ 
    110120        return self.plotted_data 
    111      
    112      
     121 
    113122    def add_fit_data(self,data): 
    114123        """  
    115             save a copy of the data select to fit 
    116             @param data: data selected 
     124        save a copy of the data select to fit 
     125         
     126        :param data: data selected 
     127         
    117128        """ 
    118129        self.fit_data = data 
    119130             
    120     
    121131    def get_fit_data(self): 
     132        """ 
     133        """ 
    122134        return self.fit_data 
    123135     
    124          
    125136    def set_model_param(self,name,value=None): 
    126137        """  
    127             Store the name and value of a parameter of this fitproblem's model 
    128             @param name: name of the given parameter 
    129             @param value: value of that parameter 
     138        Store the name and value of a parameter of this fitproblem's model 
     139         
     140        :param name: name of the given parameter 
     141        :param value: value of that parameter 
     142         
    130143        """ 
    131144        self.list_param.append([name,value]) 
    132145         
    133          
    134146    def get_model_param(self): 
    135147        """  
    136             @return list of couple of parameter name and value 
     148        return list of couple of parameter name and value 
    137149        """ 
    138150        return self.list_param 
    139151         
    140          
    141152    def schedule_tofit(self, schedule=0): 
    142153        """ 
    143              set schedule to true to decide if this fit  must be performed 
     154        set schedule to true to decide if this fit  must be performed 
    144155        """ 
    145156        self.schedule=schedule 
    146157         
    147          
    148158    def get_scheduled(self): 
    149         """ return true or false if a problem as being schedule for fitting""" 
     159        """ 
     160        return true or false if a problem as being schedule for fitting 
     161        """ 
    150162        return self.schedule 
    151163     
    152  
    153164    def set_range(self, qmin=None, qmax=None): 
    154165        """ 
    155             set fitting range  
     166        set fitting range  
    156167        """ 
    157168        self.qmin = qmin 
    158169        self.qmax = qmax 
    159170         
    160          
    161171    def get_range(self): 
    162172        """ 
    163             @return fitting range: 
     173        :return: fitting range 
     174         
    164175        """ 
    165176        return self.qmin, self.qmax 
     
    170181        """ 
    171182        self.list_param=[] 
    172          
    173      
    174      
    175          
     183    
  • sansview/perspectives/fitting/fitting.py

    r2882fb5 r5062bbf  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     1 
     2 
     3################################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7# 
     8#See the license text in license.txt 
     9# 
     10#copyright 2009, University of Tennessee 
     11################################################################################ 
     12 
     13 
    1014import  re 
    1115import sys 
     
    4953 
    5054from fitpage import Chi2UpdateEvent 
     55 
     56 
    5157class PlotInfo: 
    5258    """ 
    53         store some plotting field 
     59    store some plotting field 
    5460    """ 
    5561    _xunit = 'A^{-1}' 
     
    6571class Plugin: 
    6672    """ 
    67         Fitting plugin is used to perform fit  
     73    Fitting plugin is used to perform fit  
    6874    """ 
    6975    def __init__(self): 
     76        """ 
     77        """ 
    7078        ## Plug-in name 
    7179        self.sub_menu = "Fitting" 
     
    114122    def populate_menu(self, id, owner): 
    115123        """ 
    116             Create a menu for the Fitting plug-in 
    117             @param id: id to create a menu 
    118             @param owner: owner of menu 
    119             @ return : list of information to populate the main menu 
     124        Create a menu for the Fitting plug-in 
     125         
     126        :param id: id to create a menu 
     127        :param owner: owner of menu 
     128         
     129        :return: list of information to populate the main menu 
     130         
    120131        """ 
    121132        #Menu for fitting 
     
    157168    def on_add_sim_page(self, event): 
    158169        """ 
    159             Create a page to access simultaneous fit option 
     170        Create a page to access simultaneous fit option 
    160171        """ 
    161172        Plugin.on_perspective(self,event=event) 
     
    169180    def help(self, evt): 
    170181        """ 
    171             Show a general help dialog.  
    172             TODO: replace the text with a nice image 
     182        Show a general help dialog.  
    173183        """ 
    174184         
     
    177187        frame.Show(True) 
    178188         
    179          
    180189    def get_context_menu(self, graph=None): 
    181190        """ 
    182             Get the context menu items available for P(r).them allow fitting option 
    183             for Data2D and Data1D only. 
    184              
    185             @param graph: the Graph object to which we attach the context menu 
    186             @return: a list of menu items with call-back function 
    187             @note: if Data1D was generated from Theory1D   
    188                     the fitting option is not allowed 
     191        Get the context menu items available for P(r).them allow fitting option 
     192        for Data2D and Data1D only. 
     193         
     194        :param graph: the Graph object to which we attach the context menu 
     195         
     196        :return: a list of menu items with call-back function 
     197         
     198        :note: if Data1D was generated from Theory1D   
     199                the fitting option is not allowed 
     200                 
    189201        """ 
    190202        self.graph = graph 
     
    221233    def get_panels(self, parent): 
    222234        """ 
    223             Create and return a list of panel objects 
     235        Create and return a list of panel objects 
    224236        """ 
    225237        self.parent = parent 
     
    252264    def get_perspective(self): 
    253265        """ 
    254             Get the list of panel names for this perspective 
     266        Get the list of panel names for this perspective 
    255267        """ 
    256268        return self.perspective 
    257269     
    258      
    259270    def on_perspective(self, event): 
    260271        """ 
    261             Call back function for the perspective menu item. 
    262             We notify the parent window that the perspective 
    263             has changed. 
     272        Call back function for the perspective menu item. 
     273        We notify the parent window that the perspective 
     274        has changed. 
    264275        """ 
    265276        self.parent.set_perspective(self.perspective) 
     
    267278    def set_default_perspective(self): 
    268279        """ 
    269            Call back method that True to notify the parent that the current plug-in 
    270            can be set as default  perspective. 
    271            when returning False, the plug-in is not candidate for an automatic  
    272            default perspective setting 
     280        Call back method that True to notify the parent that the current plug-in 
     281        can be set as default  perspective. 
     282        when returning False, the plug-in is not candidate for an automatic  
     283        default perspective setting 
    273284        """ 
    274285        return True 
     
    276287    def post_init(self): 
    277288        """ 
    278             Post initialization call back to close the loose ends 
     289        Post initialization call back to close the loose ends 
    279290        """ 
    280291        pass 
     
    282293    def set_state(self, state, datainfo=None): 
    283294        """ 
    284             Call-back method for the fit page state reader. 
    285             This method is called when a .fitv file is loaded. 
    286             @param state: PageState object 
     295        Call-back method for the fit page state reader. 
     296        This method is called when a .fitv file is loaded. 
     297         
     298        :param state: PageState object 
     299         
    287300        """ 
    288301        #working on reading state 
     
    299312    def save_fit_state(self, filepath, fitstate):   
    300313        """ 
    301             save fit page state into file 
     314        save fit page state into file 
    302315        """ 
    303316        self.state_reader.write(filename=filepath, fitstate=fitstate) 
     
    305318    def copy_data(self, item, dy=None): 
    306319        """ 
    307             receive a data 1D and the list of errors on dy 
    308             and create a new data1D data 
    309             @param return  
     320        receive a data 1D and the list of errors on dy 
     321        and create a new data1D data 
     322     
    310323        """ 
    311324        id = None 
     
    327340    def set_fit_range(self, page, qmin, qmax): 
    328341        """ 
    329             Set the fitting range of a given page 
     342        Set the fitting range of a given page 
    330343        """ 
    331344        if page in self.page_finder.iterkeys(): 
     
    335348    def schedule_for_fit(self,value=0,page=None,fitproblem =None):   
    336349        """ 
    337             Set the fit problem field to 0 or 1 to schedule that problem to fit. 
    338             Schedule the specified fitproblem or get the fit problem related to  
    339             the current page and set value. 
    340             @param value : integer 0 or 1  
    341             @param fitproblem: fitproblem to schedule or not to fit 
     350        Set the fit problem field to 0 or 1 to schedule that problem to fit. 
     351        Schedule the specified fitproblem or get the fit problem related to  
     352        the current page and set value. 
     353         
     354        :param value: integer 0 or 1  
     355        :param fitproblem: fitproblem to schedule or not to fit 
     356         
    342357        """    
    343358        if fitproblem !=None: 
     
    349364           
    350365    def get_page_finder(self): 
    351         """ @return self.page_finder used also by simfitpage.py"""   
     366        """ 
     367        return self.page_finder used also by simfitpage.py 
     368        """   
    352369        return self.page_finder  
    353370     
    354      
    355371    def set_page_finder(self,modelname,names,values): 
    356372        """ 
    357              Used by simfitpage.py to reset a parameter given the string constrainst. 
    358              @param modelname: the name ot the model for with the parameter has to reset 
    359              @param value: can be a string in this case. 
    360              @param names: the paramter name 
    361              @note: expecting park used for fit. 
     373        Used by simfitpage.py to reset a parameter given the string constrainst. 
     374          
     375        :param modelname: the name ot the model for with the parameter has to reset 
     376        :param value: can be a string in this case. 
     377        :param names: the paramter name 
     378          
     379        :note: expecting park used for fit. 
     380          
    362381        """   
    363382        sim_page= self.sim_page 
     
    372391    def split_string(self,item):  
    373392        """ 
    374             receive a word containing dot and split it. used to split parameterset 
    375             name into model name and parameter name example: 
     393        receive a word containing dot and split it. used to split parameterset 
     394        name into model name and parameter name example: :: 
     395         
    376396            paramaterset (item) = M1.A 
    377             @return model_name =M1 , parameter name =A 
     397            Will return model_name = M1 , parameter name = A 
     398             
    378399        """ 
    379400        if string.find(item,".")!=-1: 
     
    389410    def stop_fit(self): 
    390411        """ 
    391             Stop the fit engine 
     412        Stop the fit engine 
    392413        """ 
    393414        if self.calc_fit!= None and self.calc_fit.isrunning(): 
     
    398419    def set_smearer_nodraw(self,smearer, qmin=None, qmax=None): 
    399420        """ 
    400             Get a smear object and store it to a fit problem 
    401             @param smearer: smear object to allow smearing data 
     421        Get a smear object and store it to a fit problem 
     422         
     423        :param smearer: smear object to allow smearing data 
     424         
    402425        """   
    403426        self.current_pg=self.fit_panel.get_current_page() 
     
    408431        ## if user has already selected a model to plot 
    409432        ## redraw the model with data smeared 
    410          
    411433        smear =self.page_finder[self.current_pg].get_smearer()    
    412434             
    413435    def set_smearer(self,smearer, qmin=None, qmax=None): 
    414436        """ 
    415             Get a smear object and store it to a fit problem 
    416             @param smearer: smear object to allow smearing data 
     437        Get a smear object and store it to a fit problem 
     438         
     439        :param smearer: smear object to allow smearing data 
     440         
    417441        """    
    418442        self.current_pg=self.fit_panel.get_current_page() 
     
    433457                   qmin= DEFAULT_QMIN, qmax= DEFAULT_QMAX, qstep= DEFAULT_NPTS): 
    434458        """ 
    435              Draw model. 
    436              @param model: the model to draw 
    437              @param name: the name of the model to draw 
    438              @param data: the data on which the model is based to be drawn 
    439              @param description: model's description 
    440              @param enable1D: if true enable drawing model 1D 
    441              @param enable2D: if true enable drawing model 2D 
    442              @param qmin:  Range's minimum value to draw model 
    443              @param qmax:  Range's maximum value to draw model 
    444              @param qstep: number of step to divide the x and y-axis 
     459        Draw model. 
     460         
     461        :param model: the model to draw 
     462        :param name: the name of the model to draw 
     463        :param data: the data on which the model is based to be drawn 
     464        :param description: model's description 
     465        :param enable1D: if true enable drawing model 1D 
     466        :param enable2D: if true enable drawing model 2D 
     467        :param qmin:  Range's minimum value to draw model 
     468        :param qmax:  Range's maximum value to draw model 
     469        :param qstep: number of step to divide the x and y-axis 
    445470              
    446471        """ 
    447  
    448472        if data.__class__.__name__ !="Data2D":     
    449473            ## draw model 1D with no loaded data 
     
    464488    def onFit(self): 
    465489        """ 
    466             perform fit  
     490        perform fit  
    467491        """ 
    468492        ##  count the number of fitproblem schedule to fit  
     
    545569    def remove_plot(self, page, theory=False): 
    546570        """ 
    547             remove model plot when a fit page is closed 
     571        remove model plot when a fit page is closed 
    548572        """ 
    549573        fitproblem = self.page_finder[page] 
     
    570594    def create_fittable_data2D(self, data): 
    571595        """ 
    572             check if the current data is a data 2d and add dy to that data 
    573             @return Data2D 
     596        check if the current data is a data 2d and add dy to that data 
     597         
     598        :return: Data2D 
     599         
    574600        """ 
    575601        if data.__class__.__name__ != "Data2D": 
     
    591617    def create_fittable_data1D(self, data): 
    592618        """ 
    593             check if the current data is a theory 1d and add dy to that data 
    594             @return Data1D 
     619        check if the current data is a theory 1d and add dy to that data 
     620         
     621        :return: Data1D 
     622         
    595623        """ 
    596624        class_name = data.__class__.__name__ 
     
    621649    def store_page(self, page, data): 
    622650        """ 
    623             Helper to save page reference into the plug-in 
    624             @param page: page to store 
     651        Helper to save page reference into the plug-in 
     652         
     653        :param page: page to store 
     654         
    625655        """ 
    626656        page.set_data(data)  
     
    632662    def add_fit_page(self, data): 
    633663        """ 
    634             given a data, ask to the fitting panel to create a new fitting page, 
    635             get this page and store it into the page_finder of this plug-in 
     664        given a data, ask to the fitting panel to create a new fitting page, 
     665        get this page and store it into the page_finder of this plug-in 
    636666        """ 
    637667        try: 
     
    651681    def _onEVT_SLICER_PANEL(self, event): 
    652682        """ 
    653             receive and event telling to update a panel with a name starting with  
    654             event.panel_name. this method update slicer panel for a given interactor. 
    655             @param event: contains type of slicer , paramaters for updating the panel 
     683        receive and event telling to update a panel with a name starting with  
     684        event.panel_name. this method update slicer panel for a given interactor. 
     685         
     686        :param event: contains type of slicer , paramaters for updating the panel 
    656687            and panel_name to find the slicer 's panel concerned. 
    657688        """ 
     
    662693        self.parent._mgr.Update() 
    663694    
    664                
    665695    def _closed_fitpage(self, event):    
    666696        """ 
    667             request fitpanel to close a given page when its unique data is removed  
    668             from the plot. close fitpage only when the a loaded data is removed 
     697        request fitpanel to close a given page when its unique data is removed  
     698        from the plot. close fitpage only when the a loaded data is removed 
    669699        """     
    670700        if event is None or event.data is None: 
     
    677707    def _add_page_onmenu(self, name,fitproblem=None): 
    678708        """ 
    679             Add name of a closed page of fitpanel in a menu  
     709        Add name of a closed page of fitpanel in a menu  
    680710        """ 
    681711        list = self.menu1.GetMenuItems() 
     
    691721            wx.EVT_MENU(self.parent,event_id,  self._open_closed_page) 
    692722         
    693          
    694723    def _open_closed_page(self, event):     
    695724        """ 
    696             reopen a closed page 
     725        reopen a closed page 
    697726        """ 
    698727        for name, value in self.closed_page_dict.iteritems(): 
     
    712741                                                  reset= True) 
    713742                    break 
    714          
    715          
     743     
    716744    def _reset_schedule_problem(self, value=0): 
    717745        """ 
    718              unschedule or schedule all fitproblem to be fit 
     746        unschedule or schedule all fitproblem to be fit 
    719747        """ 
    720748        for page, fitproblem in self.page_finder.iteritems(): 
     
    723751    def _fit_helper(self,pars,value, id, title="Single Fit " ): 
    724752        """ 
    725             helper for fitting 
     753        helper for fitting 
    726754        """ 
    727755        metadata = value.get_fit_data() 
     
    761789    def _onSelect(self,event): 
    762790        """  
    763             when Select data to fit a new page is created .Its reference is  
    764             added to self.page_finder 
     791        when Select data to fit a new page is created .Its reference is  
     792        added to self.page_finder 
    765793        """ 
    766794        self.panel = event.GetEventObject() 
     
    778806    def _single_fit_completed(self,result,pars,cpage, elapsed=None): 
    779807        """ 
    780             Display fit result on one page of the notebook. 
    781             @param result: result of fit  
    782             @param pars: list of names of parameters fitted 
    783             @param current_pg: the page where information will be displayed 
    784             @param qmin: the minimum value of x to replot the model  
    785             @param qmax: the maximum value of x to replot model 
     808        Display fit result on one page of the notebook. 
     809         
     810        :param result: result of fit  
     811        :param pars: list of names of parameters fitted 
     812        :param current_pg: the page where information will be displayed 
     813        :param qmin: the minimum value of x to replot the model  
     814        :param qmax: the maximum value of x to replot model 
    786815           
    787816        """      
     
    813842            return 
    814843        
    815         
    816844    def _simul_fit_completed(self,result,pars=None,cpage=None, elapsed=None): 
    817845        """ 
    818             Parameter estimation completed,  
    819             display the results to the user 
    820             @param alpha: estimated best alpha 
    821             @param elapsed: computation time 
     846        Parameter estimation completed,  
     847        display the results to the user 
     848         
     849        :param alpha: estimated best alpha 
     850        :param elapsed: computation time 
     851         
    822852        """ 
    823853        ## fit more than 1 model at the same time  
     
    860890             return  
    861891              
    862                             
    863          
    864892    def _on_show_panel(self, event): 
    865         print "_on_show_panel: fitting" 
    866        
    867        
     893        """ 
     894        """ 
     895        #print "_on_show_panel: fitting" 
     896        pass 
     897         
    868898    def _onset_engine_park(self,event): 
    869899        """  
    870             set engine to park 
     900        set engine to park 
    871901        """ 
    872902        Plugin.on_perspective(self,event=event) 
    873903        self._on_change_engine('park') 
    874904        
    875         
    876905    def _onset_engine_scipy(self,event): 
    877906        """  
    878             set engine to scipy 
     907        set engine to scipy 
    879908        """ 
    880909        self._on_change_engine('scipy') 
     
    882911    def _on_slicer_event(self, event): 
    883912        """ 
    884             Receive a panel as event and send it to guiframe  
    885             @param event: event containing a panel 
    886         """ 
    887         
    888         if event.panel!=None: 
     913        Receive a panel as event and send it to guiframe  
     914         
     915        :param event: event containing a panel 
     916         
     917        """ 
     918        if event.panel is not None: 
    889919            new_panel = event.panel 
    890920            self.slicer_panels.append(event.panel) 
     
    897927            new_panel.uid = event_id 
    898928            self.mypanels.append(new_panel)  
    899         return   
    900      
     929        
    901930    def _onclearslicer(self, event): 
    902931        """ 
    903             Clear the boxslicer when close the panel associate with this slicer 
     932        Clear the boxslicer when close the panel associate with this slicer 
    904933        """ 
    905934        name =event.GetPane().caption 
     
    915944                            break  
    916945                break 
    917         
    918         
    919          
    920          
     946     
    921947    def _return_engine_type(self): 
    922948        """ 
    923             return the current type of engine 
     949        return the current type of engine 
    924950        """ 
    925951        return self._fit_engine 
     
    928954    def _on_change_engine(self, engine='park'): 
    929955        """ 
    930             Allow to select the type of engine to perform fit  
    931             @param engine: the key work of the engine 
    932         """ 
    933         
     956        Allow to select the type of engine to perform fit  
     957         
     958        :param engine: the key work of the engine 
     959         
     960        """ 
    934961        ## saving fit engine name 
    935962        self._fit_engine = engine 
     
    952979            wx.PostEvent(key, event) 
    953980        
    954     
    955981    def _on_model_panel(self, evt): 
    956982        """ 
    957             react to model selection on any combo box or model menu.plot the model   
    958             @param evt: wx.combobox event 
     983        react to model selection on any combo box or model menu.plot the model   
     984         
     985        :param evt: wx.combobox event 
     986         
    959987        """ 
    960988        model = evt.model 
     
    9971025    def _on_model_menu(self, evt): 
    9981026        """ 
    999             Plot a theory from a model selected from the menu 
    1000             @param evt: wx.menu event 
     1027        Plot a theory from a model selected from the menu 
     1028         
     1029        :param evt: wx.menu event 
     1030         
    10011031        """ 
    10021032        model = evt.model 
     
    10061036        # the content will be updated and the plot refreshed 
    10071037        self.fit_panel.add_model_page(model,topmenu=True) 
    1008      
    1009     
    1010      
    1011      
     1038 
    10121039    def _update1D(self,x, output): 
    10131040        """ 
    1014             Update the output of plotting model 1D 
     1041        Update the output of plotting model 1D 
    10151042        """ 
    10161043        wx.PostEvent(self.parent, StatusEvent(status="Plot \ 
     
    10191046        #self.calc_thread.ready(0.01) 
    10201047     
    1021      
    10221048    def _fill_default_model2D(self, theory, qmax,qstep, qmin=None): 
    10231049        """ 
    1024             fill Data2D with default value  
    1025             @param theory: Data2D to fill 
     1050        fill Data2D with default value  
     1051         
     1052        :param theory: Data2D to fill 
     1053         
    10261054        """ 
    10271055        from DataLoader.data_info import Detector, Source 
     
    10391067        theory.detector[0].beam_center.x= qmax 
    10401068        theory.detector[0].beam_center.y= qmax 
    1041          
    1042          
     1069     
    10431070        ## create x_bins and y_bins of the model 2D 
    10441071        pixel_width_x = theory.detector[0].pixel_size.x 
     
    11001127        theory.ymin= ymin  
    11011128        theory.ymax= ymax  
    1102         theory.group_id ="Model" 
    1103         theory.id ="Model" 
    1104          
     1129        theory.group_id = "Model" 
     1130        theory.id = "Model" 
    11051131         
    11061132    def _get_plotting_info(self, data=None): 
    11071133        """ 
    1108             get plotting info from data if data !=None 
    1109             else use some default 
     1134        get plotting info from data if data !=None else use some default 
    11101135        """ 
    11111136        my_info = PlotInfo() 
     
    11251150            if hasattr(data, "group_id"): 
    11261151                my_info.group_id= data.group_id 
    1127          
    11281152        return my_info 
    11291153                 
    1130                  
    11311154    def _complete1D(self, x,y, elapsed,index,model,data=None): 
    11321155        """ 
    1133             Complete plotting 1D data 
     1156        Complete plotting 1D data 
    11341157        """  
    11351158        try: 
     
    11691192            msg+= " %s"%sys.exc_value 
    11701193            wx.PostEvent( self.parent, StatusEvent(status= msg, type="stop")) 
    1171             return   
    1172                    
     1194    
    11731195    def _update2D(self, output,time=None): 
    11741196        """ 
    1175             Update the output of plotting model 
     1197        Update the output of plotting model 
    11761198        """ 
    11771199        wx.PostEvent(self.parent, StatusEvent(status="Plot \ 
     
    11791201        self.ready_fit() 
    11801202        #self.calc_thread.ready(0.01) 
    1181          
    1182          
    1183     def _complete2D(self, image,data, model,  elapsed,index,qmin, qmax,qstep=DEFAULT_NPTS): 
    1184         """ 
    1185             Complete get the result of modelthread and create model 2D 
    1186             that can be plot. 
     1203     
     1204    def _complete2D(self, image, data, model, elapsed, index, qmin, 
     1205                     qmax, qstep=DEFAULT_NPTS): 
     1206        """ 
     1207        Complete get the result of modelthread and create model 2D 
     1208        that can be plot. 
    11871209        """ 
    11881210        err_image = numpy.zeros(numpy.shape(image)) 
     
    11921214         
    11931215        if data ==None: 
    1194             self._fill_default_model2D(theory= theory, qmax=qmax,qstep=qstep, qmin= qmin) 
     1216            self._fill_default_model2D(theory=theory, qmax=qmax, qstep=qstep, 
     1217                                        qmin= qmin) 
    11951218         
    11961219        else: 
     
    12181241                         title="Analytical model 2D ", reset=True )) 
    12191242        # Chisqr in fitpage 
    1220         current_pg=self.fit_panel.get_current_page() 
    1221         wx.PostEvent(current_pg,Chi2UpdateEvent(output=self._cal_chisqr(data=data,index=index))) 
     1243        current_pg = self.fit_panel.get_current_page() 
     1244        wx.PostEvent(current_pg, 
     1245            Chi2UpdateEvent(output=self._cal_chisqr(data=data,index=index))) 
    12221246        msg = "Plot 2D complete !" 
    1223         wx.PostEvent( self.parent, StatusEvent( status= msg , type="stop" )) 
     1247        wx.PostEvent( self.parent, StatusEvent(status=msg, type="stop" )) 
    12241248      
    12251249    def _on_data_error(self, event): 
    12261250        """ 
    1227             receives and event from plotting plu-gins to store the data name and  
    1228             their errors of y coordinates for 1Data hide and show error 
     1251        receives and event from plotting plu-gins to store the data name and  
     1252        their errors of y coordinates for 1Data hide and show error 
    12291253        """ 
    12301254        self.err_dy = event.err_dy 
     
    12331257                      qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep=DEFAULT_NPTS): 
    12341258        """ 
    1235             draw model in 2D 
    1236             @param model: instance of the model to draw 
    1237             @param description: the description of the model 
    1238             @param enable2D: when True allows to draw model 2D 
    1239             @param qmin: the minimum value to  draw model 2D 
    1240             @param qmax: the maximum value to draw model 2D 
    1241             @param qstep: the number of division of Qx and Qy of the model to draw 
     1259        draw model in 2D 
     1260         
     1261        :param model: instance of the model to draw 
     1262        :param description: the description of the model 
     1263        :param enable2D: when True allows to draw model 2D 
     1264        :param qmin: the minimum value to  draw model 2D 
     1265        :param qmax: the maximum value to draw model 2D 
     1266        :param qstep: the number of division of Qx and Qy of the model to draw 
    12421267             
    12431268        """ 
     
    12831308            wx.PostEvent( self.parent, StatusEvent(status= msg )) 
    12841309 
    1285     
    12861310    def _draw_model1D(self, model, data=None, smearer= None, 
    12871311                qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep= DEFAULT_NPTS,enable1D= True): 
    12881312        """ 
    1289             Draw model 1D from loaded data1D 
    1290             @param data: loaded data 
    1291             @param model: the model to plot 
     1313        Draw model 1D from loaded data1D 
     1314         
     1315        :param data: loaded data 
     1316        :param model: the model to plot 
     1317         
    12921318        """ 
    12931319        x=  numpy.linspace(start= qmin, 
     
    13321358    def _cal_chisqr(self, data=None, index=None):  
    13331359        """ 
    1334             Get handy Chisqr using the output from draw1D and 2D,  
    1335             instead of calling expansive CalcChisqr in guithread 
     1360        Get handy Chisqr using the output from draw1D and 2D,  
     1361        instead of calling expansive CalcChisqr in guithread 
    13361362        """ 
    13371363        # default chisqr 
     
    13691395     
    13701396     
    1371 def profile(fn, *args, **kw): 
    1372     import cProfile, pstats, os 
    1373     global call_result 
    1374     def call(): 
    1375         global call_result 
    1376         call_result = fn(*args, **kw) 
    1377     cProfile.runctx('call()', dict(call=call), {}, 'profile.out') 
    1378     stats = pstats.Stats('profile.out') 
    1379     #stats.sort_stats('time') 
    1380     stats.sort_stats('calls') 
    1381     stats.print_stats() 
    1382     os.unlink('profile.out') 
    1383     return call_result 
     1397#def profile(fn, *args, **kw): 
     1398#    import cProfile, pstats, os 
     1399#    global call_result 
     1400#    def call(): 
     1401#        global call_result 
     1402#        call_result = fn(*args, **kw) 
     1403#    cProfile.runctx('call()', dict(call=call), {}, 'profile.out') 
     1404#    stats = pstats.Stats('profile.out') 
     1405#    #stats.sort_stats('time') 
     1406#    stats.sort_stats('calls') 
     1407#    stats.print_stats() 
     1408#    os.unlink('profile.out') 
     1409#    return call_result 
    13841410if __name__ == "__main__": 
    13851411    i = Plugin() 
  • sansview/perspectives/fitting/help_panel.py

    r0df5d68 r5062bbf  
    11#!/usr/bin/python 
     2 
    23import wx 
    34import wx.html as html 
    45from wx.lib.splitter import MultiSplitterWindow 
    56import os 
    6 def help(): 
    7     """ 
    8         Provide general online help text 
    9         Future work: extend this function to allow topic selection 
    10     """ 
    11     info_txt  = "The inversion approach is based on Moore, J. Appl. Cryst. (1980) 13, 168-175.\n\n" 
    12     info_txt += "P(r) is set to be equal to an expansion of base functions of the type " 
    13     info_txt += "phi_n(r) = 2*r*sin(pi*n*r/D_max). The coefficient of each base functions " 
    14     info_txt += "in the expansion is found by performing a least square fit with the " 
    15     info_txt += "following fit function:\n\n" 
    16     info_txt += "chi**2 = sum_i[ I_meas(q_i) - I_th(q_i) ]**2/error**2 + Reg_term\n\n" 
    17     info_txt += "where I_meas(q) is the measured scattering intensity and I_th(q) is " 
    18     info_txt += "the prediction from the Fourier transform of the P(r) expansion. " 
    19     info_txt += "The Reg_term term is a regularization term set to the second derivative " 
    20     info_txt += "d**2P(r)/dr**2 integrated over r. It is used to produce a smooth P(r) output.\n\n" 
    21     info_txt += "The following are user inputs:\n\n" 
    22     info_txt += "   - Number of terms: the number of base functions in the P(r) expansion.\n\n" 
    23     info_txt += "   - Regularization constant: a multiplicative constant to set the size of " 
    24     info_txt += "the regularization term.\n\n" 
    25     info_txt += "   - Maximum distance: the maximum distance between any two points in the system.\n" 
    26       
    27     return info_txt 
    28      
    29 class HelpDialog(wx.Dialog): 
    30     def __init__(self, parent, id): 
    31        
    32         wx.Dialog.__init__(self, parent, id, size=(400, 420)) 
    33         self.SetTitle("P(r) help")  
    34          
    35  
    36         vbox = wx.BoxSizer(wx.VERTICAL) 
    37  
    38         explanation = help() 
    39             
    40         label_explain = wx.StaticText(self, -1, explanation, size=(350,320)) 
    41              
    42         vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15) 
    437 
    448 
    45         static_line = wx.StaticLine(self, -1) 
    46         vbox.Add(static_line, 0, wx.EXPAND, 0) 
    47          
    48         button_OK = wx.Button(self, wx.ID_OK, "OK") 
    49  
    50         sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    51         sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    52         sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
    53         vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 
    54  
    55         self.SetSizer(vbox) 
    56         self.SetAutoLayout(True) 
    57          
    58         self.Layout() 
    59         self.Centre() 
    60  
    619class HelpWindow(wx.Frame): 
     10    """ 
     11    """ 
    6212    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): 
    6313        wx.Frame.__init__(self, parent, id, title, size=(850, 500)) 
    6414        """ 
    65              contains help info 
     15        contains help info 
    6616        """ 
    6717       
     
    14393    def OnButtonClicked(self, event): 
    14494        """ 
    145             Function to diplay html page related to the hyperlinktext selected 
     95        Function to diplay html page related to the hyperlinktext selected 
    14696        """ 
    147         #link= "media/modelfunction.html" 
    14897        self.rhelp.LoadPage("media/modelfunction.html") 
    14998         
    15099    def OnLinkClicked(self, event): 
    151100        """ 
    152             Function to diplay html page related to the hyperlinktext selected 
     101        Function to diplay html page related to the hyperlinktext selected 
    153102        """ 
    154103        link= event.GetLinkInfo().GetHref() 
    155104        self.rhelp.LoadPage(link) 
     105""" 
     106Example: :: 
    156107 
    157 class ViewApp(wx.App): 
    158     def OnInit(self): 
    159         frame = HelpWindow(None, -1, 'HelpWindow')     
    160         frame.Show(True) 
    161         self.SetTopWindow(frame) 
    162          
    163         return True 
    164          
     108    class ViewApp(wx.App): 
     109        def OnInit(self): 
     110            frame = HelpWindow(None, -1, 'HelpWindow')     
     111            frame.Show(True) 
     112            self.SetTopWindow(frame) 
     113             
     114            return True 
     115             
     116     
     117    if __name__ == "__main__":  
     118    app = ViewApp(0) 
     119    app.MainLoop()   
    165120 
    166 if __name__ == "__main__":  
    167     app = ViewApp(0) 
    168     app.MainLoop()      
     121"""    
  • sansview/perspectives/fitting/hint_fitpage.py

    r533d38d r5062bbf  
     1 
    12import wx 
    23 
     
    45class HintFitPage(wx.ScrolledWindow): 
    56    """ 
    6         This class provide general structure of  fitpanel page 
     7    This class provide general structure of  fitpanel page 
    78    """ 
    89     ## Internal name for the AUI manager 
     
    1213     
    1314    def __init__(self, parent): 
     15        """ 
     16        """ 
    1417        wx.ScrolledWindow.__init__(self, parent, 
    1518                 style= wx.FULL_REPAINT_ON_RESIZE ) 
     
    2124    def do_layout(self): 
    2225        """ 
    23             Draw the page  
     26        Draw the page  
    2427        """ 
    2528        name="Hint" 
     
    4144         
    4245    def createMemento(self): 
     46        """ 
     47        """ 
    4348        return  
    44          
    45 class HelpWindow(wx.Frame): 
    46     def __init__(self, parent, id, title): 
    47         wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 
    48         
    49         self.page = HintFitPage(self)  
    50         self.Centre() 
    51         self.Show(True) 
    52   
    53 if __name__=="__main__": 
    54     app = wx.App() 
    55     HelpWindow(None, -1, 'HelpWindow') 
    56     app.MainLoop() 
    57                  
     49"""    
     50Example: :: 
     51      
     52    class HelpWindow(wx.Frame): 
     53        def __init__(self, parent, id, title): 
     54            wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 
     55            
     56            self.page = HintFitPage(self)  
     57            self.Centre() 
     58            self.Show(True) 
     59      
     60    if __name__=="__main__": 
     61        app = wx.App() 
     62        HelpWindow(None, -1, 'HelpWindow') 
     63        app.MainLoop() 
     64"""               
  • sansview/perspectives/fitting/model_thread.py

    rf72333f r5062bbf  
     1 
     2 
    13import time 
    24from data_util.calcthread import CalcThread 
     
    46import numpy,math 
    57from DataLoader.smearing_2d import Smearer2D 
    6 import fitpage 
     8 
    79class Calc2D(CalcThread): 
    810    """ 
    9         Compute 2D model 
    10         This calculation assumes a 2-fold symmetry of the model 
    11         where points are computed for one half of the detector 
    12         and I(qx, qy) = I(-qx, -qy) is assumed. 
    13     """ 
    14      
     11    Compute 2D model 
     12    This calculation assumes a 2-fold symmetry of the model 
     13    where points are computed for one half of the detector 
     14    and I(qx, qy) = I(-qx, -qy) is assumed. 
     15    """ 
    1516    def __init__(self, x, y, data,model,smearer,qmin, qmax,qstep, 
    1617                 completefn = None, 
     
    3738    def compute(self): 
    3839        """ 
    39             Compute the data given a model function 
     40        Compute the data given a model function 
    4041        """ 
    4142        self.starttime = time.time() 
     
    125126 
    126127class Calc1D(CalcThread): 
    127     """Compute 1D data""" 
    128      
     128    """ 
     129    Compute 1D data 
     130    """ 
    129131    def __init__(self, x, model, 
    130132                 data=None, 
     
    137139                 worktime   = 0.01 
    138140                 ): 
     141        """ 
     142        """ 
    139143        CalcThread.__init__(self,completefn, 
    140144                 updatefn, 
     
    151155    def compute(self): 
    152156        """ 
    153             Compute model 1d value given qmin , qmax , x value  
    154         """ 
    155          
     157        Compute model 1d value given qmin , qmax , x value  
     158        """ 
    156159        self.starttime = time.time() 
    157160        output = numpy.zeros((len(self.x))) 
     
    166169            output[index] = self.model.evalDistribution(self.x[index]) 
    167170          
    168         elapsed = time.time()-self.starttime 
     171        elapsed = time.time() - self.starttime 
    169172        
    170         self.complete(x= self.x[index], y= output[index],  
    171                       elapsed=elapsed,index=index, model= self.model, data=self.data) 
    172  
     173        self.complete(x=self.x[index], y=output[index],  
     174                      elapsed=elapsed,index=index, model=self.model, 
     175                                        data=self.data) 
    173176         
    174177    def results(self): 
    175178        """ 
    176             Send resuts of the computation 
     179        Send resuts of the computation 
    177180        """ 
    178181        return [self.out, self.index] 
    179                  
    180 class CalcCommandline: 
    181     def __init__(self, n=20000): 
    182         #print thread.get_ident() 
    183         from sans.models.CylinderModel import CylinderModel 
    184          
    185         model = CylinderModel() 
    186          
     182 
     183""" 
     184Example: :: 
     185                      
     186    class CalcCommandline: 
     187        def __init__(self, n=20000): 
     188            #print thread.get_ident() 
     189            from sans.models.CylinderModel import CylinderModel 
     190             
     191            model = CylinderModel() 
     192             
     193              
     194            print model.runXY([0.01, 0.02]) 
     195             
     196            qmax = 0.01 
     197            qstep = 0.0001 
     198            self.done = False 
     199             
     200            x = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
     201            y = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
     202         
     203         
     204            calc_thread_2D = Calc2D(x, y, None, model.clone(),None, 
     205                                    -qmax, qmax,qstep, 
     206                                            completefn=self.complete, 
     207                                            updatefn=self.update , 
     208                                            yieldtime=0.0) 
    187209          
    188         print model.runXY([0.01, 0.02]) 
    189          
    190         qmax = 0.01 
    191         qstep = 0.0001 
    192         self.done = False 
    193          
    194         x = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
    195         y = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
     210            calc_thread_2D.queue() 
     211            calc_thread_2D.ready(2.5) 
     212             
     213            while not self.done: 
     214                time.sleep(1) 
    196215     
     216        def update(self,output): 
     217            print "update" 
    197218     
    198         calc_thread_2D = Calc2D(x, y, None, model.clone(),-qmax, qmax,qstep, 
    199                                         completefn=self.complete, 
    200                                         updatefn=self.update , 
    201                                         yieldtime=0.0) 
    202       
    203         calc_thread_2D.queue() 
    204         calc_thread_2D.ready(2.5) 
    205          
    206         while not self.done: 
    207             time.sleep(1) 
    208  
    209     def update(self,output): 
    210         print "update" 
    211  
    212     def complete(self, image, data, model, elapsed, qmin, qmax, qstep ): 
    213         print "complete" 
    214         self.done = True 
    215  
    216 if __name__ == "__main__": 
    217     CalcCommandline() 
    218     
     219        def complete(self, image, data, model, elapsed, qmin, qmax,index, qstep ): 
     220            print "complete" 
     221            self.done = True 
     222     
     223    if __name__ == "__main__": 
     224        CalcCommandline() 
     225"""    
  • sansview/perspectives/fitting/models.py

    rce07fa8 r5062bbf  
    1 #TODO: add comments to document this module 
    2 #TODO: clean-up the exception handling. 
    3  
    4 #TODO: clean-up the FractalAbsModel and PowerLawAbsModel menu items. Those 
    5 #      model definitions do not belong here. They belong with the rest of the 
    6 #      models. 
    71 
    82import wx 
     
    2317     
    2418def log(message): 
     19    """ 
     20    """ 
    2521    out = open("plugins.log", 'a') 
    2622    out.write("%10g:  %s\n" % (time.clock(), message)) 
     
    2824 
    2925def findModels(): 
     26    """ 
     27    """ 
    3028    log("looking for models in: %s/plugins" % os.getcwd()) 
    3129    if os.path.isdir('plugins'): 
     
    3533def _check_plugin(model, name): 
    3634    """ 
    37         Do some checking before model adding plugins in the list 
    38         @param model: class model to add into the plugin list 
    39         @param name:name of the module plugin 
    40         @return model: model if valid model or None if not valid 
     35    Do some checking before model adding plugins in the list 
     36     
     37    :param model: class model to add into the plugin list 
     38    :param name:name of the module plugin 
     39     
     40    :return model: model if valid model or None if not valid 
     41     
    4142    """ 
    4243    #Check is the plugin is of type Model1DPlugin 
     
    7475   
    7576def _findModels(dir): 
     77    """ 
     78    """ 
    7679    # List of plugin objects 
    7780    plugins = [] 
     
    114117class ModelList(object): 
    115118    """ 
    116         Contains dictionary of model and their type 
     119    Contains dictionary of model and their type 
    117120    """ 
    118121    def __init__(self): 
    119         self.mydict={} 
     122        """ 
     123        """ 
     124        self.mydict = {} 
    120125         
    121126    def set_list(self, name, mylist): 
    122127        """ 
    123             @param name: the type of the list 
    124             @param mylist: the list to add 
     128        :param name: the type of the list 
     129        :param mylist: the list to add 
     130         
    125131        """ 
    126132        if name not in self.mydict.keys(): 
     
    130136    def get_list(self): 
    131137        """ 
    132          return all the list stored in a dictionary object 
     138        return all the list stored in a dictionary object 
    133139        """ 
    134140        return self.mydict 
    135141         
    136142class ModelManager: 
     143    """ 
     144    """ 
    137145    ## external dict for models 
    138146    model_combobox = ModelList() 
     
    156164    def _getModelList(self): 
    157165        """ 
    158             List of models we want to make available by default 
    159             for this application 
    160          
    161             @return: the next free event ID following the new menu events 
     166        List of models we want to make available by default 
     167        for this application 
     168     
     169        :return: the next free event ID following the new menu events 
     170         
    162171        """ 
    163172        ## form factor 
     
    255264        from sans.models.HayterMSAStructure import HayterMSAStructure 
    256265        self.struct_list.append(HayterMSAStructure) 
    257          
    258          
    259         ##shape-independent models 
    260              
     266     
     267        ##shape-independent models   
    261268        from sans.models.PowerLawAbsModel import PowerLawAbsModel 
    262269        self.shape_indep_list.append( PowerLawAbsModel ) 
     
    293300        self.shape_indep_list.append(PorodModel ) 
    294301         
    295          
    296302        #FractalModel (a c-model)will be used. 
    297303        #from sans.models.FractalAbsModel import FractalAbsModel 
     
    303309        from sans.models.LineModel import LineModel 
    304310        self.shape_indep_list.append(LineModel) 
    305  
    306      
     311         
    307312        #Looking for plugins 
    308313        self.plugins = findModels() 
    309         
    310314        return 0 
    311315 
     
    313317    def populate_menu(self, modelmenu, event_owner): 
    314318        """ 
    315             Populate a menu with our models 
    316              
    317             @param id: first menu event ID to use when binding the menu events 
    318             @param modelmenu: wx.Menu object to populate 
    319             @param event_owner: wx object to bind the menu events to 
    320             @return: the next free event ID following the new menu events 
     319        Populate a menu with our models 
     320         
     321        :param id: first menu event ID to use when binding the menu events 
     322        :param modelmenu: wx.Menu object to populate 
     323        :param event_owner: wx object to bind the menu events to 
     324         
     325        :return: the next free event ID following the new menu events 
     326         
    321327        """ 
    322328        ## Fill model lists 
     
    327333        self.event_owner = event_owner 
    328334         
    329          
    330335        shape_submenu = wx.Menu() 
    331336        shape_indep_submenu = wx.Menu() 
     
    334339        multip_models = wx.Menu() 
    335340        ## create menu with shape 
    336         self._fill_simple_menu( menuinfo = ["Shapes",shape_submenu," simple shape"], 
    337                          list1 = self.shape_list ) 
    338          
    339         self._fill_simple_menu( menuinfo = ["Shape-Independent",shape_indep_submenu, 
     341        self._fill_simple_menu(menuinfo=["Shapes",shape_submenu," simple shape"], 
     342                         list1=self.shape_list) 
     343         
     344        self._fill_simple_menu(menuinfo=["Shape-Independent",shape_indep_submenu, 
    340345                                    "List of shape-independent models"], 
    341                          list1 = self.shape_indep_list ) 
    342          
    343         self._fill_simple_menu( menuinfo= ["Structure Factors",structure_factor, 
     346                         list1=self.shape_indep_list ) 
     347         
     348        self._fill_simple_menu(menuinfo=["Structure Factors",structure_factor, 
    344349                                          "List of Structure factors models" ], 
    345                                 list1= self.struct_list ) 
    346          
    347         self._fill_plugin_menu( menuinfo = ["Customized Models", added_models, 
     350                                list1=self.struct_list) 
     351         
     352        self._fill_plugin_menu(menuinfo=["Customized Models", added_models, 
    348353                                            "List of additional models"], 
    349                                  list1= self.plugins ) 
     354                                 list1=self.plugins) 
    350355         
    351356        self._fill_menu(menuinfo=["P(Q)*S(Q)",multip_models, 
    352357                                  "mulplication of 2 models"], 
    353                                    list1 = self.multiplication_factor , 
    354                                    list2 =  self.struct_list) 
    355          
    356          
     358                                   list1=self.multiplication_factor , 
     359                                   list2= self.struct_list) 
    357360        return 0 
    358361     
    359     def _fill_plugin_menu(self,menuinfo, list1): 
    360         """ 
    361             fill the plugin menu with costumized models 
     362    def _fill_plugin_menu(self, menuinfo, list1): 
     363        """ 
     364        fill the plugin menu with costumized models 
    362365        """ 
    363366        if len(list1)==0: 
     
    367370        self._fill_simple_menu( menuinfo,list1) 
    368371         
    369          
    370     def _fill_simple_menu(self,menuinfo, list1): 
    371         """ 
    372             Fill the menu with list item 
    373             @param modelmenu: the menu to fill 
    374             @param menuinfo: submenu item for the first column of this modelmenu 
    375                              with info.Should be a list : 
    376                              [name(string) , menu(wx.menu), help(string)] 
    377             @param list1: contains item (form factor )to fill modelmenu second column 
     372    def _fill_simple_menu(self, menuinfo, list1): 
     373        """ 
     374        Fill the menu with list item 
     375         
     376        :param modelmenu: the menu to fill 
     377        :param menuinfo: submenu item for the first column of this modelmenu 
     378                         with info.Should be a list : 
     379                         [name(string) , menu(wx.menu), help(string)] 
     380        :param list1: contains item (form factor )to fill modelmenu second column 
     381         
    378382        """ 
    379383        if len(list1)>0: 
     
    399403        self.modelmenu.AppendMenu(id, menuinfo[0],menuinfo[1],menuinfo[2]) 
    400404         
    401          
    402          
    403     def _fill_menu(self,menuinfo, list1,list2  ): 
    404         """ 
    405             Fill the menu with list item 
    406             @param menuinfo: submenu item for the first column of this modelmenu 
    407                              with info.Should be a list : 
    408                              [name(string) , menu(wx.menu), help(string)] 
    409             @param list1: contains item (form factor )to fill modelmenu second column 
    410             @param list2: contains item (Structure factor )to fill modelmenu third column 
     405    def _fill_menu(self, menuinfo, list1, list2): 
     406        """ 
     407        Fill the menu with list item 
     408         
     409        :param menuinfo: submenu item for the first column of this modelmenu 
     410                         with info.Should be a list : 
     411                         [name(string) , menu(wx.menu), help(string)] 
     412        :param list1: contains item (form factor )to fill modelmenu second column 
     413        :param list2: contains item (Structure factor )to fill modelmenu  
     414                third column 
     415                 
    411416        """ 
    412417        if len(list1)>0: 
     
    437442        self.modelmenu.AppendMenu(id,menuinfo[0],menuinfo[1], menuinfo[2]) 
    438443         
    439          
    440          
    441          
    442444    def _on_model(self, evt): 
    443445        """ 
    444             React to a model menu event 
    445             @param event: wx menu event 
     446        React to a model menu event 
     447         
     448        :param event: wx menu event 
     449         
    446450        """ 
    447451        if int(evt.GetId()) in self.form_factor_dict.keys(): 
    448452            from sans.models.MultiplicationModel import MultiplicationModel 
    449453            model1, model2 = self.form_factor_dict[int(evt.GetId())] 
    450             model = MultiplicationModel(model1, model2) 
    451                 
     454            model = MultiplicationModel(model1, model2)     
    452455        else: 
    453456            model= self.struct_factor_dict[str(evt.GetId())]() 
    454              
    455457        evt = ModelEvent( model= model ) 
    456458        wx.PostEvent(self.event_owner, evt) 
    457459         
    458460    def get_model_list(self):     
    459         """ @ return dictionary of models for fitpanel use """ 
     461        """ 
     462        return dictionary of models for fitpanel use  
     463         
     464        """ 
    460465        self.model_combobox.set_list("multiplication", self.multiplication_factor) 
    461466        return self.model_combobox 
  • sansview/perspectives/fitting/pagestate.py

    r35b556d r5062bbf  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     1 
     2 
     3################################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7# 
     8#See the license text in license.txt 
     9# 
     10#copyright 2009, University of Tennessee 
     11################################################################################ 
     12 
    1013import time 
    1114import os 
     
    8790class PageState(object): 
    8891    """ 
    89         Contains information to reconstruct a page of the fitpanel. 
     92    Contains information to reconstruct a page of the fitpanel. 
    9093    """ 
    9194    def __init__(self, parent=None, model=None, data=None): 
    9295         
    9396        """  
    94             Initialize the current state 
    95             @param model: a selected model within a page 
    96             @param data:  
     97        Initialize the current state 
     98         
     99        :param model: a selected model within a page 
     100        :param data:  
     101         
    97102        """ 
    98103        self.file = None 
     
    201206    def clone(self): 
    202207        """ 
    203             Create a new copy of the current object 
     208        Create a new copy of the current object 
    204209        """ 
    205210        model = None 
     
    271276    def _repr_helper(self, list, rep): 
    272277        """ 
    273             Helper method to print a state 
     278        Helper method to print a state 
    274279        """ 
    275280        for item in list: 
     
    288293    def __repr__(self): 
    289294        """  
    290             output string for printing 
     295        output string for printing 
    291296        """ 
    292297        rep = "\nState name: %s\n"%self.file 
     
    321326    def _toXML_helper(self, list, element, newdoc): 
    322327        """ 
    323             Helper method to create xml file for saving state 
     328        Helper method to create xml file for saving state 
    324329        """ 
    325330        for item in list: 
     
    339344    def toXML(self, file="fitting_state.fitv", doc=None, entry_node=None): 
    340345        """ 
    341             Writes the state of the InversionControl panel to file, as XML. 
    342              
    343             Compatible with standalone writing, or appending to an 
    344             already existing XML document. In that case, the XML document 
    345             is required. An optional entry node in the XML document may also be given. 
    346              
    347             @param file: file to write to 
    348             @param doc: XML document object [optional] 
    349             @param entry_node: XML node within the XML document at which we will append the data [optional] 
     346        Writes the state of the InversionControl panel to file, as XML. 
     347         
     348        Compatible with standalone writing, or appending to an 
     349        already existing XML document. In that case, the XML document 
     350        is required. An optional entry node in the XML document may also be given. 
     351         
     352        :param file: file to write to 
     353        :param doc: XML document object [optional] 
     354        :param entry_node: XML node within the XML document at which we will append the data [optional] 
     355         
    350356        """ 
    351357        from xml.dom.minidom import getDOMImplementation 
     
    430436    def _fromXML_helper(self, node, list): 
    431437        """ 
    432             Helper function to write state to xml 
     438        Helper function to write state to xml 
    433439        """ 
    434440        for item in node: 
     
    448454    def fromXML(self, file=None, node=None): 
    449455        """ 
    450             Load fitting state from a file 
    451              
    452             @param file: .fitv file 
    453             @param node: node of a XML document to read from 
     456        Load fitting state from a file 
     457         
     458        :param file: .fitv file 
     459        :param node: node of a XML document to read from 
     460         
    454461        """ 
    455462       
     
    512519class Reader(CansasReader): 
    513520    """ 
    514         Class to load a .fitv fitting file 
     521    Class to load a .fitv fitting file 
    515522    """ 
    516523    ## File type 
     
    524531    def __init__(self, call_back=None, cansas=True): 
    525532        """ 
    526             Initialize the call-back method to be called 
    527             after we load a file 
    528             @param call_back: call-back method 
    529             @param cansas:  True = files will be written/read in CanSAS format 
    530                             False = write CanSAS format 
     533        Initialize the call-back method to be called 
     534        after we load a file 
     535         
     536        :param call_back: call-back method 
     537        :param cansas:  True = files will be written/read in CanSAS format 
     538                        False = write CanSAS format 
    531539             
    532540        """ 
     
    538546    def read(self, path): 
    539547        """  
    540             Load a new P(r) inversion state from file 
    541              
    542             @param path: file path 
    543             @return: None 
     548        Load a new P(r) inversion state from file 
     549         
     550        :param path: file path 
     551         
    544552        """ 
    545553        if self.cansas == True: 
     
    548556    def _data2d_to_xml_doc(self, datainfo): 
    549557        """ 
    550             Create an XML document to contain the content of a Data2D 
    551              
    552             @param datainfo: Data2D object 
     558        Create an XML document to contain the content of a Data2D 
     559         
     560        :param datainfo: Data2D object 
     561         
    553562        """ 
    554563        if not issubclass(datainfo.__class__, Data2D): 
     
    722731            for note in item.notes: 
    723732                write_node(doc, node, "SASprocessnote", note) 
    724          
    725733        # Return the document, and the SASentry node associated with 
    726734        # the data we just wrote 
    727735        return doc, entry_node 
    728736    
    729      
    730737    def _parse_state(self, entry): 
    731738        """ 
    732             Read a fit result from an XML node 
    733             @param entry: XML node to read from  
    734             @return: PageState object 
     739        Read a fit result from an XML node 
     740         
     741        :param entry: XML node to read from  
     742         
     743        :return: PageState object 
    735744        """ 
    736745        # Create an empty state 
     
    747756    def _parse_entry_2d(self, dom): 
    748757        """ 
    749             Parse a SASentry 
    750              
    751             @param node: SASentry node 
    752             @return: Data2D object 
    753         """ 
    754        
     758        Parse a SASentry 
     759         
     760        :param node: SASentry node 
     761         
     762        :return: Data2D object 
     763         
     764        """ 
    755765        data_info = Data2D() 
    756766         
     
    10831093    def _read_cansas(self, path): 
    10841094        """  
    1085             Load data and P(r) information from a CanSAS XML file. 
    1086              
    1087             @param path: file path 
    1088             @return: Data1D object if a single SASentry was found,  
    1089                         or a list of Data1D objects if multiple entries were found, 
    1090                         or None of nothing was found 
    1091             @raise RuntimeError: when the file can't be opened 
    1092             @raise ValueError: when the length of the data vectors are inconsistent 
     1095        Load data and P(r) information from a CanSAS XML file. 
     1096         
     1097        :param path: file path 
     1098         
     1099        :return: Data1D object if a single SASentry was found,  
     1100                    or a list of Data1D objects if multiple entries were found, 
     1101                    or None of nothing was found 
     1102                     
     1103        :raise RuntimeError: when the file can't be opened 
     1104        :raise ValueError: when the length of the data vectors are inconsistent 
     1105         
    10931106        """ 
    10941107        output = [] 
     
    11551168    def write(self, filename, datainfo=None, fitstate=None): 
    11561169        """ 
    1157             Write the content of a Data1D as a CanSAS XML file 
    1158              
    1159             @param filename: name of the file to write 
    1160             @param datainfo: Data1D object 
    1161             @param fitstate: PageState object 
     1170        Write the content of a Data1D as a CanSAS XML file 
     1171         
     1172        :param filename: name of the file to write 
     1173        :param datainfo: Data1D object 
     1174        :param fitstate: PageState object 
     1175         
    11621176        """ 
    11631177        # Sanity check 
     
    11821196            fitstate.toXML(file=filename) 
    11831197         
    1184          
    1185 if __name__ == "__main__": 
    1186     state = PageState(parent=None) 
    1187     state.toXML() 
    1188     print "state", state 
     1198"""      
     1199Example: :: 
     1200   
     1201    if __name__ == "__main__": 
     1202        state = PageState(parent=None) 
     1203        state.toXML() 
     1204        print "state", state 
     1205     
     1206""" 
  • sansview/perspectives/fitting/simfitpage.py

    r6e9976b r5062bbf  
    1414def get_fittableParam( model): 
    1515    """ 
    16         @return list of fittable parameters name of a model 
    17         @param model: the model used 
     16    return list of fittable parameters name of a model 
     17     
     18    :param model: the model used 
     19     
    1820    """ 
    1921    fittable_param=[] 
     
    3032class SimultaneousFitPage(wx.ScrolledWindow): 
    3133    """ 
    32         Simultaneous fitting panel 
    33         All that needs to be defined are the 
    34         two data members window_name and window_caption 
     34    Simultaneous fitting panel 
     35    All that needs to be defined are the 
     36    two data members window_name and window_caption 
    3537    """ 
    3638    ## Internal name for the AUI manager 
     
    4345        wx.ScrolledWindow.__init__(self, parent,style= wx.FULL_REPAINT_ON_RESIZE ) 
    4446        """ 
    45              Simultaneous page display 
     47        Simultaneous page display 
    4648        """ 
    4749        ##Font size 
     
    6769        self.set_layout() 
    6870         
    69         
    70          
    7171    def define_page_structure(self): 
    7272        """ 
    73             Create empty sizer for a panel 
     73        Create empty sizer for a panel 
    7474        """ 
    7575        self.vbox  = wx.BoxSizer(wx.VERTICAL) 
     
    8686         
    8787    def set_scroll(self): 
     88        """ 
     89        """ 
    8890        self.SetScrollbars(20,20,25,65) 
    8991        self.Layout()   
     
    9193    def set_layout(self): 
    9294        """ 
    93              layout 
     95        layout 
    9496        """ 
    9597        self.vbox.Layout() 
    9698        self.vbox.Fit(self)  
    9799        self.SetSizer(self.vbox) 
    98         
    99100        self.set_scroll() 
    100101        self.Centre() 
     
    102103    def onRemove(self, event): 
    103104        """ 
    104             Remove constraint fields 
     105        Remove constraint fields 
    105106        """ 
    106107        if len(self.constraints_list)==1: 
     
    123124                break 
    124125                 
    125          
    126126    def onFit(self,event): 
    127         """ signal for fitting""" 
     127        """ 
     128        signal for fitting 
     129         
     130        """ 
    128131        ## making sure all parameters content a constraint 
    129132        ## validity of the constraint expression is own by fit engine 
     
    145148            wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
    146149            
    147              
    148              
    149150    def set_manager(self, manager): 
    150151        """ 
    151             set panel manager 
    152             @param manager: instance of plugin fitting 
     152        set panel manager 
     153         
     154        :param manager: instance of plugin fitting 
     155         
    153156        """ 
    154157        self.manager = manager 
    155158        
    156          
    157159    def check_all_model_name(self,event): 
    158160        """ 
    159             check all models names 
     161        check all models names 
    160162        """ 
    161163        self.model_toFit=[]  
     
    179181            self._hide_constraint() 
    180182         
    181    
    182183    def check_model_name(self,event): 
    183184        """ 
    184             Save information related to checkbox and their states 
     185        Save information related to checkbox and their states 
    185186        """ 
    186187        self.model_toFit=[] 
     
    208209        else: 
    209210            self.cb1.SetValue(False) 
    210             
    211          
    212    
     211         
    213212    def draw_page(self):       
    214213        """ 
    215             Draw a sizer containing couples of data and model  
     214        Draw a sizer containing couples of data and model  
    216215        """  
    217        
    218216        self.model_list=[] 
    219217        self.model_toFit=[] 
     
    227225                self.manager.schedule_for_fit( value=0,fitproblem =item[1]) 
    228226                 
    229         self.sizer1.Clear(True) 
    230          
    231                  
     227        self.sizer1.Clear(True)     
    232228        box_description= wx.StaticBox(self, -1,"Fit Combinations") 
    233229        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    234230        sizer_title = wx.BoxSizer(wx.HORIZONTAL) 
    235231        sizer_couples = wx.GridBagSizer(5,5) 
    236          
    237232        #------------------------------------------------------ 
    238233        if len(self.page_finder)==0: 
     
    257252            ## draw fit button  
    258253            self._fill_sizer_fit() 
    259              
    260254        #-------------------------------------------------------- 
    261255        boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=5)  
     
    269263    def _store_model(self): 
    270264        """ 
    271             Store selected model 
     265         Store selected model 
    272266        """ 
    273267        if len(self.model_toFit) < 2: 
     
    278272            self.constraint_dict[page] = model 
    279273                    
    280          
    281274    def _display_constraint(self, event): 
    282275        """ 
    283             Show fields to add constraint 
     276        Show fields to add constraint 
    284277        """ 
    285278        if len(self.model_toFit)< 2: 
     
    296289           return  
    297290             
    298     
    299291    def _show_constraint(self): 
    300292        """ 
    301             Show constraint fields 
     293        Show constraint fields 
    302294        """ 
    303295        self.btAdd.Show(True) 
     
    340332        btRemove.SetToolTipString("Remove constraint.") 
    341333        
    342          
    343334        for page,model in self.constraint_dict.iteritems(): 
    344335            ## check if all parameters have been selected for constraint 
     
    350341            
    351342        wx.EVT_COMBOBOX(model_cbox,-1, self._on_select_model) 
    352          
    353         
     343     
    354344        sizer_constraint.Add(model_cbox, flag= wx.RIGHT|wx.EXPAND,border=10) 
    355345        sizer_constraint.Add(param_cbox, flag= wx.RIGHT|wx.EXPAND,border=5) 
     
    363353        ##[combobox1, combobox2,=,textcrtl, remove button ] 
    364354        self.constraints_list.append([model_cbox, param_cbox, egal_txt, ctl2,btRemove,sizer_constraint]) 
    365          
    366         
     355     
    367356        self.nb_constraint += 1 
    368357        self.sizer_constraints.Layout() 
     
    372361    def _hide_constraint(self):  
    373362        """ 
    374             hide buttons related constraint  
     363        hide buttons related constraint  
    375364        """   
    376365        for page in  self.page_finder.iterkeys(): 
     
    382371            self.btAdd.Hide() 
    383372        self._store_model() 
    384        
    385373        self.constraints_list=[]          
    386374        self.sizer_constraints.Clear(True)  
     
    389377        self.SetScrollbars(20,20,25,65) 
    390378        self.AdjustScrollbars()     
    391                  
    392      
    393          
     379             
    394380    def _on_select_model(self, event): 
    395381        """ 
    396          fill combox box with list of parameters 
     382        fill combox box with list of parameters 
    397383        """ 
    398384        ##This way PC/MAC both work, instead of using event.GetClientData(). 
     
    404390        if length < 1: 
    405391            return  
    406          
    407392        param_cbox = self.constraints_list[length-1][1] 
    408393        param_cbox.Clear() 
     
    412397             
    413398        param_cbox.Show(True) 
    414         
    415         
    416399        self.sizer2.Layout() 
    417400        self.SetScrollbars(20,20,25,65) 
    418401         
    419          
    420402    def _on_select_param(self, event): 
    421403        """ 
    422             Store the appropriate constraint in the page_finder 
     404        Store the appropriate constraint in the page_finder 
    423405        """ 
    424406        ##This way PC/MAC both work, instead of using event.GetClientData(). 
     
    435417        ctl2 = self.constraints_list[length-1][3] 
    436418        ctl2.Show(True) 
    437          
    438          
    439419        #self.sizer2.Layout() 
    440420        self.SetScrollbars(20,20,25,65) 
    441421         
    442          
    443422    def _onAdd_constraint(self, event):   
    444423        """ 
    445             Add another line for constraint 
    446         """ 
    447          
     424        Add another line for constraint 
     425        """ 
    448426        if not self.show_constraint.GetValue(): 
    449427            msg= " Select Yes to add Constraint " 
    450428            wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
    451429            return  
    452             
    453430        ## check that a constraint is added before allow to add another cosntraint 
    454          
    455431        for item in self.constraints_list: 
    456432            model_cbox = item[0] 
     
    470446                wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
    471447                return  
    472         
    473448        ## some model or parameters can be constrained 
    474449        self._show_constraint() 
     
    476451    def _fill_sizer_fit(self): 
    477452        """ 
    478             Draw fit fit button 
     453        Draw fit button 
    479454        """ 
    480455        self.sizer3.Clear(True) 
     
    501476    def _fill_sizer_constraint(self): 
    502477        """ 
    503             Fill sizer containing constraint info 
    504         """ 
    505         msg= "Select at least 2 model to add constraint " 
     478        Fill sizer containing constraint info 
     479        """ 
     480        msg = "Select at least 2 model to add constraint " 
    506481        wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
    507482         
    508483        self.sizer2.Clear(True) 
    509   
    510484        box_description= wx.StaticBox(self, -1,"Fit Constraints") 
    511485        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
     
    516490        self.hide_constraint = wx.RadioButton(self, -1, 'No', (10, 10), style=wx.RB_GROUP) 
    517491        self.show_constraint = wx.RadioButton(self, -1, 'Yes', (10, 30)) 
    518          
    519492        self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, 
    520493                    id= self.hide_constraint.GetId() ) 
    521          
    522494        self.Bind(  wx.EVT_RADIOBUTTON, self._display_constraint, 
    523495                         id= self.show_constraint.GetId()    ) 
     
    538510        self.btAdd.Hide() 
    539511      
    540          
    541512        text_hint = wx.StaticText(self,-1,"Example: [M0][paramter] = M1.parameter")  
    542513        sizer_button.Add(text_hint, 0 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    543514        sizer_button.Add(self.btAdd, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    544515        
    545         
    546516        boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=10) 
    547517        boxsizer1.Add(self.sizer_constraints, flag= wx.TOP|wx.BOTTOM,border=10) 
     
    551521        self.sizer2.Layout() 
    552522        self.SetScrollbars(20,20,25,65) 
    553          
    554          
    555          
     523     
    556524    def _set_constraint(self): 
    557525        """ 
    558             get values from the constrainst textcrtl ,parses them into model name 
    559             parameter name and parameters values. 
    560             store them in a list self.params .when when params is not empty set_model  
    561             uses it to reset the appropriate model and its appropriates parameters 
     526        get values from the constrainst textcrtl ,parses them into model name 
     527        parameter name and parameters values. 
     528        store them in a list self.params .when when params is not empty set_model  
     529        uses it to reset the appropriate model and its appropriates parameters 
    562530        """ 
    563531        for item in self.constraints_list: 
    564              
    565532            model = item[0].GetClientData(item[0].GetCurrentSelection()) 
    566533            param = item[1].GetString(item[1].GetCurrentSelection()) 
     
    580547                    self.page_finder[page].set_model_param(param,constraint) 
    581548                    break 
    582          
    583     
    584                
     549     
    585550    def _fill_sizer_model_list(self,sizer): 
    586551        """ 
    587             Receive a dictionary containing information to display model name 
    588             @param page_finder: the dictionary containing models information 
     552        Receive a dictionary containing information to display model name 
     553         
     554        :param page_finder: the dictionary containing models information 
     555         
    589556        """ 
    590557        ix = 0 
     
    597564        sizer.Add(new_name,(iy, ix),(1,1), 
    598565                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    599          
    600         ix +=2  
     566        ix += 2  
    601567        model_type = wx.StaticText(self, -1, '  Model Type') 
    602568        model_type.SetBackgroundColour('grey') 
    603569        sizer.Add(model_type,(iy, ix),(1,1), 
    604570                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    605         ix +=1  
     571        ix += 1  
    606572        data_used = wx.StaticText(self, -1, '  Used Data') 
    607573        data_used.SetBackgroundColour('grey') 
     
    619585                wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) 
    620586                 
    621                 ix +=2  
     587                ix += 2  
    622588                type = model.__class__.__name__ 
    623589                model_type = wx.StaticText(self, -1, str(type)) 
    624590                sizer.Add(model_type,( iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    625591                 
    626                 ix +=1  
     592                ix += 1  
    627593                data = value.get_fit_data() 
    628594                data_used= wx.StaticText(self, -1, str(data.name)) 
     
    633599            except: 
    634600                pass 
    635         iy +=1 
     601        iy += 1 
    636602        sizer.Add((20,20),( iy,ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    637603        sizer.Layout()     
    638          
    639     
    640    
    641          
    642 class HelpWindow(wx.Frame): 
    643     def __init__(self, parent, id, title): 
    644         wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 
    645          
    646         page_finder ={} 
    647         ## create random data 
    648         from danse.common.plottools.plottables import Data1D 
    649         data= Data1D(x=[1,2], y=[3,4], dy=[0.1, 0,1]) 
    650         data.name="mydata.txt" 
    651         ## create model 
    652         from sans.models.CylinderModel import CylinderModel 
    653         model = CylinderModel() 
    654         model.name="M0" 
    655          
    656          
    657         from fitproblem import FitProblem 
    658         page_finder["page"]= FitProblem() 
    659         ## fill the page_finder 
    660         page_finder["page"].add_fit_data(data) 
    661         page_finder["page"].set_model(model) 
    662         self.page = SimultaneousFitPage(self, page_finder=page_finder)  
    663          
    664          
    665          
    666         self.Centre() 
    667         self.Show(True) 
    668  
    669  
    670     
    671 if __name__=="__main__": 
    672     app = wx.App() 
    673     HelpWindow(None, -1, 'HelpWindow') 
    674     app.MainLoop() 
    675      
Note: See TracChangeset for help on using the changeset viewer.