Changeset a07e72f in sasview for prview


Ignore:
Timestamp:
Feb 28, 2011 4:07:14 PM (13 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:
243a8d4
Parents:
6bbeacd4
Message:

remove other type of data into sansview

Location:
prview/perspectives/pr
Files:
3 edited

Legend:

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

    r229da98 ra07e72f  
    1717from xml.dom.minidom import parse 
    1818from lxml import etree 
    19 import DataLoader 
     19from sans.guiframe.dataFitting import Data1D 
    2020from DataLoader.readers.cansas_reader import Reader as CansasReader 
    2121from DataLoader.readers.cansas_reader import get_content 
     
    519519        """ 
    520520        if datainfo is None: 
    521             datainfo = DataLoader.data_info.Data1D(x=[], y=[])     
    522         elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 
     521            datainfo = Data1D(x=[], y=[])     
     522        elif not issubclass(datainfo.__class__, Data1D): 
    523523            msg = "The cansas writer expects a Data1D " 
    524524            msg += "instance: %s" % str(datainfo.__class__.__name__) 
  • prview/perspectives/pr/pr.py

    r229da98 ra07e72f  
    2424import pylab 
    2525from sans.guiframe.dataFitting import Data1D 
    26 from sans.guiframe.dataFitting import Theory1D 
    2726from sans.guiframe.events import NewPlotEvent 
    28 from sans.guiframe.events import StatusEvent     
    29  
     27from sans.guiframe.events import StatusEvent  
     28from sans.guiframe.gui_style import GUIFRAME_ID    
    3029from sans.pr.invertor import Invertor 
    3130from DataLoader.loader import Loader 
    32 from DataLoader.data_info import Data1D as LoaderData1D 
    33 import DataLoader 
     31 
    3432from pr_widgets import load_error  
    3533from sans.guiframe.plugin_base import PluginBase 
     
    4139IQ_FIT_LABEL       = r"$I_{fit}(q)$" 
    4240IQ_SMEARED_LABEL   = r"$I_{smeared}(q)$" 
    43  
    44 #import wx.lib 
    45 #(NewPrFileEvent, EVT_PR_FILE) = wx.lib.newevent.NewEvent() 
    46  
    4741 
    4842 
     
    10397         
    10498        # Associate the inversion state reader with .prv files 
    105         from DataLoader.loader import Loader 
    10699        from inversion_state import Reader 
    107100          
     
    166159            self.control_panel.set_state(state) 
    167160        except: 
    168             raise 
    169             #logging.error("prview.set_state: %s" % sys.exc_value) 
     161            logging.error("prview.set_state: %s" % sys.exc_value) 
    170162 
    171163   
     
    188180        """ 
    189181        from sans.pr.invertor import Invertor 
    190              
    191         from danse.common.plottools import Data1D as PlotData1D 
    192         from danse.common.plottools import Theory1D as Theory1D 
    193          
    194182        # Generate P(r) for sphere 
    195183        radius = 60.0 
     
    220208        for i in range(len(out)): 
    221209            print "%g +- %g" % (out[i], math.sqrt(cov[i][i])) 
    222  
     210         
    223211        # Show input P(r) 
    224         new_plot = PlotData1D(pr.x, pr.y, dy=pr.err) 
     212        title = "Pr" 
     213        new_plot = Data1D(pr.x, pr.y, dy=pr.err) 
    225214        new_plot.name = "P_{obs}(r)" 
    226215        new_plot.xaxis("\\rm{r}", 'A') 
    227216        new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 
    228         print "_fit_pr" 
    229         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Pr")) 
     217        group_id = "P_{obs}(r)" 
     218        if group_id not in new_plot.group_id: 
     219            new_plot.group_id.append(group_id) 
     220        new_plot.id = "P_{obs}(r)" 
     221        new_plot.title = title 
     222        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    230223 
    231224        # Show P(r) fit 
     
    239232        """ 
    240233        """ 
    241         from danse.common.plottools import Theory1D as PlotTheory1D 
    242234        # Show P(r) 
    243235        y_true = numpy.zeros(len(x)) 
     
    251243         
    252244        # Show the theory P(r) 
    253         new_plot = PlotTheory1D(x, y_true) 
     245        new_plot = Data1D(x, y_true) 
     246        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    254247        new_plot.name = "P_{true}(r)" 
    255248        new_plot.xaxis("\\rm{r}", 'A') 
     
    272265        """ 
    273266        """   
    274         from danse.common.plottools import Theory1D as PlotTheory1D 
    275  
    276267        qtemp = pr.x 
    277268        if not q==None: 
     
    304295                print "Error getting error", value, x[i] 
    305296                 
    306         new_plot = PlotTheory1D(x, y) 
     297        new_plot = Data1D(x, y) 
     298        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    307299        new_plot.name = IQ_FIT_LABEL 
    308300        new_plot.xaxis("\\rm{Q}", 'A^{-1}') 
    309301        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
    310          
    311302        title = "I(q)" 
     303        new_plot.title = title 
     304         
    312305        # If we have a group ID, use it 
    313306        if pr.info.has_key("plot_group_id"): 
    314             new_plot.group_id = pr.info["plot_group_id"] 
    315             title = pr.info["plot_group_id"] 
    316              
     307            if len( pr.info["plot_group_id"]) > 0: 
     308                index =  len( pr.info["plot_group_id"]) - 1 
     309                new_plot.group_id.append( pr.info["plot_group_id"][index]) 
     310        new_plot.id = IQ_FIT_LABEL 
     311        #new_plot.group_id.append(2) 
    317312        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    318313         
     
    331326                    print "Error getting error", value, x[i] 
    332327                     
    333             new_plot = Theory1D(x, y) 
     328            new_plot = Data1D(x, y) 
     329            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    334330            new_plot.name = IQ_SMEARED_LABEL 
    335331            new_plot.xaxis("\\rm{Q}", 'A^{-1}') 
     
    337333            # If we have a group ID, use it 
    338334            if pr.info.has_key("plot_group_id"): 
    339                 new_plot.group_id = pr.info["plot_group_id"] 
     335                if len( pr.info["plot_group_id"]) > 0: 
     336                    index =  len( pr.info["plot_group_id"]) - 1 
     337                    new_plot.group_id.append( pr.info["plot_group_id"][index]) 
     338            
     339            new_plot.id = IQ_SMEARED_LABEL 
     340            new_plot.title = title 
     341            #new_plot.group_id.append(2) 
    340342            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    341343         
     
    359361        """ 
    360362        """      
    361         from danse.common.plottools import Data1D as PlotData1D  
    362         from danse.common.plottools import Theory1D as PlotTheory1D 
    363          
    364363        # Show P(r) 
    365364        x = pylab.arange(0.0, pr.d_max, pr.d_max/self._pr_npts) 
     
    394393         
    395394        if cov2==None: 
    396             new_plot = PlotTheory1D(x, y) 
     395            new_plot = Data1D(x, y) 
     396            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    397397        else: 
    398             new_plot = PlotData1D(x, y, dy=dy) 
     398            new_plot = Data1D(x, y, dy=dy) 
    399399        new_plot.name = PR_FIT_LABEL 
    400400        new_plot.xaxis("\\rm{r}", 'A') 
    401401        new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 
    402402        new_plot.title = "P(r) fit" 
     403        new_plot.id = PR_FIT_LABEL 
    403404        # Make sure that the plot is linear 
    404405        new_plot.xtransform = "x" 
     
    563564            return 0.0 
    564565 
    565     def get_context_menu(self, graph=None): 
     566    def get_context_menu(self, plotpanel=None): 
    566567        """ 
    567568        Get the context menu items available for P(r) 
     
    572573         
    573574        """ 
     575        graph = plotpanel.graph 
    574576        # Look whether this Graph contains P(r) data 
    575         #if graph.selected_plottable==IQ_DATA_LABEL: 
    576         for item in graph.plottables: 
    577             if item.name == PR_FIT_LABEL: 
    578                 #add_data_hint = "Load a data file and display it on this plot" 
    579                 #["Add P(r) data",add_data_hint , self._on_add_data], 
    580                 change_n_hint = "Change the number of" 
    581                 change_n_hint += " points on the P(r) output" 
    582                 change_n_label = "Change number of P(r) points" 
    583                 m_list = [[change_n_label, change_n_hint , self._on_pr_npts]] 
    584  
    585                 if self._scale_output_unity or self._normalize_output: 
    586                     hint = "Let the output P(r) keep the scale of the data" 
    587                     m_list.append(["Disable P(r) scaling", hint,  
    588                                    self._on_disable_scaling]) 
    589                 if not self._scale_output_unity: 
    590                     m_list.append(["Scale P_max(r) to unity",  
    591                                    "Scale P(r) so that its maximum is 1",  
    592                                    self._on_scale_unity]) 
    593                 if not self._normalize_output: 
    594                     m_list.append(["Normalize P(r) to unity",  
    595                                    "Normalize the integral of P(r) to 1",  
    596                                    self._on_normalize]) 
    597                      
    598                 return m_list 
    599                 #return [["Add P(r) data",  
    600                 #"Load a data file and display it on this plot", 
    601                 # self._on_add_data], 
    602                 #       ["Change number of P(r) points", 
    603                 # "Change the number of points on the P(r) output", 
    604                 # self._on_pr_npts]] 
    605  
    606             elif item.name == graph.selected_plottable: 
    607                     #TODO: we might want to check that the units are  
    608                     #     consistent with I(q) before allowing this menu item 
    609                 if not self.standalone and \ 
    610                 issubclass(item.__class__, DataLoader.data_info.Data1D): 
    611                     return [["Compute P(r)",  
     577        if graph.selected_plottable not in plotpanel.plots: 
     578            return [] 
     579        item = plotpanel.plots[graph.selected_plottable] 
     580        if item.id == PR_FIT_LABEL: 
     581            #add_data_hint = "Load a data file and display it on this plot" 
     582            #["Add P(r) data",add_data_hint , self._on_add_data], 
     583            change_n_hint = "Change the number of" 
     584            change_n_hint += " points on the P(r) output" 
     585            change_n_label = "Change number of P(r) points" 
     586            m_list = [[change_n_label, change_n_hint , self._on_pr_npts]] 
     587 
     588            if self._scale_output_unity or self._normalize_output: 
     589                hint = "Let the output P(r) keep the scale of the data" 
     590                m_list.append(["Disable P(r) scaling", hint,  
     591                               self._on_disable_scaling]) 
     592            if not self._scale_output_unity: 
     593                m_list.append(["Scale P_max(r) to unity",  
     594                               "Scale P(r) so that its maximum is 1",  
     595                               self._on_scale_unity]) 
     596            if not self._normalize_output: 
     597                m_list.append(["Normalize P(r) to unity",  
     598                               "Normalize the integral of P(r) to 1",  
     599                               self._on_normalize]) 
     600                 
     601            return m_list 
     602              
     603        elif item.id in [PR_LOADED_LABEL, IQ_DATA_LABEL, IQ_FIT_LABEL, 
     604                          IQ_SMEARED_LABEL]: 
     605            return [] 
     606        elif item.id == graph.selected_plottable: 
     607               if not self.standalone and issubclass(item.__class__, Data1D): 
     608                return [["Compute P(r)",  
    612609                             "Compute P(r) from distribution",  
    613610                             self._on_context_inversion]]       
     
    657654            y = self._added_plots[plot].y/sum 
    658655             
    659             new_plot = Theory1D(self._added_plots[plot].x, y) 
     656            new_plot = Data1D(self._added_plots[plot].x, y) 
     657            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
     658            index  = len(self._added_plots[plot].group_id) - 1 
     659            if group_id not in new_plot.group_id: 
     660                new_plot.group_id.append(group_id) 
     661            new_plot.id = self._added_plots[plot].id 
     662            new_plot.title = self._added_plots[plot].title 
    660663            new_plot.name = self._added_plots[plot].name 
    661664            new_plot.xaxis("\\rm{r}", 'A') 
     
    686689            y = self._added_plots[plot].y/_max 
    687690             
    688             new_plot = Theory1D(self._added_plots[plot].x, y) 
     691            new_plot = Data1D(self._added_plots[plot].x, y) 
     692            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    689693            new_plot.name = self._added_plots[plot].name 
    690694            new_plot.xaxis("\\rm{r}", 'A') 
     
    736740         
    737741        filename = os.path.basename(path) 
    738          
    739         #new_plot = Data1D(x, y, dy=err) 
    740         new_plot = Theory1D(x, y) 
     742 
     743        new_plot = Data1D(x, y) 
     744        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    741745        new_plot.name = filename 
    742746        new_plot.xaxis("\\rm{r}", 'A') 
     
    863867            new_plot.xaxis("\\rm{Q}", 'A^{-1}') 
    864868            new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
    865             #new_plot.group_id = "test group" 
     869            if pr.info.has_key("plot_group_id"): 
     870                new_plot.group_id.append(pr.info["plot_group_id"]) 
     871            new_plot.id = IQ_DATA_LABEL 
    866872            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq")) 
    867873                 
     
    884890         
    885891        """ 
    886         print "show_data", data.name 
    887892        #if path is not None: 
    888893        if data is not None: 
    889894            try: 
    890                 #pr = self._create_file_pr(path) 
    891895                pr = self._create_file_pr(data) 
    892896            except: 
     
    902906        
    903907        # Make a plot of I(q) data 
    904         if self.pr.err==None: 
    905             new_plot = Theory1D(self.pr.x, self.pr.y) 
     908        if self.pr.err == None: 
     909            new_plot = Data1D(self.pr.x, self.pr.y) 
     910            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    906911        else: 
    907912            new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err) 
     
    910915        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
    911916        new_plot.interactive = True 
    912         #new_plot.group_id = "test group" 
     917        new_plot.group_id.append(IQ_DATA_LABEL) 
     918        new_plot.id = IQ_DATA_LABEL 
     919        new_plot.title = "I(q)" 
    913920        wx.PostEvent(self.parent,  
    914921                     NewPlotEvent(plot=new_plot, title="I(q)", reset=reset)) 
    915922         
    916923        self.current_plottable = new_plot 
    917         self.current_plottable.group_id = IQ_DATA_LABEL 
    918          
    919          
    920924        # Get Q range 
    921925        self.control_panel.q_min = self.pr.x.min() 
     
    10211025        # Keep track of the plot window title to ensure that 
    10221026        # we can overlay the plots 
    1023         if hasattr(self.current_plottable, "group_id"): 
     1027        if self.current_plottable.group_id: 
     1028            index = len(self.current_plottable.group_id) - 1 
     1029            group_id = self.current_plottable.group_id[index] 
    10241030            pr.info["plot_group_id"] = self.current_plottable.group_id 
    10251031         
     
    13291335            if dlg.ShowModal() == wx.ID_OK: 
    13301336                data = dlg.get_data() 
    1331                 if issubclass(data.__class__, LoaderData1D): 
     1337                if issubclass(data.__class__, Data1D): 
    13321338                    self.control_panel._change_file(evt=None, data=data) 
    13331339                else:     
     
    13371343                             StatusEvent(status=msg, info='error')) 
    13381344        elif len(data_list) == 1: 
    1339             if issubclass(data_list[0].__class__, LoaderData1D): 
     1345            if issubclass(data_list[0].__class__, Data1D): 
    13401346                self.control_panel._change_file(evt=None, data=data_list[0]) 
    13411347            else: 
  • prview/perspectives/pr/pr_widgets.py

    raf91b68 ra07e72f  
    2727         
    2828        ## Set to True when the mouse is clicked while the whole string is selected 
    29         full_selection = False 
     29        self.full_selection = False 
    3030        ## Call back for EVT_SET_FOCUS events 
    3131        _on_set_focus_callback = None 
Note: See TracChangeset for help on using the changeset viewer.