Changeset fdb134b9 in sasview for calculatorview


Ignore:
Timestamp:
Jan 20, 2013 10:50:50 AM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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:
a30864b1
Parents:
afcb052
Message:

added bonding lines for pdb data if provided

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py

    rafd45674 rfdb134b9  
    622622        Draw 3D sld profile 
    623623        """ 
    624         color_dic = {'H':'blue', 'D':'purple', 'N': 'orange',  
    625                      'O':'red', 'C':'green', 'P':'cyan', 'Other':'k'} 
    626624        graph_title = self.file_name 
    627625        graph_title += "   3D SLD Profile " 
     
    644642        frame.Show(False) 
    645643        add_icon(self.parent, frame) 
    646         panel = frame.plotpanel 
    647          
     644        panel = frame.plotpanel     
    648645        try: 
    649646            # mpl >= 1.0.0 
     
    658655                raise 
    659656        panel.dimension = 3    
     657        self._sld_plot_helper(ax, output, has_arrow) 
     658        # Use y, z axes (in mpl 3d) as z, y axes  
     659        # that consistent with our SANS detector coords. 
     660        ax.set_xlabel('x ($\A%s$)'% output.pos_unit) 
     661        ax.set_ylabel('z ($\A%s$)'% output.pos_unit) 
     662        ax.set_zlabel('y ($\A%s$)'% output.pos_unit) 
     663        panel.subplot.figure.subplots_adjust(left=0.05, right=0.95,  
     664                                             bottom=0.05, top=0.96) 
     665        if output.pix_type == 'atom': 
     666            ax.legend(loc='upper left', prop={'size':10}) 
     667        num_graph = str(self.graph_num) 
     668        frame.SetTitle('Graph %s: %s'% (num_graph, graph_title))         
     669        wx.CallAfter(frame.Show, True) 
     670        self.graph_num += 1 
     671 
     672    def _sld_plot_helper(self, ax, output, has_arrow=False): 
     673        """ 
     674        Actual plot definition happens here 
     675        :Param ax: axis3d 
     676        :Param output: sld_data [MagSLD] 
     677        :Param has_arrow: whether or not draws M vector [bool] 
     678        """ 
     679        # Set the locals 
     680        color_dic = {'H':'blue', 'D':'purple', 'N': 'orange',  
     681                     'O':'red', 'C':'green', 'P':'cyan', 'Other':'k'} 
    660682        marker = ',' 
    661683        m_size = 2 
    662         if output.pix_type == 'atom': 
    663             marker = 'o' 
    664             m_size = 3.5 
    665684        pos_x = output.pos_x 
    666685        pos_y = output.pos_y 
     
    670689        sld_mz = output.sld_mz  
    671690        pix_symbol = output.pix_symbol  
    672  
    673         sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) +  
     691        if output.pix_type == 'atom': 
     692            marker = 'o' 
     693            m_size = 3.5 
     694        sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 
    674695                   numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 
    675696        is_nonzero = sld_tot > 0.0   
    676         is_zero = sld_tot == 0.0   
    677          
    678         # Plot null points 
     697        is_zero = sld_tot == 0.0    
     698        # I. Plot null points 
    679699        if is_zero.any(): 
    680700            ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker,  
    681                         c="y", alpha=0.5, markeredgecolor='y',  
    682                         markersize=m_size)  
     701                    c="y", alpha=0.5, markeredgecolor='y', markersize=m_size)  
    683702            pos_x = pos_x[is_nonzero] 
    684703            pos_y = pos_y[is_nonzero] 
     
    688707            sld_mz = sld_mz[is_nonzero] 
    689708            pix_symbol = output.pix_symbol[is_nonzero] 
    690         # Plot selective points in color 
     709        # II. Plot selective points in color 
    691710        other_color = numpy.ones(len(pix_symbol), dtype='bool') 
    692711        for key in color_dic.keys(): 
     
    698717                        pos_y[chosen_color], marker, c=color, alpha=0.5,  
    699718                        markeredgecolor=color, markersize=m_size, label=key)  
    700         # Plot All others         
     719        # III. Plot All others         
    701720        if numpy.any(other_color): 
     721            a_name = '' 
     722            if output.pix_type == 'atom': 
     723                # Get atom names not in the list 
     724                a_names = [symb  for symb in pix_symbol \ 
     725                           if symb not in color_dic.keys()] 
     726                a_name = a_names[0] 
     727                for name in a_names: 
     728                    new_name = ", " + name 
     729                    if a_name.count(new_name) == 0 and a_name != name: 
     730                        a_name += new_name 
     731            # plot in black 
    702732            ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color],  
    703733                    marker, c="k", alpha=0.5, markeredgecolor="k",  
    704                     markersize=m_size, label="Other")  
    705          
     734                    markersize=m_size, label=a_name)  
     735        # IV. Draws atomic bond with grey lines if any 
     736        if output.has_conect: 
     737            ax.plot(output.line_x, output.line_z, output.line_y, '-',  
     738                    lw=0.6, c="grey", alpha=0.3) 
     739        # V. Draws magnetic vectors 
    706740        if has_arrow and len(pos_x) > 0:      
    707741            graph_title += "w/ Arrows"  
    708742            def _draw_arrow(input=None, elapsed=0.1): 
    709743                """ 
    710                 draw w/arrow 
     744                draw magnetic vectors w/arrow 
    711745                """ 
    712746                max_mx = max(numpy.fabs(sld_mx)) 
     
    736770                        y_arrow = numpy.column_stack((pos_y, y2)) 
    737771                        z_arrow = numpy.column_stack((pos_z, z2)) 
    738                         colors =  numpy.column_stack((color_x,  
    739                                                       color_y, 
    740                                                       color_z)) 
    741                          
     772                        colors = numpy.column_stack((color_x, color_y, color_z)) 
    742773                        arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow,  
    743                                                   colors,  
    744                                                   mutation_scale=10, lw=1,  
    745                                                   arrowstyle="->", alpha = 0.5) 
     774                                        colors, mutation_scale=10, lw=1,  
     775                                        arrowstyle="->", alpha = 0.5) 
    746776                        ax.add_artist(arrows)  
    747777                except: 
     
    750780                status_type = 'stop' 
    751781                self._status_info(msg, status_type)  
    752             msg = "Arrow Drawing is in progress..." 
    753              
    754             status_type = 'progress' 
    755             self._status_info(msg, status_type)  
    756             draw_out = CalcGen(input=ax, 
    757                              completefn=_draw_arrow, updatefn=self._update) 
    758             draw_out.queue() 
    759  
    760         panel.subplot.figure.subplots_adjust(left=0.05, right=0.95,  
    761                                              bottom=0.05, top=0.96) 
    762         # Use y, z axes (in mpl 3d) as z, y axes  
    763         # that consistent with SANS coords. 
    764         ax.set_xlabel('x ($\A%s$)'% output.pos_unit) 
    765         ax.set_ylabel('z ($\A%s$)'% output.pos_unit) 
    766         ax.set_zlabel('y ($\A%s$)'% output.pos_unit) 
    767         if output.pix_type == 'atom': 
    768             ax.legend(loc='upper left', prop={'size':10}) 
    769         num_graph = str(self.graph_num) 
    770         frame.SetTitle('Graph %s: %s'% (num_graph, graph_title))         
    771         wx.CallAfter(frame.Show, True) 
    772         self.graph_num += 1 
    773          
     782  
    774783    def set_input_params(self): 
    775784        """ 
Note: See TracChangeset for help on using the changeset viewer.