Changes in / [51a4d78:f7bc948] in sasview
- Location:
- src/sas
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/sas/sascalc/dataloader/data_info.py ¶
r7988501 r1b1a1c1 25 25 import numpy 26 26 import math 27 28 class plottable_sesans1D(object): 29 """ 30 SESANS is a place holder for 1D SESANS plottables. 31 32 #TODO: This was directly copied from the plottables_1D. Modified Somewhat. 33 #Class has been updated. 34 """ 35 # The presence of these should be mutually 36 # exclusive with the presence of Qdev (dx) 37 x = None 38 y = None 39 lam = None 40 dx = None 41 dy = None 42 dlam = None 43 ## Slit smearing length 44 dxl = None 45 ## Slit smearing width 46 dxw = None 47 48 # Units 49 _xaxis = '' 50 _xunit = '' 51 _yaxis = '' 52 _yunit = '' 53 54 def __init__(self, x, y, lam, dx=None, dy=None, dlam=None): 55 # print "SESANS plottable working" 56 self.x = numpy.asarray(x) 57 self.y = numpy.asarray(y) 58 self.lam = numpy.asarray(lam) 59 if dx is not None: 60 self.dx = numpy.asarray(dx) 61 if dy is not None: 62 self.dy = numpy.asarray(dy) 63 if dlam is not None: 64 self.dlam = numpy.asarray(dlam) 65 66 def xaxis(self, label, unit): 67 """ 68 set the x axis label and unit 69 """ 70 self._xaxis = label 71 self._xunit = unit 72 73 def yaxis(self, label, unit): 74 """ 75 set the y axis label and unit 76 """ 77 self._yaxis = label 78 self._yunit = unit 79 27 80 28 81 class plottable_1D(object): … … 41 94 dxw = None 42 95 43 ## SESANS specific params (wavelengths for spin echo length calculation)44 45 lam = None46 dlam = None47 48 96 # Units 49 97 _xaxis = '' … … 52 100 _yunit = '' 53 101 54 def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None , lam=None, dlam=None):102 def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 55 103 self.x = numpy.asarray(x) 56 104 self.y = numpy.asarray(y) … … 63 111 if dxw is not None: 64 112 self.dxw = numpy.asarray(dxw) 65 if lam is not None:66 self.lam = numpy.asarray(lam)67 if dlam is not None:68 self.dlam = numpy.asarray(dlam)69 113 70 114 def xaxis(self, label, unit): … … 692 736 return self._perform_union(other) 693 737 694 class Data1D(plottable_1D, DataInfo): 695 """ 696 1D data class 697 """ 698 if plottable_1D.lam is None: # This means it's SANS data! 699 x_unit = '1/A' 700 y_unit = '1/cm' 701 elif plottable_1D.lam is not None: # This means it's SESANS data! 702 x_unit = 'A' 703 y_unit = 'pol' 704 else: # and if it's neither, you get punished! 705 raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 706 707 def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None): 738 class SESANSData1D(plottable_sesans1D, DataInfo): 739 """ 740 SESANS 1D data class 741 """ 742 x_unit = 'nm' 743 y_unit = 'pol' 744 745 def __init__(self, x=None, y=None, lam=None, dx=None, dy=None, dlam=None): 708 746 DataInfo.__init__(self) 709 plottable_1D.__init__(self, x, y, dx, dy,None, None, lam, dlam) 710 if self.lam is None: # This means the lam param was not detected in the data: it's SANS data! 711 x_unit = '1/A' 712 y_unit = '1/cm' 713 elif self.lam is not None: # This means lam was detected (should be an empty ndarray): it's SESANS data! 714 x_unit = 'A' 715 y_unit = 'pol' 716 else: # and if it's neither, you get punished! 717 raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 747 plottable_sesans1D.__init__(self, x, y, lam, dx, dy, dlam) 718 748 719 749 def __str__(self): … … 729 759 return _str 730 760 761 def clone_without_data(self, length=0, clone=None): 762 """ 763 Clone the current object, without copying the data (which 764 will be filled out by a subsequent operation). 765 The data arrays will be initialized to zero. 766 767 :param length: length of the data array to be initialized 768 :param clone: if provided, the data will be copied to clone 769 """ 770 from copy import deepcopy 771 if clone is None or not issubclass(clone.__class__, Data1D): 772 x = numpy.zeros(length) 773 dx = numpy.zeros(length) 774 y = numpy.zeros(length) 775 dy = numpy.zeros(length) 776 clone = Data1D(x, y, dx=dx, dy=dy) 777 778 clone.title = self.title 779 clone.run = self.run 780 clone.filename = self.filename 781 clone.instrument = self.instrument 782 clone.notes = deepcopy(self.notes) 783 clone.process = deepcopy(self.process) 784 clone.detector = deepcopy(self.detector) 785 clone.sample = deepcopy(self.sample) 786 clone.source = deepcopy(self.source) 787 clone.collimation = deepcopy(self.collimation) 788 clone.trans_spectrum = deepcopy(self.trans_spectrum) 789 clone.meta_data = deepcopy(self.meta_data) 790 clone.errors = deepcopy(self.errors) 791 792 return clone 793 794 class Data1D(plottable_1D, DataInfo): 795 """ 796 1D data class 797 """ 798 x_unit = '1/A' 799 y_unit = '1/cm' 800 801 def __init__(self, x, y, dx=None, dy=None): 802 DataInfo.__init__(self) 803 plottable_1D.__init__(self, x, y, dx, dy) 804 805 def __str__(self): 806 """ 807 Nice printout 808 """ 809 _str = "%s\n" % DataInfo.__str__(self) 810 _str += "Data:\n" 811 _str += " Type: %s\n" % self.__class__.__name__ 812 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 813 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 814 _str += " Length: %g\n" % len(self.x) 815 return _str 816 731 817 def is_slit_smeared(self): 732 818 """ … … 757 843 y = numpy.zeros(length) 758 844 dy = numpy.zeros(length) 759 lam = numpy.zeros(length) 760 dlam = numpy.zeros(length) 761 clone = Data1D(x, y, lam=lam, dx=dx, dy=dy, dlam=dlam ) 845 clone = Data1D(x, y, dx=dx, dy=dy) 762 846 763 847 clone.title = self.title -
TabularUnified src/sas/sascalc/dataloader/readers/sesans_reader.py ¶
r1b82623 r1c0e3b0 8 8 import numpy 9 9 import os 10 from sas.sascalc.dataloader.data_info import Data1D10 from sas.sascalc.dataloader.data_info import SESANSData1D 11 11 12 12 # Check whether we have a converter available … … 84 84 tdx = numpy.zeros(0) 85 85 # print "all good" 86 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam)86 output = SESANSData1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam) 87 87 # print output 88 88 self.filename = output.filename = basename -
TabularUnified src/sas/sascalc/fit/AbstractFitEngine.py ¶
r7988501 rfc18690 131 131 a way to get residuals from data. 132 132 """ 133 def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None , lam=None, dlam=None):133 def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None): 134 134 """ 135 135 :param smearer: is an object of class QSmearer or SlitSmearer … … 152 152 153 153 """ 154 Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy , lam=lam,dlam=dlam)154 Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy) 155 155 self.num_points = len(x) 156 156 self.sas_data = data -
TabularUnified src/sas/sascalc/fit/BumpsFitting.py ¶
r7988501 rb699768 26 26 from bumps import parameter 27 27 from bumps.fitproblem import FitProblem 28 28 29 29 30 from sas.sascalc.fit.AbstractFitEngine import FitEngine -
TabularUnified src/sas/sasgui/guiframe/dataFitting.py ¶
r7988501 r9b6d62d 17 17 """ 18 18 """ 19 def __init__(self, x=None, y=None, dx=None, dy=None , lam=None, dlam=None):19 def __init__(self, x=None, y=None, dx=None, dy=None): 20 20 """ 21 21 """ … … 24 24 if y is None: 25 25 y = [] 26 PlotData1D.__init__(self, x, y, lam, dx, dy, dlam)27 LoadData1D.__init__(self, x, y, lam, dx, dy, dlam)26 PlotData1D.__init__(self, x, y, dx, dy) 27 LoadData1D.__init__(self, x, y, dx, dy) 28 28 self.id = None 29 29 self.list_group_id = [] … … 68 68 # First, check the data compatibility 69 69 dy, dy_other = self._validity_check(other) 70 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None)70 result = Data1D(x=[], y=[], dx=None, dy=None) 71 71 result.clone_without_data(length=len(self.x), clone=self) 72 72 result.copy_from_datainfo(data1d=self) … … 115 115 # First, check the data compatibility 116 116 self._validity_check_union(other) 117 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None)117 result = Data1D(x=[], y=[], dx=None, dy=None) 118 118 tot_length = len(self.x) + len(other.x) 119 119 result = self.clone_without_data(length=tot_length, clone=result) 120 if self.dlam == None or other.dlam is None:121 result.dlam = None122 else:123 result.dlam = numpy.zeros(tot_length)124 120 if self.dy == None or other.dy is None: 125 121 result.dy = None … … 145 141 result.y = numpy.append(self.y, other.y) 146 142 result.y = result.y[ind] 147 result.lam = numpy.append(self.lam, other.lam)148 result.lam = result.lam[ind]149 if result.dlam != None:150 result.dlam = numpy.append(self.dlam, other.dlam)151 result.dlam = result.dlam[ind]152 143 if result.dy != None: 153 144 result.dy = numpy.append(self.dy, other.dy) … … 269 260 # First, check the data compatibility 270 261 self._validity_check_union(other) 271 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[])262 result = Data1D(x=[], y=[], dx=None, dy=None) 272 263 tot_length = len(self.x)+len(other.x) 273 264 result.clone_without_data(length=tot_length, clone=self) 274 if self.dlam == None or other.dlam is None:275 result.dlam = None276 else:277 result.dlam = numpy.zeros(tot_length)278 265 if self.dy == None or other.dy is None: 279 266 result.dy = None … … 298 285 result.y = numpy.append(self.y, other.y) 299 286 result.y = result.y[ind] 300 result.lam = numpy.append(self.lam, other.lam)301 result.lam = result.lam[ind]302 287 if result.dy != None: 303 288 result.dy = numpy.append(self.dy, other.dy) -
TabularUnified src/sas/sasgui/perspectives/fitting/basepage.py ¶
r7988501 re28f34d 142 142 self.theory_qmin_x = None 143 143 self.theory_qmax_x = None 144 self.cb1 = None145 144 self.btEditMask = None 146 145 self.btFit = None … … 281 280 num=self.npts_x, endpoint=True) 282 281 self.data = Data1D(x=x) 283 #self.data.xaxis('\\rm{Q}', "A^{-1}") 284 self.data.xaxis('\\rm{X}', "") 285 #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 286 self.data.yaxis('\\rm{Y}', "") 282 self.data.xaxis('\\rm{Q}', "A^{-1}") 283 self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 287 284 self.data.is_data = False 288 285 self.data.id = str(self.uid) + " data" … … 309 306 num=self.npts_x, endpoint=True, base=10.0) 310 307 self.data = Data1D(x=x) 311 #self.data.xaxis('\\rm{Q}', "A^{-1}") 312 #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 313 self.data.xaxis('\\rm{X}', "") 314 self.data.yaxis('\\rm{Y}', "") 308 self.data.xaxis('\\rm{Q}', "A^{-1}") 309 self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 315 310 self.data.is_data = False 316 311 self.data.id = str(self.uid) + " data" … … 431 426 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 432 427 self.sizer3 = wx.BoxSizer(wx.VERTICAL) 433 self.sizerTrafo = wx.BoxSizer(wx.VERTICAL)434 428 self.sizer4 = wx.BoxSizer(wx.VERTICAL) 435 429 self.sizer5 = wx.BoxSizer(wx.VERTICAL) … … 440 434 self.sizer2.SetMinSize((PANEL_WIDTH, -1)) 441 435 self.sizer3.SetMinSize((PANEL_WIDTH, -1)) 442 self.sizerTrafo.SetMinSize((PANEL_WIDTH, -1))443 436 self.sizer4.SetMinSize((PANEL_WIDTH, -1)) 444 437 self.sizer5.SetMinSize((PANEL_WIDTH, -1)) … … 449 442 self.vbox.Add(self.sizer2) 450 443 self.vbox.Add(self.sizer3) 451 self.vbox.Add(self.sizerTrafo)452 444 self.vbox.Add(self.sizer4) 453 445 self.vbox.Add(self.sizer5) … … 1121 1113 # set data, etc. from the state 1122 1114 # reset page between theory and fitting from bookmarking 1123 #if state.data == None:1124 # data = None1125 #else:1126 1115 data = state.data 1127 1116 … … 1149 1138 self.disp_cb_dict = state.disp_cb_dict 1150 1139 self.disp_list = state.disp_list 1151 1152 ## set the state of the radio box1153 #self.shape_rbutton.SetValue(state.shape_rbutton)1154 #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton)1155 #self.struct_rbutton.SetValue(state.struct_rbutton)1156 #self.plugin_rbutton.SetValue(state.plugin_rbutton)1157 1140 1158 1141 ## fill model combobox … … 1210 1193 else: 1211 1194 self.model_view.SetLabel("1D Mode") 1212 1213 ## set the select all check box to the a given state1214 self.cb1.SetValue(state.cb1)1215 1195 1216 1196 ## reset state of checkbox,textcrtl and regular parameters value … … 1343 1323 logging.error(traceback.format_exc()) 1344 1324 1345 # Make sure the check box updated when all checked1346 if self.cb1.GetValue():1347 self.select_all_param(None)1348 1349 1325 def _selectDlg(self): 1350 1326 """ … … 1444 1420 else: 1445 1421 self.fitrange = False 1446 1447 if not self.data.is_data:1448 is_modified = True1449 1422 1450 1423 ## if any value is modify draw model with new value … … 1463 1436 self._draw_model() 1464 1437 self.Refresh() 1438 1439 logging.info("is_modified flag set to %g",is_modified) 1465 1440 return is_modified 1466 1441 … … 2477 2452 item[2].Enable() 2478 2453 2479 # Make sure the check box updated when all checked 2480 if self.cb1.GetValue(): 2481 #self.select_all_param(None) 2482 self.get_all_checked_params() 2454 # Make sure the check box updated 2455 self.get_all_checked_params() 2483 2456 2484 2457 # update params … … 3625 3598 call back for model selection if implemented 3626 3599 """ 3627 def select_all_param(self, event):3628 """3629 set to true or false all checkBox if implemented3630 """3631 3600 def get_weight_flag(self): 3632 3601 """ -
TabularUnified src/sas/sasgui/perspectives/fitting/fitpage.py ¶
r7988501 r4c3be25 55 55 self.weightbt_string = None 56 56 self.m_name = None 57 # transform implementation58 self._fill_Trafo_sizer()59 # self.Trafobt_string()60 57 # get smear info from data 61 58 self._get_smear_info() … … 95 92 self.parent.on_set_focus(event) 96 93 self.on_tap_focus() 97 98 def onTrafo(self, event):99 """100 On Trafo radio button event, sets the Trafobt_string101 """102 self.Trafobt_string = event.GetEventObject().GetLabelText()103 self._set_Trafo()104 105 def _fill_Trafo_sizer(self):106 107 title = "Transform"108 box_description_trafo = wx.StaticBox(self, wx.ID_ANY, str(title))109 box_description_trafo.SetForegroundColour(wx.BLUE)110 #boxsizer_trafo = wx.StaticBoxSizer(box_description_trafo, wx.VERTICAL)111 boxsizer_trafo = wx.StaticBoxSizer(box_description_trafo, wx.HORIZONTAL)112 #sizer_trafo = wx.StaticBoxSizer(box_description_trafo, wx.HORIZONTAL)113 #weighting_set_box = wx.StaticBox(self, wx.ID_ANY,114 # 'Select the type of SESANS analysis')115 116 #sizer_weighting = wx.BoxSizer(wx.HORIZONTAL)117 # weighting_box.SetMinSize((_DATA_BOX_WIDTH, 60))118 119 #For every radio button (each statement x3):120 self.no_transform = wx.RadioButton(self, wx.ID_ANY,121 'None', style=wx.RB_GROUP)122 123 #self.Bind(wx.EVT_RADIOBUTTON, self.onTrafo,124 # id=self.no_transform.GetId())125 self.hankel = wx.RadioButton(self, wx.ID_ANY,126 'Hankel')127 #self.Bind(wx.EVT_RADIOBUTTON, self.onTrafo,128 # id=self.hankel.GetId())129 self.cosine = wx.RadioButton(self, wx.ID_ANY,130 'Cosine')131 #self.Bind(wx.EVT_RADIOBUTTON, self.onTrafo,132 # id=self.cosine.GetId())133 134 #Not sure about this (only once though)135 self.no_transform.SetValue(True)136 137 #For every radio button (each statement x3):138 boxsizer_trafo.Add(self.no_transform, 0, wx.LEFT, 10)139 boxsizer_trafo.Add((14, 10))140 boxsizer_trafo.Add(self.hankel)141 boxsizer_trafo.Add((14, 10))142 boxsizer_trafo.Add(self.cosine)143 boxsizer_trafo.Add((14, 10))144 #Default for weighting is False, but these need to be on by default!145 self.no_transform.Enable(True)146 147 #Not sure about this (only once though)148 #weighting_box.Add(sizer_trafo)149 150 self.sizerTrafo.Clear(True)151 self.sizerTrafo.Add(boxsizer_trafo, 0, wx.EXPAND | wx.ALL, 10)152 #self.sizerTrafo.Add(sizer_trafo, 0, wx.EXPAND | wx.ALL, 10)153 self.sizerTrafo.Layout()154 94 155 95 def _fill_data_sizer(self): … … 684 624 ## fill a sizer with the combobox to select dispersion type 685 625 model_disp = wx.StaticText(self, wx.ID_ANY, 'Function') 686 CHECK_STATE = self.cb1.GetValue()626 CHECK_STATE = False 687 627 688 628 ix = 0 … … 1029 969 self.state.model = self.model.clone() 1030 970 ## save state into 1031 self.state.cb1 = self.cb1.GetValue()1032 971 self._copy_parameters_state(self.parameters, self.state.parameters) 1033 972 self._copy_parameters_state(self.orientation_params_disp, … … 1040 979 StatusEvent(status=" Selected Distribution: Gaussian")) 1041 980 #Fill the list of fittable parameters 1042 #self.select_all_param(event=None)1043 981 self.get_all_checked_params() 1044 982 self.Layout() … … 2755 2693 self._manager.set_param2fit(self.uid, param2fit) 2756 2694 2757 def select_all_param(self, event):2758 """2759 set to true or false all checkBox given the main checkbox value cb12760 """2761 self.param_toFit = []2762 if self.parameters != []:2763 if self.cb1.GetValue():2764 for item in self.parameters:2765 if item[0].IsShown():2766 ## for data2D select all to fit2767 if self.data.__class__.__name__ == "Data2D" or \2768 self.enable2D:2769 item[0].SetValue(True)2770 self.param_toFit.append(item)2771 else:2772 ## for 1D all parameters except orientation2773 if not item in self.orientation_params:2774 item[0].SetValue(True)2775 self.param_toFit.append(item)2776 else:2777 item[0].SetValue(False)2778 #if len(self.fittable_param)>0:2779 for item in self.fittable_param:2780 if item[0].IsShown():2781 if self.data.__class__.__name__ == "Data2D" or \2782 self.enable2D:2783 item[0].SetValue(True)2784 self.param_toFit.append(item)2785 try:2786 if len(self.values[item[1]]) > 0:2787 item[0].SetValue(False)2788 except:2789 pass2790 2791 else:2792 ## for 1D all parameters except orientation2793 if not item in self.orientation_params_disp:2794 item[0].SetValue(True)2795 self.param_toFit.append(item)2796 try:2797 if len(self.values[item[1]]) > 0:2798 item[0].SetValue(False)2799 except:2800 pass2801 else:2802 item[0].SetValue(False)2803 2804 else:2805 for item in self.parameters:2806 item[0].SetValue(False)2807 for item in self.fittable_param:2808 item[0].SetValue(False)2809 self.param_toFit = []2810 2811 self.save_current_state_fit()2812 2813 if event != None:2814 #self._undo.Enable(True)2815 ## post state to fit panel2816 event = PageInfoEvent(page=self)2817 wx.PostEvent(self.parent, event)2818 param2fit = []2819 for item in self.param_toFit:2820 if item[0] and item[0].IsShown():2821 param2fit.append(item[1])2822 self.parent._manager.set_param2fit(self.uid, param2fit)2823 2824 2695 def select_param(self, event): 2825 2696 """ … … 2868 2739 if len(self.fittable_param) > 0: 2869 2740 len_orient_para *= 2 2870 #Set the value of checkbox that selected every checkbox or not2871 if len(self.parameters) + len(self.fittable_param) - len_orient_para \2872 == len(self.param_toFit):2873 self.cb1.SetValue(True)2874 else:2875 self.cb1.SetValue(False)2876 2741 2877 2742 self.save_current_state_fit() … … 2975 2840 iy = 0 2976 2841 ix = 0 2977 select_text = "Select All" 2978 self.cb1 = wx.CheckBox(self, wx.ID_ANY, str(select_text), (10, 10)) 2979 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param) 2980 self.cb1.SetToolTipString("To check/uncheck all the boxes below.") 2981 self.cb1.SetValue(True) 2982 2983 sizer.Add(self.cb1, (iy, ix), (1, 1), \ 2984 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 2842 sizer.Add(wx.StaticText(self, wx.ID_ANY, 'Parameter'), 2843 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 2985 2844 ix += 1 2986 2845 self.text2_2 = wx.StaticText(self, wx.ID_ANY, 'Value') … … 3009 2868 self.text2_4.Hide() 3010 2869 3011 CHECK_STATE = self.cb1.GetValue()2870 CHECK_STATE = False 3012 2871 for item in keys: 3013 2872 -
TabularUnified src/sas/sasgui/plottools/plottables.py ¶
r7988501 r8abd96d 1022 1022 """ 1023 1023 1024 def __init__(self, x, y, lam=None, dx=None, dy=None, dlam=None):1024 def __init__(self, x, y, dx=None, dy=None): 1025 1025 """ 1026 1026 Draw points specified by x[i],y[i] in the current color/symbol. … … 1036 1036 self.x = x 1037 1037 self.y = y 1038 self.lam = lam1039 1038 self.dx = dx 1040 1039 self.dy = dy 1041 self.dlam = dlam1042 1040 self.source = None 1043 1041 self.detector = None
Note: See TracChangeset
for help on using the changeset viewer.