Changeset 3657667 in sasview
- Timestamp:
- Jan 12, 2013 2:45:21 PM (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:
- 5917637
- Parents:
- 3540156
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py
r3540156 r3657667 131 131 self.file_name = '' 132 132 self.time_text = None 133 self.orient_combo = None 133 134 self.omfreader = sans_gen.OMFReader() 134 135 self.sldreader = sans_gen.SLDReader() … … 290 291 self.parent.set_omfpanel_default_shap(self.default_shape) 291 292 self.parent.set_omfpanel_npts() 293 294 def _fill_orient_combo(self): 295 """ 296 Fill up the orientation combo box: used only for atomic structure 297 """ 298 orient_combo = wx.ComboBox(self, -1, size=(150, -1), 299 style=wx.CB_READONLY) 300 orient_combo.Append('Fixed orientation') 301 orient_combo.Append('No orientation ') 302 303 orient_combo.Bind(wx.EVT_COMBOBOX, self._on_orient_select) 304 orient_combo.SetSelection(0) 305 return orient_combo 306 307 def _on_orient_select(self, event): 308 """ 309 On selecting a orientation 310 """ 311 event.Skip() 312 cb = event.GetEventObject() 313 is_avg = cb.GetCurrentSelection() == 1 314 self.model.set_is_avg(is_avg) 292 315 293 316 def _layout_qrange(self): … … 339 362 self.est_time = '*Estimated Computation time : %s sec' 340 363 self.time_text = wx.StaticText(self, -1, self.est_time% str(2) ) 364 self.orient_combo = self._fill_orient_combo() 365 self.orient_combo.Show(False) 341 366 self.bt_compute = wx.Button(self, wx.NewId(),'Compute') 342 367 self.bt_compute.Bind(wx.EVT_BUTTON, self.on_compute) 343 368 self.bt_compute.SetToolTipString("Compute 2D Scattering Pattern.") 344 369 self.button_sizer.AddMany([(self.time_text , 0, wx.LEFT, 20), 345 (self.bt_compute, 0, wx.LEFT, 190)]) 370 (self.orient_combo , 0, wx.LEFT, 20), 371 (self.bt_compute, 0, wx.LEFT, 20)]) 346 372 347 373 def estimate_ctime(self): 348 374 """ 375 Calculation time estimation 349 376 """ 350 377 n_qbins = float(self.npt_ctl.GetValue()) … … 366 393 def _do_layout(self): 367 394 """ 368 395 Draw window content 369 396 """ 370 397 self._define_structure() … … 513 540 self.data_name_tcl.SetValue(str(filename)) 514 541 self.file_name = filename.split('.')[0] 542 self.orient_combo.SetSelection(0) 515 543 if self.ext in self.omfreader.ext: 516 544 gen = sans_gen.OMF2SLD() … … 526 554 else: 527 555 raise 556 self.orient_combo.Show(is_pdbdata) 557 self.button_sizer.Layout() 528 558 self._set_sld_data_helper(True) 529 559 except: … … 547 577 Set sld data helper 548 578 """ 579 is_avg = self.orient_combo.GetCurrentSelection() == 1 580 self.model.set_is_avg(is_avg) 549 581 self.model.set_sld_data(self.sld_data) 550 582 self.draw_button.Enable(self.sld_data!=None) … … 606 638 marker = ',' 607 639 m_size = 2 608 if output.pix_type != 'pixel':640 if output.pix_type == 'atom': 609 641 marker = 'o' 610 m_size = 2642 m_size = 3.5 611 643 pos_x = output.pos_x 612 644 pos_y = output.pos_y … … 614 646 sld_mx = output.sld_mx 615 647 sld_my = output.sld_my 616 sld_mz = output.sld_mz 648 sld_mz = output.sld_mz 649 pix_symbol = output.pix_symbol 617 650 618 651 sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + … … 632 665 sld_my = sld_my[is_nonzero] 633 666 sld_mz = sld_mz[is_nonzero] 634 667 pix_symbol = output.pix_symbol[is_nonzero] 635 668 # Plot selective points in color 636 other_color = numpy.ones(len( output.pix_symbol), dtype='bool')669 other_color = numpy.ones(len(pix_symbol), dtype='bool') 637 670 for key in color_dic.keys(): 638 chosen_color = output.pix_symbol == key671 chosen_color = pix_symbol == key 639 672 if numpy.any(chosen_color): 640 673 other_color = other_color & (chosen_color != True) … … 1574 1607 """ 1575 1608 def __init__(self, parent=None, title="Generic Scattering Calculator", 1576 size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.5 5), *args, **kwds):1609 size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.57), *args, **kwds): 1577 1610 """ 1578 1611 Init -
calculatorview/src/sans/perspectives/calculator/media/gen_sans_help.html
rdbc01f2 r3657667 25 25 </p> 26 26 <br> 27 for β<sub>j</sub> ≠ 0 where v<sub>j</sub> is the volume of the j'th pixel. 27 for β<sub>j</sub> ≠ 0 where v<sub>j</sub> is the volume of the j'th pixel 28 (or the j'th natural atomic volume (= atomic mass/natural molar density/Abogadro number) 29 for the atomic structures given by a pdb file). 28 30 <br> 29 31 The scattering length density (SLD) of each pixel where the SLD is uniform, is a combination of the nuclear and magnetic SLDs -
sanscalculator/src/sans/calculator/sans_gen.py
r3540156 r3657667 8 8 import numpy 9 9 import os 10 import copy 10 11 11 12 MFactor_AM = 2.853E-12 … … 52 53 self.data_mz = None 53 54 self.data_vol = None #[A^3] 55 self.is_avg = False 54 56 ## Name of the model 55 57 self.name = "GenSAS" … … 58 60 self.params['scale'] = 1.0 59 61 self.params['background'] = 0.0 62 self.params['solvent_SLD'] = 0.0 60 63 self.params['Up_frac_in'] = 0.5 61 64 self.params['Up_frac_out'] = 0.5 … … 66 69 self.details['scale'] = ['', None, None] 67 70 self.details['background'] = ['[1/cm]', None, None] 71 self.details['solvent_SLD'] = ['1/A^(2)', None, None] 68 72 self.details['Up_frac_in'] = ['[u/(u+d)]', None, None] 69 73 self.details['Up_frac_out'] = ['[u/(u+d)]', None, None] … … 80 84 raise 81 85 self.data_vol = volume 82 86 87 def set_is_avg(self, is_avg=False): 88 """ 89 Sets is_avg: [bool] 90 """ 91 self.is_avg = is_avg 92 83 93 def _gen(self, x, y, i): 84 94 """ … … 90 100 """ 91 101 len_x = len(self.data_x) 102 if self.is_avg: 103 len_x *= -1 92 104 len_q = len(x) 105 sldn = copy.deepcopy(self.data_sldn) 106 sldn -= self.params['solvent_SLD'] 93 107 model = mod.new_GenI(len_x, self.data_x, self.data_y, self.data_z, 94 s elf.data_sldn, self.data_mx, self.data_my,108 sldn, self.data_mx, self.data_my, 95 109 self.data_mz, self.data_vol, 96 110 self.params['Up_frac_in'], -
sansmodels/src/c_gen/sld2i.cpp
rb1174ec r3657667 53 53 */ 54 54 void GenI :: genicom(int npoints, double *qx, double *qy, double *I_out){ 55 //npoints is given negative for angular averaging 55 56 // Assumes that q doesn't have qz component and sld_n is all real 56 57 double q = 0.0; 58 int is_avg = 0; 57 59 //double Pi = 4.0*atan(1.0); 58 60 polar_sld b_sld; … … 69 71 70 72 double count = 0.0; 73 //check if this computation is for averaging 74 if (n_pix < 0 ){ 75 is_avg = 1; 76 n_pix = fabs(n_pix); 77 } 71 78 //Assume that pixel volumes are given in vol_pix in A^3 unit 72 79 //int x_size = 0; //in Ang … … 93 100 mx_val[j], my_val[j], mz_val[j], 94 101 inspin, outspin, stheta); 95 qr = (qx[i]*x_val[j] + qy[i]*y_val[j]); 96 iqr = cassign(0.0, qr); 97 ephase = cplx_exp(iqr); 102 if (is_avg < 1){ 103 //anisotropic 104 qr = (qx[i]*x_val[j] + qy[i]*y_val[j]); 105 iqr = cassign(0.0, qr); 106 ephase = cplx_exp(iqr); 107 } 108 else{ 109 //isotropic 110 qr = sqrt(x_val[j]*x_val[j]+y_val[j]*y_val[j]+z_val[j]*z_val[j]); 111 qr *= q; 112 if (qr == 0.0){ 113 ephase = cassign(0.0, 1.0); 114 } 115 else{ 116 qr = sin(qr) / qr; 117 ephase = cassign(qr, 0.0); 118 } 119 } 98 120 //up_up 99 121 if (inspin > 0.0 && outspin > 0.0){
Note: See TracChangeset
for help on using the changeset viewer.