Changeset 660b1e6 in sasview for prview/perspectives/pr


Ignore:
Timestamp:
Jun 11, 2008 8:32:21 AM (17 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:
de9483d
Parents:
38fc601
Message:

Loaded data is now shown before hitting the inversion button.

Location:
prview/perspectives/pr
Files:
3 edited

Legend:

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

    rfc4ab6e r660b1e6  
    571571                self.file_radio.SetValue(True) 
    572572                self._on_pars_changed(None) 
     573                self.manager.show_data(path) 
    573574         
    574575 
  • prview/perspectives/pr/pr.py

    r4a5de6f r660b1e6  
    227227            else: 
    228228                (value, dy[i]) = pr.pr_err(out, cov2, x[i]) 
    229             sum += value 
     229            sum += value*pr.d_max/len(x) 
    230230            y[i] = value 
    231231             
    232         y = y/sum*pr.d_max/len(x) 
    233         dy = dy/sum*pr.d_max/len(x) 
     232        y = y/sum 
     233        dy = dy/sum 
    234234         
    235235        if cov2==None: 
     
    292292            return 0.0 
    293293 
    294     def get_context_menu(self, plot_id=None): 
     294    def get_context_menu(self, graph=None): 
    295295        """ 
    296296            Get the context menu items available for P(r) 
    297             @param plot_id: Unique ID of a plot, so that we can recognize those 
    298                             that we created 
     297            @param graph: the Graph object to which we attach the context menu 
    299298            @return: a list of menu items with call-back function 
    300299        """ 
     300        # Look whether this Graph contains P(r) data 
     301        for item in graph.plottables: 
     302            if item.name=="P_{fit}(r)": 
     303                 
     304                return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion], 
     305                       ["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data]] 
     306                 
    301307        return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]] 
    302      
     308 
     309    def _on_add_data(self, evt): 
     310        """ 
     311            Add a data curve to the plot 
     312            WARNING: this will be removed once guiframe.plotting has its full functionality 
     313        """ 
     314        path = self.choose_file() 
     315        if path==None: 
     316            return 
     317         
     318        x, y, err = self.parent.load_ascii_1D(path) 
     319         
     320        new_plot = Data1D(x, y, dy=err) 
     321        new_plot.name = "P_{loaded}(r)" 
     322        new_plot.xaxis("\\rm{r}", 'A') 
     323        new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 
     324             
     325        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="P(r) fit")) 
     326         
     327         
    303328 
    304329    def start_thread(self): 
     
    380405        # Popup result panel 
    381406        #result_panel = InversionResults(self.parent, -1, style=wx.RAISED_BORDER) 
     407         
     408    def show_data(self, path=None): 
     409        if not path==None: 
     410            self._create_file_pr(path)   
     411               
     412        # Make a plot of I(q) data 
     413        new_plot = Data1D(self.pr.x, self.pr.y, self.pr.err) 
     414        new_plot.name = "I_{obs}(q)" 
     415        new_plot.xaxis("\\rm{Q}", 'A^{-1}') 
     416        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
     417        #new_plot.group_id = "test group" 
     418        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq")) 
     419         
    382420         
    383421    def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None): 
     
    540578         
    541579         
    542            
    543580           
    544581    def _on_context_inversion(self, event): 
  • prview/perspectives/pr/requirements.txt

    r4a5de6f r660b1e6  
    272723. Plot I(q) immediately when you choose a new file. 
    282824. *** probably need to ship the perspectives separately... 
     2925. If no data is available, disable the Fit button. 
Note: See TracChangeset for help on using the changeset viewer.