Changeset feb21d8 in sasview for prview


Ignore:
Timestamp:
Jul 8, 2008 11:37:00 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
5615a7b
Parents:
6e0f53a
Message:

Added various scaling choices

Location:
prview
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • prview/local_config.py

    r9362f85 rfeb21d8  
    66# Version of the application 
    77__appname__ = "PrView" 
    8 __version__ = '0.2.1' 
     8__version__ = '0.2.2' 
    99__download_page__ = 'http://danse.chem.utk.edu' 
     10__update_URL__ = 'http://danse.chem.utk.edu/prview_version.txt' 
    1011 
    1112 
  • prview/perspectives/pr/pr.py

    r357b79b rfeb21d8  
    6060        self.invertor    = None 
    6161        self.pr          = None 
    62         self.pr_estimate = None 
     62        # Copy of the last result in case we need to display it. 
     63        self._last_pr    = None 
     64        self._last_out   = None 
     65        self._last_cov   = None 
    6366        ## Calculation thread 
    6467        self.calc_thread = None 
     
    7376        ## Flag to let the plug-in know that it is running standalone 
    7477        self.standalone = True 
     78        self._normalize_output = False 
     79        self._scale_output_unity = False 
    7580         
    7681        # Log startup 
     
    265270            self._pr_npts= dialog.get_content() 
    266271            dialog.Destroy() 
    267             self.show_pr(self.pr.out, self.pr, self.pr.cov) 
     272            self.show_pr(self._last_out, self._last_pr, self._last_cov) 
    268273        else: 
    269274            dialog.Destroy() 
     
    285290 
    286291        sum = 0.0 
     292        pmax = 0.0 
    287293        cov2 = numpy.ascontiguousarray(cov) 
    288294         
     
    293299                (value, dy[i]) = pr.pr_err(out, cov2, x[i]) 
    294300            sum += value*pr.d_max/len(x) 
     301             
     302            # keep track of the maximum P(r) value 
     303            if value>pmax: 
     304                pmax = value 
     305                 
    295306            y[i] = value 
    296              
    297         y = y/sum 
    298         dy = dy/sum 
     307                 
     308        if self._normalize_output==True: 
     309            y = y/sum 
     310            dy = dy/sum 
     311        elif self._scale_output_unity==True: 
     312            y = y/pmax 
     313            dy = dy/pmax 
    299314         
    300315        if cov2==None: 
     
    378393        for item in graph.plottables: 
    379394            if item.name==PR_FIT_LABEL: 
    380                 return [["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data], 
     395                m_list = [["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data], 
    381396                       ["Change number of P(r) points", "Change the number of points on the P(r) output", self._on_pr_npts]] 
     397 
     398                m_list.append(["Disable P(r) scaling",  
     399                               "Let the output P(r) keep the scale of the data",  
     400                               self._on_disable_scaling]) 
     401                 
     402                if self._scale_output_unity==False: 
     403                    m_list.append(["Scale P_max(r) to unity",  
     404                                   "Scale P(r) so that its maximum is 1",  
     405                                   self._on_scale_unity]) 
     406                     
     407                if self._normalize_output==False: 
     408                    m_list.append(["Normalize P(r) to unity",  
     409                                   "Normalize the integral of P(r) to 1",  
     410                                   self._on_normalize]) 
     411                     
     412                return m_list 
     413                #return [["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data], 
     414                #       ["Change number of P(r) points", "Change the number of points on the P(r) output", self._on_pr_npts]] 
    382415 
    383416            elif item.name==graph.selected_plottable: 
     
    386419        return [] 
    387420 
     421    def _on_disable_scaling(self, evt): 
     422        """ 
     423            Disable P(r) scaling 
     424            @param evt: Menu event 
     425        """ 
     426        self._normalize_output = False 
     427        self._scale_output_unity = False 
     428        self.show_pr(self._last_out, self._last_pr, self._last_cov) 
     429         
     430    def _on_normalize(self, evt): 
     431        """ 
     432            Switch normalization ON/OFF 
     433            @param evt: Menu event 
     434        """ 
     435        self._normalize_output = True 
     436        self._scale_output_unity = False 
     437             
     438        self.show_pr(self._last_out, self._last_pr, self._last_cov) 
     439         
     440    def _on_scale_unity(self, evt): 
     441        """ 
     442            Switch normalization ON/OFF 
     443            @param evt: Menu event 
     444        """ 
     445        self._scale_output_unity = True 
     446        self._normalize_output = False 
     447             
     448        self.show_pr(self._last_out, self._last_pr, self._last_cov) 
     449         
    388450    def _on_add_data(self, evt): 
    389451        """ 
     
    468530        # Save useful info 
    469531        self.elapsed = elapsed 
     532        # Keep a copy of the last result 
     533        self._last_pr  = pr.clone() 
     534        self._last_out = out 
     535        self._last_cov = cov 
     536         
    470537        # Save Pr invertor 
    471538        self.pr = pr 
  • prview/perspectives/pr/requirements.txt

    r660b1e6 rfeb21d8  
    222. Find good defaults. Automate the inversion. 
    33   -How do we estimate d_max? Guinier fit? 
    4    -How do we estimate alpha? [partially done] 
     4   -How do we estimate alpha? [done] 
    55   Compute the residuals once and choose a value that brings the reg term up to  
    66   a fraction of the residuals. 
    773. When fitting a plottable on a Graph with multiple plottables, remember the one the user chose [done] 
    8 4. What q-range do we need to make it work? What are the constraints? 
    9 5. Create handshake so that a plug-in can set context menu items to its own panels... 
    10 6. Return figure of merit values and suggest the values for d_max and alpha. 
     84. What q-range do we need to make it work? What are the constraints? [studied by Raiza] 
     95. Create handshake so that a plug-in can set context menu items to its own panels... [done] 
     106. Return figure of merit values and suggest the values for d_max and alpha. [alpha, nfunc done] 
    11117. Show time estimate [done] 
    12 8. Plot the reg term alone to see what it looks like 
    13 9. Use data loader perspective/plug-in to load data/choose file 
    14 10. Common module for file reading and file choosing 
    15 11. Define limits of applicability 
    16 12. Return figures of merit 
     128. Plot the reg term alone to see what it looks like  
     139. Use data loader perspective/plug-in to load data/choose file [done] 
     1410. Common module for file reading and file choosing  
     1511. Define limits of applicability  
     1612. Return figures of merit [done] 
    171713. Errors on output constants [done] 
    18 14. Clean up the InversionDialog 
    19 15. Add online help for inputs and outputs (especially figures of merit) 
     1814. Clean up the InversionDialog [done] 
     1915. Add online help for inputs and outputs (especially figures of merit) [done] 
    202016. Add help text to the interface (description of what we are minimizing, to explain alpha and nfunc). 
    21 17. Get rid of all output prints. 
     2117. Get rid of all output prints.  
    222218. Clean up 
    232319. Replace help dialog text with a nice image. Mention how to choose alpha and what the suggested alpha means. 
    242420. If a figure of merit is clearly bad, put its background red 
    25 21. Option to save data. 
    26 22. If you click compute before loading data, an error occurs. 
    27 23. Plot I(q) immediately when you choose a new file. 
     2521. Option to save data. [done] 
     2622. If you click compute before loading data, an error occurs. [fixed] 
     2723. Plot I(q) immediately when you choose a new file. [done] 
    282824. *** probably need to ship the perspectives separately... 
    29 25. If no data is available, disable the Fit button. 
     2925. If no data is available, disable the Fit button. [Message sent instead] 
     3026. Remove an added curve... 
     3127. Add multiple additional data curves. 
  • prview/release_notes.txt

    rab7615b rfeb21d8  
    66Package name: None 
    77 
    8 1- Version 0.2.1 
     81- Version 0.2.2 
    99 
     10        - Release date: 7/8/2008 
     11        - Added option to normalize P(r) to 1, scale P_max to 1, or leave as is. 
     12        - Fixed problem with changing the number of P(r) points. 
     13 
     14   Version 0.2.1 
    1015        - Release date: 7/04/2008 
    1116        - Improved user interface. 
Note: See TracChangeset for help on using the changeset viewer.