Changeset bd8411d5 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Apr 10, 2017 5:04:56 AM (8 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fe09e9b
- Parents:
- 8963a55
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/sld_panel.py
r8963a55 rbd8411d5 61 61 self.base = base 62 62 self.neutron_wavelength = WAVELENGTH 63 self.xray_ wavelength= WAVELENGTH63 self.xray_source_input = WAVELENGTH 64 64 self.parent = parent 65 65 #layout attribute … … 69 69 self.density = "" 70 70 self.neutron_wavelength_ctl = None 71 self.xray_ wavelength_ctl = None71 self.xray_source_input_ctl = None 72 72 self.xray_cbox = None 73 73 self.neutron_sld_real_ctl = None … … 114 114 self.neutron_wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 115 115 self.neutron_wavelength_ctl.SetValue(str(self.neutron_wavelength)) 116 xray_ wavelength_txt = wx.StaticText(self, -1, 'X-ray wavelength')117 self.xray_ wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1))118 self.xray_ wavelength_ctl.SetValue(str(self.xray_wavelength))116 xray_source_input_txt = wx.StaticText(self, -1, 'X-ray wavelength') 117 self.xray_source_input_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 118 self.xray_source_input_ctl.SetValue(str(self.xray_source_input)) 119 119 neutron_unit_a_txt = wx.StaticText(self, -1, unit_a) 120 120 … … 153 153 iy += 1 154 154 ix = 0 155 sizer_input.Add(xray_ wavelength_txt, (iy, ix), (1, 1),156 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 157 ix += 1 158 sizer_input.Add(self.xray_ wavelength_ctl, (iy, ix), (1, 1),155 sizer_input.Add(xray_source_input_txt, (iy, ix), (1, 1), 156 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 157 ix += 1 158 sizer_input.Add(self.xray_source_input_ctl, (iy, ix), (1, 1), 159 159 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 160 160 ix += 1 … … 309 309 fill the x-ray combobox with the sources 310 310 """ 311 # source_list = ['Element', 'Energy (keV)', 'Wavelength (A)']312 311 source_list = ['[A]', '[keV]', 'Element'] 313 312 for source in source_list: … … 315 314 self.xray_cbox.SetClientData(pos, str(source.strip())) 316 315 self.xray_cbox.SetSelection(0) 316 self.xray_source = source_list[0] 317 317 318 318 def on_select_xray(self, event=None): … … 377 377 378 378 self.neutron_wavelength = self.neutron_wavelength_ctl.GetValue() 379 self.xray_ wavelength = self.xray_wavelength_ctl.GetValue()379 self.xray_source_input = self.xray_source_input_ctl.GetValue() 380 380 381 381 if str(self.neutron_wavelength).lstrip().rstrip() == "": … … 392 392 msg += "Error for wavelength value :expect float" 393 393 394 if str(self.xray_ wavelength).lstrip().rstrip() == "":395 self.xray_ wavelength= WAVELENGTH396 self.xray_ wavelength_ctl.SetValue(str(WAVELENGTH))397 self.xray_ wavelength_ctl.SetBackgroundColour(wx.WHITE)398 self.xray_ wavelength_ctl.Refresh()394 if str(self.xray_source_input).lstrip().rstrip() == "": 395 self.xray_source_input = WAVELENGTH 396 self.xray_source_input_ctl.SetValue(str(WAVELENGTH)) 397 self.xray_source_input_ctl.SetBackgroundColour(wx.WHITE) 398 self.xray_source_input_ctl.Refresh() 399 399 msg += "Default value for wavelength is 6.0" 400 400 else: 401 if check_float(self.xray_wavelength_ctl): 402 self.xray_wavelength = float(self.xray_wavelength) 403 else: 404 flag = False 405 msg += "Error for wavelength value :expect float" 401 if (self.xray_source == '[A]') or (self.xray_source == '[keV]'): 402 if check_float(self.xray_source_input_ctl): 403 self.xray_source_input = float(self.xray_source_input) 404 else: 405 flag = False 406 msg += "Error for wavelength value :expect float" 407 elif (self.xray_source == 'Element'): 408 try: 409 import periodictable 410 exec("periodictable." + self.xray_source_input) 411 except AttributeError: 412 flag = False 413 msg += "X-ray element supplied isn't in the database" 414 415 406 416 407 417 self.compound = self.compound_ctl.GetValue().lstrip().rstrip() … … 438 448 return xray_sld_from_atoms(atom, density=density, energy=energy) 439 449 440 441 450 def calculateSld(self, event): 442 451 """ … … 460 469 wavelength=self.neutron_wavelength) 461 470 if self.xray_source == "[A]": 462 # xray_real, xray_im = self.calculate_sld_helper(element=self.xray_wavelength,463 # density=self.density,464 # molecule_formula=self.sld_formula)465 pass471 energy = xray_energy(self.xray_source_input) 472 xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 473 density=self.density, 474 energy=energy) 466 475 elif self.xray_source == "[keV]": 467 # xray_real, xray_im = self.calculate_sld_helper(element=self.xray_wavelength, 468 # density=self.density, 469 # molecule_formula=self.sld_formula) 470 pass 476 xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 477 density=self.density, 478 energy=self.xray_source_input) 471 479 elif self.xray_source == "Element": 472 # xray_real, xray_im = self.calculate_sld_helper(element=self.xray_wavelength, 473 # density=self.density, 474 # molecule_formula=self.sld_formula) 475 pass 480 xray_real, xray_im = self.calculate_sld_helper(element=self.xray_source_input, 481 density=self.density, 482 molecule_formula=self.sld_formula) 476 483 # set neutron sld values 477 484 val = format_number(sld_real * _SCALE) … … 504 511 self.neutron_sld_real_ctl.SetValue("") 505 512 self.neutron_sld_im_ctl.SetValue("") 506 self.mo_ka_sld_real_ctl.SetValue("") 507 self.mo_ka_sld_im_ctl.SetValue("") 508 self.cu_ka_sld_real_ctl.SetValue("") 509 self.cu_ka_sld_im_ctl.SetValue("") 513 self.xray_sld_real_ctl.SetValue("") 514 self.xray_sld_im_ctl.SetValue("") 510 515 self.neutron_abs_ctl.SetValue("") 511 516 self.neutron_inc_ctl.SetValue("")
Note: See TracChangeset
for help on using the changeset viewer.