Changeset ff11b21 in sasview
- Timestamp:
- Aug 22, 2016 7:34: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.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- caeb382
- Parents:
- 93b145a
- Location:
- src/sas
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/corfunc/corfunc_calculator.py
rc97d76a rff11b21 115 115 iq = self._data.y 116 116 117 s2 = self._fit_data(q, iq)117 params, s2 = self._fit_data(q, iq) 118 118 qs = np.arange(0, q[-1]*100, (q[1]-q[0])) 119 119 iqs = s2(qs) … … 121 121 extrapolation = Data1D(qs, iqs) 122 122 123 return extrapolation123 return params, extrapolation 124 124 125 125 def compute_transform(self, extrapolation, trans_type, background=None, … … 271 271 self.lowerq) 272 272 273 return s2 273 params = {'A': g[1], 'B': g[0], 'K': k, 'sigma': sigma} 274 275 return params, s2 -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r93b145a rff11b21 68 68 self.extracted_params = None 69 69 self.transform_type = 'fourier' 70 self._extrapolation_outputs = {} 70 71 # Dictionary for saving refs to text boxes used to display output data 71 72 self._output_boxes = None … … 148 149 if data is None: 149 150 self._disable_inputs() 151 # Reset outputs 150 152 self.set_extracted_params(reset=True) 153 self.set_extrapolation_params() 151 154 self._data = None 152 155 return … … 206 209 207 210 try: 208 self._extrapolated_data = self._calculator.compute_extrapolation()211 params, self._extrapolated_data = self._calculator.compute_extrapolation() 209 212 except: 210 213 msg = "Error extrapolating data." … … 226 229 self._extract_btn.Disable() 227 230 self.set_extracted_params(reset=True) 231 self.set_extrapolation_params(params) 228 232 229 233 def compute_transform(self, event=None): … … 329 333 self._calculator.background = bg 330 334 335 def set_extrapolation_params(self, params=None): 336 if params is None: 337 # Reset outputs 338 for output in self._extrapolation_outputs.values(): 339 output.SetValue('-') 340 return 341 for key, value in params.iteritems(): 342 output = self._extrapolation_outputs[key] 343 rounded = self._round_sig_figs(value, 6) 344 output.SetValue(rounded) 345 346 331 347 def set_extracted_params(self, params=None, reset=False): 332 348 self.extracted_params = params … … 334 350 if params is None: 335 351 if not reset: error = True 336 for key in OUTPUT_STRINGS.keys():337 self._output_boxes[key].SetValue('-')352 for output in self._output_boxes.values(): 353 output.SetValue('-') 338 354 else: 339 355 if len(params) < len(OUTPUT_STRINGS): … … 347 363 wx.PostEvent(self._manager.parent, StatusEvent( 348 364 status=msg, info='error')) 349 350 365 351 366 def plot_qrange(self, active=None, leftdown=False): … … 449 464 file_sizer = wx.GridBagSizer(5, 5) 450 465 466 y = 0 467 451 468 file_name_label = wx.StaticText(self, -1, "Name:") 452 469 file_sizer.Add(file_name_label, (0, 0), (1, 1), … … 461 478 databox_sizer.Add(file_sizer, wx.TOP, 15) 462 479 463 vbox.Add(databox_sizer, ( 0, 0), (1, 1),480 vbox.Add(databox_sizer, (y, 0), (1, 1), 464 481 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE | wx.TOP, 15) 465 482 y += 1 466 483 467 484 # Parameters … … 523 540 q_sizer.Add(self._qmax2_input, (3,3), (1, 1), wx.LEFT, 5) 524 541 525 background_label = wx.StaticText(self, -1, "Background:", size=(80,20)) 526 q_sizer.Add(background_label, (4,0), (1,1), wx.LEFT | wx.EXPAND, 5) 527 528 self._background_input = ModelTextCtrl(self, -1, size=(75,20), 529 style=wx.TE_PROCESS_ENTER, name='background_input', 542 qbox_sizer.Add(q_sizer, wx.TOP, 0) 543 544 vbox.Add(qbox_sizer, (y, 0), (1, 1), 545 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 546 y += 1 547 548 extrapolation_box = wx.StaticBox(self, -1, "Extrapolation Parameters") 549 extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box, wx.VERTICAL) 550 params_sizer = wx.GridBagSizer(5, 5) 551 552 guinier_label = wx.StaticText(self, -1, "Guinier:") 553 params_sizer.Add(guinier_label, (0, 0), (1,1), 554 wx.ALL | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 555 556 a_label = wx.StaticText(self, -1, "A: ") 557 params_sizer.Add(a_label, (1, 0), (1, 1), wx.LEFT | wx.EXPAND, 15) 558 559 a_output = OutputTextCtrl(self, wx.NewId(), 560 value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 561 params_sizer.Add(a_output, (1, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15) 562 self._extrapolation_outputs['A'] = a_output 563 564 b_label = wx.StaticText(self, -1, "B: ") 565 params_sizer.Add(b_label, (2, 0), (1, 1), wx.LEFT | wx.EXPAND, 15) 566 567 b_output = OutputTextCtrl(self, wx.NewId(), 568 value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 569 params_sizer.Add(b_output, (2, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15) 570 self._extrapolation_outputs['B'] = b_output 571 572 porod_label = wx.StaticText(self, -1, "Porod: ") 573 params_sizer.Add(porod_label, (0, 2), (1, 1), 574 wx.ALL | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 575 576 k_label = wx.StaticText(self, -1, "K: ") 577 params_sizer.Add(k_label, (1, 2), (1, 1), wx.LEFT | wx.EXPAND, 15) 578 579 k_output = OutputTextCtrl(self, wx.NewId(), 580 value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 581 params_sizer.Add(k_output, (1, 3), (1, 1), wx.RIGHT | wx.EXPAND, 15) 582 self._extrapolation_outputs['K'] = k_output 583 584 sigma_label = wx.StaticText(self, -1, u'\u03C3: ') 585 params_sizer.Add(sigma_label, (2, 2), (1, 1), wx.LEFT | wx.EXPAND, 15) 586 587 sigma_output = OutputTextCtrl(self, wx.NewId(), 588 value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 589 params_sizer.Add(sigma_output, (2, 3), (1, 1), wx.RIGHT | wx.EXPAND, 15) 590 self._extrapolation_outputs['sigma'] = sigma_output 591 592 bg_label = wx.StaticText(self, -1, "Bg: ") 593 params_sizer.Add(bg_label, (3, 2), (1, 1), wx.LEFT | wx.EXPAND, 15) 594 595 self._background_input = ModelTextCtrl(self, -1, value="-", 596 style=wx.TE_PROCESS_ENTER | wx.TE_CENTRE, name='background_input', 530 597 text_enter_callback=self._on_enter_input) 531 598 self._background_input.SetToolTipString(("A background value to " 532 599 "subtract from all intensity values")) 533 q_sizer.Add(self._background_input, (4,1), (1,1), 534 wx.RIGHT, 5) 535 536 background_button = wx.Button(self, wx.NewId(), "Calculate", 537 size=(75, 20)) 600 params_sizer.Add(self._background_input, (3, 3), (1, 1), wx.RIGHT | wx.EXPAND, 15) 601 602 background_button = wx.Button(self, wx.NewId(), "Calculate Bg", 603 size=(75, -1)) 538 604 background_button.Bind(wx.EVT_BUTTON, self._compute_background) 539 q_sizer.Add(background_button, (4, 2), (1, 1), wx.RIGHT, 5) 540 541 qbox_sizer.Add(q_sizer, wx.TOP, 0) 542 543 vbox.Add(qbox_sizer, (1, 0), (1, 1), 605 params_sizer.Add(background_button, (4,3), (1, 1), wx.EXPAND | wx.RIGHT, 15) 606 607 extrapolation_sizer.Add(params_sizer) 608 vbox.Add(extrapolation_sizer, (y, 0), (1, 1), 544 609 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 610 y += 1 545 611 546 612 # Transform type … … 561 627 562 628 transform_sizer.Add(radio_sizer, wx.TOP, 0) 563 vbox.Add(transform_sizer, ( 2, 0), (1, 1),629 vbox.Add(transform_sizer, (y, 0), (1, 1), 564 630 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 631 y += 1 565 632 566 633 # Output data … … 587 654 outputbox_sizer.Add(output_sizer, wx.TOP, 0) 588 655 589 vbox.Add(outputbox_sizer, ( 3, 0), (1, 1),656 vbox.Add(outputbox_sizer, (y, 0), (1, 1), 590 657 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 658 y += 1 591 659 592 660 # Controls … … 615 683 616 684 controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0) 617 vbox.Add(controlbox_sizer, ( 4, 0), (1, 1),685 vbox.Add(controlbox_sizer, (y, 0), (1, 1), 618 686 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 619 687 … … 654 722 # Index of first significant digit 655 723 significant_digit = -int(np.floor(np.log10(np.abs(x)))) 656 # Number of digits required for correct number of sig figs 657 digits = significant_digit + (sigfigs - 1) 658 rounded = np.round(x, decimals=digits) 659 rounded_str = "{1:.{0}f}".format(sigfigs -1 + significant_digit, 660 rounded) 724 725 if np.abs(significant_digit > 4): 726 # Use scientific notation if x > 1e5 or x < 1e4 727 rounded_str = "{1:.{0}E}".format(sigfigs-1, x) 728 else: 729 # Format as a standard decimal 730 # Number of digits required for correct number of sig figs 731 digits = significant_digit + (sigfigs - 1) 732 rounded = np.round(x, decimals=digits) 733 rounded_str = "{1:.{0}f}".format(sigfigs -1 + significant_digit, 734 rounded) 661 735 except: 662 736 # Method for finding significant_digit fails if x is 0 (since log10(0)=inf) -
src/sas/sasgui/perspectives/corfunc/media/corfunc_help.rst
rc97d76a rff11b21 33 33 34 34 .. math:: 35 I(Q) = Ae^{Bq^2}35 I(Q) = e^{A+Bq^2} 36 36 37 37 The Guinier model assumes that the small angle scattering arises from particles -
src/sas/sasgui/perspectives/corfunc/plot_labels.py
r37e7223 rff11b21 1 1 GROUP_ID_IQ_DATA = r"$I(q)$" 2 IQ_DATA_LABEL = r"$I_{obs}(q) $"2 IQ_DATA_LABEL = r"$I_{obs}(q) - Bg$" 3 3 IQ_EXTRAPOLATED_DATA_LABEL = r"$I_{extrap}(q)$" 4 4
Note: See TracChangeset
for help on using the changeset viewer.