Changeset 9087214 in sasview for src/sas


Ignore:
Timestamp:
Oct 11, 2016 11:09:47 AM (8 years ago)
Author:
jhbakker
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
4581ac9, 7949dcf7
Parents:
392056d (diff), 46dfee9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into Jurrian1D, fingers crossed!

Location:
src/sas
Files:
10 added
1 deleted
24 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/fit/MultiplicationModel.py

    rcb4ef58 r68669da  
    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) '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  
     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 
    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         ##models  
     36 
     37        ## Define parameters to exclude from multiplication model 
     38        self.excluded_params={'radius_effective','scale','background'} 
     39 
     40        ##models 
    3841        self.p_model = p_model 
    39         self.s_model = s_model         
     42        self.s_model = s_model 
    4043        self.magnetic_params = [] 
    4144        ## dispersion 
     
    4548        ## New parameter:Scaling factor 
    4649        self.params['scale_factor'] = 1 
    47          
     50        self.params['background']  = 0 
     51 
    4852        ## Parameter details [units, min, max] 
    4953        self._set_details() 
    5054        self.details['scale_factor'] = ['', 0.0, numpy.inf] 
    51          
     55        self.details['background'] = ['',-numpy.inf,numpy.inf] 
     56 
    5257        #list of parameter that can be fitted 
    53         self._set_fixed_params()   
     58        self._set_fixed_params() 
    5459        ## parameters with orientation 
    5560        for item in self.p_model.orientation_params: 
    5661            self.orientation_params.append(item) 
    57         for item in self.p_model.magnetic_params:   
    58             self.magnetic_params.append(item)  
     62        for item in self.p_model.magnetic_params: 
     63            self.magnetic_params.append(item) 
    5964        for item in self.s_model.orientation_params: 
    6065            if not item in self.orientation_params: 
     
    6671            multiplicity = 1 
    6772        ## functional multiplicity of the model 
    68         self.multiplicity = multiplicity     
    69            
     73        self.multiplicity = multiplicity 
     74 
    7075        # non-fittable parameters 
    71         self.non_fittable = p_model.non_fittable   
    72         self.multiplicity_info = []  
     76        self.non_fittable = p_model.non_fittable 
     77        self.multiplicity_info = [] 
    7378        self.fun_list = {} 
    7479        if self.non_fittable > 1: 
    7580            try: 
    76                 self.multiplicity_info = p_model.multiplicity_info  
     81                self.multiplicity_info = p_model.multiplicity_info 
    7782                self.fun_list = p_model.fun_list 
    7883                self.is_multiplicity_model = True 
     
    8287            self.is_multiplicity_model = False 
    8388            self.multiplicity_info = [0] 
    84              
     89 
    8590    def _clone(self, obj): 
    8691        """ 
     
    96101        #obj = copy.deepcopy(self) 
    97102        return obj 
    98      
    99      
     103 
     104 
    100105    def _set_dispersion(self): 
    101106        """ 
     
    103108        applied to s_model 
    104109        """ 
    105         ##set dispersion only from p_model  
     110        ##set dispersion only from p_model 
    106111        for name , value in self.p_model.dispersion.iteritems(): 
    107             self.dispersion[name] = value  
    108                                        
     112            self.dispersion[name] = value 
     113 
    109114    def getProfile(self): 
    110115        """ 
    111116        Get SLD profile of p_model if exists 
    112          
     117 
    113118        :return: (r, beta) where r is a list of radius of the transition points\ 
    114119                beta is a list of the corresponding SLD values 
     
    121126            x = None 
    122127            y = None 
    123              
     128 
    124129        return x, y 
    125      
     130 
    126131    def _set_params(self): 
    127132        """ 
    128133        Concatenate the parameters of the two models to create 
    129         these model parameters  
     134        these model parameters 
    130135        """ 
    131136 
    132137        for name , value in self.p_model.params.iteritems(): 
    133             if not name in self.params.keys() and name != 'scale': 
     138            if not name in self.params.keys() and name not in self.excluded_params: 
    134139                self.params[name] = value 
    135              
     140 
    136141        for name , value in self.s_model.params.iteritems(): 
    137             #Remove the effect_radius from the (P*S) model parameters. 
    138             if not name in self.params.keys() and name != 'effect_radius': 
     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: 
    139144                self.params[name] = value 
    140                  
     145 
    141146        # Set "scale and effec_radius to P and S model as initializing 
    142147        # since run P*S comes from P and S separately. 
     148        self._set_backgrounds() 
    143149        self._set_scale_factor() 
    144         self._set_effect_radius()        
    145              
     150        self._set_radius_effective() 
     151 
    146152    def _set_details(self): 
    147153        """ 
    148154        Concatenate details of the two models to create 
    149         this model's details  
     155        this model's details 
    150156        """ 
    151157        for name, detail in self.p_model.details.iteritems(): 
    152             if name != 'scale': 
     158            if name not in self.excluded_params: 
    153159                self.details[name] = detail 
    154              
     160 
    155161        for name , detail in self.s_model.details.iteritems(): 
    156             if not name in self.details.keys() or name != 'effect_radius': 
     162            if not name in self.details.keys() or name not in self.exluded_params: 
    157163                self.details[name] = detail 
    158      
     164 
     165    def _set_backgrounds(self): 
     166        """ 
     167        Set component backgrounds to zero 
     168        """ 
     169        if 'background' in self.p_model.params: 
     170            self.p_model.setParam('background',0) 
     171        if 'background' in self.s_model.params: 
     172            self.s_model.setParam('background',0) 
     173 
     174 
    159175    def _set_scale_factor(self): 
    160176        """ 
     
    162178        """ 
    163179        value = self.params['volfraction'] 
    164         if value != None:  
     180        if value != None: 
    165181            factor = self.p_model.calculate_VR() 
    166182            if factor == None or factor == NotImplemented or factor == 0.0: 
     
    170186            self.p_model.setParam('scale', value) 
    171187            self.s_model.setParam('volfraction', val) 
    172              
    173     def _set_effect_radius(self): 
     188 
     189    def _set_radius_effective(self): 
    174190        """ 
    175191        Set effective radius to S(Q) model 
    176192        """ 
    177         if not 'effect_radius' in self.s_model.params.keys(): 
     193        if not 'radius_effective' in self.s_model.params.keys(): 
    178194            return 
    179195        effective_radius = self.p_model.calculate_ER() 
    180196        #Reset the effective_radius of s_model just before the run 
    181197        if effective_radius != None and effective_radius != NotImplemented: 
    182             self.s_model.setParam('effect_radius', effective_radius) 
    183                  
     198            self.s_model.setParam('radius_effective', effective_radius) 
     199 
    184200    def setParam(self, name, value): 
    185         """  
     201        """ 
    186202        Set the value of a model parameter 
    187          
     203 
    188204        :param name: name of the parameter 
    189205        :param value: value of the parameter 
     
    191207        # set param to P*S model 
    192208        self._setParamHelper( name, value) 
    193          
    194         ## setParam to p model  
    195         # set 'scale' in P(Q) equal to volfraction  
     209 
     210        ## setParam to p model 
     211        # set 'scale' in P(Q) equal to volfraction 
    196212        if name == 'volfraction': 
    197213            self._set_scale_factor() 
    198         elif name in self.p_model.getParamList(): 
     214        elif name in self.p_model.getParamList() and name not in self.excluded_params: 
    199215            self.p_model.setParam( name, value) 
    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(): 
     216 
     217        ## setParam to s model 
     218        # This is a little bit abundant: Todo: find better way 
     219        self._set_radius_effective() 
     220        if name in self.s_model.getParamList() and name not in self.excluded_params: 
    205221            if name != 'volfraction': 
    206222                self.s_model.setParam( name, value) 
    207              
     223 
    208224 
    209225        #self._setParamHelper( name, value) 
    210          
     226 
    211227    def _setParamHelper(self, name, value): 
    212228        """ 
     
    228244                    self.params[item] = value 
    229245                    return 
    230              
     246 
    231247        raise ValueError, "Model does not contain parameter %s" % name 
    232               
    233     
     248 
     249 
    234250    def _set_fixed_params(self): 
    235251        """ 
     
    240256 
    241257        self.fixed.sort() 
    242                  
    243                  
     258 
     259 
    244260    def run(self, x = 0.0): 
    245         """  
     261        """ 
    246262        Evaluate the model 
    247          
     263 
    248264        :param x: input q-value (float or [float, float] as [r, theta]) 
    249265        :return: (scattering function value) 
    250266        """ 
    251267        # set effective radius and scaling factor before run 
    252         self._set_effect_radius() 
     268        self._set_radius_effective() 
    253269        self._set_scale_factor() 
    254270        return self.params['scale_factor'] * self.p_model.run(x) * \ 
    255                             self.s_model.run(x) 
     271                            self.s_model.run(x) + self.params['background'] 
    256272 
    257273    def runXY(self, x = 0.0): 
    258         """  
     274        """ 
    259275        Evaluate the model 
    260          
     276 
    261277        :param x: input q-value (float or [float, float] as [qx, qy]) 
    262278        :return: scattering function value 
    263         """   
     279        """ 
    264280        # set effective radius and scaling factor before run 
    265         self._set_effect_radius() 
     281        self._set_radius_effective() 
    266282        self._set_scale_factor() 
    267283        out = self.params['scale_factor'] * self.p_model.runXY(x) * \ 
    268                         self.s_model.runXY(x) 
     284                        self.s_model.runXY(x) + self.params['background'] 
    269285        return out 
    270      
    271     ## Now (May27,10) directly uses the model eval function  
     286 
     287    ## Now (May27,10) directly uses the model eval function 
    272288    ## instead of the for-loop in Base Component. 
    273289    def evalDistribution(self, x = []): 
    274         """  
     290        """ 
    275291        Evaluate the model in cartesian coordinates 
    276          
     292 
    277293        :param x: input q[], or [qx[], qy[]] 
    278294        :return: scattering function P(q[]) 
    279295        """ 
    280296        # set effective radius and scaling factor before run 
    281         self._set_effect_radius() 
     297        self._set_radius_effective() 
    282298        self._set_scale_factor() 
    283299        out = self.params['scale_factor'] * self.p_model.evalDistribution(x) * \ 
    284                         self.s_model.evalDistribution(x) 
     300                        self.s_model.evalDistribution(x) + self.params['background'] 
    285301        return out 
    286302 
     
    288304        """ 
    289305        Set the dispersion object for a model parameter 
    290          
     306 
    291307        :param parameter: name of the parameter [string] 
    292308        :dispersion: dispersion object of type DispersionModel 
     
    299315            return value 
    300316        except: 
    301             raise  
     317            raise 
    302318 
    303319    def fill_description(self, p_model, s_model): 
     
    306322        """ 
    307323        description = "" 
    308         description += "Note:1) The effect_radius (effective radius) of %s \n"%\ 
     324        description += "Note:1) The radius_effective (effective radius) of %s \n"%\ 
    309325                                                                (s_model.name) 
    310326        description += "             is automatically calculated " 
     
    318334        description += "        for details of individual models." 
    319335        self.description += description 
    320      
  • src/sas/sasgui/guiframe/aboutbox.py

    re0f28e6 r49e000b  
    117117        self.bitmap_button_ill = wx.BitmapButton(self, -1, wx.NullBitmap) 
    118118        self.bitmap_button_ansto = wx.BitmapButton(self, -1, wx.NullBitmap) 
     119        self.bitmap_button_tudelft = wx.BitmapButton(self, -1, wx.NullBitmap) 
    119120         
    120121        self.static_line_3 = wx.StaticLine(self, -1) 
     
    135136        self.Bind(wx.EVT_BUTTON, self.onIllLogo, self.bitmap_button_ill) 
    136137        self.Bind(wx.EVT_BUTTON, self.onAnstoLogo, self.bitmap_button_ansto) 
     138        self.Bind(wx.EVT_BUTTON, self.onTudelftLogo, self.bitmap_button_tudelft) 
    137139        # end wxGlade 
    138140        # fill in acknowledgements 
     
    221223        logo = wx.Bitmap(image) 
    222224        self.bitmap_button_ansto.SetBitmapLabel(logo) 
     225         
     226        image = file_dir + "/images/tudelft_logo.png" 
     227        if os.path.isfile(config._tudelft_logo): 
     228            image = config._tudelft_logo 
     229        logo = wx.Bitmap(image) 
     230        self.bitmap_button_tudelft.SetBitmapLabel(logo) 
    223231                 
    224232        # resize dialog window to fit version number nicely 
     
    251259        self.bitmap_button_ill.SetSize(self.bitmap_button_ill.GetBestSize()) 
    252260        self.bitmap_button_ansto.SetSize(self.bitmap_button_ansto.GetBestSize()) 
     261        self.bitmap_button_tudelft.SetSize(self.bitmap_button_tudelft.GetBestSize()) 
    253262        # end wxGlade 
    254263 
     
    314323        sizer_logos.Add(self.bitmap_button_ansto, 0,  
    315324                        wx.LEFT|wx.ADJUST_MINSIZE, 2) 
     325        sizer_logos.Add(self.bitmap_button_tudelft, 0,  
     326                        wx.LEFT|wx.ADJUST_MINSIZE, 2) 
    316327                 
    317328        sizer_logos.Add((10, 50), 0, wx.ADJUST_MINSIZE, 0) 
     
    405416        event.Skip() 
    406417 
     418    def onTudelftLogo(self, event): 
     419        """ 
     420        """  
     421        # wxGlade: DialogAbout.<event_handler> 
     422        launchBrowser(config._tudelft_url) 
     423        event.Skip() 
     424 
    407425# end of class DialogAbout 
    408426 
  • src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py

    rd0248bd r0f7c930  
    181181        self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    182182        self.qrange_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    183         self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
     183        self.button_sizer = wx.BoxSizer(wx.VERTICAL) 
     184        self.button_sizer1 = wx.BoxSizer(wx.HORIZONTAL) 
     185        self.button_sizer2 = wx.BoxSizer(wx.HORIZONTAL) 
    184186 
    185187    def _layout_data_name(self): 
     
    392394        self.bt_close.SetToolTipString("Close this window") 
    393395 
    394         self.button_sizer.AddMany([(self.time_text , 0, wx.LEFT, 20), 
    395                                    (self.orient_combo , 0, wx.LEFT, 20), 
    396                                    (self.bt_compute, 0, wx.LEFT, 20), 
     396        self.button_sizer1.AddMany([(self.bt_compute, 0, wx.LEFT, 20), 
     397                                   (self.orient_combo , 0, wx.LEFT, 20)]) 
     398        self.button_sizer2.AddMany([(self.time_text , 0, wx.LEFT, 20), 
    397399                                   (self.bt_help, 0, wx.LEFT, 20), 
    398                                    (self.bt_close, 0, wx.LEFT, 5)]) 
     400                                   (self.bt_close, 0, wx.LEFT, 20)]) 
     401        self.button_sizer.AddMany([(self.button_sizer1 , 0, wx.BOTTOM|wx.LEFT, 10), 
     402                                   (self.button_sizer2 , 0, wx.LEFT, 10)]) 
    399403 
    400404    def estimate_ctime(self): 
     
    600604                raise 
    601605            self.orient_combo.Show(is_pdbdata) 
    602             self.button_sizer.Layout() 
     606            #self.button_sizer.Layout() 
     607            self.FitInside() 
    603608            self._set_sld_data_helper(True) 
    604609        except: 
  • src/sas/sasgui/perspectives/calculator/media/python_shell_help.rst

    rd85c194 rafb93df  
    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. 
    56 
    6 Python Shell Tool 
    7 ================= 
     7.. _Python_shell: 
     8 
     9Python Shell-Editor Tool 
     10======================== 
    811 
    912Description  
    1013----------- 
    1114 
    12 This is a Python shell/editor (PyCrust) provided with WxPython. An editing  
    13 notebook will show up when a Python file is created/loaded with the *New* or  
    14 *Open* options on the menu.  
     15This is a Python shell/editor provided with WxPython. 
    1516 
    16 *Run* enables the editor to compile and run the Python code. 
     17For the help about Python, visit the website http://docs.python.org/tutorial/ 
    1718 
    18 For the details about the Python, visit the website http://docs.python.org/tutorial/ 
     19.. note:: This shell/editor has its own help, but the Help() and Credits() calls do not work on Macs. 
    1920 
    20 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView.  
    21 However, some functionality may not work. 
     21The 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. 
    2222 
    23 PyCrust has its own Help. 
     23.. image:: new_pycrust_example.png 
     24   :align: center 
    2425 
    25 *NOTE! The Help() and Credits() calls do not work on Macs.* 
     26When 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. 
    2627 
    27 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     28.. image:: new_pycrust_example_2.png 
     29   :align: center 
    2830 
    29 Example 
    30 ------- 
     31If 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. 
    3132 
    32 An example calling the Matplotlib plotting gallery: 
    33  
    34 .. image:: pycrust_example.png 
     33To 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. 
    3534 
    3635.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    3736 
    38 .. note::  This help document was last changed by Steve King, 19Feb2015 
     37.. note::  This help document was last changed by Steve King, 10Oct2015 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r9501661 rec72ceb  
    7070 
    7171    This Dialog pops up for the user when they press 'Sum|Multi(p1,p2)' under 
    72     'Edit Custom Model' under 'Fitting' menu.  This is currently called as 
     72    'Plugin Model Operations' under 'Fitting' menu.  This is currently called as 
    7373    a Modal Dialog. 
    7474 
  • src/sas/sasgui/perspectives/calculator/pyconsole.py

    r0912b405 rd472e86  
    103103    window_name = "Custom Model Editor" 
    104104    ## Name to appear on the window title bar 
    105     window_caption = "Custom Model Editor" 
     105    window_caption = "Plugin Model Editor" 
    106106    ## Flag to tell the AUI manager to put this panel in the center pane 
    107107    CENTER_PANE = False 
     
    110110                    size=(PANEL_WIDTH, PANEL_HEIGHT)): 
    111111        self.config = None 
     112 
    112113        editor.EditorNotebookFrame.__init__(self, parent=parent, 
    113                                         title=title, size=size, 
    114                                         filename=filename) 
     114                                        title=title, size=size) 
    115115        self.parent = parent 
    116116        self._manager = manager 
     
    126126        self.dataDir = dataDir 
    127127        self.Centre() 
     128 
     129        # See if there is a corresponding C file 
     130        if filename != None: 
     131            c_filename = os.path.splitext(filename)[0] + ".c" 
     132            if os.path.isfile(c_filename): 
     133                self.bufferCreate(c_filename) 
     134 
     135            # If not, just open the requested .py, if any. 
     136            # Needs to be after the C file so the tab focus is correct. 
     137            if os.path.isfile(filename): 
     138                    self.bufferCreate(filename) 
    128139 
    129140        self.Bind(wx.EVT_MENU, self.OnNewFile, id=wx.ID_NEW) 
  • src/sas/sasgui/perspectives/corfunc/media/corfunc_help.rst

    rda456fb r1404cce  
    1010 
    1111This performs a correlation function analysis of one-dimensional 
    12 SANS data, or generates a model-independent volume fraction profile from a 
    13 one-dimensional SANS pattern of an adsorbed layer. 
    14  
    15 The correlation function analysis is performed in 3 stages: 
     12SAXS/SANS data, or generates a model-independent volume fraction  
     13profile from the SANS from an adsorbed polymer/surfactant layer. 
     14 
     15A correlation function may be interpreted in terms of an imaginary rod moving  
     16through the structure of the material. Γ\ :sub:`1D`\ (R) is the probability that  
     17a rod of length R moving through the material has equal electron/neutron scattering  
     18length density at either end. Hence a frequently occurring spacing within a structure  
     19manifests itself as a peak. 
     20 
     21A volume fraction profile :math:`\Phi`\ (z) describes how the density of polymer segments/surfactant molecules varies with distance from an (assumed locally flat) interface. 
     22 
     23Both functions are returned in *real space*. 
     24 
     25The analysis is performed in 3 stages: 
    1626 
    1727*  Extrapolation of the scattering curve to :math:`Q = 0` and 
    1828   :math:`Q = \infty` 
    19 *  Fourier/Hilbert Transform of the extrapolated data to give the correlation 
    20    function/volume fraction profile 
    21 *  Interpretation of the 1D correlation function based on an ideal lamellar 
    22    morphology 
     29*  Smoothed merging of the two extrapolations into the original data 
     30*  Fourier / Hilbert Transform of the smoothed data to give the correlation 
     31   function / volume fraction profile, respectively 
     32*  (Optional) Interpretation of the 1D correlation function based on an ideal  
     33   lamellar morphology 
    2334 
    2435.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    2839 
    2940To :math:`Q = 0` 
    30 ^^^^^^^^^^^^^^^^ 
     41................ 
    3142 
    3243The data are extrapolated to Q = 0 by fitting a Guinier model to the data 
    33 points in the lower Q range. 
     44points in the low-Q range. 
     45 
    3446The equation used is: 
    3547 
    3648.. math:: 
    37     I(Q) = e^{A+Bq^2} 
     49    I(Q) = Ae^{Bq^2} 
    3850 
    3951The Guinier model assumes that the small angle scattering arises from particles 
     
    4153particles. This has dubious applicability to polymer systems. However, the 
    4254correlation function is affected by the Guinier back-extrapolation to the 
    43 greatest extent at large values of R and so the back-extrapolation only has a 
    44 small effect on the analysis. 
     55greatest extent at large values of R and so only has a 
     56small effect on the final analysis. 
    4557 
    4658To :math:`Q = \infty` 
    47 ^^^^^^^^^^^^^^^^^^^^^ 
     59..................... 
    4860 
    4961The data are extrapolated to Q = :math:`\infty` by fitting a Porod model to 
    50 the data points in the upper Q range. 
     62the data points in the high-Q range. 
    5163 
    5264The equation used is: 
    5365 
    5466.. math:: 
    55     I(Q) = Bg + KQ^{-4}e^{-Q^2\sigma^2} 
    56  
    57 Where :math:`Bg` is the Bonart thermal background, :math:`K` is the Porod 
    58 constant, and :math:`\sigma > 0` describes the electron (or neutron scattering 
    59 length) density profile at the interface between crystalline and amorphous 
    60 regions (see figure 1). 
     67    I(Q) = K Q^{-4}e^{-Q^2\sigma^2} + Bg 
     68 
     69Where :math:`Bg` is the background, :math:`K` is the Porod 
     70constant, and :math:`\sigma` (which must be > 0) describes the width of the electron or neutron scattering length density profile at the interface between the crystalline and amorphous 
     71regions as shown below. 
    6172 
    6273.. figure:: fig1.gif 
    6374   :align: center 
    6475 
    65    **Figure 1** The value of :math:`\sigma` is a measure of the electron 
    66    density profile at the interface between crystalline and amorphous regions. 
    67  
     76    
    6877Smoothing 
    69 ^^^^^^^^^ 
    70  
    71 The extrapolated data set consists of the Guinier back-extrapolation up to the 
    72 highest Q value of the lower Q range, the original scattering data up to the 
    73 highest value in the upper Q range, and the Porod tail-fit beyond this. The 
    74 joins between the original data and the Guinier/Porod fits are smoothed using 
    75 the algorithm below, to avoid the formation of ripples in the transformed data. 
     78--------- 
     79 
     80The extrapolated data set consists of the Guinier back-extrapolation from Q~0  
     81up to the lowest Q value in the original data, then the original scattering data, and the Porod tail-fit beyond this. The joins between the original data and the Guinier/Porod fits are smoothed using the algorithm below to avoid the formation of ripples in the transformed data. 
    7682 
    7783Functions :math:`f(x_i)` and :math:`g(x_i)` where :math:`x_i \in \left\{ 
     
    8793    h_i = \frac{1}{1 + \frac{(x_i-b)^2}{(x_i-a)^2}} 
    8894 
     95         
    8996Transform 
    9097--------- 
    9198 
    9299Fourier 
    93 ^^^^^^^ 
    94  
    95 If Fourier is selected for the transform type, the analysis will perform a 
     100....... 
     101 
     102If "Fourier" is selected for the transform type, the analysis will perform a 
    96103discrete cosine transform on the extrapolated data in order to calculate the 
    97 correlation function. The following algorithm is applied: 
     104correlation function 
     105 
     106.. math:: 
     107    \Gamma _{1D}(R) = \frac{1}{Q^{*}} \int_{0}^{\infty }I(q) q^{2} cos(qR) dq 
     108 
     109where Q\ :sup:`*` is the Scattering Invariant. 
     110 
     111The following algorithm is applied: 
    98112 
    99113.. math:: 
     
    103117 
    104118Hilbert 
    105 ^^^^^^^ 
    106 If Hilbert is selected for the transform type, the analysis will perform a 
     119....... 
     120 
     121If "Hilbert" is selected for the transform type, the analysis will perform a 
    107122Hilbert transform on the extrapolated data in order to calculate the Volume 
    108123Fraction Profile. 
    109124 
     125.. note:: This functionality is not yet implemented in SasView. 
     126 
     127 
    110128Interpretation 
    111129-------------- 
    112 Once the correlation function has been calculated by transforming the 
    113 extrapolated data, it may be interpreted by clicking the "Compute Parameters" 
    114 button. The correlation function is interpreted in terms of an ideal lamellar 
    115 morphology, and structural parameters are obtained as shown in Figure 2 below. 
    116 It should be noted that a small beam size is assumed; no de-smearing is 
     130 
     131Correlation Function 
     132.................... 
     133 
     134Once the correlation function has been calculated it may be interpreted by clicking the "Compute Parameters" button. 
     135 
     136The correlation function is interpreted in terms of an ideal lamellar 
     137morphology, and structural parameters are obtained from it as shown below. 
     138It should be noted that a small beam size is assumed; ie, no de-smearing is 
    117139performed. 
    118140 
    119141.. figure:: fig2.gif 
    120142   :align: center 
    121  
    122    **Figure 2** Interpretation of the correlation function. 
    123143 
    124144The structural parameters obtained are: 
     
    131151*   Local Crystallinity :math:`= L_c/L_p` 
    132152 
     153Volume Fraction Profile 
     154....................... 
     155 
     156SasView does not provide any automatic interpretation of volume fraction profiles in the same way that it does for correlation functions. However, a number of structural parameters are obtainable by other means: 
     157 
     158*   Surface Coverage :math:`=\theta` 
     159*   Anchor Separation :math:`= D` 
     160*   Bound Fraction :math:`= <p>` 
     161*   Second Moment :math:`= \sigma` 
     162*   Maximum Extent :math:`= \delta_{\text{h}}` 
     163*   Adsorbed Amount :math:`= \Gamma` 
     164 
     165.. figure:: profile1.png 
     166   :align: center 
     167  
     168.. figure:: profile2.png 
     169   :align: center 
     170    
     171 
     172References 
     173---------- 
     174 
     175Strobl, G. R.; Schneider, M. *J. Polym. Sci.* (1980), 18, 1343-1359 
     176 
     177Koberstein, J.; Stein R. *J. Polym. Sci. Phys. Ed.* (1983), 21, 2181-2200 
     178 
     179Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 247-251 
     180 
     181Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 257-261 
     182 
     183Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 260-270 
     184 
     185:ref:`FDR` (PDF format) 
     186 
    133187.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     188 
    134189 
    135190Usage 
    136191----- 
    137192Upon sending data for correlation function analysis, it will be plotted (minus 
    138 the background value), along with a red bar indicating the lower Q range (used 
    139 for back-extrapolation), and 2 purple bars indicating the upper Q range (used 
    140 for forward-extrapolation) [figure 3]. These bars may be moved my clicking and 
    141 dragging, or by entering the appropriate values in the Q range input boxes. 
     193the background value), along with a *red* bar indicating the *upper end of the  
     194low-Q range* (used for back-extrapolation), and 2 *purple* bars indicating the range to be used for forward-extrapolation. These bars may be moved my clicking and 
     195dragging, or by entering appropriate values in the Q range input boxes. 
    142196 
    143197.. figure:: tutorial1.png 
    144198   :align: center 
    145199 
    146    **Figure 3** A plot of some data showing the Q range bars 
    147  
    148 Once the Q ranges have been set, click the "Calculate" button next to the 
    149 background input field to calculate the Bonart thermal background level. 
    150 Alternatively, enter your own value into the field. Click the "Extrapolate" 
    151 button to extrapolate the data and plot the extrapolation in the same figure. 
    152 The values of the parameters used for the Guinier and Porod models will also be 
    153 shown in the "Extrapolation Parameters" section [figure 4] 
     200Once the Q ranges have been set, click the "Calculate" button to determine the background level. Alternatively, enter your own value into the field. If the box turns yellow this indicates that background subtraction has resulted in some negative intensities. 
     201 
     202Click the "Extrapolate" button to extrapolate the data and plot the extrapolation in the same figure. The values of the parameters used for the Guinier and Porod models will also be shown in the "Extrapolation Parameters" section of the window. 
    154203 
    155204.. figure:: tutorial2.png 
    156205   :align: center 
    157206 
    158    **Figure 4** A plot showing the extrapolated data and the original data 
    159  
    160 Then, select which type of transform you would like to perform, using the radio 
     207Now select which type of transform you would like to perform, using the radio 
    161208buttons: 
    162209 
    163210*   **Fourier** Perform a Fourier Transform to calculate the correlation 
    164     function of the extrapolated data 
     211    function 
    165212*   **Hilbert** Perform a Hilbert Transform to calculate the volume fraction 
    166     profile of the extrapolated data 
    167  
    168 Clicking the transform button will then perform the selected transform and plot 
    169 it in a new figure. If a Fourier Transform was performed, the "Compute 
    170 Parameters" button can also be clicked to calculate values for the output 
    171 parameters [figure 5] 
     213    profile 
     214 
     215Click the "Transform" button to perform the selected transform and plot 
     216the result in a new graph window. 
     217 
     218If a Fourier Transform was performed, the "Compute Parameters" button can now be clicked to interpret the correlation function as described earlier. 
    172219 
    173220 .. figure:: tutorial3.png 
    174221    :align: center 
    175222 
    176     **Figure 5** The Fourier Transform (correlation function) of the 
    177     extrapolated data, and the parameters extracted from it. 
     223         
     224.. note:: 
     225    This help document was last changed by Steve King, 08Oct2016 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r51a4d78 r9087214  
    10371037            dispersity = self.disp_box.GetClientData(n) 
    10381038            name = dispersity.__name__ 
    1039  
    10401039            self._set_dipers_Param(event=None) 
    10411040 
     
    11081107        self.Refresh() 
    11091108 
     1109    def get_cat_combo_box_pos(self, state): 
     1110        """ 
     1111        Iterate through the categories to find the structurefactor 
     1112        :return: combo_box_position 
     1113        """ 
     1114        for key, value in self.master_category_dict.iteritems(): 
     1115            for list_item in value: 
     1116                if state.formfactorcombobox in list_item: 
     1117                    return self.categorybox.Items.index(key) 
     1118 
    11101119    def reset_page_helper(self, state): 
    11111120        """ 
     
    11631172            category_pos = int(state.categorycombobox) 
    11641173        except: 
     1174            state.formfactorcombobox = unicode(state.formfactorcombobox.lower()) 
     1175            state.categorycombobox = unicode(state.categorycombobox) 
    11651176            category_pos = 0 
    1166             for ind_cat in range(self.categorybox.GetCount()): 
    1167                 if self.categorybox.GetString(ind_cat) == \ 
    1168                                         state.categorycombobox: 
    1169                     category_pos = int(ind_cat) 
    1170                     break 
     1177            if state.categorycombobox in self.categorybox.Items: 
     1178                category_pos = self.categorybox.Items.index( 
     1179                    state.categorycombobox) 
     1180            else: 
     1181                # Look in master list for model name (model.lower) 
     1182                category_pos = self.get_cat_combo_box_pos(state) 
    11711183 
    11721184        self.categorybox.Select(category_pos) 
     
    11891201            structfactor_pos = int(state.structurecombobox) 
    11901202        except: 
    1191             structfactor_pos = 0 
    1192             for ind_struct in range(self.structurebox.GetCount()): 
    1193                 if self.structurebox.GetString(ind_struct) == \ 
    1194                                                     (state.structurecombobox): 
    1195                     structfactor_pos = int(ind_struct) 
    1196                     break 
     1203            if state.structurecombobox is not None: 
     1204                structfactor_pos = 0 
     1205                state.structurecombobox = unicode(state.structurecombobox) 
     1206                for ind_struct in range(self.structurebox.GetCount()): 
     1207                    if self.structurebox.GetString(ind_struct) == \ 
     1208                                                        (state.structurecombobox): 
     1209                        structfactor_pos = int(ind_struct) 
     1210                        break 
    11971211 
    11981212        self.structurebox.SetSelection(structfactor_pos) 
     
    14071421        self.state.npts = self.npts_x 
    14081422 
    1409     def _onparamEnter_helper(self): 
     1423    def _onparamEnter_helper(self,is_modified = False): 
    14101424        """ 
    14111425        check if values entered by the user are changed and valid to replot 
     
    14131427        """ 
    14141428        # Flag to register when a parameter has changed. 
    1415         is_modified = False 
     1429        #is_modified = False 
    14161430        self.fitrange = True 
    14171431        is_2Ddata = False 
     
    14211435            is_2Ddata = True 
    14221436        if self.model != None: 
    1423             is_modified = (self._check_value_enter(self.fittable_param) 
    1424                            or self._check_value_enter(self.fixed_param) 
    1425                            or self._check_value_enter(self.parameters)) 
     1437            #Either we get a is_modified = True passed in because 
     1438            #_update_paramv_on_fit() has been called already or 
     1439            # we need to check here ourselves. 
     1440            if not is_modified: 
     1441                is_modified = (self._check_value_enter(self.fittable_param) 
     1442                               or self._check_value_enter(self.fixed_param) 
     1443                               or self._check_value_enter(self.parameters)) 
    14261444 
    14271445            # Here we should check whether the boundaries have been modified. 
     
    14721490        flag = True 
    14731491        self.fitrange = True 
     1492        is_modified = False 
    14741493 
    14751494        #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
     
    14841503                                                                [self.data]) 
    14851504            ##Check the values 
    1486             self._check_value_enter(self.fittable_param) 
    1487             self._check_value_enter(self.fixed_param) 
    1488             self._check_value_enter(self.parameters) 
     1505            is_modified = (self._check_value_enter(self.fittable_param) 
     1506                            or self._check_value_enter(self.fixed_param) 
     1507                            or self._check_value_enter(self.parameters)) 
    14891508 
    14901509            # If qmin and qmax have been modified, update qmin and qmax and 
     
    15681587            logging.error(traceback.format_exc()) 
    15691588 
    1570         return flag 
     1589        return flag,is_modified 
    15711590 
    15721591    def _reset_parameters_state(self, listtorestore, statelist): 
     
    19791998            form_factor = self.formfactorbox.GetClientData(f_id) 
    19801999 
    1981         if form_factor is None or not form_factor.is_form_factor: 
     2000        if form_factor is None or \ 
     2001            not hasattr(form_factor, 'is_form_factor') or \ 
     2002            not form_factor.is_form_factor: 
    19822003            self.structurebox.Hide() 
    19832004            self.text2.Hide() 
     
    23062327            wx.PostEvent(self.parent, event) 
    23072328        #draw the model with the current dispersity 
    2308         self._draw_model() 
     2329 
     2330        #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
     2331        #By comenting it we save an extra Iq calculation 
     2332        #self._draw_model() 
     2333 
    23092334        ## Need to use FitInside again here to replace the next four lines. 
    23102335        ## Otherwised polydispersity off does not resize the scrollwindow. 
     
    30553080        """ 
    30563081        content = '' 
     3082        bound_hi = '' 
     3083        bound_lo = '' 
    30573084        # go through the str params 
    30583085        for item in param: 
     
    30863113                    value = item[2].GetValue() 
    30873114 
     3115            # Bounds 
     3116            try: 
     3117                bound_lo = item[5].GetValue() 
     3118                bound_hi = item[6].GetValue() 
     3119            except Exception: 
     3120                # harmless - need to just pass 
     3121                pass 
     3122 
    30883123            # add to the content 
    30893124            if disfunc != '': 
     
    31013136            except Exception: 
    31023137                logging.error(traceback.format_exc()) 
    3103             content += name + ',' + str(check) + ',' + value + disfunc + ':' 
     3138            content += name + ',' + str(check) + ',' +\ 
     3139                    value + disfunc + ',' + bound_lo + ',' +\ 
     3140                    bound_hi + ':' 
    31043141 
    31053142        return content 
     
    31523189                # Transfer the text to content[dictionary] 
    31533190                context[name] = [check, value] 
     3191 
     3192                # limits 
     3193                limit_lo = item[3] 
     3194                context[name].append(limit_lo) 
     3195                limit_hi = item[4] 
     3196                context[name].append(limit_hi) 
     3197 
    31543198            # ToDo: PlugIn this poly disp function for pasting 
    31553199            try: 
    3156                 poly_func = item[3] 
     3200                poly_func = item[5] 
    31573201                context[name].append(poly_func) 
    31583202                try: 
    31593203                    # take the vals and weights for  array 
    3160                     array_values = item[4].split(' ') 
    3161                     array_weights = item[5].split(' ') 
     3204                    array_values = item[6].split(' ') 
     3205                    array_weights = item[7].split(' ') 
    31623206                    val = [float(a_val) for a_val in array_values[1:]] 
    31633207                    weit = [float(a_weit) for a_weit in array_weights[1:]] 
     
    32073251                name = item[1] 
    32083252                if name in content.keys(): 
    3209                     check = content[name][0] 
    3210                     pd = content[name][1] 
     3253                    values = content[name] 
     3254                    check = values[0] 
     3255                    pd = values[1] 
     3256 
    32113257                    if name.count('.') > 0: 
    32123258                        # If this is parameter.width, then pd may be a floating 
     
    32313277                            fun_val = self.model.fun_list[content[name][1]] 
    32323278                            self.model.setParam(name, fun_val) 
     3279                    try: 
     3280                        item[5].SetValue(str(values[-3])) 
     3281                        item[6].SetValue(str(values[-2])) 
     3282                    except Exception: 
     3283                        # passing as harmless non-update 
     3284                        pass 
    32333285 
    32343286                    value = content[name][1:] 
     
    32753327                                self.model.setParam(name, fun_val) 
    32763328                                # save state 
     3329                        try: 
     3330                            item[5].SetValue(str(value[-3])) 
     3331                            item[6].SetValue(str(value[-2])) 
     3332                        except Exception: 
     3333                            # passing as harmless non-update 
     3334                            pass 
     3335 
    32773336                        self._paste_poly_help(item, value) 
    32783337                        if check == 'True': 
     
    33093368        """ 
    33103369        # Do nothing if not setting polydispersity 
    3311         if len(value[1]) == 0: 
     3370        if len(value[3]) == 0: 
    33123371            return 
    33133372 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r7988501 r9087214  
    424424        self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, 
    425425                  id=self.slit_smearer.GetId()) 
    426         self.disable_smearer.SetValue(True) 
     426        self.enable_smearer.SetValue(True) 
    427427 
    428428        sizer_smearer.Add(self.disable_smearer, 0, wx.LEFT, 10) 
     
    10581058            self.create_default_data() 
    10591059        """ 
    1060         flag = self._update_paramv_on_fit() 
    1061  
    1062         wx.CallAfter(self._onparamEnter_helper) 
     1060        flag,is_modified = self._update_paramv_on_fit() 
     1061 
     1062        wx.CallAfter(self._onparamEnter_helper,is_modified) 
    10631063        if not flag: 
    10641064            msg = "The parameters are invalid" 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    rff3f5821 rec72ceb  
    221221        self.id_edit = wx.NewId() 
    222222        editmodel_help = "Edit customized model sample file" 
    223         self.menu1.AppendMenu(self.id_edit, "Edit Custom Model", 
     223        self.menu1.AppendMenu(self.id_edit, "Plugin Model Operations", 
    224224                              self.edit_model_menu, editmodel_help) 
    225225        #create  menubar items 
     
    236236        frame = PyConsole(parent=self.parent, manager=self, 
    237237                          panel=self.fit_panel, 
    238                           title='Advanced Custom Model Editor', 
     238                          title='Advanced Plugin Model Editor', 
    239239                          filename=filename) 
    240240        self.put_icon(frame) 
     
    302302            event_id = event.GetId() 
    303303            dir_path = models.find_plugins_dir() 
    304             title = "New Custom Model Function" 
     304            title = "New Plugin Model Function" 
    305305            self.new_model_frame = EditorWindow(parent=self, base=self, 
    306306                                                path=dir_path, title=title) 
     
    319319        Update custom model list in the fitpage combo box 
    320320        """ 
    321         custom_model = 'Customized Models' 
     321        custom_model = 'Plugin Models' 
    322322        try: 
    323323            # Update edit menus 
     
    350350        wx_id = wx.NewId() 
    351351        #new_model_menu = wx.Menu() 
    352         self.edit_model_menu.Append(wx_id, 'New', 
     352        self.edit_model_menu.Append(wx_id, 'New Plugin Model', 
    353353                                   'Add a new model function') 
    354354        wx.EVT_MENU(owner, wx_id, self.make_new_model) 
     
    362362        self.edit_menu = wx.Menu() 
    363363        self.edit_model_menu.AppendMenu(e_id, 
    364                                     'Advanced', self.edit_menu) 
     364                                    'Advanced Plugin Editor', self.edit_menu) 
    365365        self.set_edit_menu_helper(owner, self.edit_custom_model) 
    366366 
     
    368368        self.delete_menu = wx.Menu() 
    369369        self.edit_model_menu.AppendMenu(d_id, 
    370                                         'Delete', self.delete_menu) 
     370                                        'Delete Plugin Models', self.delete_menu) 
    371371        self.set_edit_menu_helper(owner, self.delete_custom_model) 
    372372 
    373373        wx_id = wx.NewId() 
    374         self.edit_model_menu.Append(wx_id, 'Load Models', 
     374        self.edit_model_menu.Append(wx_id, 'Load Plugin Models', 
    375375          '(Re)Load all models present in user plugin_models folder') 
    376376        wx.EVT_MENU(owner, wx_id, self.load_plugin_models) 
    377  
     377                 
    378378    def set_edit_menu_helper(self, owner=None, menu=None): 
    379379        """ 
  • src/sas/sasgui/perspectives/fitting/media/fitting.rst

    r05829fb r46dfee9  
    33Fitting Documentation 
    44===================== 
     5 
     6.. note:: In Windows use [Alt]-[Cursor left] to return to the previous page 
    57 
    68.. toctree:: 
     
    1820 
    1921   Information on the SasView Optimisers <optimizer.rst> 
    20  
    21    Writing a Plugin <plugin.rst> 
     22       
     23   Converting SANS to SESANS for Fitting <../../../sans_to_sesans> 
     24    
     25   Fitting SESANS Data <../../../sesans_fitting.rst> 
     26    
     27   Writing a Plugin Model <plugin.rst> 
     28       
     29   Computations with a GPU <../../../gpu_computations> 
     30    
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    r05829fb r3e1c9e5  
    1818======= 
    1919 
     20.. note:: If some code blocks are not readable, expand the documentation window 
     21 
    2022.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    2123 
     
    116118--------------- 
    117119 
    118 For a complete list of all the library models available in SasView, see the Model Documentation. 
     120For a complete list of all the library models available in SasView, see the `Model Documentation <../../../index.html>`_ . 
    119121 
    120122It is also possible to add your own models. 
     
    124126.. _Adding_your_own_models: 
    125127 
    126 Adding your own models 
     128Adding your own Models 
    127129---------------------- 
    128130 
    129 There are currently two ways to add your own models to SasView: 
    130  
    131 * Using the :ref:`Custom_Model_Editor` 
    132 * By :ref:`Writing_a_Plugin` 
    133  
    134 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    135  
    136 .. _Custom_Model_Editor: 
    137  
    138 Custom Model Editor 
    139 ------------------- 
    140  
    141 From the *Fitting* option in the menu bar, select *Edit Custom Model*. 
    142  
    143 .. image:: edit_model_menu.bmp 
    144  
    145 and then one of the options 
    146  
    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 
    150 *  *Delete* - to delete a custom model 
    151  
    152 New 
    153 ^^^^ 
     131There are essentially three ways to generate new fitting models for SasView: 
     132 
     133* Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners and/or relatively simple models) 
     134* By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` (suitable for all use cases) 
     135* By writing a model from scratch outside of SasView (only recommended for code monkeys!) 
     136 
     137Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. 
     138 
     139**To be found by SasView your model must reside in the *~\\.sasview\\plugin_models* folder.** 
     140 
     141.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     142 
     143.. _Plugin_Model_Operations: 
     144 
     145Plugin Model Operations 
     146----------------------- 
     147 
     148From the *Fitting* option in the menu bar, select *Plugin Model Operations* 
     149 
     150.. image:: edit_model_menu.png 
     151 
     152and then one of the sub-options 
     153 
     154*  *New Plugin Model* - to create a plugin model template with a helper dialog 
     155*  *Sum|Multi(p1,p2)* - to create a plugin model by summing/multiplying *existing models* in the model library 
     156*  *Advanced Plugin Editor* - to create/edit a plugin model in a Python shell 
     157*  *Delete Plugin Models* - to delete a plugin model 
     158*  *Load Plugin Models* - to (re-)load plugin models 
     159 
     160.. _New_Plugin_Model: 
     161 
     162New Plugin Model 
     163^^^^^^^^^^^^^^^^ 
    154164 
    155165.. image:: new_model.bmp 
    156166 
    157167A model template generated by this option can be viewed and further modified using 
    158 the :ref:`Advanced` option. 
     168the :ref:`Advanced_Plugin_Editor` . 
    159169 
    160170*NB: "Fit Parameters" has been split into two sections, those which can be 
     
    167177.. image:: sum_model.bmp 
    168178 
    169 This option creates a custom model of the form 
    170  
    171 Custom Model = scale_factor \* (model1 +/\* model2) 
    172  
    173 In the *Easy Sum/Multi Editor* give the new custom model a function name and brief 
    174 description (to appear under the *Details* button on the *Fit Page*). Then select 
     179This option creates a custom model of the form:: 
     180 
     181     Custom Model = scale_factor \* {(scale_1 \* model_1) \+ (scale_2 \* model_2)} \+ background 
     182 
     183or:: 
     184 
     185     Custom Model = scale_factor \* model_1 \* model_2 \+ background 
     186 
     187In the *Easy Sum/Multi Editor* give the new model a function name and brief 
     188description (to appear under the *Details* button on the *FitPage*). Then select 
    175189two existing models, as p1 and p2, and the required operator, '+' or '*' between 
    176190them. Finally, click the *Apply* button to generate the model and then click *Close*. 
    177191 
    178 *NB: Any changes to a custom model generated in this way only become effective after* 
    179 *it is re-selected from the model drop-down menu on the Fit Page.* 
    180  
    181 .. _Advanced: 
    182  
    183 Advanced 
    184 ^^^^^^^^ 
    185  
    186 Selecting this option shows all the custom models in the plugin model folder 
    187  
    188   *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 
     192Any changes to a plugin model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. 
     193 
     194.. _Advanced_Plugin_Editor: 
     195 
     196Advanced Plugin Editor 
     197^^^^^^^^^^^^^^^^^^^^^^ 
     198 
     199Selecting this option shows all the plugin models in the plugin model folder, on Windows this is 
     200 
     201  *C:\\Users\\{username}\\.sasview\\plugin_models* 
    189202 
    190203You can edit, modify, and save the Python code in any of these models using the 
    191 *Advanced Custom Model Editor*. 
    192  
    193 See :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 
    196 you are confident about what you are doing, it is recommended that you 
    197 only modify lines denoted with the ## <----- comments!* 
    198  
    199 When 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 
    201 model will only be usable if the tests 'pass'. 
    202  
    203 To use the model, go to the relevant *Fit Page*, select the *Customized Models* 
     204*Advanced Plugin Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . 
     205 
     206For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . 
     207 
     208.. 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! 
     209 
     210When editing is complete, select *Run* > *Check Model* from the *Advanced Plugin 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'. 
     211 
     212.. image:: ../calculator/new_pycrust_example_2.png 
     213 
     214To use the model, go to the relevant *Fit Page*, select the *Plugin Models* 
    204215category and then select the model from the drop-down menu. 
    205216 
    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.* 
    208  
    209 Delete 
    210 ^^^^^^ 
    211  
    212 Simply highlight the custom model to be removed. This operation is final! 
    213  
    214 *NB: Custom models shipped with SasView cannot be removed in this way.* 
     217Any changes to a plugin model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. 
     218 
     219Delete Plugin Models 
     220^^^^^^^^^^^^^^^^^^^^ 
     221 
     222Simply highlight the plugin model to be removed. The operation is final!!! 
     223 
     224*NB: Plugin models shipped with SasView cannot be removed in this way.* 
     225 
     226Load Plugin Models 
     227^^^^^^^^^^^^^^^^^^ 
     228 
     229This option loads (or re-loads) all models present in the *~\\.sasview\\plugin_models* folder. 
    215230 
    216231.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    600615.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    601616 
    602 .. note::  This help document was last changed by Steve King, 04Jun2015 
     617.. note::  This help document was last changed by Steve King, 10Oct2016 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    rb2a3814 r3e1c9e5  
    66.. note:: If some code blocks are not readable, expand the documentation window 
    77 
     8Introduction 
     9^^^^^^^^^^^^ 
     10 
     11There are essentially three ways to generate new fitting models for SasView: 
     12 
     13* Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners and/or relatively simple models) 
     14* By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` as described below (suitable for all use cases) 
     15* By writing a model from scratch outside of SasView (only recommended for code monkeys!) 
     16 
    817Overview 
    918^^^^^^^^ 
    1019 
    11 You can write your own model and save it to the the SasView 
    12 *plugin_models* folder 
    13  
    14   *C:\\Users\\[username]\\.sasview\\plugin_models* (on Windows) 
    15  
    16 The next time SasView is started it will compile the plugin and add 
    17 it to the list of *Customized Models* in a FitPage.  It is recommended that an 
    18 existing model be used as a template. 
    19  
    20 SasView has three ways of writing models: 
    21  
    22 - As a pure python model : Example - 
     20If you write your own model and save it to the the SasView *plugin_models* folder 
     21 
     22  *C:\\Users\\{username}\\.sasview\\plugin_models* (on Windows) 
     23 
     24the next time SasView is started it will compile the plugin and add 
     25it to the list of *Plugin Models* in a FitPage. 
     26 
     27SasView models can be of three types: 
     28 
     29- A pure python model : Example - 
    2330  `broadpeak.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/broad_peak.py>`_ 
    24 - As a python model with embedded C : Example - 
     31- A python model with embedded C : Example - 
    2532  `sphere.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/sphere.py>`_ 
    26 - As a python wrapper with separate C code : Example - 
     33- A python wrapper with separate C code : Example - 
    2734  `cylinder.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.py>`_, 
    2835  `cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.c>`_ 
     
    4249 
    4350In the *~\\.sasview\\plugin_models* directory, copy the appropriate files 
    44 (using the examples above as templates) to mymodel.py (and mymodel.c, etc) 
     51(we recommend using the examples above as templates) to mymodel.py (and mymodel.c, etc) 
    4552as required, where "mymodel" is the name for the model you are creating. 
    4653 
     
    662669^^^^^^^^^^^^^^^^^^^ 
    663670 
    664 Installed SasView 
    665 ................. 
    666  
    667 If you are editing your model from the SasView GUI, you can test it 
    668 by selecting *Run > Check Model* from the *Model Editor* menu bar. An 
    669 *Info* box will appear with the results of the compilation and a 
    670 check that the model runs. 
    671  
    672  
    673 Built SasView 
    674 ............. 
     671Minimal Testing 
     672............... 
     673 
     674Either open the :ref:`Python_shell` (*Tools* > *Python Shell/Editor*) or the :ref:`Advanced_Plugin_Editor` (*Fitting* > *Plugin Model Operations* > *Advanced  
     675Plugin Editor*), load your model, and then select *Run > Check Model* from the  
     676menu bar. 
     677 
     678An *Info* box will appear with the results of the compilation and a check that  
     679the model runs. 
     680 
     681Recommended Testing 
     682................... 
    675683 
    676684If the model compiles and runs, you can next run the unit tests that 
     
    793801consider adding your model to the 
    794802`Model Marketplace <http://marketplace.sasview.org/>`_ so that others may use it! 
     803 
     804.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     805 
     806.. note::  This help document was last changed by Steve King, 10Oct2016 
  • src/sas/sasgui/perspectives/fitting/models.py

    r212bfc2 r5de7f69  
    181181            try: 
    182182                model = load_custom_model(path) 
     183                model.name = "[plug-in] "+model.name 
    183184                plugins[model.name] = model 
    184185            except Exception: 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    re6de6b8 r467202f  
    17531753 
    17541754        return doc 
     1755 
     1756# Simple html report templet 
     1757HEADER = "<html>\n" 
     1758HEADER += "<head>\n" 
     1759HEADER += "<meta http-equiv=Content-Type content='text/html; " 
     1760HEADER += "charset=windows-1252'> \n" 
     1761HEADER += "<meta name=Generator >\n" 
     1762HEADER += "</head>\n" 
     1763HEADER += "<body lang=EN-US>\n" 
     1764HEADER += "<div class=WordSection1>\n" 
     1765HEADER += "<p class=MsoNormal><b><span ><center><font size='4' >" 
     1766HEADER += "%s</font></center></span></center></b></p>" 
     1767HEADER += "<p class=MsoNormal>&nbsp;</p>" 
     1768PARA = "<p class=MsoNormal><font size='4' > %s \n" 
     1769PARA += "</font></p>" 
     1770CENTRE = "<p class=MsoNormal><center><font size='4' > %s \n" 
     1771CENTRE += "</font></center></p>" 
     1772FEET_1 = \ 
     1773""" 
     1774<p class=MsoNormal>&nbsp;</p> 
     1775<br> 
     1776<p class=MsoNormal><b><span ><center> <font size='4' > Graph 
     1777</font></span></center></b></p> 
     1778<p class=MsoNormal>&nbsp;</p> 
     1779<center> 
     1780<br><font size='4' >Model Computation</font> 
     1781<br><font size='4' >Data: "%s"</font><br> 
     1782""" 
     1783FEET_2 = \ 
     1784""" 
     1785<img src="%s" > 
     1786</img> 
     1787""" 
     1788FEET_3 = \ 
     1789""" 
     1790</center> 
     1791</div> 
     1792</body> 
     1793</html> 
     1794""" 
     1795ELINE = "<p class=MsoNormal>&nbsp;</p>" 
  • src/sas/sasgui/perspectives/fitting/simfitpage.py

    r998ca90 ra28e52b  
    10931093                sim_page.constraints_list[index][3].SetValue(constraint_value) 
    10941094                sim_page._on_add_constraint(None) 
     1095                sim_page._manager.sim_page = sim_page 
    10951096 
    10961097    def _format_id(self, original_id): 
  • src/sas/sascalc/data_util/qsmearing.py

    rf8aa738 r392056d  
    55#This software was developed by the University of Tennessee as part of the 
    66#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     7#project funded by the US National Science Foundation. 
    88#See the license text in license.txt 
    99#copyright 2008, University of Tennessee 
     
    1313import logging 
    1414import sys 
     15from sasmodels import sesans 
    1516 
    16 from sasmodels.resolution import Slit1D, Pinhole1D 
     17from sasmodels.resolution import Slit1D, Pinhole1D, SESANS1D 
    1718from sasmodels.resolution2d import Pinhole2D 
    1819 
     
    4849 
    4950    # Look for resolution smearing data 
     51    _found_sesans = False 
     52    if data.dx is not None and data.meta_data['loader']=='SESANS': 
     53        if data.dx[0] > 0.0: 
     54            _found_sesans = True 
     55 
     56    if _found_sesans == True: 
     57        return sesans_smear(data, model) 
     58 
    5059    _found_resolution = False 
    5160    if data.dx is not None and len(data.dx) == len(data.x): 
     
    92101        self.model = model 
    93102        self.resolution = resolution 
    94         self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     103        if hasattr(self.resolution, 'data'): 
     104            if self.resolution.data.meta_data['loader'] == 'SESANS': 
     105                self.offset = 0 
     106            # This is default behaviour, for future resolution/transform functions this needs to be revisited. 
     107            else: 
     108                self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     109        else: 
     110            self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     111 
     112        #self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
    95113 
    96114    def apply(self, iq_in, first_bin=0, last_bin=None): 
     
    126144        q[first:last+1]. 
    127145        """ 
     146 
    128147        q = self.resolution.q 
    129148        first = numpy.searchsorted(q, q_min) 
     
    142161    width = data.dx if data.dx is not None else 0 
    143162    return PySmear(Pinhole1D(q, width), model) 
     163 
     164def sesans_smear(data, model=None): 
     165    #This should be calculated characteristic length scale 
     166    #Probably not a data prameter either 
     167    #Need function to calculate this based on model 
     168    #Here assume a number 
     169    Rmax = 1000000 
     170    q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
     171    return PySmear(SESANS1D(data,q_calc),model) 
  • src/sas/sascalc/dataloader/data_info.py

    r1b1a1c1 r1fac6c0  
    2525import numpy 
    2626import math 
    27  
    28 class plottable_sesans1D(object): 
    29     """ 
    30     SESANS is a place holder for 1D SESANS plottables. 
    31  
    32     #TODO: This was directly copied from the plottables_1D. Modified Somewhat. 
    33     #Class has been updated. 
    34     """ 
    35     # The presence of these should be mutually 
    36     # exclusive with the presence of Qdev (dx) 
    37     x = None 
    38     y = None 
    39     lam = None 
    40     dx = None 
    41     dy = None 
    42     dlam = None 
    43     ## Slit smearing length 
    44     dxl = None 
    45     ## Slit smearing width 
    46     dxw = None 
    47  
    48     # Units 
    49     _xaxis = '' 
    50     _xunit = '' 
    51     _yaxis = '' 
    52     _yunit = '' 
    53  
    54     def __init__(self, x, y, lam, dx=None, dy=None, dlam=None): 
    55 #        print "SESANS plottable working" 
    56         self.x = numpy.asarray(x) 
    57         self.y = numpy.asarray(y) 
    58         self.lam = numpy.asarray(lam) 
    59         if dx is not None: 
    60             self.dx = numpy.asarray(dx) 
    61         if dy is not None: 
    62             self.dy = numpy.asarray(dy) 
    63         if dlam is not None: 
    64             self.dlam = numpy.asarray(dlam) 
    65  
    66     def xaxis(self, label, unit): 
    67         """ 
    68         set the x axis label and unit 
    69         """ 
    70         self._xaxis = label 
    71         self._xunit = unit 
    72  
    73     def yaxis(self, label, unit): 
    74         """ 
    75         set the y axis label and unit 
    76         """ 
    77         self._yaxis = label 
    78         self._yunit = unit 
    79  
    80  
    8127class plottable_1D(object): 
    8228    """ 
     
    9440    dxw = None 
    9541 
     42    ## SESANS specific params (wavelengths for spin echo length calculation) 
     43 
     44    lam = None 
     45    dlam = None 
     46 
    9647    # Units 
    9748    _xaxis = '' 
     
    10051    _yunit = '' 
    10152 
    102     def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 
     53    def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None): 
    10354        self.x = numpy.asarray(x) 
    10455        self.y = numpy.asarray(y) 
     
    11162        if dxw is not None: 
    11263            self.dxw = numpy.asarray(dxw) 
     64        if lam is not None: 
     65            self.lam = numpy.asarray(lam) 
     66        if dlam is not None: 
     67            self.dlam = numpy.asarray(dlam) 
    11368 
    11469    def xaxis(self, label, unit): 
     
    736691        return self._perform_union(other) 
    737692 
    738 class SESANSData1D(plottable_sesans1D, DataInfo): 
    739     """ 
    740     SESANS 1D data class 
    741     """ 
    742     x_unit = 'nm' 
    743     y_unit = 'pol' 
    744  
    745     def __init__(self, x=None, y=None, lam=None, dx=None, dy=None, dlam=None): 
     693class Data1D(plottable_1D, DataInfo): 
     694    """ 
     695    1D data class 
     696    """ 
     697    #if plottable_1D.lam is None: # This means it's SANS data! 
     698     #   x_unit = '1/A' 
     699      #  y_unit = '1/cm' 
     700    #elif plottable_1D.lam is not None: # This means it's SESANS data! 
     701     #   x_unit = 'A' 
     702      #  y_unit = 'pol' 
     703    #else: # and if it's neither, you get punished! 
     704     #   raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
     705 
     706    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
     707        self.isSesans = isSesans 
    746708        DataInfo.__init__(self) 
    747         plottable_sesans1D.__init__(self, x, y, lam, dx, dy, dlam) 
     709        plottable_1D.__init__(self, x, y, dx, dy,None, None, lam, dlam) 
     710        if self.isSesans: 
     711            x_unit = 'A' 
     712            y_unit = 'pol' 
     713        elif not self.isSesans: # it's SANS data! (Could also be simple else statement, but i prefer exhaustive conditionals...-JHB) 
     714            x_unit = '1/A' 
     715            y_unit = '1/cm' 
     716        else: # and if it's neither, you get punished! 
     717            raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
    748718 
    749719    def __str__(self): 
     
    759729        return _str 
    760730 
    761     def clone_without_data(self, length=0, clone=None): 
    762         """ 
    763         Clone the current object, without copying the data (which 
    764         will be filled out by a subsequent operation). 
    765         The data arrays will be initialized to zero. 
    766  
    767         :param length: length of the data array to be initialized 
    768         :param clone: if provided, the data will be copied to clone 
    769         """ 
    770         from copy import deepcopy 
    771         if clone is None or not issubclass(clone.__class__, Data1D): 
    772             x = numpy.zeros(length) 
    773             dx = numpy.zeros(length) 
    774             y = numpy.zeros(length) 
    775             dy = numpy.zeros(length) 
    776             clone = Data1D(x, y, dx=dx, dy=dy) 
    777  
    778         clone.title = self.title 
    779         clone.run = self.run 
    780         clone.filename = self.filename 
    781         clone.instrument = self.instrument 
    782         clone.notes = deepcopy(self.notes) 
    783         clone.process = deepcopy(self.process) 
    784         clone.detector = deepcopy(self.detector) 
    785         clone.sample = deepcopy(self.sample) 
    786         clone.source = deepcopy(self.source) 
    787         clone.collimation = deepcopy(self.collimation) 
    788         clone.trans_spectrum = deepcopy(self.trans_spectrum) 
    789         clone.meta_data = deepcopy(self.meta_data) 
    790         clone.errors = deepcopy(self.errors) 
    791  
    792         return clone 
    793  
    794 class Data1D(plottable_1D, DataInfo): 
    795     """ 
    796     1D data class 
    797     """ 
    798     x_unit = '1/A' 
    799     y_unit = '1/cm' 
    800  
    801     def __init__(self, x, y, dx=None, dy=None): 
    802         DataInfo.__init__(self) 
    803         plottable_1D.__init__(self, x, y, dx, dy) 
    804  
    805     def __str__(self): 
    806         """ 
    807         Nice printout 
    808         """ 
    809         _str = "%s\n" % DataInfo.__str__(self) 
    810         _str += "Data:\n" 
    811         _str += "   Type:         %s\n" % self.__class__.__name__ 
    812         _str += "   X-axis:       %s\t[%s]\n" % (self._xaxis, self._xunit) 
    813         _str += "   Y-axis:       %s\t[%s]\n" % (self._yaxis, self._yunit) 
    814         _str += "   Length:       %g\n" % len(self.x) 
    815         return _str 
    816  
    817731    def is_slit_smeared(self): 
    818732        """ 
     
    843757            y = numpy.zeros(length) 
    844758            dy = numpy.zeros(length) 
    845             clone = Data1D(x, y, dx=dx, dy=dy) 
     759            lam = numpy.zeros(length) 
     760            dlam = numpy.zeros(length) 
     761            clone = Data1D(x, y, lam=lam, dx=dx, dy=dy, dlam=dlam ) 
    846762 
    847763        clone.title = self.title 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r1c0e3b0 r392056d  
    88import numpy 
    99import os 
    10 from sas.sascalc.dataloader.data_info import SESANSData1D 
     10from sas.sascalc.dataloader.data_info import Data1D 
    1111 
    1212# Check whether we have a converter available 
     
    8484                tdx = numpy.zeros(0) 
    8585#                print "all good" 
    86                 output = SESANSData1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam) 
     86                output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True ) 
    8787#                print output                 
    8888                self.filename = output.filename = basename 
     
    121121                        paramvals.append(toks[1]) 
    122122                    if len(toks)>5: 
     123                       #zvals.append(toks[0]) 
     124                        #dzvals.append(toks[1]) 
     125                        #lamvals.append(toks[2]) 
     126                        #dlamvals.append(toks[3]) 
     127                        #Pvals.append(toks[4]) 
     128                        #dPvals.append(toks[5]) 
     129 
    123130                        zvals.append(toks[0]) 
    124                         dzvals.append(toks[1]) 
    125                         lamvals.append(toks[2]) 
    126                         dlamvals.append(toks[3]) 
    127                         Pvals.append(toks[4]) 
    128                         dPvals.append(toks[5]) 
     131                        dzvals.append(toks[3]) 
     132                        lamvals.append(toks[4]) 
     133                        dlamvals.append(toks[5]) 
     134                        Pvals.append(toks[1]) 
     135                        dPvals.append(toks[2]) 
    129136                    else: 
    130137                        continue 
     
    140147                default_z_unit = "A" 
    141148                data_conv_P = None 
    142                 default_p_unit = " " 
     149                default_p_unit = " " # Adjust unit for axis (L^-3) 
    143150                lam_unit = lam_header[1].replace("[","").replace("]","") 
     151                if lam_unit == 'AA': 
     152                    lam_unit = 'A' 
    144153                varheader=[zvals[0],dzvals[0],lamvals[0],dlamvals[0],Pvals[0],dPvals[0]] 
    145154                valrange=range(1, len(zvals)) 
     
    161170                output.x, output.x_unit = self._unit_conversion(x, lam_unit, default_z_unit) 
    162171                output.y = y 
     172                output.y_unit = '\AA^{-2} cm^{-1}' # output y_unit erbij 
    163173                output.dx, output.dx_unit = self._unit_conversion(dx, lam_unit, default_z_unit) 
    164174                output.dy = dy 
     
    166176                output.dlam, output.dlam_unit = self._unit_conversion(dlam, lam_unit, default_z_unit) 
    167177 
    168                 output.xaxis("\rm{z}", output.x_unit) 
    169                 output.yaxis("\\rm{P/P0}", output.y_unit) 
     178                output.xaxis("\\rm{z}", output.x_unit) 
     179                output.yaxis("\\rm{ln(P)/(t \lambda^2)}", output.y_unit) # Adjust label to ln P/(lam^2 t), remove lam column refs 
    170180                # Store loading process information 
    171181                output.meta_data['loader'] = self.type_name 
    172                 output.sample.thickness = float(paramvals[6]) 
     182                #output.sample.thickness = float(paramvals[6]) 
    173183                output.sample.name = paramvals[1] 
    174184                output.sample.ID = paramvals[0] 
    175185                zaccept_unit_split = paramnames[7].split("[") 
    176186                zaccept_unit = zaccept_unit_split[1].replace("]","") 
    177                 if zaccept_unit.strip() == '\AA^-1': 
     187                if zaccept_unit.strip() == '\AA^-1' or zaccept_unit.strip() == '\A^-1': 
    178188                    zaccept_unit = "1/A" 
    179189                output.sample.zacceptance=(float(paramvals[7]),zaccept_unit) 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    rfc18690 r7988501  
    131131        a way to get residuals from data. 
    132132    """ 
    133     def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None): 
     133    def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None, lam=None, dlam=None): 
    134134        """ 
    135135            :param smearer: is an object of class QSmearer or SlitSmearer 
     
    152152                 
    153153        """ 
    154         Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy) 
     154        Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy, lam=lam,dlam=dlam) 
    155155        self.num_points = len(x) 
    156156        self.sas_data = data 
  • src/sas/sascalc/fit/BumpsFitting.py

    rb699768 r7988501  
    2626from bumps import parameter 
    2727from bumps.fitproblem import FitProblem 
    28  
    2928 
    3029from sas.sascalc.fit.AbstractFitEngine import FitEngine 
  • src/sas/sasgui/guiframe/dataFitting.py

    r9b6d62d r1fac6c0  
    1717    """ 
    1818    """ 
    19     def __init__(self, x=None, y=None, dx=None, dy=None): 
     19    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
    2020        """ 
    2121        """ 
     
    2424        if y is None: 
    2525            y = [] 
    26         PlotData1D.__init__(self, x, y, dx, dy) 
    27         LoadData1D.__init__(self, x, y, dx, dy) 
     26        self.isSesans = isSesans 
     27        PlotData1D.__init__(self, x, y, dx, dy, lam, dlam) 
     28        LoadData1D.__init__(self, x, y, dx, dy, lam, dlam, isSesans) 
    2829        self.id = None 
    2930        self.list_group_id = [] 
     
    6869        # First, check the data compatibility 
    6970        dy, dy_other = self._validity_check(other) 
    70         result = Data1D(x=[], y=[], dx=None, dy=None) 
     71        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    7172        result.clone_without_data(length=len(self.x), clone=self) 
    7273        result.copy_from_datainfo(data1d=self) 
     
    115116        # First, check the data compatibility 
    116117        self._validity_check_union(other) 
    117         result = Data1D(x=[], y=[], dx=None, dy=None) 
     118        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    118119        tot_length = len(self.x) + len(other.x) 
    119120        result = self.clone_without_data(length=tot_length, clone=result) 
     121        if self.dlam == None or other.dlam is None: 
     122            result.dlam = None 
     123        else: 
     124            result.dlam = numpy.zeros(tot_length) 
    120125        if self.dy == None or other.dy is None: 
    121126            result.dy = None 
     
    141146        result.y = numpy.append(self.y, other.y) 
    142147        result.y = result.y[ind] 
     148        result.lam = numpy.append(self.lam, other.lam) 
     149        result.lam = result.lam[ind] 
     150        if result.dlam != None: 
     151            result.dlam = numpy.append(self.dlam, other.dlam) 
     152            result.dlam = result.dlam[ind] 
    143153        if result.dy != None: 
    144154            result.dy = numpy.append(self.dy, other.dy) 
     
    260270        # First, check the data compatibility 
    261271        self._validity_check_union(other) 
    262         result = Data1D(x=[], y=[], dx=None, dy=None) 
     272        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[]) 
    263273        tot_length = len(self.x)+len(other.x) 
    264274        result.clone_without_data(length=tot_length, clone=self) 
     275        if self.dlam == None or other.dlam is None: 
     276            result.dlam = None 
     277        else: 
     278            result.dlam = numpy.zeros(tot_length) 
    265279        if self.dy == None or other.dy is None: 
    266280            result.dy = None 
     
    285299        result.y = numpy.append(self.y, other.y) 
    286300        result.y = result.y[ind] 
     301        result.lam = numpy.append(self.lam, other.lam) 
     302        result.lam = result.lam[ind] 
    287303        if result.dy != None: 
    288304            result.dy = numpy.append(self.dy, other.dy) 
  • src/sas/sasgui/guiframe/data_manager.py

    rd85c194 r1fac6c0  
    6262        if issubclass(Data2D, data.__class__): 
    6363            new_plot = Data2D(image=None, err_image=None)  
    64         else:  
    65             new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
     64        elif data.meta_data['loader'] == 'SESANS': 
     65            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True) 
     66        else: 
     67            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check??? 
    6668            
    6769        new_plot.copy_from_datainfo(data) 
  • src/sas/sasgui/plottools/plottables.py

    r8abd96d r1fac6c0  
    10221022    """ 
    10231023 
    1024     def __init__(self, x, y, dx=None, dy=None): 
     1024    def __init__(self, x, y, dx=None, dy=None, lam=None, dlam=None): 
    10251025        """ 
    10261026        Draw points specified by x[i],y[i] in the current color/symbol. 
     
    10361036        self.x = x 
    10371037        self.y = y 
     1038        self.lam = lam 
    10381039        self.dx = dx 
    10391040        self.dy = dy 
     1041        self.dlam = dlam 
    10401042        self.source = None 
    10411043        self.detector = None 
Note: See TracChangeset for help on using the changeset viewer.