Changeset 077207b in sasview
- Timestamp:
- Jan 4, 2013 9:30:31 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:
- d7b6913
- Parents:
- ab7e3a4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py
rdbc5dc9b r077207b 20 20 21 21 from data_util.calcthread import CalcThread 22 #from sans.guiframe.local_perspectives.plotting.Plotter2D import ModelPanel2D \23 # as PlotPanel24 #from danse.common.plottools.PlotPanel import PlotPanel25 #from danse.common.plottools.SimplePlot import PlotFrame26 22 from sans.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame 27 #from danse.common.plottools.plottables import Graph28 23 from sans.guiframe.dataFitting import Data2D 29 #from sans.guiframe.utils import PanelMenu30 24 from sans.dataloader.data_info import Detector 31 25 from sans.dataloader.data_info import Source … … 38 32 from wx.lib.scrolledpanel import ScrolledPanel 39 33 from sans.perspectives.calculator.load_thread import GenReader 40 #import matplotlib.pyplot as plt41 34 from danse.common.plottools.arrow3d import Arrow3D 42 #from danse.common.plottools.toolbar import NavigationToolBar 35 43 36 _BOX_WIDTH = 76 44 37 #Slit length panel size … … 51 44 PANEL_HEIGHT = 370 52 45 FONT_VARIANT = 1 53 _QMAX_DEFAULT = 0. 146 _QMAX_DEFAULT = 0.3 54 47 _NPTS_DEFAULT = 50 55 48 … … 434 427 for type in omf_type: 435 428 wildcard.append(type) 436 #for type in pdb_type:437 #wildcard.append(type)429 for type in pdb_type: 430 wildcard.append(type) 438 431 wildcard = '|'.join(wildcard) 439 432 dlg = wx.FileDialog(self, "Choose a file", location, … … 474 467 if self.reader is not None and self.reader.isrunning(): 475 468 self.reader.stop() 469 self.browse_button.Enable(False) 470 self.browse_button.SetLabel("Loading...") 476 471 if self.parent.parent is not None: 477 472 wx.PostEvent(self.parent.parent, … … 482 477 updatefn=self.load_update) 483 478 self.reader.queue() 484 self.load_update()479 #self.load_update() 485 480 except: 486 481 self.ext = None … … 496 491 """ 497 492 print update on the status bar 498 """ 493 """ 499 494 if self.parent.parent is None: 500 495 return … … 511 506 """ 512 507 #compute the slit size 508 self.browse_button.Enable(True) 509 self.browse_button.SetLabel('Load') 513 510 try: 514 511 filename = data.filename … … 529 526 self._set_sld_data_helper(True) 530 527 except: 531 #raise532 528 if self.parent.parent is None: 533 r eturn529 raise 534 530 msg = "Loading Error: This file format is not supported " 535 531 msg += "for GenSANS." … … 540 536 if self.parent.parent is None: 541 537 return 538 542 539 msg = "Load Complete" 543 540 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) … … 619 616 is_zero = sld_tot == 0.0 620 617 if is_zero.any(): 621 ax.plot(pos_x[is_zero], pos_ y[is_zero], pos_z[is_zero], marker,618 ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker, 622 619 c="y", alpha=0.5, markeredgecolor='y', 623 620 markersize=m_size) … … 629 626 sld_mz = sld_mz[is_nonzero] 630 627 631 ax.plot(pos_x, pos_ y,632 pos_z,marker, c="k",628 ax.plot(pos_x, pos_z, pos_y, 629 marker, c="k", 633 630 alpha=0.5, markeredgecolor="k", markersize=m_size) 634 631 … … 671 668 color_z)) 672 669 673 arrows = Arrow3D(panel, x_arrow, y_arrow,674 z_arrow,colors,670 arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 671 colors, 675 672 mutation_scale=10, lw=1, 676 673 arrowstyle="->", alpha = 0.5) … … 692 689 panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 693 690 bottom=0.05, top=0.96) 691 # Use y, z axes (in mpl 3d) as z, y axes 692 # that consistent with SANS coords. 694 693 ax.set_xlabel('x ($\A%s$)'% output.pos_unit) 695 ax.set_ylabel(' y($\A%s$)'% output.pos_unit)696 ax.set_zlabel(' z($\A%s$)'% output.pos_unit)694 ax.set_ylabel('z ($\A%s$)'% output.pos_unit) 695 ax.set_zlabel('y ($\A%s$)'% output.pos_unit) 697 696 num_graph = str(self.graph_num) 698 697 frame.SetTitle('Graph %s: %s'% (num_graph, graph_title)) … … 1137 1136 1138 1137 self.npixels_sizer = wx.BoxSizer(wx.HORIZONTAL) 1139 self.box_sld = wx.StaticBox(self, -1, str("Mean SLD")) 1138 self.box_sld = wx.StaticBox(self, -1, 1139 str("Scattering Length (Density)")) 1140 1140 self.box_node = wx.StaticBox(self, -1, str("Nodes")) 1141 1141 self.boxsizer_sld = wx.StaticBoxSizer(self.box_sld, wx.VERTICAL) … … 1360 1360 def set_sld_ctr(self, sld_data): 1361 1361 """ 1362 Set sld textctrls 1362 1363 """ 1363 1364 if sld_data == None: … … 1375 1376 max_val = numpy.max(sld_list[key]) 1376 1377 mean_val = numpy.mean(sld_list[key]) 1377 enable = (min_val == max_val) 1378 enable = (min_val == max_val) and \ 1379 sld_data.pix_type == 'pixel' 1378 1380 ctr_list[1].SetValue(format_number(mean_val, True)) 1379 1381 ctr_list[1].Enable(enable) -
calculatorview/src/sans/perspectives/calculator/media/gen_sans_help.html
r318b5bbb r077207b 112 112 </p> 113 113 <br> 114 *Note: The values of 'Up_frac_i' and 'Up_frac_f' must be in the range between 0 and 1. 114 *Note I: The values of 'Up_frac_i' and 'Up_frac_f' must be in the range between 0 and 1. 115 For example, both values are 0.5 for unpolarized neutrons. 116 <br> 117 *Note II: The unit of intensity calculated from .sld, .omf, or .txt files is 1/cm, otherwise 118 it is Å<sup>2</sup>. (In the first equation above, the V is set to 1.) 119 <br> 120 *Note III: This computation is totally based on the pixel (or atomic) data fixed 121 in the xyz coordinates. Thus no angular orientational averaging is considered. 122 <br> 123 *Note IV: For the neutron scattering length density, only the its real component is taken account. 115 124 </body> -
sanscalculator/src/sans/calculator/sans_gen.py
rab7e3a4 r077207b 4 4 from sans.models.BaseComponent import BaseComponent 5 5 import sans.models.sans_extension.sld2i as mod 6 from periodictable import formula 6 7 import numpy 7 8 import os … … 54 55 self.params['scale'] = 1.0 55 56 self.params['background'] = 0.0 56 self.params['Up_frac_i'] = 1.057 self.params['Up_frac_f'] = 1.057 self.params['Up_frac_i'] = 0.5 58 self.params['Up_frac_f'] = 0.5 58 59 self.params['Up_theta'] = 0.0 59 60 self.description='GenSAS' … … 440 441 ## List of allowed extensions 441 442 ext = ['.pdb', '.PDB'] 442 443 443 444 def read(self, path): 444 445 """ … … 458 459 sld_my = numpy.zeros(0) 459 460 sld_mz = numpy.zeros(0) 460 pix_symbol = numpy.zeros(0) #numpy.array([])461 pix_symbol = numpy.zeros(0) 461 462 try: 462 463 input_f = open(path, 'rb') 463 464 buff = input_f.read() 464 #buff.replace(' ', '')465 465 lines = buff.split('\n') 466 466 input_f.close() 467 467 for line in lines: 468 468 try: 469 toks = line.split()469 #toks = line.split() 470 470 # check if line starts with "ATOM" 471 if toks[0].count('ATM') > 0 or toks[0] == 'ATOM': 471 if line[0:6].strip().count('ATM') > 0 or \ 472 line[0:6].strip() == 'ATOM': 472 473 # define fields of interest 473 atom_id = toks[1] 474 atom_name = toks[2] 475 if line[12] == '' or len(atom_name) == 4: 476 atom_name = atom_name[0].upper() 477 else: 478 atom_name = atom_name[0].upper() + \ 479 atom_name[1].lower() 474 atom_id = line[6:11].strip() 475 atom_name = line[12:16].strip() 480 476 try: 481 float( toks[3])482 ind = 3477 float(line[12]) 478 atom_name = atom_name[1].upper() 483 479 except: 484 ind = 4 485 res_name = toks[ind] 486 #chain_name = toks[3].strip() 487 #residue_id = toks[4].strip() 488 try: 489 float(toks[4]) 490 except: 491 ind += 1 492 ind += 1 493 _pos_x = float(toks[ind]) 494 ind += 1 495 _pos_y = float(toks[ind]) 496 ind += 1 497 _pos_z = float(toks[ind]) 480 if len(atom_name) == 4: 481 atom_name = atom_name[0].upper() 482 elif line[12] != ' ': 483 atom_name = atom_name[0].upper() + \ 484 atom_name[1].lower() 485 else: 486 atom_name = atom_name[0].upper() 487 #res_name = line[17:20].strip() 488 #chain_name = line[21:22].strip() 489 _pos_x = float(line[30:38].strip()) 490 _pos_y = float(line[38:46].strip()) 491 _pos_z = float(line[46:54].strip()) 492 498 493 pos_x = numpy.append(pos_x, _pos_x) 499 494 pos_y = numpy.append(pos_y, _pos_y) 500 495 pos_z = numpy.append(pos_z, _pos_z) 501 sld_n = numpy.append(sld_n, 7e-06) 496 try: 497 #from periodictable import nsf 498 #val = nsf.neutron_sld(atom_name) 499 val = formula(atom_name).atoms.keys()[0].neutron.b_c 500 # sld in Ang unit (from fm) 501 val = float(val) 502 val *= 1.0e-5 503 sld_n = numpy.append(sld_n, val) 504 except: 505 print "Error: set the sld of %s to zero"% atom_name 506 sld_n = numpy.append(sld_n, 0.0) 502 507 sld_mx = numpy.append(sld_mx, 0) 503 508 sld_my = numpy.append(sld_my, 0) … … 883 888 self.ynodes = None 884 889 self.znodes = None 885 890 886 891 def set_stepsize(self): 887 892 """
Note: See TracChangeset
for help on using the changeset viewer.