Changeset d2ee6f6 in sasview


Ignore:
Timestamp:
May 26, 2009 8:46:49 PM (15 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:
1c8015f
Parents:
ee6f84c
Message:

prview: added setup script to install pr perspective as module. Modified perspective for use in SansView? (see standalone mode).

Location:
prview/perspectives/pr
Files:
2 edited

Legend:

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

    r5d98370 rd2ee6f6  
    207207            if self.standalone==False: 
    208208                self.plot_data.SetValue(str(value)) 
    209                 self.plot_radio.SetValue(True) 
    210209                self._on_pars_changed(None) 
    211210        elif name=='datafile': 
    212211            self.data_file.SetValue(str(value)) 
    213             self.file_radio.SetValue(True) 
    214212            self._on_pars_changed(None) 
    215213        else: 
     
    433431 
    434432        iy = 0 
    435         if self.standalone==False: 
    436             self.file_radio = wx.RadioButton(self, -1, "File data:") 
     433        self.file_radio = wx.StaticText(self, -1, "Data:") 
     434        pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     435         
     436        if self.standalone==True: 
     437            self.data_file = wx.TextCtrl(self, -1, size=(220,20)) 
     438            self.data_file.SetEditable(False) 
     439            self.data_file.SetValue("") 
     440            pars_sizer.Add(self.data_file, (iy,1), (1,1), wx.ADJUST_MINSIZE, 15) 
    437441        else: 
    438             self.file_radio = wx.StaticText(self, -1, "Data file:") 
    439         self.data_file = wx.TextCtrl(self, -1, size=(220,20)) 
    440         self.data_file.SetEditable(False) 
    441         self.data_file.SetValue("") 
    442         id = wx.NewId() 
    443         pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    444         pars_sizer.Add(self.data_file, (iy,1), (1,1), wx.ADJUST_MINSIZE, 15) 
    445          
    446         if self.standalone==False: 
    447             iy += 1 
    448             self.plot_radio = wx.RadioButton(self, -1, "Plot data:") 
    449             self.plot_data = wx.TextCtrl(self, -1, size=(100,20)) 
     442            self.plot_data = wx.TextCtrl(self, -1, size=(220,20)) 
    450443            self.plot_data.SetEditable(False) 
    451             pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    452444            pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    453445         
     
    788780            self.alpha_estimate_ctl.Enable(False) 
    789781             
    790             if self.standalone==False and self.plot_radio.GetValue(): 
     782            if self.standalone==False: 
    791783                dataset = self.plot_data.GetValue() 
    792784                self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc,  
     
    923915         
    924916        if flag: 
    925             if self.standalone==False and self.plot_radio.GetValue(): 
     917            if self.standalone==False: 
    926918                dataset = self.plot_data.GetValue() 
    927919                if len(dataset.strip())==0: 
     
    962954            if path and os.path.isfile(path): 
    963955                self.data_file.SetValue(str(path)) 
    964                 if self.standalone==False: 
    965                     self.file_radio.SetValue(True) 
    966956                self.manager.show_data(path, reset=True) 
    967957                self._on_pars_changed(None) 
  • prview/perspectives/pr/pr.py

    r6f1f129 rd2ee6f6  
    2929    DEFAULT_DMAX  = 140.0 
    3030     
    31     def __init__(self): 
     31    def __init__(self, standalone=True): 
    3232        ## Plug-in name 
    3333        self.sub_menu = "Pr inversion" 
     
    7777        self._pr_npts = 51 
    7878        ## Flag to let the plug-in know that it is running standalone 
    79         self.standalone = True 
     79        self.standalone = standalone 
    8080        self._normalize_output = False 
    8181        self._scale_output_unity = False 
     
    257257        new_plot.xaxis("\\rm{Q}", 'A^{-1}') 
    258258        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
    259         #new_plot.group_id = "test group" 
    260         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="I(q)")) 
     259         
     260        title = "I(q)" 
     261        # If we have a group ID, use it 
     262        if pr.info.has_key("plot_group_id"): 
     263            new_plot.group_id = pr.info["plot_group_id"] 
     264            title = pr.info["plot_group_id"] 
     265             
     266        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    261267         
    262268        # If we have used slit smearing, plot the smeared I(q) too 
     
    342348        new_plot.xaxis("\\rm{r}", 'A') 
    343349        new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 
    344              
     350        # Make sure that the plot is linear 
     351        new_plot.xtransform="x" 
     352        new_plot.ytransform="y"                  
    345353        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="P(r) fit")) 
    346354         
     
    538546 
    539547            elif item.name==graph.selected_plottable: 
     548                    #TODO: we might want to check that the units are consistent with I(q) 
     549                    #      before allowing this menu item 
    540550                return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]]       
    541551                 
     
    876886        pr.slit_width = self.slit_width 
    877887         
     888        # Keep track of the plot window title to ensure that 
     889        # we can overlay the plots 
     890        if hasattr(self.current_plottable, "group_id"): 
     891            pr.info["plot_group_id"] = self.current_plottable.group_id 
     892         
    878893        # Fill in errors if none were provided 
    879         if self.current_plottable.dy == None: 
    880             print "no error", self.current_plottable.name 
    881             y = numpy.zeros(len(pr.y)) 
     894        err = self.current_plottable.dy 
     895        all_zeros = True 
     896        if err == None: 
     897            err = numpy.zeros(len(y))  
     898        else:     
     899            for i in range(len(err)): 
     900                if err[i]>0: 
     901                    all_zeros = False 
     902         
     903        if all_zeros:         
     904            scale = None 
     905            min_err = 0.0 
    882906            for i in range(len(pr.y)): 
    883                 y[i] = math.sqrt(pr.y[i]) 
    884             pr.err = y 
    885         else: 
    886             pr.err = self.current_plottable.dy 
    887          
    888         #self.pr = pr 
     907                # Scale the error so that we can fit over several decades of Q 
     908                if scale==None: 
     909                    scale = 0.05*math.sqrt(pr.y[i]) 
     910                    min_err = 0.01*pr.y[i] 
     911                err[i] = scale*math.sqrt( math.fabs(pr.y[i]) ) + min_err 
     912            message = "The loaded file had no error bars, statistical errors are assumed." 
     913            wx.PostEvent(self.parent, StatusEvent(status=message)) 
     914 
     915        pr.err = err 
     916         
    889917        return pr 
    890918 
     
    11601188            [Somehow openGL needs this call] 
    11611189        """ 
    1162         self.parent.set_perspective(self.perspective) 
     1190        if self.standalone==True: 
     1191            self.parent.set_perspective(self.perspective) 
    11631192   
    11641193if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.