Changeset aab8ad7 in sasview


Ignore:
Timestamp:
Sep 14, 2008 10:11: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:
14d05ba
Parents:
c7bc3e7
Message:

prview update for DataLoader?

Location:
prview
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • prview/perspectives/pr/pr.py

    rf1181977 raab8ad7  
    1111import math, numpy 
    1212from sans.pr.invertor import Invertor 
     13from DataLoader.loader import Loader 
    1314 
    1415PR_FIT_LABEL       = r"$P_{fit}(r)$" 
     
    344345            by our standard DataLoader class. 
    345346        """ 
    346         #TODO: use DataLoader 
    347347        class FileData: 
    348348            x = None 
     
    355355                 
    356356        self._current_file_data = FileData(path) 
    357         basename = os.path.basename(path) 
    358         root, ext = os.path.splitext(basename) 
    359         if ext.lower()=='.abs': 
    360             x, y, err = self.load_abs(path) 
    361          
    362         else:  
    363             x, y, err = self.load_columns(path) 
    364              
     357         
     358        # Use data loader to load file 
     359        dataread = Loader().load(path) 
     360        x = None 
     361        y = None 
     362        err = None 
     363        if dataread.__class__.__name__ == 'Data1D': 
     364            x = dataread.x 
     365            y = dataread.y 
     366            err = dataread.dy 
     367        else: 
     368            raise RuntimeError, "This tool can only read 1D data" 
     369         
    365370        self._current_file_data.x = x 
    366371        self._current_file_data.y = y 
     
    874879            @param path: path of the file to read in  
    875880        """ 
    876         from sans.guiframe.data_loader import load_ascii_1D 
    877         import numpy 
    878          
    879881        # Load data 
    880882        if os.path.isfile(path): 
     
    882884            if self._current_file_data is not None \ 
    883885                and self._current_file_data.path==path: 
     886                # Protect against corrupted data from  
     887                # previous failed load attempt 
     888                if self._current_file_data.x is None: 
     889                    return None 
    884890                x = self._current_file_data.x 
    885891                y = self._current_file_data.y 
     
    887893            else: 
    888894                x, y, err = self.load(path) 
    889             #x, y, err = load_ascii_1D(path) 
    890895             
    891896            # If we have not errors, add statistical errors 
    892             if err==None: 
     897            if err==None and y is not None: 
    893898                err = numpy.zeros(len(y)) 
     899                scale = None 
     900                min_err = 0.0 
    894901                for i in range(len(y)): 
    895                     err[i] = math.sqrt( math.fabs(y[i]) ) 
     902                    # Scale the error so that we can fit over several decades of Q 
     903                    if scale==None: 
     904                        scale = 0.05*math.sqrt(y[i]) 
     905                        min_err = 0.01*y[i] 
     906                    err[i] = scale*math.sqrt( math.fabs(y[i]) ) + min_err 
    896907                message = "The loaded file had no error bars, statistical errors are assumed." 
    897908                wx.PostEvent(self.parent, StatusEvent(status=message)) 
     
    899910                wx.PostEvent(self.parent, StatusEvent(status='')) 
    900911             
    901             # Get the data from the chosen data set and perform inversion 
    902             pr = Invertor() 
    903             pr.d_max = self.max_length 
    904             pr.alpha = self.alpha 
    905             pr.q_min = self.q_min 
    906             pr.q_max = self.q_max 
    907             pr.x = x 
    908             pr.y = y 
    909             pr.err = err 
    910             pr.has_bck = self.has_bck 
    911             pr.slit_height = self.slit_height 
    912             pr.slit_width = self.slit_width 
    913             return pr 
     912            try: 
     913                # Get the data from the chosen data set and perform inversion 
     914                pr = Invertor() 
     915                pr.d_max = self.max_length 
     916                pr.alpha = self.alpha 
     917                pr.q_min = self.q_min 
     918                pr.q_max = self.q_max 
     919                pr.x = x 
     920                pr.y = y 
     921                pr.err = err 
     922                pr.has_bck = self.has_bck 
     923                pr.slit_height = self.slit_height 
     924                pr.slit_width = self.slit_width 
     925                return pr 
     926            except: 
     927                wx.PostEvent(self.parent, StatusEvent(status="Problem reading data: %s" % sys.exc_value)) 
    914928        return None 
    915929         
  • prview/release_notes.txt

    rea5551f raab8ad7  
    44PrView 0.2 
    55 
    6 Package name: None 
     6Package name: prview 
    77 
    881- Version 0.2.x 
     
    1111        - Fixed problem with loading additional data after the P(r) graph's scale has been changed. 
    1212        - Fixed problem of silent failure upon loading a file with a point at Q=0. 
    13  
     13        - Added use of SANS DataLoader 
     14    
     15   Version 0.2.3 
     16    - Release date: 7/9/2008 
     17    - Mac compatibility  
     18     
    1419   Version 0.2.2 
    15  
    1620        - Release date: 7/8/2008 
    1721        - Added option to normalize P(r) to 1, scale P_max to 1, or leave as is. 
     
    2630        - Constant background estimation. 
    2731        - Functionality to compare p(r) output with data from a file. 
    28         - Functionality to change the number of p(r) points of the output dsitribution. 
     32        - Functionality to change the number of p(r) points of the output distribution. 
    2933 
    3034   Version 0.1.0 
     
    4650                        svn://danse.us/sans/releases/pr_inversion-0.2.1 
    4751                - The following modules are required: 
    48                         * matplotlib 0.91.4 (avoid 0.98.1) 
     52                        * matplotlib 
    4953                        * numpy 
    5054                        * scipy 
     
    5458 
    5559        3.1- All systems: 
    56                 Version 0.2.2: 
    57                 - The application only loads .txt files. The expected format is 2- or 3-column ascii. 
    58         - More than a single additional data set should be plottable on the P(r) graph. 
    59         - Additional data plotted on the P(r) graph should also be normalizable. 
    60         - If additional P(r) data is loaded after a scale change has been done, the loaded data appears in another window rather than on the same graph. If additional P(r) data is loaded while the scale of the P(r) graph is linear, the behavior is correct. 
    61         - The application will not load data files with a point at Q=0. The user will not be notified. 
    62  
     60                - None 
    6361 
    6462        3.2- Windows: 
    6563                - None 
    6664 
    67         3.3- Linux: 
    68                 - None 
     65        3.3- Mac OS: 
     66                - Context menu dialog interfere with dragging when displayed over plots. 
    6967 
    70684- Troubleshooting 
Note: See TracChangeset for help on using the changeset viewer.