Changeset a48842a2 in sasview


Ignore:
Timestamp:
Jun 13, 2012 2:40:41 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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:
1a98ded
Parents:
9a14138
Message:

added data operation tool

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/calculator.py

    r9520702 ra48842a2  
    1414 
    1515from sans.guiframe.plugin_base import PluginBase 
     16from sans.perspectives.calculator.data_operator import DataOperatorWindow 
    1617import logging 
    1718 
     
    2627        logging.info("Calculator plug-in started")    
    2728        self.sub_menu = "Tool"  
    28    
     29        # data operator use one frame all the time 
     30        self.data_operator_frame = None 
     31         
    2932    def help(self, evt): 
    3033        """ 
     
    6164        pyconsole_help = "Python Console." 
    6265        #data_editor_help = "Meta Data Editor" 
    63         return [("SLD Calculator", sld_help, self.on_calculate_sld), 
     66        return [("Data Operation",  
     67                        'Data operation', self.on_data_operation), 
     68                ("SLD Calculator", sld_help, self.on_calculate_sld), 
    6469                ("Density/Volume Calculator", mass_volume_help,  
    6570                                            self.on_calculate_dv), 
     
    7681        Edit meta data  
    7782        """ 
    78         from data_editor import DataEditorWindow 
     83        from sans.perspectives.calculator.data_editor import DataEditorWindow 
    7984        frame = DataEditorWindow(parent=self.parent, data=[], 
    8085                                  title="Data Editor") 
    8186        self.put_icon(frame) 
    8287        frame.Show(True) 
    83  
     88               
     89    def on_data_operation(self, event): 
     90        """ 
     91        Data operation 
     92        """ 
     93        if self.data_operator_frame == None: 
     94            # Use one frame all the time 
     95            self.data_operator_frame = DataOperatorWindow(parent=self.parent,  
     96                                                title="Data Operation") 
     97            self.put_icon(self.data_operator_frame) 
     98        self.data_operator_frame.Show(False) 
     99        self.data_operator_frame.Show(True) 
     100         
    84101    def on_calculate_kiessig(self, event): 
    85102        """ 
    86103        Compute the Kiessig thickness 
    87104        """ 
    88         from kiessig_calculator_panel import KiessigWindow 
     105        from sans.perspectives.calculator.kiessig_calculator_panel \ 
     106        import KiessigWindow 
    89107        frame = KiessigWindow() 
    90108        self.put_icon(frame) 
     
    95113        Compute the scattering length density of molecula 
    96114        """ 
    97         from sld_panel import SldWindow 
     115        from sans.perspectives.calculator.sld_panel import SldWindow 
    98116        frame = SldWindow(base=self.parent) 
    99117        self.put_icon(frame) 
     
    104122        Compute the mass density or molar voulme 
    105123        """ 
    106         from density_panel import DensityWindow 
     124        from sans.perspectives.calculator.density_panel import DensityWindow 
    107125        frame = DensityWindow(base=self.parent) 
    108126        self.put_icon(frame) 
     
    113131        Compute the slit size a given data 
    114132        """ 
    115         from slit_length_calculator_panel import SlitLengthCalculatorWindow 
     133        from sans.perspectives.calculator.slit_length_calculator_panel \ 
     134        import SlitLengthCalculatorWindow 
    116135        frame = SlitLengthCalculatorWindow(parent=self.parent)   
    117136        self.put_icon(frame)   
     
    122141        Estimate the instrumental resolution 
    123142        """ 
    124         from resolution_calculator_panel import ResolutionWindow 
     143        from sans.perspectives.calculator.resolution_calculator_panel \ 
     144        import ResolutionWindow 
    125145        frame = ResolutionWindow(parent=self.parent) 
    126146        self.put_icon(frame) 
     
    153173        :param filename: file name to open in editor 
    154174        """ 
    155         from pyconsole import PyConsole 
     175        from sans.perspectives.calculator.pyconsole import PyConsole 
    156176        frame = PyConsole(parent=self.parent, filename=filename) 
    157177        self.put_icon(frame) 
  • plottools/src/danse/common/plottools/PlotPanel.py

    r10bfeb3 ra48842a2  
    177177        self.prevXtrans = "log10(x)" 
    178178        self.prevYtrans = "log10(y)" 
    179         self.canvas.mpl_connect('scroll_event', self.onWheel) 
     179        self.scroll_id = self.canvas.mpl_connect('scroll_event', self.onWheel) 
    180180        #taking care of dragging 
    181         self.canvas.mpl_connect('motion_notify_event', self.onMouseMotion) 
    182         self.canvas.mpl_connect('button_press_event', self.onLeftDown) 
    183         self.canvas.mpl_connect('pick_event', self.onPick) 
    184         self.canvas.mpl_connect('button_release_event', self.onLeftUp) 
     181        self.motion_id = self.canvas.mpl_connect('motion_notify_event',  
     182                                                 self.onMouseMotion) 
     183        self.press_id = self.canvas.mpl_connect('button_press_event',  
     184                                                self.onLeftDown) 
     185        self.pick_id = self.canvas.mpl_connect('pick_event', self.onPick) 
     186        self.release_id = self.canvas.mpl_connect('button_release_event',  
     187                                                  self.onLeftUp) 
    185188         
    186189        wx.EVT_RIGHT_DOWN(self, self.onLeftDown) 
  • sansdataloader/src/sans/dataloader/data_info.py

    rbd365666 ra48842a2  
    625625        return self._perform_operation(other, operation) 
    626626             
    627              
     627         
     628    def __or__(self, other): 
     629        """ 
     630        Union a data set with another 
     631         
     632        :param other: data set to be unified 
     633         
     634        :return: new data set 
     635         
     636        :raise ValueError: raised when two data sets are incompatible 
     637         
     638        """ 
     639        return self._perform_union(other) 
     640         
     641    def __ror__(self, other): 
     642        """ 
     643        Union a data set with another 
     644         
     645        :param other: data set to be unified 
     646         
     647        :return: new data set 
     648         
     649        :raise ValueError: raised when two data sets are incompatible 
     650         
     651        """ 
     652        return self._perform_union(other) 
     653                 
    628654class Data1D(plottable_1D, DataInfo): 
    629655    """ 
     
    728754                    msg = "Incompatible data sets: x-values do not match" 
    729755                    raise ValueError, msg 
     756                """ 
    730757                if self.dxl != None and other.dxl == None: 
    731758                    msg = "Incompatible data sets: dxl-values do not match" 
     
    740767                    msg = "Incompatible data sets: dxw-values do not match" 
    741768                    raise ValueError, msg 
    742              
     769                """ 
    743770            # Check that the other data set has errors, otherwise 
    744771            # create zero vector 
     
    788815                if result.dxl is not None and other.dxl is not None: 
    789816                    result.dxl[i] *= self.dxl[i] 
    790                     other.dxl[i] += (other.dxl[i]**2) 
     817                    result.dxl[i] += (other.dxl[i]**2) 
    791818                    result.dxl[i] /= 2 
    792819                    result.dxl[i] = math.sqrt(result.dxl[i]) 
    793                 if result.dxw is not None and self.dxw is not None: 
    794                     result.dxw[i] *= self.dxw[i] 
    795                     other.dxw[i] += (other.dxw[i]**2) 
    796                     result.dxw[i] /= 2 
    797                     result.dxw[i] = math.sqrt(result.dxw[i]) 
    798820            else: 
    799821                b = other 
     
    802824            result.y[i] = output.x 
    803825            result.dy[i] = math.sqrt(math.fabs(output.variance)) 
     826        return result 
     827     
     828    def _validity_check_union(self, other): 
     829        """ 
     830        Checks that the data lengths are compatible. 
     831        Checks that the x vectors are compatible. 
     832        Returns errors vectors equal to original 
     833        errors vectors if they were present or vectors 
     834        of zeros when none was found. 
     835         
     836        :param other: other data set for operation 
     837         
     838        :return: bool 
     839         
     840        :raise ValueError: when data types are not compatible 
     841         
     842        """ 
     843        if not isinstance(other, Data1D): 
     844            msg = "Unable to perform operation: different types of data set" 
     845            raise ValueError, msg    
     846        return True 
     847 
     848    def _perform_union(self, other): 
     849        """ 
     850        """ 
     851        # First, check the data compatibility 
     852        self._validity_check_union(other) 
     853        result = self.clone_without_data(len(self.x) + len(other.x)) 
     854        if self.dy == None or other.dy is None: 
     855            result.dy = None 
     856        else: 
     857            result.dy = numpy.zeros(len(self.x) + len(other.x)) 
     858        if self.dx == None or other.dx is None: 
     859            result.dx = None 
     860        else: 
     861            result.dx = numpy.zeros(len(self.x) + len(other.x)) 
     862        if self.dxw == None or other.dxw is None: 
     863            result.dxw = None 
     864        else: 
     865            result.dxw = numpy.zeros(len(self.x) + len(other.x)) 
     866        if self.dxl == None or other.dxl is None: 
     867            result.dxl = None 
     868        else: 
     869            result.dxl = numpy.zeros(len(self.x) + len(other.x)) 
     870 
     871        result.x = numpy.append(self.x, other.x) 
     872        #argsorting 
     873        ind = numpy.argsort(result.x) 
     874        result.x = result.x[ind] 
     875        result.y = numpy.append(self.y, other.y) 
     876        result.y = result.y[ind] 
     877        if result.dy != None: 
     878            result.dy = numpy.append(self.dy, other.dy) 
     879            result.dy = result.dy[ind] 
     880        if result.dx is not None: 
     881            result.dx = numpy.append(self.dx, other.dx) 
     882            result.dx = result.dx[ind] 
     883        if result.dxw is not None: 
     884            result.dxw = numpy.append(self.dxw, other.dxw) 
     885            result.dxw = result.dxw[ind] 
     886        if result.dxl is not None: 
     887            result.dxl = numpy.append(self.dxl, other.dxl) 
     888            result.dxl = result.dxl[ind] 
    804889        return result 
    805890         
     
    9151000                msg = "Incompatible data sets: I-values do not match" 
    9161001                raise ValueError, msg  
    917             if self.qx_data.all() != other.qx_data.all(): 
    918                 msg = "Incompatible data sets: qx-values do not match" 
    919                 raise ValueError, msg 
    920             if self.qy_data.all() != other.qy_data.all(): 
    921                 msg = "Incompatible data sets: qy-values do not match" 
    922                 raise ValueError, msg 
     1002            for ind in range(len(self.data)): 
     1003                if self.qx_data[ind] != other.qx_data[ind]: 
     1004                    msg = "Incompatible data sets: qx-values do not match" 
     1005                    raise ValueError, msg 
     1006                if self.qy_data[ind] != other.qy_data[ind]: 
     1007                    msg = "Incompatible data sets: qy-values do not match" 
     1008                    raise ValueError, msg 
    9231009                    
    9241010            # Check that the scales match 
     
    9931079            result.err_data[i] = math.sqrt(math.fabs(output.variance)) 
    9941080        return result 
     1081     
     1082    def _validity_check_union(self, other): 
     1083        """ 
     1084        Checks that the data lengths are compatible. 
     1085        Checks that the x vectors are compatible. 
     1086        Returns errors vectors equal to original 
     1087        errors vectors if they were present or vectors 
     1088        of zeros when none was found. 
     1089         
     1090        :param other: other data set for operation 
     1091         
     1092        :return: bool 
     1093         
     1094        :raise ValueError: when data types are not compatible 
     1095         
     1096        """ 
     1097        if not isinstance(other, Data2D): 
     1098            msg = "Unable to perform operation: different types of data set" 
     1099            raise ValueError, msg    
     1100        return True 
     1101     
     1102    def _perform_union(self, other): 
     1103        """ 
     1104        Perform 2D operations between data sets 
     1105         
     1106        :param other: other data set 
     1107        :param operation: function defining the operation 
     1108         
     1109        """ 
     1110        # First, check the data compatibility 
     1111        self._validity_check_union(other) 
     1112        result = self.clone_without_data(numpy.size(self.data) + \ 
     1113                                         numpy.size(other.data)) 
     1114        result.xmin = self.xmin 
     1115        result.xmax = self.xmax 
     1116        result.ymin = self.ymin 
     1117        result.ymax = self.ymax 
     1118        if self.dqx_data == None or self.dqy_data == None or \ 
     1119                other.dqx_data == None or other.dqy_data == None : 
     1120            result.dqx_data = None 
     1121            result.dqy_data = None 
     1122        else: 
     1123            result.dqx_data = numpy.zeros(len(self.data) + \ 
     1124                                         numpy.size(other.data)) 
     1125            result.dqy_data = numpy.zeros(len(self.data) + \ 
     1126                                         numpy.size(other.data)) 
     1127         
     1128        result.data = numpy.append(self.data, other.data) 
     1129        result.qx_data = numpy.append(self.qx_data, other.qx_data) 
     1130        result.qy_data = numpy.append(self.qy_data, other.qy_data) 
     1131        result.q_data = numpy.append(self.q_data, other.q_data) 
     1132        result.mask = numpy.append(self.mask, other.mask) 
     1133        if result.err_data is not None: 
     1134            result.err_data = numpy.append(self.err_data, other.err_data)  
     1135        if self.dqx_data is not None: 
     1136            result.dqx_data = numpy.append(self.dqx_data, other.dqx_data) 
     1137        if self.dqy_data is not None: 
     1138            result.dqy_data = numpy.append(self.dqy_data, other.dqy_data) 
     1139 
     1140        return result 
  • sansguiframe/src/sans/guiframe/dataFitting.py

    rb21d32b ra48842a2  
    6969        dy, dy_other = self._validity_check(other) 
    7070        result = Data1D(x=[], y=[], dx=None, dy=None) 
    71         result.clone_without_data(clone=self) 
     71        result.clone_without_data(length=len(self.x), clone=self) 
    7272        result.copy_from_datainfo(data1d=self) 
     73        if self.dxw == None: 
     74            result.dxw = None 
     75        else: 
     76            result.dxw = numpy.zeros(len(self.x)) 
     77        if self.dxl == None: 
     78            result.dxl = None 
     79        else: 
     80            result.dxl = numpy.zeros(len(self.x)) 
     81 
    7382        for i in range(len(self.x)): 
    7483            result.x[i] = self.x[i] 
    7584            if self.dx is not None and len(self.x) == len(self.dx): 
    7685                result.dx[i] = self.dx[i] 
     86            if self.dxw is not None and len(self.x) == len(self.dxw): 
     87                result.dxw[i] = self.dxw[i] 
     88            if self.dxl is not None and len(self.x) == len(self.dxl): 
     89                result.dxl[i] = self.dxl[i] 
    7790             
    7891            a = Uncertainty(self.y[i], dy[i]**2) 
    7992            if isinstance(other, Data1D): 
    8093                b = Uncertainty(other.y[i], dy_other[i]**2) 
     94                if other.dx is not None: 
     95                    result.dx[i] *= self.dx[i] 
     96                    result.dx[i] += (other.dx[i]**2) 
     97                    result.dx[i] /= 2 
     98                    result.dx[i] = math.sqrt(result.dx[i]) 
     99                if result.dxl is not None and other.dxl is not None: 
     100                    result.dxl[i] *= self.dxl[i] 
     101                    result.dxl[i] += (other.dxl[i]**2) 
     102                    result.dxl[i] /= 2 
     103                    result.dxl[i] = math.sqrt(result.dxl[i]) 
    81104            else: 
    82105                b = other 
     
    84107            output = operation(a, b) 
    85108            result.y[i] = output.x 
    86             if result.dy is None: result.dy = numpy.zeros(len(self.x)) 
    87109            result.dy[i] = math.sqrt(math.fabs(output.variance)) 
     110        return result 
     111     
     112    def _perform_union(self, other): 
     113        """ 
     114        """ 
     115        # First, check the data compatibility 
     116        self._validity_check_union(other) 
     117        result = Data1D(x=[], y=[], dx=None, dy=None) 
     118        tot_length = len(self.x) + len(other.x) 
     119        result = self.clone_without_data(length=tot_length, clone=result) 
     120        if self.dy == None or other.dy is None: 
     121            result.dy = None 
     122        else: 
     123            result.dy = numpy.zeros(tot_length) 
     124        if self.dx == None or other.dx is None: 
     125            result.dx = None 
     126        else: 
     127            result.dx = numpy.zeros(tot_length) 
     128        if self.dxw == None or other.dxw is None: 
     129            result.dxw = None 
     130        else: 
     131            result.dxw = numpy.zeros(tot_length) 
     132        if self.dxl == None or other.dxl is None: 
     133            result.dxl = None 
     134        else: 
     135            result.dxl = numpy.zeros(tot_length) 
     136 
     137        result.x = numpy.append(self.x, other.x) 
     138        #argsorting 
     139        ind = numpy.argsort(result.x) 
     140        result.x = result.x[ind] 
     141        result.y = numpy.append(self.y, other.y) 
     142        result.y = result.y[ind] 
     143        if result.dy != None: 
     144            result.dy = numpy.append(self.dy, other.dy) 
     145            result.dy = result.dy[ind] 
     146        if result.dx is not None: 
     147            result.dx = numpy.append(self.dx, other.dx) 
     148            result.dx = result.dx[ind] 
     149        if result.dxw is not None: 
     150            result.dxw = numpy.append(self.dxw, other.dxw) 
     151            result.dxw = result.dxw[ind] 
     152        if result.dxl is not None: 
     153            result.dxl = numpy.append(self.dxl, other.dxl) 
     154            result.dxl = result.dxl[ind] 
    88155        return result 
    89156     
     
    142209        # First, check the data compatibility 
    143210        dy, dy_other = self._validity_check(other) 
    144         result = Theory1D(x=[], y=[], dy=None) 
    145         result.clone_without_data(clone=self) 
     211        result = self.clone_without_data(len(self.x)) 
    146212        result.copy_from_datainfo(data1d=self) 
    147         for i in range(len(self.x)): 
     213        if self.dxw == None: 
     214            result.dxw = None 
     215        else: 
     216            result.dxw = numpy.zeros(len(self.x)) 
     217        if self.dxl == None: 
     218            result.dxl = None 
     219        else: 
     220            result.dxl = numpy.zeros(len(self.x)) 
     221 
     222        for i in range(numpy.size(self.x)): 
    148223            result.x[i] = self.x[i] 
    149             
     224            if self.dx is not None and len(self.x) == len(self.dx): 
     225                result.dx[i] = self.dx[i] 
     226            if self.dxw is not None and len(self.x) == len(self.dxw): 
     227                result.dxw[i] = self.dxw[i] 
     228            if self.dxl is not None and len(self.x) == len(self.dxl): 
     229                result.dxl[i] = self.dxl[i] 
     230             
    150231            a = Uncertainty(self.y[i], dy[i]**2) 
    151232            if isinstance(other, Data1D): 
    152233                b = Uncertainty(other.y[i], dy_other[i]**2) 
     234                if other.dx is not None: 
     235                    result.dx[i] *= self.dx[i] 
     236                    result.dx[i] += (other.dx[i]**2) 
     237                    result.dx[i] /= 2 
     238                    result.dx[i] = math.sqrt(result.dx[i]) 
     239                if result.dxl is not None and other.dxl is not None: 
     240                    result.dxl[i] *= self.dxl[i] 
     241                    other.dxl[i] += (other.dxl[i]**2) 
     242                    result.dxl[i] /= 2 
     243                    result.dxl[i] = math.sqrt(result.dxl[i]) 
     244                if result.dxw is not None and self.dxw is not None: 
     245                    result.dxw[i] *= self.dxw[i] 
     246                    other.dxw[i] += (other.dxw[i]**2) 
     247                    result.dxw[i] /= 2 
     248                    result.dxw[i] = math.sqrt(result.dxw[i]) 
    153249            else: 
    154250                b = other 
     251             
    155252            output = operation(a, b) 
    156253            result.y[i] = output.x 
    157             if result.dy is None: 
    158                 result.dy = numpy.zeros(len(self.x)) 
    159254            result.dy[i] = math.sqrt(math.fabs(output.variance)) 
    160255        return result 
    161256     
     257    def _perform_union(self, other): 
     258        """ 
     259        """ 
     260        # First, check the data compatibility 
     261        self._validity_check_union(other) 
     262        result = Data1D(x=[], y=[], dx=None, dy=None) 
     263        tot_length = len(self.x)+len(other.x) 
     264        result.clone_without_data(length=tot_length, clone=self) 
     265        if self.dy == None or other.dy is None: 
     266            result.dy = None 
     267        else: 
     268            result.dy = numpy.zeros(tot_length) 
     269        if self.dx == None or other.dx is None: 
     270            result.dx = None 
     271        else: 
     272            result.dx = numpy.zeros(tot_length) 
     273        if self.dxw == None or other.dxw is None: 
     274            result.dxw = None 
     275        else: 
     276            result.dxw = numpy.zeros(tot_length) 
     277        if self.dxl == None or other.dxl is None: 
     278            result.dxl = None 
     279        else: 
     280            result.dxl = numpy.zeros(tot_length) 
     281        result.x = numpy.append(self.x, other.x) 
     282        #argsorting 
     283        ind = numpy.argsort(result.x) 
     284        result.x = result.x[ind] 
     285        result.y = numpy.append(self.y, other.y) 
     286        result.y = result.y[ind] 
     287        if result.dy != None: 
     288            result.dy = numpy.append(self.dy, other.dy) 
     289            result.dy = result.dy[ind] 
     290        if result.dx is not None: 
     291            result.dx = numpy.append(self.dx, other.dx) 
     292            result.dx = result.dx[ind] 
     293        if result.dxw is not None: 
     294            result.dxw = numpy.append(self.dxw, other.dxw) 
     295            result.dxw = result.dxw[ind] 
     296        if result.dxl is not None: 
     297            result.dxl = numpy.append(self.dxl, other.dxl) 
     298            result.dxl = result.dxl[ind] 
     299        return result 
     300  
    162301       
    163302class Data2D(PlotData2D, LoadData2D): 
     
    234373        # First, check the data compatibility 
    235374        dy, dy_other = self._validity_check(other) 
    236      
    237375        result = Data2D(image=None, qx_data=None, qy_data=None, 
    238                          err_image=None, xmin=None, xmax=None, 
     376                         q_data=None, err_image=None, xmin=None, xmax=None, 
    239377                         ymin=None, ymax=None, zmin=None, zmax=None) 
    240          
    241         result.clone_without_data(clone=self) 
     378        result.clone_without_data(len(self.data), self) 
    242379        result.copy_from_datainfo(data2d=self) 
    243          
    244         for i in range(numpy.size(self.data, 0)): 
    245             for j in range(numpy.size(self.data, 1)): 
    246                 result.data[i][j] = self.data[i][j] 
    247                 if self.err_data is not None and \ 
    248                         numpy.size(self.data) == numpy.size(self.err_data): 
    249                     result.err_data[i][j] = self.err_data[i][j] 
    250                  
    251                 a = Uncertainty(self.data[i][j], dy[i][j]**2) 
    252                 if isinstance(other, Data2D): 
    253                     b = Uncertainty(other.data[i][j], dy_other[i][j]**2) 
    254                 else: 
    255                     b = other 
    256                 output = operation(a, b) 
    257                 result.data[i][j] = output.x 
    258                 result.err_data[i][j] = math.sqrt(math.fabs(output.variance)) 
     380        result.xmin = self.xmin 
     381        result.xmax = self.xmax 
     382        result.ymin = self.ymin 
     383        result.ymax = self.ymax 
     384        if self.dqx_data == None or self.dqy_data == None: 
     385            result.dqx_data = None 
     386            result.dqy_data = None 
     387        else: 
     388            result.dqx_data = numpy.zeros(len(self.data)) 
     389            result.dqy_data = numpy.zeros(len(self.data)) 
     390        for i in range(numpy.size(self.data)): 
     391            result.data[i] = self.data[i] 
     392            if self.err_data is not None and \ 
     393                numpy.size(self.data) == numpy.size(self.err_data): 
     394                result.err_data[i] = self.err_data[i]     
     395            if self.dqx_data is not None: 
     396                result.dqx_data[i] = self.dqx_data[i] 
     397            if self.dqy_data is not None: 
     398                result.dqy_data[i] = self.dqy_data[i] 
     399            result.qx_data[i] = self.qx_data[i] 
     400            result.qy_data[i] = self.qy_data[i] 
     401            result.q_data[i] = self.q_data[i] 
     402            result.mask[i] = self.mask[i] 
     403             
     404            a = Uncertainty(self.data[i], dy[i]**2) 
     405            if isinstance(other, Data2D): 
     406                b = Uncertainty(other.data[i], dy_other[i]**2) 
     407                if other.dqx_data is not None and \ 
     408                        result.dqx_data is not None: 
     409                    result.dqx_data[i] *= self.dqx_data[i] 
     410                    result.dqx_data[i] += (other.dqx_data[i]**2) 
     411                    result.dqx_data[i] /= 2 
     412                    result.dqx_data[i] = math.sqrt(result.dqx_data[i])      
     413                if other.dqy_data is not None and \ 
     414                        result.dqy_data is not None: 
     415                    result.dqy_data[i] *= self.dqy_data[i] 
     416                    result.dqy_data[i] += (other.dqy_data[i]**2) 
     417                    result.dqy_data[i] /= 2 
     418                    result.dqy_data[i] = math.sqrt(result.dqy_data[i]) 
     419            else: 
     420                b = other 
     421             
     422            output = operation(a, b) 
     423            result.data[i] = output.x 
     424            result.err_data[i] = math.sqrt(math.fabs(output.variance)) 
     425        return result 
     426     
     427    def _perform_union(self, other): 
     428        """ 
     429        Perform 2D operations between data sets 
     430         
     431        :param other: other data set 
     432        :param operation: function defining the operation 
     433         
     434        """ 
     435        # First, check the data compatibility 
     436        self._validity_check_union(other) 
     437        result = Data2D(image=None, qx_data=None, qy_data=None, 
     438                         q_data=None, err_image=None, xmin=None, xmax=None, 
     439                         ymin=None, ymax=None, zmin=None, zmax=None) 
     440        length = len(self.data) 
     441        tot_length = length + len(other.data) 
     442        result.clone_without_data(tot_length, self) 
     443        result.xmin = self.xmin 
     444        result.xmax = self.xmax 
     445        result.ymin = self.ymin 
     446        result.ymax = self.ymax 
     447        if self.dqx_data == None or self.dqy_data == None or \ 
     448                other.dqx_data == None or other.dqy_data == None : 
     449            result.dqx_data = None 
     450            result.dqy_data = None 
     451        else: 
     452            result.dqx_data = numpy.zeros(len(self.data) + \ 
     453                                         numpy.size(other.data)) 
     454            result.dqy_data = numpy.zeros(len(self.data) + \ 
     455                                         numpy.size(other.data)) 
     456         
     457        result.data = numpy.append(self.data, other.data) 
     458        result.qx_data = numpy.append(self.qx_data, other.qx_data) 
     459        result.qy_data = numpy.append(self.qy_data, other.qy_data) 
     460        result.q_data = numpy.append(self.q_data, other.q_data) 
     461        result.mask = numpy.append(self.mask, other.mask) 
     462        if result.err_data is not None: 
     463            result.err_data = numpy.append(self.err_data, other.err_data)  
     464        if self.dqx_data is not None: 
     465            result.dqx_data = numpy.append(self.dqx_data, other.dqx_data) 
     466        if self.dqy_data is not None: 
     467            result.dqy_data = numpy.append(self.dqy_data, other.dqy_data) 
     468 
    259469        return result 
    260470         
  • sansguiframe/src/sans/guiframe/gui_manager.py

    r9a14138 ra48842a2  
    194194    IS_WIN = False 
    195195    TIME_FACTOR = 2 
    196     if int(str(wx.__version__).split('.')[0]) == 2: 
    197         if int(str(wx.__version__).split('.')[1]) < 9: 
     196    if int(wx.__version__.split('.')[0]) == 2: 
     197        if int(wx.__version__.split('.')[1]) < 9: 
    198198            CLOSE_SHOW = False 
    199199     
     
    831831                        continue 
    832832                    path = [os.path.abspath(dir)] 
    833                     file = None 
     833                    file = '' 
    834834                    try: 
    835835                        if toks[1] == '': 
     
    17871787                if self._data_panel is not None and \ 
    17881788                            ID in self.plot_panels.keys(): 
    1789                     self._data_panel.cb_plotpanel.Append(str(caption),  
    1790                                                          self.panels[ID]) 
     1789                    self._data_panel.cb_plotpanel.Append(str(caption), p) 
    17911790                # Do not Hide default panel here... 
    17921791                #self._mgr.GetPane(self.panels["default"].window_name).Hide() 
     
    18541853            log_msg += "Try Data opening...." 
    18551854            logging.info(log_msg) 
    1856             print log_msg 
    1857             #self.load_complete(output=output, error_message=error_message, 
    1858             #       message=log_msg, path=path)     
     1855            self.load_complete(output=output, error_message=error_message, 
     1856                   message=log_msg, path=path)     
    18591857            return 
    18601858         
     
    26182616            for i in range(len(data.x)): 
    26192617                if has_errors: 
    2620                     if data.dx != [] and data.dx != None: 
     2618                    if data.dx != None and data.dx != []: 
    26212619                        if  data.dx[i] != None: 
    26222620                            out.write("%g  %g  %g  %g\n" % (data.x[i],  
     
    32103208        drag  
    32113209        """ 
    3212         #if self.cpanel_on_focus is not None: 
    3213         #    self._toolbar.enable_drag(self.panel_on_focus) 
     3210        if self.cpanel_on_focus is not None: 
     3211            self._toolbar.enable_drag(self.panel_on_focus) 
    32143212             
    32153213    def enable_reset(self): 
     
    34193417            self.frame.Show() 
    34203418  
    3421         #if hasattr(self.frame, 'special'): 
    3422         #    self.frame.special.SetCurrent() 
     3419        if hasattr(self.frame, 'special'): 
     3420            self.frame.special.SetCurrent() 
    34233421        self.SetTopWindow(self.frame) 
    34243422   
Note: See TracChangeset for help on using the changeset viewer.