Changeset 7116b6e0 in sasview for prview


Ignore:
Timestamp:
Jun 4, 2010 1:38:32 PM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
79ac6f8
Parents:
d84a90c
Message:

working on documentation

Location:
prview
Files:
55 added
8 edited

Legend:

Unmodified
Added
Removed
  • prview/local_config.py

    r009f827 r7116b6e0  
    11""" 
    2     Application settings 
     2Application settings 
    33""" 
    44import time 
  • prview/perspectives/pr/explore_dialog.py

    r3b865c1 r7116b6e0  
     1 
     2################################################################################ 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6# 
     7#See the license text in license.txt 
     8# 
     9#copyright 2009, University of Tennessee 
     10################################################################################ 
     11 
    112""" 
    2     Dialog panel to explore the P(r) inversion results for a range 
    3     of D_max value. User picks a number of points and a range of 
    4     distances, then can toggle between inversion outputs and see 
    5     their distribution as a function of D_max. 
     13Dialog panel to explore the P(r) inversion results for a range 
     14of D_max value. User picks a number of points and a range of 
     15distances, then can toggle between inversion outputs and see 
     16their distribution as a function of D_max. 
     17""" 
    618     
    7     This software was developed by the University of Tennessee as part of the 
    8     Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    9     project funded by the US National Science Foundation.  
    10  
    11     See the license text in license.txt 
    12  
    13     copyright 2009, University of Tennessee 
    14 """ 
     19 
    1520import wx 
    1621import numpy 
     
    3742class OutputPlot(PlotPanel): 
    3843    """ 
    39         Plot panel used to show the selected results as a function 
    40         of D_max 
     44    Plot panel used to show the selected results as a function 
     45    of D_max 
    4146    """ 
    4247    def __init__(self, d_min, d_max, parent, id = -1, color = None,\ 
    4348        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 
    4449        """ 
    45             Initialization. The parameters added to PlotPanel are: 
    46              
    47             @param d_min: Minimum value of D_max to explore 
    48             @param d_max: Maximum value of D_max to explore 
     50        Initialization. The parameters added to PlotPanel are: 
     51         
     52        :param d_min: Minimum value of D_max to explore 
     53        :param d_max: Maximum value of D_max to explore 
     54         
    4955        """ 
    5056        PlotPanel.__init__(self, parent, id = id, style = style, **kwargs) 
     
    7480    def onContextMenu(self, event): 
    7581        """ 
    76             Default context menu for the plot panel 
    77              
    78             #TODO: Would be nice to add printing and log/linear scales. 
     82        Default context menu for the plot panel 
     83         
     84        :TODO: Would be nice to add printing and log/linear scales. 
    7985            The current verison of plottools no longer plays well with  
    8086            plots outside of guiframe. Guiframe team needs to fix this.  
     
    95101        self.PopupMenu(slicerpop, pos) 
    96102 
    97          
    98103class Results: 
    99104    """ 
    100         Class to hold the inversion output parameters 
    101         as a function of D_max 
     105    Class to hold the inversion output parameters 
     106    as a function of D_max 
    102107    """ 
    103108    def __init__(self): 
    104109        """ 
    105             Initialization. Create empty arrays 
    106             and dictionary of labels. 
     110        Initialization. Create empty arrays 
     111        and dictionary of labels. 
    107112        """ 
    108113        # Array of output for each inversion 
     
    128133class ExploreDialog(wx.Dialog): 
    129134    """ 
    130         The explorer dialog box. This dialog is meant to be 
    131         invoked by the InversionControl class. 
     135    The explorer dialog box. This dialog is meant to be 
     136    invoked by the InversionControl class. 
    132137    """ 
    133138     
    134139    def __init__(self, pr_state, nfunc, *args, **kwds): 
    135140        """ 
    136             Initialization. The parameters added to Dialog are: 
    137              
    138             @param pr_state: sans.pr.invertor.Invertor object 
    139             @param nfunc: Number of terms in the expansion 
     141        Initialization. The parameters added to Dialog are: 
     142         
     143        :param pr_state: sans.pr.invertor.Invertor object 
     144        :param nfunc: Number of terms in the expansion 
     145         
    140146        """ 
    141147        kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 
     
    174180    class Event: 
    175181        """ 
    176             Class that holds the content of the form 
     182        Class that holds the content of the form 
    177183        """ 
    178184        ## Number of points to be plotted 
     
    185191    def _get_values(self, event=None): 
    186192        """ 
    187             Invoked when the user changes a value of the form. 
    188             Check that the values are of the right type. 
    189              
    190             @return: ExploreDialog.Event object if the content is good, None otherwise 
     193        Invoked when the user changes a value of the form. 
     194        Check that the values are of the right type. 
     195         
     196        :return: ExploreDialog.Event object if the content is good,  
     197            None otherwise 
    191198        """ 
    192199        # Flag to make sure that all values are good 
     
    237244    def _plot_output(self, event=None): 
    238245        """ 
    239             Invoked when a new output type is selected for plotting,  
    240             or when a new computation is finished. 
     246        Invoked when a new output type is selected for plotting,  
     247        or when a new computation is finished. 
    241248        """ 
    242249        # Get the output type selection 
     
    264271    def __do_layout(self): 
    265272        """ 
    266             Do the layout of the dialog 
     273        Do the layout of the dialog 
    267274        """ 
    268275        # Dialog box properties 
     
    337344    def _recalc(self, event=None): 
    338345        """ 
    339             Invoked when the user changed a value on the form. 
    340             Process the form and compute the output to be plottted. 
     346        Invoked when the user changed a value on the form. 
     347        Process the form and compute the output to be plottted. 
    341348        """ 
    342349        # Get the content of the form 
     
    381388             
    382389##### testing code ############################################################ 
     390""" 
     391Example: :: 
     392 
    383393class MyApp(wx.App): 
    384     """ 
    385         Test application used to invoke the ExploreDialog for testing 
    386     """ 
     394     
     395    #Test application used to invoke the ExploreDialog for testing 
     396    
    387397    def OnInit(self): 
    388398        from inversion_state import Reader 
     
    391401         
    392402        def call_back(state, datainfo=None): 
    393             """ 
    394                 Dummy call-back method used by the P(r)  
    395                 file reader. 
    396             """ 
     403             
     404            #Dummy call-back method used by the P(r)  
     405            #file reader. 
     406             
    397407            print state 
    398408             
     
    429439    app = MyApp(0) 
    430440    app.MainLoop() 
    431   
     441     
     442"""  
  • prview/perspectives/pr/inversion_panel.py

    r9bc4ed23 r7116b6e0  
    1717 
    1818class InversionControl(ScrolledPanel): 
     19    """ 
     20    """ 
    1921    window_name = 'pr_control' 
    2022    window_caption = "P(r) control panel" 
     
    2729     
    2830    def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 
     31        """ 
     32        """ 
    2933        ScrolledPanel.__init__(self, parent, id = id, **kwargs) 
    3034        self.SetupScrolling() 
     
    8589    def __setattr__(self, name, value): 
    8690        """ 
    87             Allow direct hooks to text boxes 
     91        Allow direct hooks to text boxes 
    8892        """ 
    8993        if name=='nfunc': 
     
    138142    def __getattr__(self, name): 
    139143        """ 
    140             Allow direct hooks to text boxes 
     144        Allow direct hooks to text boxes 
    141145        """ 
    142146        if name=='nfunc': 
     
    234238    def _save_state(self, evt=None): 
    235239        """ 
    236             Method used to create a memento of the current state 
     240        Method used to create a memento of the current state 
    237241             
    238             @return: state object  
     242        :return: state object  
    239243        """ 
    240244        # Ask the user the location of the file to write to. 
     
    290294    def set_state(self, state): 
    291295        """ 
    292             Set the state of the panel and inversion problem to 
    293             the state passed as a parameter. 
    294             Execute the inversion immediately after filling the  
    295             controls. 
    296              
    297             @param state: InversionState object 
     296        Set the state of the panel and inversion problem to 
     297        the state passed as a parameter. 
     298        Execute the inversion immediately after filling the  
     299        controls. 
     300         
     301        :param state: InversionState object 
    298302        """ 
    299303        if state.nfunc is not None: 
     
    638642    def _on_accept_alpha(self, evt): 
    639643        """ 
    640             User has accepted the estimated alpha,  
    641             set it as part of the input parameters 
     644        User has accepted the estimated alpha,  
     645        set it as part of the input parameters 
    642646        """ 
    643647        try: 
     
    653657    def _on_accept_nterms(self, evt): 
    654658        """ 
    655             User has accepted the estimated number of terms,  
    656             set it as part of the input parameters 
     659        User has accepted the estimated number of terms,  
     660        set it as part of the input parameters 
    657661        """ 
    658662        try: 
     
    668672    def _on_reset(self, evt): 
    669673        """ 
    670             Resets inversion parameters 
     674        Resets inversion parameters 
    671675        """ 
    672676        self.nfunc = self.manager.DEFAULT_NFUNC 
     
    691695    def _on_pars_changed(self, evt=None): 
    692696        """ 
    693             Called when an input parameter has changed 
    694             We will estimate the alpha parameter behind the 
    695             scenes.  
     697        Called when an input parameter has changed 
     698        We will estimate the alpha parameter behind the 
     699        scenes.  
    696700        """ 
    697701        flag, alpha, dmax, nfunc, qmin, qmax, height, width = self._read_pars() 
     
    711715                                                 width=width) 
    712716         
    713     def _read_pars(self, evt=None):     
     717    def _read_pars(self, evt=None): 
     718        """ 
     719        """     
    714720        alpha = 0 
    715721        nfunc = 5 
     
    818824    def _on_explore(self, evt): 
    819825        """ 
    820             Invoke the d_max exploration dialog 
     826        Invoke the d_max exploration dialog 
    821827        """ 
    822828        from explore_dialog import ExploreDialog 
     
    831837    def _on_invert(self, evt): 
    832838        """ 
    833             Perform inversion 
    834             @param silent: when True, there will be no output for the user  
     839        Perform inversion 
     840         
     841        :param silent: when True, there will be no output for the user  
     842         
    835843        """ 
    836844        # Get the data from the form 
     
    858866    def _change_file(self, evt=None, filepath=None): 
    859867        """ 
    860             Choose a new input file for I(q) 
     868        Choose a new input file for I(q) 
    861869        """ 
    862870        import os 
     
    878886 
    879887class HelpDialog(wx.Dialog): 
     888    """ 
     889    """ 
    880890    def __init__(self, parent, id): 
     891        """ 
     892        """ 
    881893        from sans.pr.invertor import help 
    882894        wx.Dialog.__init__(self, parent, id, size=(400, 420)) 
     
    913925class PrDistDialog(wx.Dialog): 
    914926    """ 
    915         Property dialog to let the user change the number 
    916         of points on the P(r) plot. 
     927    Property dialog to let the user change the number 
     928    of points on the P(r) plot. 
    917929    """ 
    918930    def __init__(self, parent, id): 
     
    956968    def _checkValues(self, event): 
    957969        """ 
    958             Check the dialog content. 
     970        Check the dialog content. 
    959971        """ 
    960972        flag = True 
     
    972984    def get_content(self): 
    973985        """ 
    974             Return the content of the dialog. 
    975             At this point the values have already been 
    976             checked. 
     986        Return the content of the dialog. 
     987        At this point the values have already been 
     988        checked. 
    977989        """ 
    978990        value = int(self.npts_ctl.GetValue()) 
     
    981993    def set_content(self, npts): 
    982994        """ 
    983             Initialize the content of the dialog. 
     995        Initialize the content of the dialog. 
    984996        """ 
    985997        self.npts_ctl.SetValue("%i" % npts) 
    986998 
    987999##### testing code ############################################################ 
     1000""" 
     1001Example: :: 
     1002 
    9881003class TestPlot: 
    9891004    def __init__(self, text): 
     
    10061021    app.MainLoop() 
    10071022     
     1023""" 
    10081024##### end of testing code #####################################################     
  • prview/perspectives/pr/inversion_state.py

    r80d2872 r7116b6e0  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     1 
     2################################################################################ 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6# 
     7#See the license text in license.txt 
     8# 
     9#copyright 2009, University of Tennessee 
     10################################################################################ 
     11 
     12 
    1013import time, os, sys 
    1114import logging 
     
    2225# Translation of names between stored and object data 
    2326## List of P(r) inversion inputs  
    24 in_list=  [["nterms",       "nfunc"], 
     27in_list =  [["nterms",       "nfunc"], 
    2528           ["d_max",        "d_max"], 
    2629           ["alpha",        "alpha"], 
     
    3134 
    3235## List of P(r) inversion outputs 
    33 out_list= [["elapsed", "elapsed"], 
     36out_list = [["elapsed", "elapsed"], 
    3437           ["rg",      "rg"], 
    3538           ["iq0",     "iq0"], 
     
    4447class InversionState(object): 
    4548    """ 
    46         Class to hold the state information of the InversionControl panel. 
     49    Class to hold the state information of the InversionControl panel. 
    4750    """ 
    4851    def __init__(self): 
    4952        """ 
    50             Default values 
     53        Default values 
    5154        """ 
    5255        # Input  
     
    9396    def __str__(self): 
    9497        """ 
    95             Pretty print 
    96              
    97             @return: string representing the state 
     98        Pretty print 
     99         
     100        :return: string representing the state 
     101         
    98102        """ 
    99103        state  = "File:         %s\n" % self.file 
     
    128132    def toXML(self, file="pr_state.prv", doc=None, entry_node=None): 
    129133        """ 
    130             Writes the state of the InversionControl panel to file, as XML. 
    131              
    132             Compatible with standalone writing, or appending to an 
    133             already existing XML document. In that case, the XML document 
    134             is required. An optional entry node in the XML document may also be given. 
    135              
    136             @param file: file to write to 
    137             @param doc: XML document object [optional] 
    138             @param entry_node: XML node within the XML document at which we will append the data [optional] 
     134        Writes the state of the InversionControl panel to file, as XML. 
     135         
     136        Compatible with standalone writing, or appending to an 
     137        already existing XML document. In that case, the XML document 
     138        is required. An optional entry node in the XML document may also be given. 
     139         
     140        :param file: file to write to 
     141        :param doc: XML document object [optional] 
     142        :param entry_node: XML node within the XML document at which  
     143            we will append the data [optional] 
     144         
    139145        """ 
    140146        from xml.dom.minidom import getDOMImplementation 
     
    213219    def fromXML(self, file=None, node=None): 
    214220        """ 
    215             Load a P(r) inversion state from a file 
    216              
    217             @param file: .prv file 
    218             @param node: node of a XML document to read from 
     221        Load a P(r) inversion state from a file 
     222         
     223        :param file: .prv file 
     224        :param node: node of a XML document to read from 
     225         
    219226        """ 
    220227        if file is not None: 
     
    328335class Reader(CansasReader): 
    329336    """ 
    330         Class to load a .prv P(r) inversion file 
     337    Class to load a .prv P(r) inversion file 
    331338    """ 
    332339    ## File type 
     
    340347    def __init__(self, call_back, cansas=True): 
    341348        """ 
    342             Initialize the call-back method to be called 
    343             after we load a file 
    344             @param call_back: call-back method 
    345             @param cansas:  True = files will be written/read in CanSAS format 
    346                             False = write CanSAS format 
     349        Initialize the call-back method to be called 
     350        after we load a file 
     351         
     352        :param call_back: call-back method 
     353        :param cansas:  True = files will be written/read in CanSAS format 
     354                        False = write CanSAS format 
    347355             
    348356        """ 
     
    354362    def read(self, path): 
    355363        """  
    356             Load a new P(r) inversion state from file 
    357              
    358             @param path: file path 
    359             @return: None 
     364        Load a new P(r) inversion state from file 
     365         
     366        :param path: file path 
     367         
     368        :return: None 
     369         
    360370        """ 
    361371        if self.cansas==True: 
     
    366376    def _read_standalone(self, path): 
    367377        """  
    368             Load a new P(r) inversion state from file. 
    369             The P(r) node is assumed to be the top element. 
    370              
    371             @param path: file path 
    372             @return: None 
     378        Load a new P(r) inversion state from file. 
     379        The P(r) node is assumed to be the top element. 
     380         
     381        :param path: file path 
     382         
     383        :return: None 
     384         
    373385        """ 
    374386        # Read the new state from file 
     
    382394    def _parse_prstate(self, entry): 
    383395        """ 
    384             Read a p(r) inversion result from an XML node 
    385             @param entry: XML node to read from  
    386             @return: InversionState object 
     396        Read a p(r) inversion result from an XML node 
     397         
     398        :param entry: XML node to read from  
     399         
     400        :return: InversionState object 
     401         
    387402        """ 
    388403        # Create an empty state 
     
    400415    def _read_cansas(self, path): 
    401416        """  
    402             Load data and P(r) information from a CanSAS XML file. 
    403              
    404             @param path: file path 
    405             @return: Data1D object if a single SASentry was found,  
    406                         or a list of Data1D objects if multiple entries were found, 
    407                         or None of nothing was found 
    408             @raise RuntimeError: when the file can't be opened 
    409             @raise ValueError: when the length of the data vectors are inconsistent 
     417        Load data and P(r) information from a CanSAS XML file. 
     418         
     419        :param path: file path 
     420         
     421        :return: Data1D object if a single SASentry was found,  
     422                    or a list of Data1D objects if multiple entries were found, 
     423                    or None of nothing was found 
     424                     
     425        :raise RuntimeError: when the file can't be opened 
     426        :raise ValueError: when the length of the data vectors are inconsistent 
     427         
    410428        """ 
    411429        output = [] 
     
    448466    def write(self, filename, datainfo=None, prstate=None): 
    449467        """ 
    450             Write the content of a Data1D as a CanSAS XML file 
    451              
    452             @param filename: name of the file to write 
    453             @param datainfo: Data1D object 
    454             @param prstate: InversionState object 
    455         """ 
    456  
     468        Write the content of a Data1D as a CanSAS XML file 
     469         
     470        :param filename: name of the file to write 
     471        :param datainfo: Data1D object 
     472        :param prstate: InversionState object 
     473         
     474        """ 
    457475        # Sanity check 
    458476        if self.cansas == True: 
  • prview/perspectives/pr/pr.py

    rf0ff8d65 r7116b6e0  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     1 
     2################################################################################ 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6# 
     7#See the license text in license.txt 
     8# 
     9#copyright 2009, University of Tennessee 
     10################################################################################ 
     11 
    1012 
    1113# Make sure the option of saving each curve is available  
     
    3941 
    4042class Plugin: 
    41      
     43    """ 
     44    """ 
    4245    DEFAULT_ALPHA = 0.0001 
    4346    DEFAULT_NFUNC = 10 
     
    4548     
    4649    def __init__(self, standalone=True): 
     50        """ 
     51        """ 
    4752        ## Plug-in name 
    4853        self.sub_menu = "Pr inversion" 
     
    114119    def set_state(self, state, datainfo=None): 
    115120        """ 
    116             Call-back method for the inversion state reader. 
    117             This method is called when a .prv file is loaded. 
    118              
    119             @param state: InversionState object 
    120             @param datainfo: Data1D object [optional] 
     121        Call-back method for the inversion state reader. 
     122        This method is called when a .prv file is loaded. 
     123         
     124        :param state: InversionState object 
     125        :param datainfo: Data1D object [optional] 
     126         
    121127        """ 
    122128        try: 
     
    150156    def populate_menu(self, id, owner): 
    151157        """ 
    152             Create a menu for the plug-in 
     158        Create a menu for the plug-in 
    153159        """ 
    154160        return [] 
     
    156162    def help(self, evt): 
    157163        """ 
    158             Show a general help dialog.  
    159             TODO: replace the text with a nice image 
     164        Show a general help dialog.  
     165         
     166        :TODO: replace the text with a nice image 
     167         
    160168        """ 
    161169        from inversion_panel import HelpDialog 
     
    167175     
    168176    def _fit_pr(self, evt): 
     177        """ 
     178        """ 
    169179        from sans.pr.invertor import Invertor 
    170180        import numpy 
     
    178188        d_max  = 2*radius 
    179189         
    180          
    181190        r = pylab.arange(0.01, d_max, d_max/51.0) 
    182191        M = len(r) 
     
    191200            pr_err[j] = math.sqrt(y[j]) 
    192201 
    193              
    194202        y = y/sum*d_max/len(r) 
    195  
    196  
    197203 
    198204        # Perform fit 
     
    207213            print "%g +- %g" % (out[i], math.sqrt(cov[i][i])) 
    208214 
    209  
    210215        # Show input P(r) 
    211216        new_plot = Data1D(pr.x, pr.y, dy=pr.err) 
     
    222227        self.show_iq(out, pr, q) 
    223228         
    224          
    225229    def show_shpere(self, x, radius=70.0, x_range=70.0): 
     230        """ 
     231        """ 
    226232        import numpy 
    227233        import pylab 
     
    251257    def get_npts(self): 
    252258        """ 
    253             Returns the number of points in the I(q) data 
     259        Returns the number of points in the I(q) data 
    254260        """ 
    255261        try: 
     
    259265         
    260266    def show_iq(self, out, pr, q=None): 
     267        """ 
     268        """ 
    261269        import numpy 
    262270        import pylab 
     
    334342    def _on_pr_npts(self, evt): 
    335343        """ 
    336             Redisplay P(r) with a different number of points 
     344        Redisplay P(r) with a different number of points 
    337345        """    
    338346        from inversion_panel import PrDistDialog 
     
    348356         
    349357    def show_pr(self, out, pr, cov=None): 
     358        """ 
     359        """ 
    350360        import numpy 
    351361        import pylab 
     
    402412    def choose_file(self, path=None): 
    403413        """ 
    404          
    405414        """ 
    406415        #TODO: this should be in a common module 
     
    410419    def load(self, path): 
    411420        """ 
    412             Load data. This will eventually be replaced 
    413             by our standard DataLoader class. 
     421        Load data. This will eventually be replaced 
     422        by our standard DataLoader class. 
    414423        """ 
    415424        class FileData: 
     
    458467    def load_columns(self, path = "sphere_60_q0_2.txt"): 
    459468        """ 
    460             Load 2- or 3- column ascii 
     469        Load 2- or 3- column ascii 
    461470        """ 
    462471        import numpy, math, sys 
     
    502511    def load_abs(self, path): 
    503512        """ 
    504             Load an IGOR .ABS reduced file 
    505             @param path: file path 
    506             @return: x, y, err vectors 
     513        Load an IGOR .ABS reduced file 
     514         
     515        :param path: file path 
     516         
     517        :return: x, y, err vectors 
     518         
    507519        """ 
    508520        import numpy, math, sys 
     
    551563        return data_x, data_y, data_err      
    552564         
    553          
    554          
    555565    def pr_theory(self, r, R): 
    556         """ 
    557             
     566        """   
    558567        """ 
    559568        if r<=2*R: 
     
    564573    def get_context_menu(self, graph=None): 
    565574        """ 
    566             Get the context menu items available for P(r) 
    567             @param graph: the Graph object to which we attach the context menu 
    568             @return: a list of menu items with call-back function 
     575        Get the context menu items available for P(r) 
     576         
     577        :param graph: the Graph object to which we attach the context menu 
     578         
     579        :return: a list of menu items with call-back function 
     580         
    569581        """ 
    570582        # Look whether this Graph contains P(r) data 
     
    604616    def _on_disable_scaling(self, evt): 
    605617        """ 
    606             Disable P(r) scaling 
    607             @param evt: Menu event 
     618        Disable P(r) scaling 
     619             
     620        :param evt: Menu event 
     621         
    608622        """ 
    609623        self._normalize_output = False 
     
    623637    def _on_normalize(self, evt): 
    624638        """ 
    625             Normalize the area under the P(r) curve to 1. 
    626             This operation is done for all displayed plots. 
    627              
    628             @param evt: Menu event 
     639        Normalize the area under the P(r) curve to 1. 
     640        This operation is done for all displayed plots. 
     641         
     642        :param evt: Menu event 
     643         
    629644        """ 
    630645        self._normalize_output = True 
     
    647662            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, update=True, 
    648663                                                   title=self._added_plots[plot].name)) 
    649                  
    650          
    651664         
    652665    def _on_scale_unity(self, evt): 
    653666        """ 
    654             Scale the maximum P(r) value on each displayed plot to 1. 
    655              
    656             @param evt: Menu event 
     667        Scale the maximum P(r) value on each displayed plot to 1. 
     668         
     669        :param evt: Menu event 
     670         
    657671        """ 
    658672        self._scale_output_unity = True 
     
    680694    def _on_add_data(self, evt): 
    681695        """ 
    682             Add a data curve to the plot 
    683             WARNING: this will be removed once guiframe.plotting has its full functionality 
     696        Add a data curve to the plot 
     697         
     698        :WARNING: this will be removed once guiframe.plotting has 
     699             its full functionality 
    684700        """ 
    685701        path = self.choose_file() 
     
    731747 
    732748    def start_thread(self): 
     749        """ 
     750        """ 
    733751        from pr_thread import CalcPr 
    734752        from copy import deepcopy 
     
    744762     
    745763    def _thread_error(self, error): 
     764        """ 
     765        """ 
    746766        wx.PostEvent(self.parent, StatusEvent(status=error)) 
    747767     
    748768    def _estimate_completed(self, alpha, message, elapsed): 
    749769        """ 
    750             Parameter estimation completed,  
    751             display the results to the user 
    752             @param alpha: estimated best alpha 
    753             @param elapsed: computation time 
     770        Parameter estimation completed,  
     771        display the results to the user 
     772         
     773        :param alpha: estimated best alpha 
     774        :param elapsed: computation time 
     775         
    754776        """ 
    755777        # Save useful info 
     
    765787    def _estimateNT_completed(self, nterms, alpha, message, elapsed): 
    766788        """ 
    767             Parameter estimation completed,  
    768             display the results to the user 
    769             @param alpha: estimated best alpha 
    770             @param nterms: estimated number of terms 
    771             @param elapsed: computation time 
     789        Parameter estimation completed,  
     790        display the results to the user 
     791         
     792        :param alpha: estimated best alpha 
     793        :param nterms: estimated number of terms 
     794        :param elapsed: computation time 
     795         
    772796        """ 
    773797        # Save useful info 
     
    780804    def _completed(self, out, cov, pr, elapsed): 
    781805        """ 
    782             Method called with the results when the inversion 
    783             is done 
    784              
    785             @param out: output coefficient for the base functions 
    786             @param cov: covariance matrix 
    787             @param pr: Invertor instance 
    788             @param elapsed: time spent computing 
     806        Method called with the results when the inversion 
     807        is done 
     808         
     809        :param out: output coefficient for the base functions 
     810        :param cov: covariance matrix 
     811        :param pr: Invertor instance 
     812        :param elapsed: time spent computing 
     813         
    789814        """ 
    790815        from copy import deepcopy 
     
    843868    def show_data(self, path=None, reset=False): 
    844869        """ 
    845             Show data read from a file 
    846             @param path: file path 
    847             @param reset: if True all other plottables will be cleared 
     870        Show data read from a file 
     871         
     872        :param path: file path 
     873        :param reset: if True all other plottables will be cleared 
     874         
    848875        """ 
    849876        if path is not None: 
     
    883910    def save_data(self, filepath, prstate=None): 
    884911        """ 
    885             Save data in provided state object. 
    886             TODO: move the state code away from inversion_panel and move it here.  
    887                     Then remove the "prstate" input and make this method private. 
    888                      
    889             @param filepath: path of file to write to 
    890             @param prstate: P(r) inversion state  
     912        Save data in provided state object. 
     913         
     914        :TODO: move the state code away from inversion_panel and move it here.  
     915                Then remove the "prstate" input and make this method private. 
     916                 
     917        :param filepath: path of file to write to 
     918        :param prstate: P(r) inversion state  
     919         
    891920        """ 
    892921        #TODO: do we need this or can we use DataLoader.loader.save directly? 
     
    906935    def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None,  
    907936                             bck=False, height=0, width=0): 
     937        """ 
     938        """ 
    908939        self.alpha = alpha 
    909940        self.nfunc = nfunc 
     
    925956    def estimate_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None,  
    926957                                bck=False, height=0, width=0): 
     958        """ 
     959        """ 
    927960        self.alpha = alpha 
    928961        self.nfunc = nfunc 
     
    944977    def _create_plot_pr(self, estimate=False): 
    945978        """ 
    946             Create and prepare invertor instance from 
    947             a plottable data set. 
    948             @param path: path of the file to read in  
     979        Create and prepare invertor instance from 
     980        a plottable data set. 
     981         
     982        :param path: path of the file to read in  
     983         
    949984        """ 
    950985        # Sanity check 
     
    10001035    def setup_file_inversion(self, alpha, nfunc, d_max, path, q_min=None, q_max=None,  
    10011036                             bck=False, height=0, width=0): 
     1037        """ 
     1038        """ 
    10021039        self.alpha = alpha 
    10031040        self.nfunc = nfunc 
     
    10191056    def estimate_file_inversion(self, alpha, nfunc, d_max, path, q_min=None, q_max=None,  
    10201057                                bck=False, height=0, width=0): 
     1058        """ 
     1059        """ 
    10211060        self.alpha = alpha 
    10221061        self.nfunc = nfunc 
     
    10391078    def _create_file_pr(self, path): 
    10401079        """ 
    1041             Create and prepare invertor instance from 
    1042             a file data set. 
    1043             @param path: path of the file to read in  
     1080        Create and prepare invertor instance from 
     1081        a file data set. 
     1082         
     1083        :param path: path of the file to read in  
     1084         
    10441085        """ 
    10451086        # Load data 
     
    11071148         
    11081149    def perform_estimate(self): 
     1150        """ 
     1151        """ 
    11091152        from pr_thread import EstimatePr 
    11101153        from copy import deepcopy 
     
    11221165     
    11231166    def perform_estimateNT(self): 
     1167        """ 
     1168        """ 
    11241169        from pr_thread import EstimateNT 
    11251170        from copy import deepcopy 
     
    11411186         
    11421187    def perform_inversion(self): 
    1143          
     1188        """ 
     1189        """ 
    11441190        # Time estimate 
    11451191        #estimated = self.elapsed*self.nfunc**2 
     
    11611207            except:  
    11621208                print "%d: %g +- ?" % (i, out[i])         
    1163          
    1164          
    11651209         
    11661210        # Make a plot of I(q) data 
  • prview/perspectives/pr/pr_thread.py

    ra00ee4c r7116b6e0  
    44class CalcPr(CalcThread): 
    55    """ 
    6         Compute P(r) 
     6    Compute P(r) 
     7    """ 
     8     
     9    def __init__(self, pr, nfunc=5, error_func=None, 
     10                 completefn = None, 
     11                 updatefn   = None, 
     12                 yieldtime  = 0.01, 
     13                 worktime   = 0.01 
     14                 ): 
     15        """ 
     16        """ 
     17        CalcThread.__init__(self,completefn, 
     18                 updatefn, 
     19                 yieldtime, 
     20                 worktime) 
     21        self.pr = pr 
     22        self.nfunc = nfunc 
     23        self.error_func = error_func 
     24        self.starttime = 0 
     25         
     26    def compute(self): 
     27        """ 
     28        Perform P(r) inversion 
     29        """ 
     30        try: 
     31            self.starttime = time.time() 
     32            out, cov = self.pr.invert(self.nfunc) 
     33            #out, cov = self.pr.lstsq(self.nfunc) 
     34            #out, cov = self.pr.invert_optimize(self.nfunc) 
     35            elapsed = time.time()-self.starttime 
     36            self.complete(out=out, cov=cov, pr=self.pr, elapsed=elapsed) 
     37        except KeyboardInterrupt: 
     38            # Thread was interrupted, just proceed 
     39            pass 
     40        except: 
     41            if not self.error_func==None: 
     42                self.error_func("CalcPr.compute: %s" % sys.exc_value) 
     43 
     44class EstimatePr(CalcThread): 
     45    """ 
     46    Estimate P(r) 
    747    """ 
    848     
     
    2464    def compute(self): 
    2565        """ 
    26             Perform P(r) inversion 
    27         """ 
    28         try: 
    29             self.starttime = time.time() 
    30             out, cov = self.pr.invert(self.nfunc) 
    31             #out, cov = self.pr.lstsq(self.nfunc) 
    32             #out, cov = self.pr.invert_optimize(self.nfunc) 
    33             elapsed = time.time()-self.starttime 
    34             self.complete(out=out, cov=cov, pr=self.pr, elapsed=elapsed) 
    35         except KeyboardInterrupt: 
    36             # Thread was interrupted, just proceed 
    37             pass 
    38         except: 
    39             if not self.error_func==None: 
    40                 self.error_func("CalcPr.compute: %s" % sys.exc_value) 
    41  
    42 class EstimatePr(CalcThread): 
    43     """ 
    44         Estimate P(r) 
    45     """ 
    46      
    47     def __init__(self, pr, nfunc=5, error_func=None, 
    48                  completefn = None, 
    49                  updatefn   = None, 
    50                  yieldtime  = 0.01, 
    51                  worktime   = 0.01 
    52                  ): 
    53         CalcThread.__init__(self,completefn, 
    54                  updatefn, 
    55                  yieldtime, 
    56                  worktime) 
    57         self.pr = pr 
    58         self.nfunc = nfunc 
    59         self.error_func = error_func 
    60         self.starttime = 0 
    61          
    62     def compute(self): 
    63         """ 
    64             Calculates the estimate 
     66        Calculates the estimate 
    6567        """ 
    6668        try:             
     
    7678 
    7779class EstimateNT(CalcThread): 
    78      
     80    """ 
     81    """ 
    7982    def __init__(self, pr, nfunc=5, error_func=None, 
    8083                 completefn = None, 
     
    9699 
    97100    def isquit(self): 
     101        """ 
     102        """ 
    98103        CalcThread.isquit(self) 
    99104        if time.time()>self._time_for_sleep+self._sleep_delay: 
     
    103108    def compute(self): 
    104109        """ 
    105             Calculates the estimate 
     110        Calculates the estimate 
    106111        """ 
    107112        try:             
  • prview/perspectives/pr/pr_widgets.py

    r8eeb0b6 r7116b6e0  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    51 
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     2################################################################################ 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6# 
     7#See the license text in license.txt 
     8# 
     9#copyright 2009, University of Tennessee 
     10################################################################################ 
    1011 
    1112""" 
    12     Text controls for input/output of the main PrView panel 
     13Text controls for input/output of the main PrView panel 
    1314""" 
    1415 
     
    1819class PrTextCtrl(wx.TextCtrl): 
    1920    """ 
    20         Text control for model and fit parameters. 
    21         Binds the appropriate events for user interactions. 
     21    Text control for model and fit parameters. 
     22    Binds the appropriate events for user interactions. 
    2223    """ 
    2324    def __init__(self, *args, **kwds): 
     
    3536    def _on_set_focus(self, event): 
    3637        """ 
    37             Catch when the text control is set in focus to highlight the whole 
    38             text if necessary 
    39             @param event: mouse event 
     38        Catch when the text control is set in focus to highlight the whole 
     39        text if necessary 
     40         
     41        :param event: mouse event 
     42         
    4043        """ 
    4144        event.Skip() 
     
    4447    def _highlight_text(self, event): 
    4548        """ 
    46             Highlight text of a TextCtrl only of no text has be selected 
    47             @param event: mouse event 
     49        Highlight text of a TextCtrl only of no text has be selected 
     50         
     51        :param event: mouse event 
     52         
    4853        """ 
    4954        # Make sure the mouse event is available to other listeners 
     
    6267class OutputTextCtrl(wx.TextCtrl): 
    6368    """ 
    64         Text control used to display outputs. 
    65         No editing allowed. The background is  
    66         grayed out. User can't select text. 
     69    Text control used to display outputs. 
     70    No editing allowed. The background is  
     71    grayed out. User can't select text. 
    6772    """ 
    6873    def __init__(self, *args, **kwds): 
     74        """ 
     75        """ 
    6976        wx.TextCtrl.__init__(self, *args, **kwds) 
    7077        self.SetEditable(False) 
     
    7885    def _click(self, event): 
    7986        """ 
    80             Prevent further handling of the mouse event 
    81             by not calling Skip(). 
     87        Prevent further handling of the mouse event 
     88        by not calling Skip(). 
    8289        """  
    8390        pass 
     
    8693class DataFileTextCtrl(OutputTextCtrl): 
    8794    """ 
    88         Text control used to display only the file name 
    89         given a full path. 
    90           
    91         TODO: now that we no longer choose the data file from the panel, 
     95    Text control used to display only the file name 
     96    given a full path. 
     97      
     98    :TODO: now that we no longer choose the data file from the panel, 
    9299        it's no longer necessary to pass around the file path. That code 
    93100        should be refactored away and simplified.  
    94101    """ 
    95102    def __init__(self, *args, **kwds): 
     103        """ 
     104        """ 
    96105        OutputTextCtrl.__init__(self, *args, **kwds) 
    97106        self._complete_path = None 
     
    99108    def SetValue(self, value): 
    100109        """ 
    101             Sets the file name given a path 
     110        Sets the file name given a path 
    102111        """ 
    103112        self._complete_path = str(value) 
     
    107116    def GetValue(self): 
    108117        """ 
    109             Return the full path 
     118        Return the full path 
    110119        """ 
    111120        return self._complete_path 
  • prview/sansview.py

    r4d5005e r7116b6e0  
    1313 
    1414class PrFrame(gui_manager.ViewerFrame): 
     15    """ 
     16    """ 
    1517    def _on_open(self, event): 
     18        """ 
     19        """ 
    1620        wx.PostEvent(self, NewPrFileEvent()) 
    1721 
    1822class PrApp(gui_manager.ViewApp): 
     23    """ 
     24    """ 
    1925    def OnInit(self): 
    20          
     26        """ 
     27        """ 
    2128        # Check the size of the screen 
    2229        # Add some padding to make sure to clear any OS tool bar 
     
    3542     
    3643class SansView(): 
    37      
     44    """ 
     45    """ 
    3846    def __init__(self): 
    3947        """ 
    40          
    4148        """ 
    4249        #from gui_manager import ViewApp 
Note: See TracChangeset for help on using the changeset viewer.