Changes in / [46dfee9:9087214] in sasview


Ignore:
Location:
src/sas
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/data_util/qsmearing.py

    rf8aa738 r392056d  
    55#This software was developed by the University of Tennessee as part of the 
    66#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     7#project funded by the US National Science Foundation. 
    88#See the license text in license.txt 
    99#copyright 2008, University of Tennessee 
     
    1313import logging 
    1414import sys 
     15from sasmodels import sesans 
    1516 
    16 from sasmodels.resolution import Slit1D, Pinhole1D 
     17from sasmodels.resolution import Slit1D, Pinhole1D, SESANS1D 
    1718from sasmodels.resolution2d import Pinhole2D 
    1819 
     
    4849 
    4950    # Look for resolution smearing data 
     51    _found_sesans = False 
     52    if data.dx is not None and data.meta_data['loader']=='SESANS': 
     53        if data.dx[0] > 0.0: 
     54            _found_sesans = True 
     55 
     56    if _found_sesans == True: 
     57        return sesans_smear(data, model) 
     58 
    5059    _found_resolution = False 
    5160    if data.dx is not None and len(data.dx) == len(data.x): 
     
    92101        self.model = model 
    93102        self.resolution = resolution 
    94         self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     103        if hasattr(self.resolution, 'data'): 
     104            if self.resolution.data.meta_data['loader'] == 'SESANS': 
     105                self.offset = 0 
     106            # This is default behaviour, for future resolution/transform functions this needs to be revisited. 
     107            else: 
     108                self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     109        else: 
     110            self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     111 
     112        #self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
    95113 
    96114    def apply(self, iq_in, first_bin=0, last_bin=None): 
     
    126144        q[first:last+1]. 
    127145        """ 
     146 
    128147        q = self.resolution.q 
    129148        first = numpy.searchsorted(q, q_min) 
     
    142161    width = data.dx if data.dx is not None else 0 
    143162    return PySmear(Pinhole1D(q, width), model) 
     163 
     164def sesans_smear(data, model=None): 
     165    #This should be calculated characteristic length scale 
     166    #Probably not a data prameter either 
     167    #Need function to calculate this based on model 
     168    #Here assume a number 
     169    Rmax = 1000000 
     170    q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
     171    return PySmear(SESANS1D(data,q_calc),model) 
  • src/sas/sascalc/dataloader/data_info.py

    r1b1a1c1 r1fac6c0  
    2525import numpy 
    2626import 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  
    80  
    8127class plottable_1D(object): 
    8228    """ 
     
    9440    dxw = None 
    9541 
     42    ## SESANS specific params (wavelengths for spin echo length calculation) 
     43 
     44    lam = None 
     45    dlam = None 
     46 
    9647    # Units 
    9748    _xaxis = '' 
     
    10051    _yunit = '' 
    10152 
    102     def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 
     53    def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None): 
    10354        self.x = numpy.asarray(x) 
    10455        self.y = numpy.asarray(y) 
     
    11162        if dxw is not None: 
    11263            self.dxw = numpy.asarray(dxw) 
     64        if lam is not None: 
     65            self.lam = numpy.asarray(lam) 
     66        if dlam is not None: 
     67            self.dlam = numpy.asarray(dlam) 
    11368 
    11469    def xaxis(self, label, unit): 
     
    736691        return self._perform_union(other) 
    737692 
    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): 
     693class Data1D(plottable_1D, DataInfo): 
     694    """ 
     695    1D data class 
     696    """ 
     697    #if plottable_1D.lam is None: # This means it's SANS data! 
     698     #   x_unit = '1/A' 
     699      #  y_unit = '1/cm' 
     700    #elif plottable_1D.lam is not None: # This means it's SESANS data! 
     701     #   x_unit = 'A' 
     702      #  y_unit = 'pol' 
     703    #else: # and if it's neither, you get punished! 
     704     #   raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
     705 
     706    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
     707        self.isSesans = isSesans 
    746708        DataInfo.__init__(self) 
    747         plottable_sesans1D.__init__(self, x, y, lam, dx, dy, dlam) 
     709        plottable_1D.__init__(self, x, y, dx, dy,None, None, lam, dlam) 
     710        if self.isSesans: 
     711            x_unit = 'A' 
     712            y_unit = 'pol' 
     713        elif not self.isSesans: # it's SANS data! (Could also be simple else statement, but i prefer exhaustive conditionals...-JHB) 
     714            x_unit = '1/A' 
     715            y_unit = '1/cm' 
     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??') 
    748718 
    749719    def __str__(self): 
     
    759729        return _str 
    760730 
    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  
    817731    def is_slit_smeared(self): 
    818732        """ 
     
    843757            y = numpy.zeros(length) 
    844758            dy = numpy.zeros(length) 
    845             clone = Data1D(x, y, dx=dx, dy=dy) 
     759            lam = numpy.zeros(length) 
     760            dlam = numpy.zeros(length) 
     761            clone = Data1D(x, y, lam=lam, dx=dx, dy=dy, dlam=dlam ) 
    846762 
    847763        clone.title = self.title 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r1c0e3b0 r392056d  
    88import numpy 
    99import os 
    10 from sas.sascalc.dataloader.data_info import SESANSData1D 
     10from sas.sascalc.dataloader.data_info import Data1D 
    1111 
    1212# Check whether we have a converter available 
     
    8484                tdx = numpy.zeros(0) 
    8585#                print "all good" 
    86                 output = SESANSData1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam) 
     86                output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True ) 
    8787#                print output                 
    8888                self.filename = output.filename = basename 
     
    121121                        paramvals.append(toks[1]) 
    122122                    if len(toks)>5: 
     123                       #zvals.append(toks[0]) 
     124                        #dzvals.append(toks[1]) 
     125                        #lamvals.append(toks[2]) 
     126                        #dlamvals.append(toks[3]) 
     127                        #Pvals.append(toks[4]) 
     128                        #dPvals.append(toks[5]) 
     129 
    123130                        zvals.append(toks[0]) 
    124                         dzvals.append(toks[1]) 
    125                         lamvals.append(toks[2]) 
    126                         dlamvals.append(toks[3]) 
    127                         Pvals.append(toks[4]) 
    128                         dPvals.append(toks[5]) 
     131                        dzvals.append(toks[3]) 
     132                        lamvals.append(toks[4]) 
     133                        dlamvals.append(toks[5]) 
     134                        Pvals.append(toks[1]) 
     135                        dPvals.append(toks[2]) 
    129136                    else: 
    130137                        continue 
     
    140147                default_z_unit = "A" 
    141148                data_conv_P = None 
    142                 default_p_unit = " " 
     149                default_p_unit = " " # Adjust unit for axis (L^-3) 
    143150                lam_unit = lam_header[1].replace("[","").replace("]","") 
     151                if lam_unit == 'AA': 
     152                    lam_unit = 'A' 
    144153                varheader=[zvals[0],dzvals[0],lamvals[0],dlamvals[0],Pvals[0],dPvals[0]] 
    145154                valrange=range(1, len(zvals)) 
     
    161170                output.x, output.x_unit = self._unit_conversion(x, lam_unit, default_z_unit) 
    162171                output.y = y 
     172                output.y_unit = '\AA^{-2} cm^{-1}' # output y_unit erbij 
    163173                output.dx, output.dx_unit = self._unit_conversion(dx, lam_unit, default_z_unit) 
    164174                output.dy = dy 
     
    166176                output.dlam, output.dlam_unit = self._unit_conversion(dlam, lam_unit, default_z_unit) 
    167177 
    168                 output.xaxis("\rm{z}", output.x_unit) 
    169                 output.yaxis("\\rm{P/P0}", output.y_unit) 
     178                output.xaxis("\\rm{z}", output.x_unit) 
     179                output.yaxis("\\rm{ln(P)/(t \lambda^2)}", output.y_unit) # Adjust label to ln P/(lam^2 t), remove lam column refs 
    170180                # Store loading process information 
    171181                output.meta_data['loader'] = self.type_name 
    172                 output.sample.thickness = float(paramvals[6]) 
     182                #output.sample.thickness = float(paramvals[6]) 
    173183                output.sample.name = paramvals[1] 
    174184                output.sample.ID = paramvals[0] 
    175185                zaccept_unit_split = paramnames[7].split("[") 
    176186                zaccept_unit = zaccept_unit_split[1].replace("]","") 
    177                 if zaccept_unit.strip() == '\AA^-1': 
     187                if zaccept_unit.strip() == '\AA^-1' or zaccept_unit.strip() == '\A^-1': 
    178188                    zaccept_unit = "1/A" 
    179189                output.sample.zacceptance=(float(paramvals[7]),zaccept_unit) 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    rfc18690 r7988501  
    131131        a way to get residuals from data. 
    132132    """ 
    133     def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None): 
     133    def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None, lam=None, dlam=None): 
    134134        """ 
    135135            :param smearer: is an object of class QSmearer or SlitSmearer 
     
    152152                 
    153153        """ 
    154         Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy) 
     154        Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy, lam=lam,dlam=dlam) 
    155155        self.num_points = len(x) 
    156156        self.sas_data = data 
  • src/sas/sascalc/fit/BumpsFitting.py

    rb699768 r7988501  
    2626from bumps import parameter 
    2727from bumps.fitproblem import FitProblem 
    28  
    2928 
    3029from sas.sascalc.fit.AbstractFitEngine import FitEngine 
  • src/sas/sasgui/guiframe/dataFitting.py

    r9b6d62d r1fac6c0  
    1717    """ 
    1818    """ 
    19     def __init__(self, x=None, y=None, dx=None, dy=None): 
     19    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
    2020        """ 
    2121        """ 
     
    2424        if y is None: 
    2525            y = [] 
    26         PlotData1D.__init__(self, x, y, dx, dy) 
    27         LoadData1D.__init__(self, x, y, dx, dy) 
     26        self.isSesans = isSesans 
     27        PlotData1D.__init__(self, x, y, dx, dy, lam, dlam) 
     28        LoadData1D.__init__(self, x, y, dx, dy, lam, dlam, isSesans) 
    2829        self.id = None 
    2930        self.list_group_id = [] 
     
    6869        # First, check the data compatibility 
    6970        dy, dy_other = self._validity_check(other) 
    70         result = Data1D(x=[], y=[], dx=None, dy=None) 
     71        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    7172        result.clone_without_data(length=len(self.x), clone=self) 
    7273        result.copy_from_datainfo(data1d=self) 
     
    115116        # First, check the data compatibility 
    116117        self._validity_check_union(other) 
    117         result = Data1D(x=[], y=[], dx=None, dy=None) 
     118        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    118119        tot_length = len(self.x) + len(other.x) 
    119120        result = self.clone_without_data(length=tot_length, clone=result) 
     121        if self.dlam == None or other.dlam is None: 
     122            result.dlam = None 
     123        else: 
     124            result.dlam = numpy.zeros(tot_length) 
    120125        if self.dy == None or other.dy is None: 
    121126            result.dy = None 
     
    141146        result.y = numpy.append(self.y, other.y) 
    142147        result.y = result.y[ind] 
     148        result.lam = numpy.append(self.lam, other.lam) 
     149        result.lam = result.lam[ind] 
     150        if result.dlam != None: 
     151            result.dlam = numpy.append(self.dlam, other.dlam) 
     152            result.dlam = result.dlam[ind] 
    143153        if result.dy != None: 
    144154            result.dy = numpy.append(self.dy, other.dy) 
     
    260270        # First, check the data compatibility 
    261271        self._validity_check_union(other) 
    262         result = Data1D(x=[], y=[], dx=None, dy=None) 
     272        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[]) 
    263273        tot_length = len(self.x)+len(other.x) 
    264274        result.clone_without_data(length=tot_length, clone=self) 
     275        if self.dlam == None or other.dlam is None: 
     276            result.dlam = None 
     277        else: 
     278            result.dlam = numpy.zeros(tot_length) 
    265279        if self.dy == None or other.dy is None: 
    266280            result.dy = None 
     
    285299        result.y = numpy.append(self.y, other.y) 
    286300        result.y = result.y[ind] 
     301        result.lam = numpy.append(self.lam, other.lam) 
     302        result.lam = result.lam[ind] 
    287303        if result.dy != None: 
    288304            result.dy = numpy.append(self.dy, other.dy) 
  • src/sas/sasgui/guiframe/data_manager.py

    rd85c194 r1fac6c0  
    6262        if issubclass(Data2D, data.__class__): 
    6363            new_plot = Data2D(image=None, err_image=None)  
    64         else:  
    65             new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
     64        elif data.meta_data['loader'] == 'SESANS': 
     65            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True) 
     66        else: 
     67            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check??? 
    6668            
    6769        new_plot.copy_from_datainfo(data) 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    rf22b43c rf22b43c  
    142142        self.theory_qmin_x = None 
    143143        self.theory_qmax_x = None 
     144        self.cb1 = None 
    144145        self.btEditMask = None 
    145146        self.btFit = None 
     
    280281                           num=self.npts_x, endpoint=True) 
    281282        self.data = Data1D(x=x) 
    282         self.data.xaxis('\\rm{Q}', "A^{-1}") 
    283         self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
     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}', "") 
    284287        self.data.is_data = False 
    285288        self.data.id = str(self.uid) + " data" 
     
    306309                           num=self.npts_x, endpoint=True, base=10.0) 
    307310        self.data = Data1D(x=x) 
    308         self.data.xaxis('\\rm{Q}', "A^{-1}") 
    309         self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
     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}', "") 
    310315        self.data.is_data = False 
    311316        self.data.id = str(self.uid) + " data" 
     
    426431        self.sizer2 = wx.BoxSizer(wx.VERTICAL) 
    427432        self.sizer3 = wx.BoxSizer(wx.VERTICAL) 
     433        self.sizerTrafo = wx.BoxSizer(wx.VERTICAL) 
    428434        self.sizer4 = wx.BoxSizer(wx.VERTICAL) 
    429435        self.sizer5 = wx.BoxSizer(wx.VERTICAL) 
     
    434440        self.sizer2.SetMinSize((PANEL_WIDTH, -1)) 
    435441        self.sizer3.SetMinSize((PANEL_WIDTH, -1)) 
     442        self.sizerTrafo.SetMinSize((PANEL_WIDTH, -1)) 
    436443        self.sizer4.SetMinSize((PANEL_WIDTH, -1)) 
    437444        self.sizer5.SetMinSize((PANEL_WIDTH, -1)) 
     
    442449        self.vbox.Add(self.sizer2) 
    443450        self.vbox.Add(self.sizer3) 
     451        self.vbox.Add(self.sizerTrafo) 
    444452        self.vbox.Add(self.sizer4) 
    445453        self.vbox.Add(self.sizer5) 
     
    11221130        # set data, etc. from the state 
    11231131        # reset page between theory and fitting from bookmarking 
     1132        #if state.data == None: 
     1133        #    data = None 
     1134        #else: 
    11241135        data = state.data 
    11251136 
     
    11471158        self.disp_cb_dict = state.disp_cb_dict 
    11481159        self.disp_list = state.disp_list 
     1160 
     1161        ## set the state of the radio box 
     1162        #self.shape_rbutton.SetValue(state.shape_rbutton) 
     1163        #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 
     1164        #self.struct_rbutton.SetValue(state.struct_rbutton) 
     1165        #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    11491166 
    11501167        ## fill model combobox 
     
    12071224            else: 
    12081225                self.model_view.SetLabel("1D Mode") 
     1226 
     1227        ## set the select all check box to the a given state 
     1228        self.cb1.SetValue(state.cb1) 
    12091229 
    12101230        ## reset state of checkbox,textcrtl  and  regular parameters value 
     
    13371357                            logging.error(traceback.format_exc()) 
    13381358 
     1359        # Make sure the check box updated when all checked 
     1360        if self.cb1.GetValue(): 
     1361            self.select_all_param(None) 
     1362 
    13391363    def _selectDlg(self): 
    13401364        """ 
     
    14391463                self.fitrange = False 
    14401464 
     1465            if not self.data.is_data: 
     1466                is_modified = True 
     1467 
    14411468            ## if any value is modify draw model with new value 
    14421469            if not self.fitrange: 
     
    14541481                self._draw_model() 
    14551482                self.Refresh() 
    1456  
    1457         #logging.info("is_modified flag set to %g",is_modified) 
    14581483        return is_modified 
    14591484 
     
    24772502                        item[2].Enable() 
    24782503 
    2479             # Make sure the check box updated 
    2480             self.get_all_checked_params() 
     2504            # Make sure the check box updated when all checked 
     2505            if self.cb1.GetValue(): 
     2506                #self.select_all_param(None) 
     2507                self.get_all_checked_params() 
    24812508 
    24822509            # update params 
     
    36573684        call back for model selection if implemented 
    36583685        """ 
     3686    def select_all_param(self, event): 
     3687        """ 
     3688        set to true or false all checkBox if implemented 
     3689        """ 
    36593690    def get_weight_flag(self): 
    36603691        """ 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r3bec50a r3bec50a  
    5555        self.weightbt_string = None 
    5656        self.m_name = None 
     57        # transform implementation 
     58        self._fill_Trafo_sizer() 
     59       # self.Trafobt_string() 
    5760        # get smear info from data 
    5861        self._get_smear_info() 
     
    9295        self.parent.on_set_focus(event) 
    9396        self.on_tap_focus() 
     97 
     98    def onTrafo(self, event): 
     99        """ 
     100        On Trafo radio button event, sets the Trafobt_string 
     101        """ 
     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() 
    94154 
    95155    def _fill_data_sizer(self): 
     
    624684        ## fill a sizer with the combobox to select dispersion type 
    625685        model_disp = wx.StaticText(self, wx.ID_ANY, 'Function') 
    626         CHECK_STATE = False 
     686        CHECK_STATE = self.cb1.GetValue() 
    627687 
    628688        ix = 0 
     
    9691029        self.state.model = self.model.clone() 
    9701030        ## save state into 
     1031        self.state.cb1 = self.cb1.GetValue() 
    9711032        self._copy_parameters_state(self.parameters, self.state.parameters) 
    9721033        self._copy_parameters_state(self.orientation_params_disp, 
     
    9791040                     StatusEvent(status=" Selected Distribution: Gaussian")) 
    9801041        #Fill the list of fittable parameters 
     1042        #self.select_all_param(event=None) 
    9811043        self.get_all_checked_params() 
    9821044        self.Layout() 
     
    26932755        self._manager.set_param2fit(self.uid, param2fit) 
    26942756 
     2757    def select_all_param(self, event): 
     2758        """ 
     2759        set to true or false all checkBox given the main checkbox value cb1 
     2760        """ 
     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 fit 
     2767                        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 orientation 
     2773                            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                                pass 
     2790 
     2791                        else: 
     2792                            ## for 1D all parameters except orientation 
     2793                            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                                    pass 
     2801                    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 panel 
     2816            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 
    26952824    def select_param(self, event): 
    26962825        """ 
     
    27392868        if len(self.fittable_param) > 0: 
    27402869            len_orient_para *= 2 
     2870        #Set the value of checkbox that selected every checkbox or not 
     2871        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) 
    27412876 
    27422877        self.save_current_state_fit() 
     
    28402975        iy = 0 
    28412976        ix = 0 
    2842         sizer.Add(wx.StaticText(self, wx.ID_ANY, 'Parameter'), 
    2843                   (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 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) 
    28442985        ix += 1 
    28452986        self.text2_2 = wx.StaticText(self, wx.ID_ANY, 'Value') 
     
    28683009        self.text2_4.Hide() 
    28693010 
    2870         CHECK_STATE = False 
     3011        CHECK_STATE = self.cb1.GetValue() 
    28713012        for item in keys: 
    28723013 
  • src/sas/sasgui/plottools/plottables.py

    r8abd96d r1fac6c0  
    10221022    """ 
    10231023 
    1024     def __init__(self, x, y, dx=None, dy=None): 
     1024    def __init__(self, x, y, dx=None, dy=None, lam=None, dlam=None): 
    10251025        """ 
    10261026        Draw points specified by x[i],y[i] in the current color/symbol. 
     
    10361036        self.x = x 
    10371037        self.y = y 
     1038        self.lam = lam 
    10381039        self.dx = dx 
    10391040        self.dy = dy 
     1041        self.dlam = dlam 
    10401042        self.source = None 
    10411043        self.detector = None 
Note: See TracChangeset for help on using the changeset viewer.