Changeset fdb134b9 in sasview for calculatorview/src/sans/perspectives/calculator
- Timestamp:
- Jan 20, 2013 10:50:50 AM (12 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py
rafd45674 rfdb134b9 622 622 Draw 3D sld profile 623 623 """ 624 color_dic = {'H':'blue', 'D':'purple', 'N': 'orange',625 'O':'red', 'C':'green', 'P':'cyan', 'Other':'k'}626 624 graph_title = self.file_name 627 625 graph_title += " 3D SLD Profile " … … 644 642 frame.Show(False) 645 643 add_icon(self.parent, frame) 646 panel = frame.plotpanel 647 644 panel = frame.plotpanel 648 645 try: 649 646 # mpl >= 1.0.0 … … 658 655 raise 659 656 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'} 660 682 marker = ',' 661 683 m_size = 2 662 if output.pix_type == 'atom':663 marker = 'o'664 m_size = 3.5665 684 pos_x = output.pos_x 666 685 pos_y = output.pos_y … … 670 689 sld_mz = output.sld_mz 671 690 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) + \ 674 695 numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 675 696 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 679 699 if is_zero.any(): 680 700 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) 683 702 pos_x = pos_x[is_nonzero] 684 703 pos_y = pos_y[is_nonzero] … … 688 707 sld_mz = sld_mz[is_nonzero] 689 708 pix_symbol = output.pix_symbol[is_nonzero] 690 # Plot selective points in color709 # II. Plot selective points in color 691 710 other_color = numpy.ones(len(pix_symbol), dtype='bool') 692 711 for key in color_dic.keys(): … … 698 717 pos_y[chosen_color], marker, c=color, alpha=0.5, 699 718 markeredgecolor=color, markersize=m_size, label=key) 700 # Plot All others719 # III. Plot All others 701 720 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 702 732 ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color], 703 733 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 706 740 if has_arrow and len(pos_x) > 0: 707 741 graph_title += "w/ Arrows" 708 742 def _draw_arrow(input=None, elapsed=0.1): 709 743 """ 710 draw w/arrow744 draw magnetic vectors w/arrow 711 745 """ 712 746 max_mx = max(numpy.fabs(sld_mx)) … … 736 770 y_arrow = numpy.column_stack((pos_y, y2)) 737 771 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)) 742 773 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) 746 776 ax.add_artist(arrows) 747 777 except: … … 750 780 status_type = 'stop' 751 781 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 774 783 def set_input_params(self): 775 784 """
Note: See TracChangeset
for help on using the changeset viewer.