Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/data_info.py

    r4fdcc65 re090ba90  
    2626import numpy as np 
    2727import math 
     28from math import fabs 
    2829 
    2930class plottable_1D(object): 
     
    656657        return self._perform_operation(other, operation) 
    657658 
    658     def __div__(self, other): 
     659    def __truediv__(self, other): 
    659660        """ 
    660661        Divided a data set by another 
     
    667668            return a/b 
    668669        return self._perform_operation(other, operation) 
    669  
    670     def __rdiv__(self, other): 
     670    __div__ = __truediv__ 
     671 
     672    def __rtruediv__(self, other): 
    671673        """ 
    672674        Divided a data set by another 
     
    679681            return b/a 
    680682        return self._perform_operation(other, operation) 
     683    __rdiv__ = __rtruediv__ 
    681684 
    682685    def __or__(self, other): 
     
    800803            TOLERANCE = 0.01 
    801804            for i in range(len(self.x)): 
    802                 if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 
     805                if fabs(self.x[i] - other.x[i]) > self.x[i]*TOLERANCE: 
    803806                    msg = "Incompatible data sets: x-values do not match" 
    804807                    raise ValueError(msg) 
     
    954957        _str += "Data:\n" 
    955958        _str += "   Type:         %s\n" % self.__class__.__name__ 
    956         _str += "   X-axis:       %s\t[%s]\n" % (self._xaxis, self._xunit) 
    957         _str += "   Y-axis:       %s\t[%s]\n" % (self._yaxis, self._yunit) 
     959        _str += "   X- & Y-axis:  %s\t[%s]\n" % (self._yaxis, self._yunit) 
    958960        _str += "   Z-axis:       %s\t[%s]\n" % (self._zaxis, self._zunit) 
    959961        _str += "   Length:       %g \n" % (len(self.data)) 
     
    984986                           qx_data=qx_data, qy_data=qy_data, 
    985987                           q_data=q_data, mask=mask) 
    986  
    987         clone._xaxis = self._xaxis 
    988         clone._yaxis = self._yaxis 
    989         clone._zaxis = self._zaxis 
    990         clone._xunit = self._xunit 
    991         clone._yunit = self._yunit 
    992         clone._zunit = self._zunit 
    993         clone.x_bins = self.x_bins 
    994         clone.y_bins = self.y_bins 
    995988 
    996989        clone.title = self.title 
     
    10321025                raise ValueError(msg) 
    10331026            for ind in range(len(self.data)): 
    1034                 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 
     1027                if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 
    10351028                    msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 
    10361029                    raise ValueError(msg) 
    1037                 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 
     1030                if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 
    10381031                    msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 
    10391032                    raise ValueError(msg) 
     
    11631156def combine_data_info_with_plottable(data, datainfo): 
    11641157    """ 
    1165     A function that combines the DataInfo data in self.current_datainto with a 
    1166     plottable_1D or 2D data object. 
     1158    A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object. 
    11671159 
    11681160    :param data: A plottable_1D or plottable_2D data object 
     
    11821174        final_dataset.yaxis(data._yaxis, data._yunit) 
    11831175    elif isinstance(data, plottable_2D): 
    1184         final_dataset = Data2D(data.data, data.err_data, data.qx_data, 
    1185                                data.qy_data, data.q_data, data.mask, 
    1186                                data.dqx_data, data.dqy_data) 
     1176        final_dataset = Data2D(data.data, data.err_data, data.qx_data, data.qy_data, data.q_data, 
     1177                               data.mask, data.dqx_data, data.dqy_data) 
    11871178        final_dataset.xaxis(data._xaxis, data._xunit) 
    11881179        final_dataset.yaxis(data._yaxis, data._yunit) 
    11891180        final_dataset.zaxis(data._zaxis, data._zunit) 
    1190         final_dataset.y_bins = data.y_bins 
    1191         final_dataset.x_bins = data.x_bins 
     1181        if len(data.data.shape) == 2: 
     1182            n_rows, n_cols = data.data.shape 
     1183            final_dataset.y_bins = data.qy_data[0::int(n_cols)] 
     1184            final_dataset.x_bins = data.qx_data[:int(n_cols)] 
    11921185    else: 
    1193         return_string = ("Should Never Happen: _combine_data_info_with_plottabl" 
    1194                          "e input is not a plottable1d or plottable2d data " 
    1195                          "object") 
     1186        return_string = "Should Never Happen: _combine_data_info_with_plottable input is not a plottable1d or " + \ 
     1187                        "plottable2d data object" 
    11961188        return return_string 
    11971189 
Note: See TracChangeset for help on using the changeset viewer.