Changes in / [13f5656:131d94b] in sasview


Ignore:
Files:
2 added
4 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • docs/sphinx-docs/source/dev/dev.rst

    re8447d8 r476d4e3  
    11Developer Documentation 
    22======================= 
    3  
    4 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page 
    53 
    64Contents 
  • docs/sphinx-docs/source/user/tutorial.rst

    re8447d8 rec860a8f  
    66======== 
    77 
    8 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page 
    9  
    108:download:`Tutorial <../../../../sasview/media/Tutorial.pdf>` 
  • src/sas/sascalc/fit/MultiplicationModel.py

    rfd62331 rcb4ef58  
    88    r""" 
    99        Use for P(Q)\*S(Q); function call must be in the order of P(Q) and then S(Q): 
    10         The model parameters are combined from both models, P(Q) and S(Q), except 1) 'radius_effective' of S(Q) 
    11         which will be calculated from P(Q) via calculate_ER(), 
    12         and 2) 'scale' in P model which is synchronized w/ volfraction in S 
     10        The model parameters are combined from both models, P(Q) and S(Q), except 1) 'effect_radius' of S(Q) 
     11        which will be calculated from P(Q) via calculate_ER(),  
     12        and 2) 'scale' in P model which is synchronized w/ volfraction in S  
    1313        then P*S is multiplied by a new parameter, 'scale_factor'. 
    1414        The polydispersion is applicable only to P(Q), not to S(Q). 
     
    3434        ## Parameter details [units, min, max] 
    3535        self.details = {} 
    36  
    37         ## Define parameters to exclude from multiplication model 
    38         self.excluded_params={'radius_effective','scale','background'} 
    39  
    40         ##models 
     36         
     37        ##models  
    4138        self.p_model = p_model 
    42         self.s_model = s_model 
     39        self.s_model = s_model         
    4340        self.magnetic_params = [] 
    4441        ## dispersion 
     
    4845        ## New parameter:Scaling factor 
    4946        self.params['scale_factor'] = 1 
    50         self.params['background']  = 0 
    51  
     47         
    5248        ## Parameter details [units, min, max] 
    5349        self._set_details() 
    5450        self.details['scale_factor'] = ['', 0.0, numpy.inf] 
    55         self.details['background'] = ['',-numpy.inf,numpy.inf] 
    56  
     51         
    5752        #list of parameter that can be fitted 
    58         self._set_fixed_params() 
     53        self._set_fixed_params()   
    5954        ## parameters with orientation 
    6055        for item in self.p_model.orientation_params: 
    6156            self.orientation_params.append(item) 
    62         for item in self.p_model.magnetic_params: 
    63             self.magnetic_params.append(item) 
     57        for item in self.p_model.magnetic_params:   
     58            self.magnetic_params.append(item)  
    6459        for item in self.s_model.orientation_params: 
    6560            if not item in self.orientation_params: 
     
    7166            multiplicity = 1 
    7267        ## functional multiplicity of the model 
    73         self.multiplicity = multiplicity 
    74  
     68        self.multiplicity = multiplicity     
     69           
    7570        # non-fittable parameters 
    76         self.non_fittable = p_model.non_fittable 
    77         self.multiplicity_info = [] 
     71        self.non_fittable = p_model.non_fittable   
     72        self.multiplicity_info = []  
    7873        self.fun_list = {} 
    7974        if self.non_fittable > 1: 
    8075            try: 
    81                 self.multiplicity_info = p_model.multiplicity_info 
     76                self.multiplicity_info = p_model.multiplicity_info  
    8277                self.fun_list = p_model.fun_list 
    8378                self.is_multiplicity_model = True 
     
    8782            self.is_multiplicity_model = False 
    8883            self.multiplicity_info = [0] 
    89  
     84             
    9085    def _clone(self, obj): 
    9186        """ 
     
    10196        #obj = copy.deepcopy(self) 
    10297        return obj 
    103  
    104  
     98     
     99     
    105100    def _set_dispersion(self): 
    106101        """ 
     
    108103        applied to s_model 
    109104        """ 
    110         ##set dispersion only from p_model 
     105        ##set dispersion only from p_model  
    111106        for name , value in self.p_model.dispersion.iteritems(): 
    112             self.dispersion[name] = value 
    113  
     107            self.dispersion[name] = value  
     108                                       
    114109    def getProfile(self): 
    115110        """ 
    116111        Get SLD profile of p_model if exists 
    117  
     112         
    118113        :return: (r, beta) where r is a list of radius of the transition points\ 
    119114                beta is a list of the corresponding SLD values 
     
    126121            x = None 
    127122            y = None 
    128  
     123             
    129124        return x, y 
    130  
     125     
    131126    def _set_params(self): 
    132127        """ 
    133128        Concatenate the parameters of the two models to create 
    134         these model parameters 
     129        these model parameters  
    135130        """ 
    136131 
    137132        for name , value in self.p_model.params.iteritems(): 
    138             if not name in self.params.keys() and name not in self.excluded_params: 
     133            if not name in self.params.keys() and name != 'scale': 
    139134                self.params[name] = value 
    140  
     135             
    141136        for name , value in self.s_model.params.iteritems(): 
    142             #Remove the radius_effective from the (P*S) model parameters. 
    143             if not name in self.params.keys() and name not in self.excluded_params: 
     137            #Remove the effect_radius from the (P*S) model parameters. 
     138            if not name in self.params.keys() and name != 'effect_radius': 
    144139                self.params[name] = value 
    145  
     140                 
    146141        # Set "scale and effec_radius to P and S model as initializing 
    147142        # since run P*S comes from P and S separately. 
    148         self._set_backgrounds() 
    149143        self._set_scale_factor() 
    150         self._set_radius_effective() 
    151  
     144        self._set_effect_radius()        
     145             
    152146    def _set_details(self): 
    153147        """ 
    154148        Concatenate details of the two models to create 
    155         this model's details 
     149        this model's details  
    156150        """ 
    157151        for name, detail in self.p_model.details.iteritems(): 
    158             if name not in self.excluded_params: 
     152            if name != 'scale': 
    159153                self.details[name] = detail 
    160  
     154             
    161155        for name , detail in self.s_model.details.iteritems(): 
    162             if not name in self.details.keys() or name not in self.exluded_params: 
     156            if not name in self.details.keys() or name != 'effect_radius': 
    163157                self.details[name] = detail 
    164  
    165     def _set_backgrounds(self): 
    166         """ 
    167         Set component backgrounds to zero 
    168         """ 
    169         self.p_model.setParam('background',0) 
    170         self.s_model.setParam('background',0) 
    171  
    172  
     158     
    173159    def _set_scale_factor(self): 
    174160        """ 
     
    176162        """ 
    177163        value = self.params['volfraction'] 
    178         if value != None: 
     164        if value != None:  
    179165            factor = self.p_model.calculate_VR() 
    180166            if factor == None or factor == NotImplemented or factor == 0.0: 
     
    184170            self.p_model.setParam('scale', value) 
    185171            self.s_model.setParam('volfraction', val) 
    186  
    187     def _set_radius_effective(self): 
     172             
     173    def _set_effect_radius(self): 
    188174        """ 
    189175        Set effective radius to S(Q) model 
    190176        """ 
    191         if not 'radius_effective' in self.s_model.params.keys(): 
     177        if not 'effect_radius' in self.s_model.params.keys(): 
    192178            return 
    193179        effective_radius = self.p_model.calculate_ER() 
    194180        #Reset the effective_radius of s_model just before the run 
    195181        if effective_radius != None and effective_radius != NotImplemented: 
    196             self.s_model.setParam('radius_effective', effective_radius) 
    197  
     182            self.s_model.setParam('effect_radius', effective_radius) 
     183                 
    198184    def setParam(self, name, value): 
    199         """ 
     185        """  
    200186        Set the value of a model parameter 
    201  
     187         
    202188        :param name: name of the parameter 
    203189        :param value: value of the parameter 
     
    205191        # set param to P*S model 
    206192        self._setParamHelper( name, value) 
    207  
    208         ## setParam to p model 
    209         # set 'scale' in P(Q) equal to volfraction 
     193         
     194        ## setParam to p model  
     195        # set 'scale' in P(Q) equal to volfraction  
    210196        if name == 'volfraction': 
    211197            self._set_scale_factor() 
    212         elif name in self.p_model.getParamList() and name not in self.excluded_params: 
     198        elif name in self.p_model.getParamList(): 
    213199            self.p_model.setParam( name, value) 
    214  
    215         ## setParam to s model 
    216         # This is a little bit abundant: Todo: find better way 
    217         self._set_radius_effective() 
    218         if name in self.s_model.getParamList() and name not in self.excluded_params: 
     200         
     201        ## setParam to s model  
     202        # This is a little bit abundant: Todo: find better way          
     203        self._set_effect_radius() 
     204        if name in self.s_model.getParamList(): 
    219205            if name != 'volfraction': 
    220206                self.s_model.setParam( name, value) 
    221  
     207             
    222208 
    223209        #self._setParamHelper( name, value) 
    224  
     210         
    225211    def _setParamHelper(self, name, value): 
    226212        """ 
     
    242228                    self.params[item] = value 
    243229                    return 
    244  
     230             
    245231        raise ValueError, "Model does not contain parameter %s" % name 
    246  
    247  
     232              
     233    
    248234    def _set_fixed_params(self): 
    249235        """ 
     
    254240 
    255241        self.fixed.sort() 
    256  
    257  
     242                 
     243                 
    258244    def run(self, x = 0.0): 
    259         """ 
     245        """  
    260246        Evaluate the model 
    261  
     247         
    262248        :param x: input q-value (float or [float, float] as [r, theta]) 
    263249        :return: (scattering function value) 
    264250        """ 
    265251        # set effective radius and scaling factor before run 
    266         self._set_radius_effective() 
     252        self._set_effect_radius() 
    267253        self._set_scale_factor() 
    268254        return self.params['scale_factor'] * self.p_model.run(x) * \ 
    269                             self.s_model.run(x) + self.params['background'] 
     255                            self.s_model.run(x) 
    270256 
    271257    def runXY(self, x = 0.0): 
    272         """ 
     258        """  
    273259        Evaluate the model 
    274  
     260         
    275261        :param x: input q-value (float or [float, float] as [qx, qy]) 
    276262        :return: scattering function value 
    277         """ 
     263        """   
    278264        # set effective radius and scaling factor before run 
    279         self._set_radius_effective() 
     265        self._set_effect_radius() 
    280266        self._set_scale_factor() 
    281267        out = self.params['scale_factor'] * self.p_model.runXY(x) * \ 
    282                         self.s_model.runXY(x) + self.params['background'] 
     268                        self.s_model.runXY(x) 
    283269        return out 
    284  
    285     ## Now (May27,10) directly uses the model eval function 
     270     
     271    ## Now (May27,10) directly uses the model eval function  
    286272    ## instead of the for-loop in Base Component. 
    287273    def evalDistribution(self, x = []): 
    288         """ 
     274        """  
    289275        Evaluate the model in cartesian coordinates 
    290  
     276         
    291277        :param x: input q[], or [qx[], qy[]] 
    292278        :return: scattering function P(q[]) 
    293279        """ 
    294280        # set effective radius and scaling factor before run 
    295         self._set_radius_effective() 
     281        self._set_effect_radius() 
    296282        self._set_scale_factor() 
    297283        out = self.params['scale_factor'] * self.p_model.evalDistribution(x) * \ 
    298                         self.s_model.evalDistribution(x) + self.params['background'] 
     284                        self.s_model.evalDistribution(x) 
    299285        return out 
    300286 
     
    302288        """ 
    303289        Set the dispersion object for a model parameter 
    304  
     290         
    305291        :param parameter: name of the parameter [string] 
    306292        :dispersion: dispersion object of type DispersionModel 
     
    313299            return value 
    314300        except: 
    315             raise 
     301            raise  
    316302 
    317303    def fill_description(self, p_model, s_model): 
     
    320306        """ 
    321307        description = "" 
    322         description += "Note:1) The radius_effective (effective radius) of %s \n"%\ 
     308        description += "Note:1) The effect_radius (effective radius) of %s \n"%\ 
    323309                                                                (s_model.name) 
    324310        description += "             is automatically calculated " 
     
    332318        description += "        for details of individual models." 
    333319        self.description += description 
     320     
  • src/sas/sasgui/perspectives/calculator/media/python_shell_help.rst

    rafb93df rd85c194  
    33.. This is a port of the original SasView html help file to ReSTructured text 
    44.. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 
    5 .. Text revised during Code Camp V in Oct 2016. 
    65 
    7 .. _Python_shell: 
    8  
    9 Python Shell-Editor Tool 
    10 ======================== 
     6Python Shell Tool 
     7================= 
    118 
    129Description  
    1310----------- 
    1411 
    15 This is a Python shell/editor provided with WxPython. 
     12This is a Python shell/editor (PyCrust) provided with WxPython. An editing  
     13notebook will show up when a Python file is created/loaded with the *New* or  
     14*Open* options on the menu.  
    1615 
    17 For the help about Python, visit the website http://docs.python.org/tutorial/ 
     16*Run* enables the editor to compile and run the Python code. 
    1817 
    19 .. note:: This shell/editor has its own help, but the Help() and Credits() calls do not work on Macs. 
     18For the details about the Python, visit the website http://docs.python.org/tutorial/ 
    2019 
    21 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView and so functions from these can be imported into the shell/editor, however, some functionality may not work. 
     20The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView.  
     21However, some functionality may not work. 
    2222 
    23 .. image:: new_pycrust_example.png 
    24    :align: center 
     23PyCrust has its own Help. 
    2524 
    26 When a Python file, for example a fitting model, is created or loaded with the *New* or *Open* options from the menu, a new tab opens with an editing notebook. 
     25*NOTE! The Help() and Credits() calls do not work on Macs.* 
    2726 
    28 .. image:: new_pycrust_example_2.png 
    29    :align: center 
     27.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    3028 
    31 If a Python (.py) model has a linked C (.c) subroutine *in the same folder* then the shell/editor will open both! However input focus is usually transferred to the tab with the .c file. 
     29Example 
     30------- 
    3231 
    33 To compile a model, select *Run* > *Check Model* from the shell/editor menu. If the model contains a unit test (which it should!!!) then this will also run and a popup window will report the success/failure of the test. 
     32An example calling the Matplotlib plotting gallery: 
     33 
     34.. image:: pycrust_example.png 
    3435 
    3536.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    3637 
    37 .. note::  This help document was last changed by Steve King, 10Oct2015 
     38.. note::  This help document was last changed by Steve King, 19Feb2015 
  • src/sas/sasgui/perspectives/fitting/media/fitting.rst

    re8447d8 r2a6d757  
    33Fitting Documentation 
    44===================== 
    5  
    6 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page 
    75 
    86.. toctree:: 
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    rafb93df r05829fb  
    141141From the *Fitting* option in the menu bar, select *Edit Custom Model*. 
    142142 
    143 .. image:: edit_model_menu.png 
     143.. image:: edit_model_menu.bmp 
    144144 
    145145and then one of the options 
    146146 
    147 *  *New* - to create a custom model template with a help dialog 
    148 *  *Sum|Multi(p1,p2)* - to create a custom model by summing/multiplying *existing models* in the model library 
    149 *  *Advanced* - to create/edit a custom model in a Python shell 
     147*  *New* - to create a new custom model template 
     148*  *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library 
     149*  *Advanced* - to edit a new custom model 
    150150*  *Delete* - to delete a custom model 
    151 *  *Load* - to (re-)load custom models 
    152151 
    153152New 
     
    185184^^^^^^^^ 
    186185 
    187 Selecting this option shows all the custom models in the plugin model folder, on Windows this is 
    188  
    189   *C:\\Users\\{username}\\.sasview\\plugin_models* 
     186Selecting this option shows all the custom models in the plugin model folder 
     187 
     188  *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 
    190189 
    191190You can edit, modify, and save the Python code in any of these models using the 
    192 *Advanced Custom Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . 
    193  
    194 For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . 
    195  
    196 .. note:: Model files generated with the Sum/Multi option are still using the SasView 3.x model format. Unless you are confident about what you are doing, it is recommended that you only modify lines denoted with the ## <----- comments! 
    197  
    198 When editing is complete, select *Run* > *Check Model* from the *Advanced Custom Model Editor* menu bar. An *Info* box will appear with the results of the compilation and model unit tests. The model will only be usable if the tests 'pass'. 
     191*Advanced Custom Model Editor*. 
     192 
     193See :ref:`Writing_a_Plugin` for details on the plugin format. 
     194 
     195*NB: Sum/Product models are still using the SasView 3.x model format.  Unless 
     196you are confident about what you are doing, it is recommended that you 
     197only modify lines denoted with the ## <----- comments!* 
     198 
     199When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An 
     200*Info* box will appear with the results of the compilation and model unit tests. The 
     201model will only be usable if the tests 'pass'. 
    199202 
    200203To use the model, go to the relevant *Fit Page*, select the *Customized Models* 
    201204category and then select the model from the drop-down menu. 
    202205 
    203 Any changes to a custom model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. 
     206*NB: Any changes to a custom model generated in this way only become effective after* 
     207*it is re-selected from the model drop-down menu on the Fit Page.* 
    204208 
    205209Delete 
     
    209213 
    210214*NB: Custom models shipped with SasView cannot be removed in this way.* 
    211  
    212 Load 
    213 ^^^^ 
    214  
    215 This option loads (or re-loads) all models present in the plugin model folder. 
    216215 
    217216.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
Note: See TracChangeset for help on using the changeset viewer.