Changeset ed2276f in sasview for src/sas/sascalc


Ignore:
Timestamp:
Apr 4, 2017 12:00:18 PM (7 years ago)
Author:
GitHub <noreply@…>
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7b15990
Parents:
9a5097c (diff), 571bf4b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Andrew Jackson <andrew.jackson@…> (04/04/17 12:00:18)
git-committer:
GitHub <noreply@…> (04/04/17 12:00:18)
Message:

Merge branch 'master' into numpy_import

Location:
src/sas/sascalc
Files:
31 edited

Legend:

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

    r9a5097c red2276f  
    8080 
    8181    """ 
    82     if data2d.data == None or data2d.x_bins == None or data2d.y_bins == None: 
     82    if data2d.data is None or data2d.x_bins is None or data2d.y_bins is None: 
    8383        raise ValueError, "Can't convert this data: data=None..." 
    8484    new_x = np.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
     
    9292    if data2d.err_data == None or np.any(data2d.err_data <= 0): 
    9393        new_err_data = np.sqrt(np.abs(new_data)) 
     94 
    9495    else: 
    9596        new_err_data = data2d.err_data.flatten() 
  • src/sas/sascalc/dataloader/readers/IgorReader.py

    r9a5097c red2276f  
    1313############################################################################# 
    1414import os 
     15 
    1516import numpy as np 
    1617import math 
    1718#import logging 
     19 
    1820from sas.sascalc.dataloader.data_info import Data2D 
    1921from sas.sascalc.dataloader.data_info import Detector 
     
    4042        """ Read file """ 
    4143        if not os.path.isfile(filename): 
    42             raise ValueError, \ 
    43             "Specified file %s is not a regular file" % filename 
    44          
    45         # Read file 
    46         f = open(filename, 'r') 
    47         buf = f.read() 
    48          
    49         # Instantiate data object 
     44            raise ValueError("Specified file %s is not a regular " 
     45                             "file" % filename) 
     46         
    5047        output = Data2D() 
     48 
    5149        output.filename = os.path.basename(filename) 
    5250        detector = Detector() 
    53         if len(output.detector) > 0: 
    54             print str(output.detector[0]) 
     51        if len(output.detector): 
     52            print(str(output.detector[0])) 
    5553        output.detector.append(detector) 
    56                  
    57         # Get content 
    58         dataStarted = False 
    59          
    60         lines = buf.split('\n') 
    61         itot = 0 
    62         x = [] 
    63         y = [] 
    64          
    65         ncounts = 0 
    66          
    67         xmin = None 
    68         xmax = None 
    69         ymin = None 
    70         ymax = None 
    71          
    72         i_x = 0 
    73         i_y = -1 
    74         i_tot_row = 0 
    75          
    76         isInfo = False 
    77         isCenter = False 
    78         
    79         data_conv_q = None 
    80         data_conv_i = None 
    81          
    82         if has_converter == True and output.Q_unit != '1/A': 
     54 
     55        data_conv_q = data_conv_i = None 
     56         
     57        if has_converter and output.Q_unit != '1/A': 
    8358            data_conv_q = Converter('1/A') 
    8459            # Test it 
    8560            data_conv_q(1.0, output.Q_unit) 
    8661             
    87         if has_converter == True and output.I_unit != '1/cm': 
     62        if has_converter and output.I_unit != '1/cm': 
    8863            data_conv_i = Converter('1/cm') 
    8964            # Test it 
    9065            data_conv_i(1.0, output.I_unit) 
    91           
     66 
    9267        for line in lines: 
    9368             
     
    12095        output.data = np.zeros([size_x, size_y]) 
    12196        output.err_data = np.zeros([size_x, size_y]) 
    122       
    123         #Read Header and 2D data 
    124         for line in lines: 
    125             # Find setup info line 
    126             if isInfo: 
    127                 isInfo = False 
    128                 line_toks = line.split() 
    129                 # Wavelength in Angstrom 
    130                 try: 
    131                     wavelength = float(line_toks[1]) 
    132                 except: 
    133                     msg = "IgorReader: can't read this file, missing wavelength" 
    134                     raise ValueError, msg 
    135                 # Distance in meters 
    136                 try: 
    137                     distance = float(line_toks[3]) 
    138                 except: 
    139                     msg = "IgorReader: can't read this file, missing distance" 
    140                     raise ValueError, msg 
    141                  
    142                 # Distance in meters 
    143                 try: 
    144                     transmission = float(line_toks[4]) 
    145                 except: 
    146                     msg = "IgorReader: can't read this file, " 
    147                     msg += "missing transmission" 
    148                     raise ValueError, msg 
    149                                              
    150             if line.count("LAMBDA") > 0: 
    151                 isInfo = True 
    152                  
    153             # Find center info line 
    154             if isCenter: 
    155                 isCenter = False 
    156                 line_toks = line.split() 
    157                  
    158                 # Center in bin number: Must substrate 1 because 
    159                 #the index starts from 1 
    160                 center_x = float(line_toks[0]) - 1 
    161                 center_y = float(line_toks[1]) - 1 
    162  
    163             if line.count("BCENT") > 0: 
    164                 isCenter = True 
    165                  
    166             # Find data start 
    167             if line.count("***")>0: 
    168                 dataStarted = True 
    169                  
    170                 # Check that we have all the info 
    171                 if wavelength == None \ 
    172                     or distance == None \ 
    173                     or center_x == None \ 
    174                     or center_y == None: 
    175                     msg = "IgorReader:Missing information in data file" 
    176                     raise ValueError, msg 
    177                  
    178             if dataStarted == True: 
    179                 try: 
    180                     value = float(line) 
    181                 except: 
    182                     # Found a non-float entry, skip it 
    183                     continue 
    184                  
    185                 # Get bin number 
    186                 if math.fmod(itot, i_tot_row) == 0: 
    187                     i_x = 0 
    188                     i_y += 1 
    189                 else: 
    190                     i_x += 1 
    191                      
    192                 output.data[i_y][i_x] = value 
    193                 ncounts += 1 
    194                  
    195                 # Det 640 x 640 mm 
    196                 # Q = 4pi/lambda sin(theta/2) 
    197                 # Bin size is 0.5 cm  
    198                 #REmoved +1 from theta = (i_x-center_x+1)*0.5 / distance 
    199                 # / 100.0 and  
    200                 #REmoved +1 from theta = (i_y-center_y+1)*0.5 / 
    201                 # distance / 100.0 
    202                 #ToDo: Need  complete check if the following 
    203                 # covert process is consistent with fitting.py. 
    204                 theta = (i_x - center_x) * 0.5 / distance / 100.0 
    205                 qx = 4.0 * math.pi / wavelength * math.sin(theta/2.0) 
    206  
    207                 if has_converter == True and output.Q_unit != '1/A': 
    208                     qx = data_conv_q(qx, units=output.Q_unit) 
    209  
    210                 if xmin == None or qx < xmin: 
    211                     xmin = qx 
    212                 if xmax == None or qx > xmax: 
    213                     xmax = qx 
    214                  
    215                 theta = (i_y - center_y) * 0.5 / distance / 100.0 
    216                 qy = 4.0 * math.pi / wavelength * math.sin(theta / 2.0) 
    217  
    218                 if has_converter == True and output.Q_unit != '1/A': 
    219                     qy = data_conv_q(qy, units=output.Q_unit) 
    220                  
    221                 if ymin == None or qy < ymin: 
    222                     ymin = qy 
    223                 if ymax == None or qy > ymax: 
    224                     ymax = qy 
    225                  
    226                 if not qx in x: 
    227                     x.append(qx) 
    228                 if not qy in y: 
    229                     y.append(qy) 
    230                  
    231                 itot += 1 
    232                    
    233                    
     97   
     98        data_row = 0 
     99        wavelength = distance = center_x = center_y = None 
     100        dataStarted = isInfo = isCenter = False 
     101 
     102        with open(filename, 'r') as f: 
     103            for line in f: 
     104                data_row += 1 
     105                # Find setup info line 
     106                if isInfo: 
     107                    isInfo = False 
     108                    line_toks = line.split() 
     109                    # Wavelength in Angstrom 
     110                    try: 
     111                        wavelength = float(line_toks[1]) 
     112                    except ValueError: 
     113                        msg = "IgorReader: can't read this file, missing wavelength" 
     114                        raise ValueError(msg) 
     115                    # Distance in meters 
     116                    try: 
     117                        distance = float(line_toks[3]) 
     118                    except ValueError: 
     119                        msg = "IgorReader: can't read this file, missing distance" 
     120                        raise ValueError(msg) 
     121 
     122                    # Distance in meters 
     123                    try: 
     124                        transmission = float(line_toks[4]) 
     125                    except: 
     126                        msg = "IgorReader: can't read this file, " 
     127                        msg += "missing transmission" 
     128                        raise ValueError(msg) 
     129 
     130                if line.count("LAMBDA"): 
     131                    isInfo = True 
     132 
     133                # Find center info line 
     134                if isCenter: 
     135                    isCenter = False 
     136                    line_toks = line.split() 
     137 
     138                    # Center in bin number: Must subtract 1 because 
     139                    # the index starts from 1 
     140                    center_x = float(line_toks[0]) - 1 
     141                    center_y = float(line_toks[1]) - 1 
     142 
     143                if line.count("BCENT"): 
     144                    isCenter = True 
     145 
     146                # Find data start 
     147                if line.count("***"): 
     148                    # now have to continue to blank line 
     149                    dataStarted = True 
     150 
     151                    # Check that we have all the info 
     152                    if (wavelength is None 
     153                            or distance is None 
     154                            or center_x is None 
     155                            or center_y is None): 
     156                        msg = "IgorReader:Missing information in data file" 
     157                        raise ValueError(msg) 
     158 
     159                if dataStarted: 
     160                    if len(line.rstrip()): 
     161                        continue 
     162                    else: 
     163                        break 
     164 
     165        # The data is loaded in row major order (last index changing most 
     166        # rapidly). However, the original data is in column major order (first 
     167        # index changing most rapidly). The swap to column major order is done 
     168        # in reader2D_converter at the end of this method. 
     169        data = np.loadtxt(filename, skiprows=data_row) 
     170        size_x = size_y = int(np.rint(np.sqrt(data.size))) 
     171        output.data = np.reshape(data, (size_x, size_y)) 
     172        output.err_data = np.zeros_like(output.data) 
     173 
     174        # Det 640 x 640 mm 
     175        # Q = 4 * pi/lambda * sin(theta/2) 
     176        # Bin size is 0.5 cm 
     177        # Removed +1 from theta = (i_x - center_x + 1)*0.5 / distance 
     178        # / 100.0 and 
     179        # Removed +1 from theta = (i_y - center_y + 1)*0.5 / 
     180        # distance / 100.0 
     181        # ToDo: Need  complete check if the following 
     182        # convert process is consistent with fitting.py. 
     183 
     184        # calculate qx, qy bin centers of each pixel in the image 
     185        theta = (np.arange(size_x) - center_x) * 0.5 / distance / 100. 
     186        qx = 4 * np.pi / wavelength * np.sin(theta/2) 
     187 
     188        theta = (np.arange(size_y) - center_y) * 0.5 / distance / 100. 
     189        qy = 4 * np.pi / wavelength * np.sin(theta/2) 
     190 
     191        if has_converter and output.Q_unit != '1/A': 
     192            qx = data_conv_q(qx, units=output.Q_unit) 
     193            qy = data_conv_q(qx, units=output.Q_unit) 
     194 
     195        xmax = np.max(qx) 
     196        xmin = np.min(qx) 
     197        ymax = np.max(qy) 
     198        ymin = np.min(qy) 
     199 
     200        # calculate edge offset in q. 
    234201        theta = 0.25 / distance / 100.0 
    235         xstep = 4.0 * math.pi / wavelength * math.sin(theta / 2.0) 
     202        xstep = 4.0 * np.pi / wavelength * np.sin(theta / 2.0) 
    236203         
    237204        theta = 0.25 / distance / 100.0 
    238         ystep = 4.0 * math.pi/ wavelength * math.sin(theta / 2.0) 
     205        ystep = 4.0 * np.pi/ wavelength * np.sin(theta / 2.0) 
    239206         
    240207        # Store all data ###################################### 
    241208        # Store wavelength 
    242         if has_converter == True and output.source.wavelength_unit != 'A': 
     209        if has_converter and output.source.wavelength_unit != 'A': 
    243210            conv = Converter('A') 
    244211            wavelength = conv(wavelength, units=output.source.wavelength_unit) 
     
    246213 
    247214        # Store distance 
    248         if has_converter == True and detector.distance_unit != 'm': 
     215        if has_converter and detector.distance_unit != 'm': 
    249216            conv = Converter('m') 
    250217            distance = conv(distance, units=detector.distance_unit) 
     
    254221        output.sample.transmission = transmission 
    255222         
    256         # Store pixel size 
     223        # Store pixel size (mm) 
    257224        pixel = 5.0 
    258         if has_converter == True and detector.pixel_size_unit != 'mm': 
     225        if has_converter and detector.pixel_size_unit != 'mm': 
    259226            conv = Converter('mm') 
    260227            pixel = conv(pixel, units=detector.pixel_size_unit) 
     
    267234         
    268235        # Store limits of the image (2D array) 
    269         xmin = xmin - xstep / 2.0 
    270         xmax = xmax + xstep / 2.0 
    271         ymin = ymin - ystep / 2.0 
    272         ymax = ymax + ystep / 2.0 
    273         if has_converter == True and output.Q_unit != '1/A': 
     236        xmin -= xstep / 2.0 
     237        xmax += xstep / 2.0 
     238        ymin -= ystep / 2.0 
     239        ymax += ystep / 2.0 
     240        if has_converter and output.Q_unit != '1/A': 
    274241            xmin = data_conv_q(xmin, units=output.Q_unit) 
    275242            xmax = data_conv_q(xmax, units=output.Q_unit) 
     
    282249         
    283250        # Store x and y axis bin centers 
    284         output.x_bins = x 
    285         output.y_bins = y 
     251        output.x_bins = qx.tolist() 
     252        output.y_bins = qy.tolist() 
    286253         
    287254        # Units 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    rc221349 r8434365  
    930930            self._write_data(datainfo, entry_node) 
    931931        # Transmission Spectrum Info 
    932         self._write_trans_spectrum(datainfo, entry_node) 
     932        # TODO: fix the writer to linearize all data, including T_spectrum 
     933        # self._write_trans_spectrum(datainfo, entry_node) 
    933934        # Sample info 
    934935        self._write_sample_info(datainfo, entry_node) 
  • src/sas/sascalc/calculator/BaseComponent.py

    rdeddda1 r9a5097c  
    99from collections import OrderedDict 
    1010 
    11 import numpy 
     11import numpy as np 
    1212#TO DO: that about a way to make the parameter 
    1313#is self return if it is fittable or not 
     
    119119        Then get :: 
    120120 
    121             q = numpy.sqrt(qx_prime^2+qy_prime^2) 
     121            q = np.sqrt(qx_prime^2+qy_prime^2) 
    122122 
    123123        that is a qr in 1D array; :: 
     
    150150 
    151151            # calculate q_r component for 2D isotropic 
    152             q = numpy.sqrt(qx**2+qy**2) 
     152            q = np.sqrt(qx**2+qy**2) 
    153153            # vectorize the model function runXY 
    154             v_model = numpy.vectorize(self.runXY, otypes=[float]) 
     154            v_model = np.vectorize(self.runXY, otypes=[float]) 
    155155            # calculate the scattering 
    156156            iq_array = v_model(q) 
     
    160160        elif qdist.__class__.__name__ == 'ndarray': 
    161161            # We have a simple 1D distribution of q-values 
    162             v_model = numpy.vectorize(self.runXY, otypes=[float]) 
     162            v_model = np.vectorize(self.runXY, otypes=[float]) 
    163163            iq_array = v_model(qdist) 
    164164            return iq_array 
  • src/sas/sascalc/calculator/instrument.py

    rb699768 r9a5097c  
    33control instrumental parameters 
    44""" 
    5 import numpy 
     5import numpy as np 
    66 
    77# defaults in cgs unit 
     
    168168        self.spectrum = self.get_default_spectrum() 
    169169        # intensity in counts/sec 
    170         self.intensity = numpy.interp(self.wavelength, 
     170        self.intensity = np.interp(self.wavelength, 
    171171                                      self.spectrum[0], 
    172172                                      self.spectrum[1], 
     
    203203        """ 
    204204        spectrum = self.spectrum 
    205         intensity = numpy.interp(self.wavelength, 
     205        intensity = np.interp(self.wavelength, 
    206206                                 spectrum[0], 
    207207                                 spectrum[1], 
     
    244244        self.wavelength = wavelength 
    245245        validate(wavelength) 
    246         self.intensity = numpy.interp(self.wavelength, 
     246        self.intensity = np.interp(self.wavelength, 
    247247                                      self.spectrum[0], 
    248248                                      self.spectrum[1], 
     
    305305        get default spectrum 
    306306        """ 
    307         return numpy.array(_LAMBDA_ARRAY) 
     307        return np.array(_LAMBDA_ARRAY) 
    308308 
    309309    def get_band(self): 
     
    345345        get list of the intensity wrt wavelength_list 
    346346        """ 
    347         out = numpy.interp(self.wavelength_list, 
     347        out = np.interp(self.wavelength_list, 
    348348                           self.spectrum[0], 
    349349                           self.spectrum[1], 
  • src/sas/sascalc/calculator/resolution_calculator.py

    rb699768 r9a5097c  
    1212from math import sqrt 
    1313import math 
    14 import numpy 
     14import numpy as np 
    1515import sys 
    1616import logging 
     
    393393        dx_size = (self.qx_max - self.qx_min) / (1000 - 1) 
    394394        dy_size = (self.qy_max - self.qy_min) / (1000 - 1) 
    395         x_val = numpy.arange(self.qx_min, self.qx_max, dx_size) 
    396         y_val = numpy.arange(self.qy_max, self.qy_min, -dy_size) 
    397         q_1, q_2 = numpy.meshgrid(x_val, y_val) 
     395        x_val = np.arange(self.qx_min, self.qx_max, dx_size) 
     396        y_val = np.arange(self.qy_max, self.qy_min, -dy_size) 
     397        q_1, q_2 = np.meshgrid(x_val, y_val) 
    398398        #q_phi = numpy.arctan(q_1,q_2) 
    399399        # check whether polar or cartesian 
     
    887887        x_value = x_val - x0_val 
    888888        y_value = y_val - y0_val 
    889         phi_i = numpy.arctan2(y_val, x_val) 
     889        phi_i = np.arctan2(y_val, x_val) 
    890890 
    891891        # phi correction due to the gravity shift (in phi) 
     
    893893        phi_i = phi_i - phi_0 + self.gravity_phi 
    894894 
    895         sin_phi = numpy.sin(self.gravity_phi) 
    896         cos_phi = numpy.cos(self.gravity_phi) 
     895        sin_phi = np.sin(self.gravity_phi) 
     896        cos_phi = np.cos(self.gravity_phi) 
    897897 
    898898        x_p = x_value * cos_phi + y_value * sin_phi 
     
    908908        nu_value = -0.5 * (new_x * new_x + new_y * new_y) 
    909909 
    910         gaussian = numpy.exp(nu_value) 
     910        gaussian = np.exp(nu_value) 
    911911        # normalizing factor correction 
    912912        gaussian /= gaussian.sum() 
     
    954954            nu_value *= nu_value 
    955955            nu_value *= -0.5 
    956             gaussian *= numpy.exp(nu_value) 
     956            gaussian *= np.exp(nu_value) 
    957957            gaussian /= sigma 
    958958            # normalize 
     
    10261026                                                           offset_x, offset_y) 
    10271027        # distance [cm] from the beam center on detector plane 
    1028         detector_ind_x = numpy.arange(detector_pix_nums_x) 
    1029         detector_ind_y = numpy.arange(detector_pix_nums_y) 
     1028        detector_ind_x = np.arange(detector_pix_nums_x) 
     1029        detector_ind_y = np.arange(detector_pix_nums_y) 
    10301030 
    10311031        # shif 0.5 pixel so that pix position is at the center of the pixel 
     
    10411041        detector_ind_y = detector_ind_y * pix_y_size 
    10421042 
    1043         qx_value = numpy.zeros(len(detector_ind_x)) 
    1044         qy_value = numpy.zeros(len(detector_ind_y)) 
     1043        qx_value = np.zeros(len(detector_ind_x)) 
     1044        qy_value = np.zeros(len(detector_ind_y)) 
    10451045        i = 0 
    10461046 
     
    10611061 
    10621062        # p min and max values among the center of pixels 
    1063         self.qx_min = numpy.min(qx_value) 
    1064         self.qx_max = numpy.max(qx_value) 
    1065         self.qy_min = numpy.min(qy_value) 
    1066         self.qy_max = numpy.max(qy_value) 
     1063        self.qx_min = np.min(qx_value) 
     1064        self.qx_max = np.max(qx_value) 
     1065        self.qy_min = np.min(qy_value) 
     1066        self.qy_max = np.max(qy_value) 
    10671067 
    10681068        # Appr. min and max values of the detector display limits 
     
    10881088            from sas.sascalc.dataloader.data_info import Data2D 
    10891089            output = Data2D() 
    1090             inten = numpy.zeros_like(qx_value) 
     1090            inten = np.zeros_like(qx_value) 
    10911091            output.data = inten 
    10921092            output.qx_data = qx_value 
     
    11071107        plane_dist = dx_size 
    11081108        # full scattering angle on the x-axis 
    1109         theta = numpy.arctan(plane_dist / det_dist) 
    1110         qx_value = (2.0 * pi / wavelength) * numpy.sin(theta) 
     1109        theta = np.arctan(plane_dist / det_dist) 
     1110        qx_value = (2.0 * pi / wavelength) * np.sin(theta) 
    11111111        return qx_value 
    11121112 
  • src/sas/sascalc/calculator/sas_gen.py

    rd2fd8fc r9a5097c  
    77from periodictable import formula 
    88from periodictable import nsf 
    9 import numpy 
     9import numpy as np 
    1010import os 
    1111import copy 
     
    8080        ## Parameter details [units, min, max] 
    8181        self.details = {} 
    82         self.details['scale'] = ['', 0.0, numpy.inf] 
    83         self.details['background'] = ['[1/cm]', 0.0, numpy.inf] 
    84         self.details['solvent_SLD'] = ['1/A^(2)', -numpy.inf, numpy.inf] 
    85         self.details['total_volume'] = ['A^(3)', 0.0, numpy.inf] 
     82        self.details['scale'] = ['', 0.0, np.inf] 
     83        self.details['background'] = ['[1/cm]', 0.0, np.inf] 
     84        self.details['solvent_SLD'] = ['1/A^(2)', -np.inf, np.inf] 
     85        self.details['total_volume'] = ['A^(3)', 0.0, np.inf] 
    8686        self.details['Up_frac_in'] = ['[u/(u+d)]', 0.0, 1.0] 
    8787        self.details['Up_frac_out'] = ['[u/(u+d)]', 0.0, 1.0] 
    88         self.details['Up_theta'] = ['[deg]', -numpy.inf, numpy.inf] 
     88        self.details['Up_theta'] = ['[deg]', -np.inf, np.inf] 
    8989        # fixed parameters 
    9090        self.fixed = [] 
     
    171171                msg = "Not a 1D." 
    172172                raise ValueError, msg 
    173             i_out = numpy.zeros_like(x[0]) 
     173            i_out = np.zeros_like(x[0]) 
    174174            # 1D I is found at y =0 in the 2D pattern 
    175175            out = self._gen(x[0], [], i_out) 
     
    187187        """ 
    188188        if x.__class__.__name__ == 'list': 
    189             i_out = numpy.zeros_like(x[0]) 
     189            i_out = np.zeros_like(x[0]) 
    190190            out = self._gen(x[0], x[1], i_out) 
    191191            return out 
     
    237237        self.omfdata = omfdata 
    238238        length = int(omfdata.xnodes * omfdata.ynodes * omfdata.znodes) 
    239         pos_x = numpy.arange(omfdata.xmin, 
     239        pos_x = np.arange(omfdata.xmin, 
    240240                             omfdata.xnodes*omfdata.xstepsize + omfdata.xmin, 
    241241                             omfdata.xstepsize) 
    242         pos_y = numpy.arange(omfdata.ymin, 
     242        pos_y = np.arange(omfdata.ymin, 
    243243                             omfdata.ynodes*omfdata.ystepsize + omfdata.ymin, 
    244244                             omfdata.ystepsize) 
    245         pos_z = numpy.arange(omfdata.zmin, 
     245        pos_z = np.arange(omfdata.zmin, 
    246246                             omfdata.znodes*omfdata.zstepsize + omfdata.zmin, 
    247247                             omfdata.zstepsize) 
    248         self.pos_x = numpy.tile(pos_x, int(omfdata.ynodes * omfdata.znodes)) 
     248        self.pos_x = np.tile(pos_x, int(omfdata.ynodes * omfdata.znodes)) 
    249249        self.pos_y = pos_y.repeat(int(omfdata.xnodes)) 
    250         self.pos_y = numpy.tile(self.pos_y, int(omfdata.znodes)) 
     250        self.pos_y = np.tile(self.pos_y, int(omfdata.znodes)) 
    251251        self.pos_z = pos_z.repeat(int(omfdata.xnodes * omfdata.ynodes)) 
    252252        self.mx = omfdata.mx 
    253253        self.my = omfdata.my 
    254254        self.mz = omfdata.mz 
    255         self.sld_n = numpy.zeros(length) 
     255        self.sld_n = np.zeros(length) 
    256256 
    257257        if omfdata.mx == None: 
    258             self.mx = numpy.zeros(length) 
     258            self.mx = np.zeros(length) 
    259259        if omfdata.my == None: 
    260             self.my = numpy.zeros(length) 
     260            self.my = np.zeros(length) 
    261261        if omfdata.mz == None: 
    262             self.mz = numpy.zeros(length) 
     262            self.mz = np.zeros(length) 
    263263 
    264264        self._check_data_length(length) 
    265265        self.remove_null_points(False, False) 
    266         mask = numpy.ones(len(self.sld_n), dtype=bool) 
     266        mask = np.ones(len(self.sld_n), dtype=bool) 
    267267        if shape.lower() == 'ellipsoid': 
    268268            try: 
     
    328328        """ 
    329329        if remove: 
    330             is_nonzero = (numpy.fabs(self.mx) + numpy.fabs(self.my) + 
    331                           numpy.fabs(self.mz)).nonzero() 
     330            is_nonzero = (np.fabs(self.mx) + np.fabs(self.my) + 
     331                          np.fabs(self.mz)).nonzero() 
    332332            if len(is_nonzero[0]) > 0: 
    333333                self.pos_x = self.pos_x[is_nonzero] 
     
    369369        """ 
    370370        desc = "" 
    371         mx = numpy.zeros(0) 
    372         my = numpy.zeros(0) 
    373         mz = numpy.zeros(0) 
     371        mx = np.zeros(0) 
     372        my = np.zeros(0) 
     373        mz = np.zeros(0) 
    374374        try: 
    375375            input_f = open(path, 'rb') 
     
    389389                    _my = mag2sld(_my, valueunit) 
    390390                    _mz = mag2sld(_mz, valueunit) 
    391                     mx = numpy.append(mx, _mx) 
    392                     my = numpy.append(my, _my) 
    393                     mz = numpy.append(mz, _mz) 
     391                    mx = np.append(mx, _mx) 
     392                    my = np.append(my, _my) 
     393                    mz = np.append(mz, _mz) 
    394394                except: 
    395395                    # Skip non-data lines 
     
    501501        :raise RuntimeError: when the file can't be opened 
    502502        """ 
    503         pos_x = numpy.zeros(0) 
    504         pos_y = numpy.zeros(0) 
    505         pos_z = numpy.zeros(0) 
    506         sld_n = numpy.zeros(0) 
    507         sld_mx = numpy.zeros(0) 
    508         sld_my = numpy.zeros(0) 
    509         sld_mz = numpy.zeros(0) 
    510         vol_pix = numpy.zeros(0) 
    511         pix_symbol = numpy.zeros(0) 
     503        pos_x = np.zeros(0) 
     504        pos_y = np.zeros(0) 
     505        pos_z = np.zeros(0) 
     506        sld_n = np.zeros(0) 
     507        sld_mx = np.zeros(0) 
     508        sld_my = np.zeros(0) 
     509        sld_mz = np.zeros(0) 
     510        vol_pix = np.zeros(0) 
     511        pix_symbol = np.zeros(0) 
    512512        x_line = [] 
    513513        y_line = [] 
     
    543543                        _pos_y = float(line[38:46].strip()) 
    544544                        _pos_z = float(line[46:54].strip()) 
    545                         pos_x = numpy.append(pos_x, _pos_x) 
    546                         pos_y = numpy.append(pos_y, _pos_y) 
    547                         pos_z = numpy.append(pos_z, _pos_z) 
     545                        pos_x = np.append(pos_x, _pos_x) 
     546                        pos_y = np.append(pos_y, _pos_y) 
     547                        pos_z = np.append(pos_z, _pos_z) 
    548548                        try: 
    549549                            val = nsf.neutron_sld(atom_name)[0] 
    550550                            # sld in Ang^-2 unit 
    551551                            val *= 1.0e-6 
    552                             sld_n = numpy.append(sld_n, val) 
     552                            sld_n = np.append(sld_n, val) 
    553553                            atom = formula(atom_name) 
    554554                            # cm to A units 
    555555                            vol = 1.0e+24 * atom.mass / atom.density / NA 
    556                             vol_pix = numpy.append(vol_pix, vol) 
     556                            vol_pix = np.append(vol_pix, vol) 
    557557                        except: 
    558558                            print "Error: set the sld of %s to zero"% atom_name 
    559                             sld_n = numpy.append(sld_n, 0.0) 
    560                         sld_mx = numpy.append(sld_mx, 0) 
    561                         sld_my = numpy.append(sld_my, 0) 
    562                         sld_mz = numpy.append(sld_mz, 0) 
    563                         pix_symbol = numpy.append(pix_symbol, atom_name) 
     559                            sld_n = np.append(sld_n, 0.0) 
     560                        sld_mx = np.append(sld_mx, 0) 
     561                        sld_my = np.append(sld_my, 0) 
     562                        sld_mz = np.append(sld_mz, 0) 
     563                        pix_symbol = np.append(pix_symbol, atom_name) 
    564564                    elif line[0:6].strip().count('CONECT') > 0: 
    565565                        toks = line.split() 
     
    630630        """ 
    631631        try: 
    632             pos_x = numpy.zeros(0) 
    633             pos_y = numpy.zeros(0) 
    634             pos_z = numpy.zeros(0) 
    635             sld_n = numpy.zeros(0) 
    636             sld_mx = numpy.zeros(0) 
    637             sld_my = numpy.zeros(0) 
    638             sld_mz = numpy.zeros(0) 
     632            pos_x = np.zeros(0) 
     633            pos_y = np.zeros(0) 
     634            pos_z = np.zeros(0) 
     635            sld_n = np.zeros(0) 
     636            sld_mx = np.zeros(0) 
     637            sld_my = np.zeros(0) 
     638            sld_mz = np.zeros(0) 
    639639            try: 
    640640                # Use numpy to speed up loading 
    641                 input_f = numpy.loadtxt(path, dtype='float', skiprows=1, 
     641                input_f = np.loadtxt(path, dtype='float', skiprows=1, 
    642642                                        ndmin=1, unpack=True) 
    643                 pos_x = numpy.array(input_f[0]) 
    644                 pos_y = numpy.array(input_f[1]) 
    645                 pos_z = numpy.array(input_f[2]) 
    646                 sld_n = numpy.array(input_f[3]) 
    647                 sld_mx = numpy.array(input_f[4]) 
    648                 sld_my = numpy.array(input_f[5]) 
    649                 sld_mz = numpy.array(input_f[6]) 
     643                pos_x = np.array(input_f[0]) 
     644                pos_y = np.array(input_f[1]) 
     645                pos_z = np.array(input_f[2]) 
     646                sld_n = np.array(input_f[3]) 
     647                sld_mx = np.array(input_f[4]) 
     648                sld_my = np.array(input_f[5]) 
     649                sld_mz = np.array(input_f[6]) 
    650650                ncols = len(input_f) 
    651651                if ncols == 8: 
    652                     vol_pix = numpy.array(input_f[7]) 
     652                    vol_pix = np.array(input_f[7]) 
    653653                elif ncols == 7: 
    654654                    vol_pix = None 
     
    669669                        _sld_my = float(toks[5]) 
    670670                        _sld_mz = float(toks[6]) 
    671                         pos_x = numpy.append(pos_x, _pos_x) 
    672                         pos_y = numpy.append(pos_y, _pos_y) 
    673                         pos_z = numpy.append(pos_z, _pos_z) 
    674                         sld_n = numpy.append(sld_n, _sld_n) 
    675                         sld_mx = numpy.append(sld_mx, _sld_mx) 
    676                         sld_my = numpy.append(sld_my, _sld_my) 
    677                         sld_mz = numpy.append(sld_mz, _sld_mz) 
     671                        pos_x = np.append(pos_x, _pos_x) 
     672                        pos_y = np.append(pos_y, _pos_y) 
     673                        pos_z = np.append(pos_z, _pos_z) 
     674                        sld_n = np.append(sld_n, _sld_n) 
     675                        sld_mx = np.append(sld_mx, _sld_mx) 
     676                        sld_my = np.append(sld_my, _sld_my) 
     677                        sld_mz = np.append(sld_mz, _sld_mz) 
    678678                        try: 
    679679                            _vol_pix = float(toks[7]) 
    680                             vol_pix = numpy.append(vol_pix, _vol_pix) 
     680                            vol_pix = np.append(vol_pix, _vol_pix) 
    681681                        except: 
    682682                            vol_pix = None 
     
    712712        sld_n = data.sld_n 
    713713        if sld_n == None: 
    714             sld_n = numpy.zeros(length) 
     714            sld_n = np.zeros(length) 
    715715        sld_mx = data.sld_mx 
    716716        if sld_mx == None: 
    717             sld_mx = numpy.zeros(length) 
    718             sld_my = numpy.zeros(length) 
    719             sld_mz = numpy.zeros(length) 
     717            sld_mx = np.zeros(length) 
     718            sld_my = np.zeros(length) 
     719            sld_mz = np.zeros(length) 
    720720        else: 
    721721            sld_my = data.sld_my 
     
    893893            if self.is_data: 
    894894                # For data, put the value to only the pixels w non-zero M 
    895                 is_nonzero = (numpy.fabs(self.sld_mx) + 
    896                               numpy.fabs(self.sld_my) + 
    897                               numpy.fabs(self.sld_mz)).nonzero() 
    898                 self.sld_n = numpy.zeros(len(self.pos_x)) 
     895                is_nonzero = (np.fabs(self.sld_mx) + 
     896                              np.fabs(self.sld_my) + 
     897                              np.fabs(self.sld_mz)).nonzero() 
     898                self.sld_n = np.zeros(len(self.pos_x)) 
    899899                if len(self.sld_n[is_nonzero]) > 0: 
    900900                    self.sld_n[is_nonzero] = sld_n 
     
    903903            else: 
    904904                # For non-data, put the value to all the pixels 
    905                 self.sld_n = numpy.ones(len(self.pos_x)) * sld_n 
     905                self.sld_n = np.ones(len(self.pos_x)) * sld_n 
    906906        else: 
    907907            self.sld_n = sld_n 
     
    912912        """ 
    913913        if sld_mx.__class__.__name__ == 'float': 
    914             self.sld_mx = numpy.ones(len(self.pos_x)) * sld_mx 
     914            self.sld_mx = np.ones(len(self.pos_x)) * sld_mx 
    915915        else: 
    916916            self.sld_mx = sld_mx 
    917917        if sld_my.__class__.__name__ == 'float': 
    918             self.sld_my = numpy.ones(len(self.pos_x)) * sld_my 
     918            self.sld_my = np.ones(len(self.pos_x)) * sld_my 
    919919        else: 
    920920            self.sld_my = sld_my 
    921921        if sld_mz.__class__.__name__ == 'float': 
    922             self.sld_mz = numpy.ones(len(self.pos_x)) * sld_mz 
     922            self.sld_mz = np.ones(len(self.pos_x)) * sld_mz 
    923923        else: 
    924924            self.sld_mz = sld_mz 
    925925 
    926         sld_m = numpy.sqrt(sld_mx * sld_mx + sld_my * sld_my + \ 
     926        sld_m = np.sqrt(sld_mx * sld_mx + sld_my * sld_my + \ 
    927927                                sld_mz * sld_mz) 
    928928        self.sld_m = sld_m 
     
    936936            return 
    937937        if symbol.__class__.__name__ == 'str': 
    938             self.pix_symbol = numpy.repeat(symbol, len(self.sld_n)) 
     938            self.pix_symbol = np.repeat(symbol, len(self.sld_n)) 
    939939        else: 
    940940            self.pix_symbol = symbol 
     
    950950            self.vol_pix = vol 
    951951        elif vol.__class__.__name__.count('float') > 0: 
    952             self.vol_pix = numpy.repeat(vol, len(self.sld_n)) 
     952            self.vol_pix = np.repeat(vol, len(self.sld_n)) 
    953953        else: 
    954954            self.vol_pix = None 
     
    993993                for x_pos in self.pos_x: 
    994994                    if xpos_pre != x_pos: 
    995                         self.xstepsize = numpy.fabs(x_pos - xpos_pre) 
     995                        self.xstepsize = np.fabs(x_pos - xpos_pre) 
    996996                        break 
    997997                for y_pos in self.pos_y: 
    998998                    if ypos_pre != y_pos: 
    999                         self.ystepsize = numpy.fabs(y_pos - ypos_pre) 
     999                        self.ystepsize = np.fabs(y_pos - ypos_pre) 
    10001000                        break 
    10011001                for z_pos in self.pos_z: 
    10021002                    if zpos_pre != z_pos: 
    1003                         self.zstepsize = numpy.fabs(z_pos - zpos_pre) 
     1003                        self.zstepsize = np.fabs(z_pos - zpos_pre) 
    10041004                        break 
    10051005                #default pix volume 
    1006                 self.vol_pix = numpy.ones(len(self.pos_x)) 
     1006                self.vol_pix = np.ones(len(self.pos_x)) 
    10071007                vol = self.xstepsize * self.ystepsize * self.zstepsize 
    10081008                self.set_pixel_volumes(vol) 
     
    10711071    y2 = output.pos_y+output.sld_my/max_m * gap 
    10721072    z2 = output.pos_z+output.sld_mz/max_m * gap 
    1073     x_arrow = numpy.column_stack((output.pos_x, x2)) 
    1074     y_arrow = numpy.column_stack((output.pos_y, y2)) 
    1075     z_arrow = numpy.column_stack((output.pos_z, z2)) 
     1073    x_arrow = np.column_stack((output.pos_x, x2)) 
     1074    y_arrow = np.column_stack((output.pos_y, y2)) 
     1075    z_arrow = np.column_stack((output.pos_z, z2)) 
    10761076    unit_x2 = output.sld_mx / max_m 
    10771077    unit_y2 = output.sld_my / max_m 
    10781078    unit_z2 = output.sld_mz / max_m 
    1079     color_x = numpy.fabs(unit_x2 * 0.8) 
    1080     color_y = numpy.fabs(unit_y2 * 0.8) 
    1081     color_z = numpy.fabs(unit_z2 * 0.8) 
    1082     colors = numpy.column_stack((color_x, color_y, color_z)) 
     1079    color_x = np.fabs(unit_x2 * 0.8) 
     1080    color_y = np.fabs(unit_y2 * 0.8) 
     1081    color_z = np.fabs(unit_z2 * 0.8) 
     1082    colors = np.column_stack((color_x, color_y, color_z)) 
    10831083    plt.show() 
    10841084 
     
    11031103    model = GenSAS() 
    11041104    model.set_sld_data(foutput.output) 
    1105     x = numpy.arange(1000)/10000. + 1e-5 
    1106     y = numpy.arange(1000)/10000. + 1e-5 
    1107     i = numpy.zeros(1000) 
     1105    x = np.arange(1000)/10000. + 1e-5 
     1106    y = np.arange(1000)/10000. + 1e-5 
     1107    i = np.zeros(1000) 
    11081108    model.runXY([x, y, i]) 
    11091109 
  • src/sas/sascalc/data_util/err1d.py

    rb699768 r9a5097c  
    88""" 
    99from __future__ import division  # Get true division 
    10 import numpy 
     10import numpy as np 
    1111 
    1212 
     
    5959def exp(X, varX): 
    6060    """Exponentiation with error propagation""" 
    61     Z = numpy.exp(X) 
     61    Z = np.exp(X) 
    6262    varZ = varX * Z**2 
    6363    return Z, varZ 
     
    6666def log(X, varX): 
    6767    """Logarithm with error propagation""" 
    68     Z = numpy.log(X) 
     68    Z = np.log(X) 
    6969    varZ = varX / X**2 
    7070    return Z, varZ 
     
    7373# def pow(X,varX, Y,varY): 
    7474#    Z = X**Y 
    75 #    varZ = (Y**2 * varX/X**2 + varY * numpy.log(X)**2) * Z**2 
     75#    varZ = (Y**2 * varX/X**2 + varY * np.log(X)**2) * Z**2 
    7676#    return Z,varZ 
    7777# 
  • src/sas/sascalc/data_util/formatnum.py

    rb699768 r9a5097c  
    4040 
    4141import math 
    42 import numpy 
     42import numpy as np 
    4343__all__ = ['format_uncertainty', 'format_uncertainty_pm', 
    4444           'format_uncertainty_compact'] 
     
    102102    """ 
    103103    # Handle indefinite value 
    104     if numpy.isinf(value): 
     104    if np.isinf(value): 
    105105        return "inf" if value > 0 else "-inf" 
    106     if numpy.isnan(value): 
     106    if np.isnan(value): 
    107107        return "NaN" 
    108108 
    109109    # Handle indefinite uncertainty 
    110     if uncertainty is None or uncertainty <= 0 or numpy.isnan(uncertainty): 
     110    if uncertainty is None or uncertainty <= 0 or np.isnan(uncertainty): 
    111111        return "%g" % value 
    112     if numpy.isinf(uncertainty): 
     112    if np.isinf(uncertainty): 
    113113        if compact: 
    114114            return "%.2g(inf)" % value 
     
    279279 
    280280    # non-finite values 
    281     assert value_str(-numpy.inf,None) == "-inf" 
    282     assert value_str(numpy.inf,None) == "inf" 
    283     assert value_str(numpy.NaN,None) == "NaN" 
     281    assert value_str(-np.inf,None) == "-inf" 
     282    assert value_str(np.inf,None) == "inf" 
     283    assert value_str(np.NaN,None) == "NaN" 
    284284     
    285285    # bad or missing uncertainty 
    286     assert value_str(-1.23567,numpy.NaN) == "-1.23567" 
    287     assert value_str(-1.23567,-numpy.inf) == "-1.23567" 
     286    assert value_str(-1.23567,np.NaN) == "-1.23567" 
     287    assert value_str(-1.23567,-np.inf) == "-1.23567" 
    288288    assert value_str(-1.23567,-0.1) == "-1.23567" 
    289289    assert value_str(-1.23567,0) == "-1.23567" 
    290290    assert value_str(-1.23567,None) == "-1.23567" 
    291     assert value_str(-1.23567,numpy.inf) == "-1.2(inf)" 
     291    assert value_str(-1.23567,np.inf) == "-1.2(inf)" 
    292292 
    293293def test_pm(): 
     
    410410 
    411411    # non-finite values 
    412     assert value_str(-numpy.inf,None) == "-inf" 
    413     assert value_str(numpy.inf,None) == "inf" 
    414     assert value_str(numpy.NaN,None) == "NaN" 
     412    assert value_str(-np.inf,None) == "-inf" 
     413    assert value_str(np.inf,None) == "inf" 
     414    assert value_str(np.NaN,None) == "NaN" 
    415415     
    416416    # bad or missing uncertainty 
    417     assert value_str(-1.23567,numpy.NaN) == "-1.23567" 
    418     assert value_str(-1.23567,-numpy.inf) == "-1.23567" 
     417    assert value_str(-1.23567,np.NaN) == "-1.23567" 
     418    assert value_str(-1.23567,-np.inf) == "-1.23567" 
    419419    assert value_str(-1.23567,-0.1) == "-1.23567" 
    420420    assert value_str(-1.23567,0) == "-1.23567" 
    421421    assert value_str(-1.23567,None) == "-1.23567" 
    422     assert value_str(-1.23567,numpy.inf) == "-1.2 +/- inf" 
     422    assert value_str(-1.23567,np.inf) == "-1.2 +/- inf" 
    423423 
    424424def test_default(): 
  • src/sas/sascalc/data_util/qsmearing.py

    r775e0b7 r9a5097c  
    99#copyright 2008, University of Tennessee 
    1010###################################################################### 
    11 import numpy 
    1211import math 
    1312import logging 
     
    6059    if data.dx is not None and data.isSesans: 
    6160        #if data.dx[0] > 0.0: 
    62         if numpy.size(data.dx[data.dx <= 0]) == 0: 
     61        if np.size(data.dx[data.dx <= 0]) == 0: 
    6362            _found_sesans = True 
    6463        # if data.dx[0] <= 0.0: 
    65         if numpy.size(data.dx[data.dx <= 0]) > 0: 
     64        if np.size(data.dx[data.dx <= 0]) > 0: 
    6665            raise ValueError('one or more of your dx values are negative, please check the data file!') 
    6766 
     
    121120        self.resolution = resolution 
    122121        if offset is None: 
    123             offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     122            offset = np.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
    124123        self.offset = offset 
    125124 
     
    137136        start, end = first_bin + self.offset, last_bin + self.offset 
    138137        q_calc = self.resolution.q_calc 
    139         iq_calc = numpy.empty_like(q_calc) 
     138        iq_calc = np.empty_like(q_calc) 
    140139        if start > 0: 
    141140            iq_calc[:start] = self.model.evalDistribution(q_calc[:start]) 
     
    157156        """ 
    158157        q = self.resolution.q 
    159         first = numpy.searchsorted(q, q_min) 
    160         last = numpy.searchsorted(q, q_max) 
     158        first = np.searchsorted(q, q_min) 
     159        last = np.searchsorted(q, q_max) 
    161160        return first, min(last,len(q)-1) 
    162161 
  • src/sas/sascalc/data_util/uncertainty.py

    rb699768 r9a5097c  
    1717from __future__ import division 
    1818 
    19 import numpy 
     19import numpy as np 
    2020import err1d 
    2121from formatnum import format_uncertainty 
     
    2727class Uncertainty(object): 
    2828    # Make standard deviation available 
    29     def _getdx(self): return numpy.sqrt(self.variance) 
     29    def _getdx(self): return np.sqrt(self.variance) 
    3030    def _setdx(self,dx):  
    3131        # Direct operation 
     
    144144        return self 
    145145    def __abs__(self): 
    146         return Uncertainty(numpy.abs(self.x),self.variance) 
     146        return Uncertainty(np.abs(self.x),self.variance) 
    147147 
    148148    def __str__(self): 
    149         #return str(self.x)+" +/- "+str(numpy.sqrt(self.variance)) 
    150         if numpy.isscalar(self.x): 
    151             return format_uncertainty(self.x,numpy.sqrt(self.variance)) 
     149        #return str(self.x)+" +/- "+str(np.sqrt(self.variance)) 
     150        if np.isscalar(self.x): 
     151            return format_uncertainty(self.x,np.sqrt(self.variance)) 
    152152        else: 
    153153            return [format_uncertainty(v,dv)  
    154                     for v,dv in zip(self.x,numpy.sqrt(self.variance))] 
     154                    for v,dv in zip(self.x,np.sqrt(self.variance))] 
    155155    def __repr__(self): 
    156156        return "Uncertainty(%s,%s)"%(str(self.x),str(self.variance)) 
     
    287287    # =============== vector operations ================ 
    288288    # Slicing 
    289     z = Uncertainty(numpy.array([1,2,3,4,5]),numpy.array([2,1,2,3,2])) 
     289    z = Uncertainty(np.array([1,2,3,4,5]),np.array([2,1,2,3,2])) 
    290290    assert z[2].x == 3 and z[2].variance == 2 
    291291    assert (z[2:4].x == [3,4]).all() 
    292292    assert (z[2:4].variance == [2,3]).all() 
    293     z[2:4] = Uncertainty(numpy.array([8,7]),numpy.array([4,5])) 
     293    z[2:4] = Uncertainty(np.array([8,7]),np.array([4,5])) 
    294294    assert z[2].x == 8 and z[2].variance == 4 
    295     A = Uncertainty(numpy.array([a.x]*2),numpy.array([a.variance]*2)) 
    296     B = Uncertainty(numpy.array([b.x]*2),numpy.array([b.variance]*2)) 
     295    A = Uncertainty(np.array([a.x]*2),np.array([a.variance]*2)) 
     296    B = Uncertainty(np.array([b.x]*2),np.array([b.variance]*2)) 
    297297 
    298298    # TODO complete tests of copy and inplace operations for vectors and slices. 
  • src/sas/sascalc/dataloader/data_info.py

    r2ffe241 r9a5097c  
    2323#from sas.guitools.plottables import Data1D as plottable_1D 
    2424from sas.sascalc.data_util.uncertainty import Uncertainty 
    25 import numpy 
     25import numpy as np 
    2626import math 
    2727 
     
    5151 
    5252    def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None): 
    53         self.x = numpy.asarray(x) 
    54         self.y = numpy.asarray(y) 
     53        self.x = np.asarray(x) 
     54        self.y = np.asarray(y) 
    5555        if dx is not None: 
    56             self.dx = numpy.asarray(dx) 
     56            self.dx = np.asarray(dx) 
    5757        if dy is not None: 
    58             self.dy = numpy.asarray(dy) 
     58            self.dy = np.asarray(dy) 
    5959        if dxl is not None: 
    60             self.dxl = numpy.asarray(dxl) 
     60            self.dxl = np.asarray(dxl) 
    6161        if dxw is not None: 
    62             self.dxw = numpy.asarray(dxw) 
     62            self.dxw = np.asarray(dxw) 
    6363        if lam is not None: 
    64             self.lam = numpy.asarray(lam) 
     64            self.lam = np.asarray(lam) 
    6565        if dlam is not None: 
    66             self.dlam = numpy.asarray(dlam) 
     66            self.dlam = np.asarray(dlam) 
    6767 
    6868    def xaxis(self, label, unit): 
     
    109109                 qy_data=None, q_data=None, mask=None, 
    110110                 dqx_data=None, dqy_data=None): 
    111         self.data = numpy.asarray(data) 
    112         self.qx_data = numpy.asarray(qx_data) 
    113         self.qy_data = numpy.asarray(qy_data) 
    114         self.q_data = numpy.asarray(q_data) 
    115         self.mask = numpy.asarray(mask) 
    116         self.err_data = numpy.asarray(err_data) 
     111        self.data = np.asarray(data) 
     112        self.qx_data = np.asarray(qx_data) 
     113        self.qy_data = np.asarray(qy_data) 
     114        self.q_data = np.asarray(q_data) 
     115        self.mask = np.asarray(mask) 
     116        self.err_data = np.asarray(err_data) 
    117117        if dqx_data is not None: 
    118             self.dqx_data = numpy.asarray(dqx_data) 
     118            self.dqx_data = np.asarray(dqx_data) 
    119119        if dqy_data is not None: 
    120             self.dqy_data = numpy.asarray(dqy_data) 
     120            self.dqy_data = np.asarray(dqy_data) 
    121121 
    122122    def xaxis(self, label, unit): 
     
    734734        """ 
    735735        def _check(v): 
    736             if (v.__class__ == list or v.__class__ == numpy.ndarray) \ 
     736            if (v.__class__ == list or v.__class__ == np.ndarray) \ 
    737737                and len(v) > 0 and min(v) > 0: 
    738738                return True 
     
    752752 
    753753        if clone is None or not issubclass(clone.__class__, Data1D): 
    754             x = numpy.zeros(length) 
    755             dx = numpy.zeros(length) 
    756             y = numpy.zeros(length) 
    757             dy = numpy.zeros(length) 
    758             lam = numpy.zeros(length) 
    759             dlam = numpy.zeros(length) 
     754            x = np.zeros(length) 
     755            dx = np.zeros(length) 
     756            y = np.zeros(length) 
     757            dy = np.zeros(length) 
     758            lam = np.zeros(length) 
     759            dlam = np.zeros(length) 
    760760            clone = Data1D(x, y, lam=lam, dx=dx, dy=dy, dlam=dlam) 
    761761 
     
    806806            dy_other = other.dy 
    807807            if other.dy == None or (len(other.dy) != len(other.y)): 
    808                 dy_other = numpy.zeros(len(other.y)) 
     808                dy_other = np.zeros(len(other.y)) 
    809809 
    810810        # Check that we have errors, otherwise create zero vector 
    811811        dy = self.dy 
    812812        if self.dy == None or (len(self.dy) != len(self.y)): 
    813             dy = numpy.zeros(len(self.y)) 
     813            dy = np.zeros(len(self.y)) 
    814814 
    815815        return dy, dy_other 
     
    824824            result.dxw = None 
    825825        else: 
    826             result.dxw = numpy.zeros(len(self.x)) 
     826            result.dxw = np.zeros(len(self.x)) 
    827827        if self.dxl == None: 
    828828            result.dxl = None 
    829829        else: 
    830             result.dxl = numpy.zeros(len(self.x)) 
     830            result.dxl = np.zeros(len(self.x)) 
    831831 
    832832        for i in range(len(self.x)): 
     
    886886            result.dy = None 
    887887        else: 
    888             result.dy = numpy.zeros(len(self.x) + len(other.x)) 
     888            result.dy = np.zeros(len(self.x) + len(other.x)) 
    889889        if self.dx == None or other.dx is None: 
    890890            result.dx = None 
    891891        else: 
    892             result.dx = numpy.zeros(len(self.x) + len(other.x)) 
     892            result.dx = np.zeros(len(self.x) + len(other.x)) 
    893893        if self.dxw == None or other.dxw is None: 
    894894            result.dxw = None 
    895895        else: 
    896             result.dxw = numpy.zeros(len(self.x) + len(other.x)) 
     896            result.dxw = np.zeros(len(self.x) + len(other.x)) 
    897897        if self.dxl == None or other.dxl is None: 
    898898            result.dxl = None 
    899899        else: 
    900             result.dxl = numpy.zeros(len(self.x) + len(other.x)) 
    901  
    902         result.x = numpy.append(self.x, other.x) 
     900            result.dxl = np.zeros(len(self.x) + len(other.x)) 
     901 
     902        result.x = np.append(self.x, other.x) 
    903903        #argsorting 
    904         ind = numpy.argsort(result.x) 
     904        ind = np.argsort(result.x) 
    905905        result.x = result.x[ind] 
    906         result.y = numpy.append(self.y, other.y) 
     906        result.y = np.append(self.y, other.y) 
    907907        result.y = result.y[ind] 
    908908        if result.dy != None: 
    909             result.dy = numpy.append(self.dy, other.dy) 
     909            result.dy = np.append(self.dy, other.dy) 
    910910            result.dy = result.dy[ind] 
    911911        if result.dx is not None: 
    912             result.dx = numpy.append(self.dx, other.dx) 
     912            result.dx = np.append(self.dx, other.dx) 
    913913            result.dx = result.dx[ind] 
    914914        if result.dxw is not None: 
    915             result.dxw = numpy.append(self.dxw, other.dxw) 
     915            result.dxw = np.append(self.dxw, other.dxw) 
    916916            result.dxw = result.dxw[ind] 
    917917        if result.dxl is not None: 
    918             result.dxl = numpy.append(self.dxl, other.dxl) 
     918            result.dxl = np.append(self.dxl, other.dxl) 
    919919            result.dxl = result.dxl[ind] 
    920920        return result 
     
    970970 
    971971        if clone is None or not issubclass(clone.__class__, Data2D): 
    972             data = numpy.zeros(length) 
    973             err_data = numpy.zeros(length) 
    974             qx_data = numpy.zeros(length) 
    975             qy_data = numpy.zeros(length) 
    976             q_data = numpy.zeros(length) 
    977             mask = numpy.zeros(length) 
     972            data = np.zeros(length) 
     973            err_data = np.zeros(length) 
     974            qx_data = np.zeros(length) 
     975            qy_data = np.zeros(length) 
     976            q_data = np.zeros(length) 
     977            mask = np.zeros(length) 
    978978            dqx_data = None 
    979979            dqy_data = None 
     
    10311031            if other.err_data == None or \ 
    10321032                (len(other.err_data) != len(other.data)): 
    1033                 err_other = numpy.zeros(len(other.data)) 
     1033                err_other = np.zeros(len(other.data)) 
    10341034 
    10351035        # Check that we have errors, otherwise create zero vector 
     
    10371037        if self.err_data == None or \ 
    10381038            (len(self.err_data) != len(self.data)): 
    1039             err = numpy.zeros(len(other.data)) 
     1039            err = np.zeros(len(other.data)) 
    10401040        return err, err_other 
    10411041 
     
    10491049        # First, check the data compatibility 
    10501050        dy, dy_other = self._validity_check(other) 
    1051         result = self.clone_without_data(numpy.size(self.data)) 
     1051        result = self.clone_without_data(np.size(self.data)) 
    10521052        if self.dqx_data == None or self.dqy_data == None: 
    10531053            result.dqx_data = None 
    10541054            result.dqy_data = None 
    10551055        else: 
    1056             result.dqx_data = numpy.zeros(len(self.data)) 
    1057             result.dqy_data = numpy.zeros(len(self.data)) 
    1058         for i in range(numpy.size(self.data)): 
     1056            result.dqx_data = np.zeros(len(self.data)) 
     1057            result.dqy_data = np.zeros(len(self.data)) 
     1058        for i in range(np.size(self.data)): 
    10591059            result.data[i] = self.data[i] 
    10601060            if self.err_data is not None and \ 
    1061                 numpy.size(self.data) == numpy.size(self.err_data): 
     1061                            np.size(self.data) == np.size(self.err_data): 
    10621062                result.err_data[i] = self.err_data[i] 
    10631063            if self.dqx_data is not None: 
     
    11181118        # First, check the data compatibility 
    11191119        self._validity_check_union(other) 
    1120         result = self.clone_without_data(numpy.size(self.data) + \ 
    1121                                          numpy.size(other.data)) 
     1120        result = self.clone_without_data(np.size(self.data) + \ 
     1121                                         np.size(other.data)) 
    11221122        result.xmin = self.xmin 
    11231123        result.xmax = self.xmax 
     
    11291129            result.dqy_data = None 
    11301130        else: 
    1131             result.dqx_data = numpy.zeros(len(self.data) + \ 
    1132                                          numpy.size(other.data)) 
    1133             result.dqy_data = numpy.zeros(len(self.data) + \ 
    1134                                          numpy.size(other.data)) 
    1135  
    1136         result.data = numpy.append(self.data, other.data) 
    1137         result.qx_data = numpy.append(self.qx_data, other.qx_data) 
    1138         result.qy_data = numpy.append(self.qy_data, other.qy_data) 
    1139         result.q_data = numpy.append(self.q_data, other.q_data) 
    1140         result.mask = numpy.append(self.mask, other.mask) 
     1131            result.dqx_data = np.zeros(len(self.data) + \ 
     1132                                       np.size(other.data)) 
     1133            result.dqy_data = np.zeros(len(self.data) + \ 
     1134                                       np.size(other.data)) 
     1135 
     1136        result.data = np.append(self.data, other.data) 
     1137        result.qx_data = np.append(self.qx_data, other.qx_data) 
     1138        result.qy_data = np.append(self.qy_data, other.qy_data) 
     1139        result.q_data = np.append(self.q_data, other.q_data) 
     1140        result.mask = np.append(self.mask, other.mask) 
    11411141        if result.err_data is not None: 
    1142             result.err_data = numpy.append(self.err_data, other.err_data) 
     1142            result.err_data = np.append(self.err_data, other.err_data) 
    11431143        if self.dqx_data is not None: 
    1144             result.dqx_data = numpy.append(self.dqx_data, other.dqx_data) 
     1144            result.dqx_data = np.append(self.dqx_data, other.dqx_data) 
    11451145        if self.dqy_data is not None: 
    1146             result.dqy_data = numpy.append(self.dqy_data, other.dqy_data) 
     1146            result.dqy_data = np.append(self.dqy_data, other.dqy_data) 
    11471147 
    11481148        return result 
  • src/sas/sascalc/dataloader/readers/abs_reader.py

    rb699768 r9a5097c  
    99###################################################################### 
    1010 
    11 import numpy 
     11import numpy as np 
    1212import os 
    1313from sas.sascalc.dataloader.data_info import Data1D 
     
    5353                buff = input_f.read() 
    5454                lines = buff.split('\n') 
    55                 x  = numpy.zeros(0) 
    56                 y  = numpy.zeros(0) 
    57                 dy = numpy.zeros(0) 
    58                 dx = numpy.zeros(0) 
     55                x  = np.zeros(0) 
     56                y  = np.zeros(0) 
     57                dy = np.zeros(0) 
     58                dx = np.zeros(0) 
    5959                output = Data1D(x, y, dy=dy, dx=dx) 
    6060                detector = Detector() 
     
    204204                                _dy = data_conv_i(_dy, units=output.y_unit) 
    205205                            
    206                             x = numpy.append(x, _x) 
    207                             y = numpy.append(y, _y) 
    208                             dy = numpy.append(dy, _dy) 
    209                             dx = numpy.append(dx, _dx) 
     206                            x = np.append(x, _x) 
     207                            y = np.append(y, _y) 
     208                            dy = np.append(dy, _dy) 
     209                            dx = np.append(dx, _dx) 
    210210                             
    211211                        except: 
  • src/sas/sascalc/dataloader/readers/ascii_reader.py

    rd2471870 r9a5097c  
    1414 
    1515 
    16 import numpy 
     16import numpy as np 
    1717import os 
    1818from sas.sascalc.dataloader.data_info import Data1D 
     
    6969 
    7070                # Arrays for data storage 
    71                 tx = numpy.zeros(0) 
    72                 ty = numpy.zeros(0) 
    73                 tdy = numpy.zeros(0) 
    74                 tdx = numpy.zeros(0) 
     71                tx = np.zeros(0) 
     72                ty = np.zeros(0) 
     73                tdy = np.zeros(0) 
     74                tdx = np.zeros(0) 
    7575 
    7676                # The first good line of data will define whether 
     
    140140                            is_data == False: 
    141141                            try: 
    142                                 tx = numpy.zeros(0) 
    143                                 ty = numpy.zeros(0) 
    144                                 tdy = numpy.zeros(0) 
    145                                 tdx = numpy.zeros(0) 
     142                                tx = np.zeros(0) 
     143                                ty = np.zeros(0) 
     144                                tdy = np.zeros(0) 
     145                                tdx = np.zeros(0) 
    146146                            except: 
    147147                                pass 
    148148 
    149149                        if has_error_dy == True: 
    150                             tdy = numpy.append(tdy, _dy) 
     150                            tdy = np.append(tdy, _dy) 
    151151                        if has_error_dx == True: 
    152                             tdx = numpy.append(tdx, _dx) 
    153                         tx = numpy.append(tx, _x) 
    154                         ty = numpy.append(ty, _y) 
     152                            tdx = np.append(tdx, _dx) 
     153                        tx = np.append(tx, _x) 
     154                        ty = np.append(ty, _y) 
    155155 
    156156                        #To remember the # of columns on the current line 
     
    188188                #Let's re-order the data to make cal. 
    189189                # curve look better some cases 
    190                 ind = numpy.lexsort((ty, tx)) 
    191                 x = numpy.zeros(len(tx)) 
    192                 y = numpy.zeros(len(ty)) 
    193                 dy = numpy.zeros(len(tdy)) 
    194                 dx = numpy.zeros(len(tdx)) 
     190                ind = np.lexsort((ty, tx)) 
     191                x = np.zeros(len(tx)) 
     192                y = np.zeros(len(ty)) 
     193                dy = np.zeros(len(tdy)) 
     194                dx = np.zeros(len(tdx)) 
    195195                output = Data1D(x, y, dy=dy, dx=dx) 
    196196                self.filename = output.filename = basename 
     
    212212                output.y = y[x != 0] 
    213213                output.dy = dy[x != 0] if has_error_dy == True\ 
    214                     else numpy.zeros(len(output.y)) 
     214                    else np.zeros(len(output.y)) 
    215215                output.dx = dx[x != 0] if has_error_dx == True\ 
    216                     else numpy.zeros(len(output.x)) 
     216                    else np.zeros(len(output.x)) 
    217217 
    218218                output.xaxis("\\rm{Q}", 'A^{-1}') 
  • src/sas/sascalc/dataloader/readers/danse_reader.py

    rb699768 r9a5097c  
    1515import os 
    1616import sys 
    17 import numpy 
     17import numpy as np 
    1818import logging 
    1919from sas.sascalc.dataloader.data_info import Data2D, Detector 
     
    7979            output.detector.append(detector) 
    8080             
    81             output.data = numpy.zeros([size_x,size_y]) 
    82             output.err_data = numpy.zeros([size_x, size_y]) 
     81            output.data = np.zeros([size_x,size_y]) 
     82            output.err_data = np.zeros([size_x, size_y]) 
    8383             
    8484            data_conv_q = None 
  • src/sas/sascalc/dataloader/readers/hfir1d_reader.py

    rb699768 r9a5097c  
    99#copyright 2008, University of Tennessee 
    1010###################################################################### 
    11 import numpy 
     11import numpy as np 
    1212import os 
    1313from sas.sascalc.dataloader.data_info import Data1D 
     
    5252                buff = input_f.read() 
    5353                lines = buff.split('\n') 
    54                 x = numpy.zeros(0) 
    55                 y = numpy.zeros(0) 
    56                 dx = numpy.zeros(0) 
    57                 dy = numpy.zeros(0) 
     54                x = np.zeros(0) 
     55                y = np.zeros(0) 
     56                dx = np.zeros(0) 
     57                dy = np.zeros(0) 
    5858                output = Data1D(x, y, dx=dx, dy=dy) 
    5959                self.filename = output.filename = basename 
     
    8888                            _dy = data_conv_i(_dy, units=output.y_unit) 
    8989                                                     
    90                         x = numpy.append(x, _x) 
    91                         y = numpy.append(y, _y) 
    92                         dx = numpy.append(dx, _dx) 
    93                         dy = numpy.append(dy, _dy) 
     90                        x = np.append(x, _x) 
     91                        y = np.append(y, _y) 
     92                        dx = np.append(dx, _dx) 
     93                        dy = np.append(dy, _dy) 
    9494                    except: 
    9595                        # Couldn't parse this line, skip it  
  • src/sas/sascalc/dataloader/readers/red2d_reader.py

    rb699768 r9a5097c  
    1010###################################################################### 
    1111import os 
    12 import numpy 
     12import numpy as np 
    1313import math 
    1414from sas.sascalc.dataloader.data_info import Data2D, Detector 
     
    198198                break 
    199199        # Make numpy array to remove header lines using index 
    200         lines_array = numpy.array(lines) 
     200        lines_array = np.array(lines) 
    201201 
    202202        # index for lines_array 
    203         lines_index = numpy.arange(len(lines)) 
     203        lines_index = np.arange(len(lines)) 
    204204         
    205205        # get the data lines 
     
    225225 
    226226        # numpy array form 
    227         data_array = numpy.array(data_list1) 
     227        data_array = np.array(data_list1) 
    228228        # Redimesion based on the row_num and col_num, 
    229229        #otherwise raise an error. 
     
    235235        ## Get the all data: Let's HARDcoding; Todo find better way 
    236236        # Defaults 
    237         dqx_data = numpy.zeros(0) 
    238         dqy_data = numpy.zeros(0) 
    239         err_data = numpy.ones(row_num) 
    240         qz_data = numpy.zeros(row_num) 
    241         mask = numpy.ones(row_num, dtype=bool) 
     237        dqx_data = np.zeros(0) 
     238        dqy_data = np.zeros(0) 
     239        err_data = np.ones(row_num) 
     240        qz_data = np.zeros(row_num) 
     241        mask = np.ones(row_num, dtype=bool) 
    242242        # Get from the array 
    243243        qx_data = data_point[0] 
     
    254254            dqy_data = data_point[(5 + ver)] 
    255255        #if col_num > (6 + ver): mask[data_point[(6 + ver)] < 1] = False 
    256         q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data+qz_data*qz_data) 
     256        q_data = np.sqrt(qx_data*qx_data+qy_data*qy_data+qz_data*qz_data) 
    257257            
    258258        # Extra protection(it is needed for some data files):  
     
    262262   
    263263        # Store limits of the image in q space 
    264         xmin = numpy.min(qx_data) 
    265         xmax = numpy.max(qx_data) 
    266         ymin = numpy.min(qy_data) 
    267         ymax = numpy.max(qy_data) 
     264        xmin = np.min(qx_data) 
     265        xmax = np.max(qx_data) 
     266        ymin = np.min(qy_data) 
     267        ymax = np.max(qy_data) 
    268268 
    269269        # units 
     
    287287         
    288288        # store x and y axis bin centers in q space 
    289         x_bins = numpy.arange(xmin, xmax + xstep, xstep) 
    290         y_bins = numpy.arange(ymin, ymax + ystep, ystep) 
     289        x_bins = np.arange(xmin, xmax + xstep, xstep) 
     290        y_bins = np.arange(ymin, ymax + ystep, ystep) 
    291291        
    292292        # get the limits of q values 
     
    300300        output.data = data 
    301301        if (err_data == 1).all(): 
    302             output.err_data = numpy.sqrt(numpy.abs(data)) 
     302            output.err_data = np.sqrt(np.abs(data)) 
    303303            output.err_data[output.err_data == 0.0] = 1.0 
    304304        else: 
     
    335335                # tranfer the comp. to cartesian coord. for newer version. 
    336336                if ver != 1: 
    337                     diag = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     337                    diag = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    338338                    cos_th = qx_data / diag 
    339339                    sin_th = qy_data / diag 
    340                     output.dqx_data = numpy.sqrt((dqx_data * cos_th) * \ 
     340                    output.dqx_data = np.sqrt((dqx_data * cos_th) * \ 
    341341                                                 (dqx_data * cos_th) \ 
    342342                                                 + (dqy_data * sin_th) * \ 
    343343                                                  (dqy_data * sin_th)) 
    344                     output.dqy_data = numpy.sqrt((dqx_data * sin_th) * \ 
     344                    output.dqy_data = np.sqrt((dqx_data * sin_th) * \ 
    345345                                                 (dqx_data * sin_th) \ 
    346346                                                 + (dqy_data * cos_th) * \ 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r7caf3e5 r9a5097c  
    66    Jurrian Bakker  
    77""" 
    8 import numpy 
     8import numpy as np 
    99import os 
    1010from sas.sascalc.dataloader.data_info import Data1D 
     
    6060                buff = input_f.read() 
    6161                lines = buff.splitlines() 
    62                 x  = numpy.zeros(0) 
    63                 y  = numpy.zeros(0) 
    64                 dy = numpy.zeros(0) 
    65                 lam  = numpy.zeros(0) 
    66                 dlam = numpy.zeros(0) 
    67                 dx = numpy.zeros(0) 
     62                x  = np.zeros(0) 
     63                y  = np.zeros(0) 
     64                dy = np.zeros(0) 
     65                lam  = np.zeros(0) 
     66                dlam = np.zeros(0) 
     67                dx = np.zeros(0) 
    6868                 
    6969               #temp. space to sort data 
    70                 tx  = numpy.zeros(0) 
    71                 ty  = numpy.zeros(0) 
    72                 tdy = numpy.zeros(0) 
    73                 tlam  = numpy.zeros(0) 
    74                 tdlam = numpy.zeros(0) 
    75                 tdx = numpy.zeros(0) 
     70                tx  = np.zeros(0) 
     71                ty  = np.zeros(0) 
     72                tdy = np.zeros(0) 
     73                tlam  = np.zeros(0) 
     74                tdlam = np.zeros(0) 
     75                tdx = np.zeros(0) 
    7676                output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True) 
    7777                self.filename = output.filename = basename 
     
    128128 
    129129                x,y,lam,dy,dx,dlam = [ 
    130                    numpy.asarray(v, 'double') 
     130                    np.asarray(v, 'double') 
    131131                   for v in (x,y,lam,dy,dx,dlam) 
    132132                ] 
  • src/sas/sascalc/dataloader/readers/tiff_reader.py

    rb699768 r9a5097c  
    1313import logging 
    1414import os 
    15 import numpy 
     15import numpy as np 
    1616from sas.sascalc.dataloader.data_info import Data2D 
    1717from sas.sascalc.dataloader.manipulations import reader2D_converter 
     
    5656 
    5757        # Initiazed the output data object 
    58         output.data = numpy.zeros([im.size[0], im.size[1]]) 
    59         output.err_data = numpy.zeros([im.size[0], im.size[1]]) 
    60         output.mask = numpy.ones([im.size[0], im.size[1]], dtype=bool) 
     58        output.data = np.zeros([im.size[0], im.size[1]]) 
     59        output.err_data = np.zeros([im.size[0], im.size[1]]) 
     60        output.mask = np.ones([im.size[0], im.size[1]], dtype=bool) 
    6161         
    6262        # Initialize 
     
    9494        output.x_bins = x_vals 
    9595        output.y_bins = y_vals 
    96         output.qx_data = numpy.array(x_vals) 
    97         output.qy_data = numpy.array(y_vals) 
     96        output.qx_data = np.array(x_vals) 
     97        output.qy_data = np.array(y_vals) 
    9898        output.xmin = 0 
    9999        output.xmax = im.size[0] - 1 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    ra9f579c r9a5097c  
    44import sys 
    55import math 
    6 import numpy 
     6import numpy as np 
    77 
    88from sas.sascalc.dataloader.data_info import Data1D 
     
    162162        # constant, or dy data 
    163163        if dy is None or dy == [] or dy.all() == 0: 
    164             self.dy = numpy.ones(len(y)) 
     164            self.dy = np.ones(len(y)) 
    165165        else: 
    166             self.dy = numpy.asarray(dy).copy() 
     166            self.dy = np.asarray(dy).copy() 
    167167 
    168168        ## Min Q-value 
    169169        #Skip the Q=0 point, especially when y(q=0)=None at x[0]. 
    170170        if min(self.x) == 0.0 and self.x[0] == 0 and\ 
    171                      not numpy.isfinite(self.y[0]): 
     171                     not np.isfinite(self.y[0]): 
    172172            self.qmin = min(self.x[self.x != 0]) 
    173173        else: 
     
    188188        # Skip Q=0 point, (especially for y(q=0)=None at x[0]). 
    189189        # ToDo: Find better way to do it. 
    190         if qmin == 0.0 and not numpy.isfinite(self.y[qmin]): 
     190        if qmin == 0.0 and not np.isfinite(self.y[qmin]): 
    191191            self.qmin = min(self.x[self.x != 0]) 
    192192        elif qmin != None: 
     
    239239        """ 
    240240        # Compute theory data f(x) 
    241         fx = numpy.zeros(len(self.x)) 
     241        fx = np.zeros(len(self.x)) 
    242242        fx[self.idx_unsmeared] = fn(self.x[self.idx_unsmeared]) 
    243243        
     
    247247                              self._last_unsmeared_bin) 
    248248        ## Sanity check 
    249         if numpy.size(self.dy) != numpy.size(fx): 
     249        if np.size(self.dy) != np.size(fx): 
    250250            msg = "FitData1D: invalid error array " 
    251             msg += "%d <> %d" % (numpy.shape(self.dy), numpy.size(fx)) 
     251            msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 
    252252            raise RuntimeError, msg 
    253253        return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 
     
    300300        ## new error image for fitting purpose 
    301301        if self.err_data == None or self.err_data == []: 
    302             self.res_err_data = numpy.ones(len(self.data)) 
     302            self.res_err_data = np.ones(len(self.data)) 
    303303        else: 
    304304            self.res_err_data = copy.deepcopy(self.err_data) 
    305305        #self.res_err_data[self.res_err_data==0]=1 
    306306         
    307         self.radius = numpy.sqrt(self.qx_data**2 + self.qy_data**2) 
     307        self.radius = np.sqrt(self.qx_data**2 + self.qy_data**2) 
    308308         
    309309        # Note: mask = True: for MASK while mask = False for NOT to mask 
     
    311311                            (self.radius <= self.qmax)) 
    312312        self.idx = (self.idx) & (self.mask) 
    313         self.idx = (self.idx) & (numpy.isfinite(self.data)) 
    314         self.num_points = numpy.sum(self.idx) 
     313        self.idx = (self.idx) & (np.isfinite(self.data)) 
     314        self.num_points = np.sum(self.idx) 
    315315 
    316316    def set_smearer(self, smearer): 
     
    334334        if qmax != None: 
    335335            self.qmax = qmax 
    336         self.radius = numpy.sqrt(self.qx_data**2 + self.qy_data**2) 
     336        self.radius = np.sqrt(self.qx_data**2 + self.qy_data**2) 
    337337        self.idx = ((self.qmin <= self.radius) &\ 
    338338                            (self.radius <= self.qmax)) 
    339339        self.idx = (self.idx) & (self.mask) 
    340         self.idx = (self.idx) & (numpy.isfinite(self.data)) 
     340        self.idx = (self.idx) & (np.isfinite(self.data)) 
    341341        self.idx = (self.idx) & (self.res_err_data != 0) 
    342342 
     
    351351        Number of measurement points in data set after masking, etc. 
    352352        """ 
    353         return numpy.sum(self.idx) 
     353        return np.sum(self.idx) 
    354354 
    355355    def residuals(self, fn): 
  • src/sas/sascalc/fit/BumpsFitting.py

    r1a30720 r9a5097c  
    66import traceback 
    77 
    8 import numpy 
     8import numpy as np 
    99 
    1010from bumps import fitters 
     
    9797        try: 
    9898            p = history.population_values[0] 
    99             n,p = len(p), numpy.sort(p) 
     99            n,p = len(p), np.sort(p) 
    100100            QI,Qmid, = int(0.2*n),int(0.5*n) 
    101101            self.convergence.append((best, p[0],p[QI],p[Qmid],p[-1-QI],p[-1])) 
     
    194194 
    195195    def numpoints(self): 
    196         return numpy.sum(self.data.idx) # number of fitted points 
     196        return np.sum(self.data.idx) # number of fitted points 
    197197 
    198198    def nllf(self): 
    199         return 0.5*numpy.sum(self.residuals()**2) 
     199        return 0.5*np.sum(self.residuals()**2) 
    200200 
    201201    def theory(self): 
     
    295295            if R.success: 
    296296                if result['stderr'] is None: 
    297                     R.stderr = numpy.NaN*numpy.ones(len(param_list)) 
     297                    R.stderr = np.NaN*np.ones(len(param_list)) 
    298298                else: 
    299                     R.stderr = numpy.hstack((result['stderr'][fitted_index], 
    300                                              numpy.NaN*numpy.ones(len(fitness.computed_pars)))) 
    301                 R.pvec = numpy.hstack((result['value'][fitted_index], 
     299                    R.stderr = np.hstack((result['stderr'][fitted_index], 
     300                                          np.NaN*np.ones(len(fitness.computed_pars)))) 
     301                R.pvec = np.hstack((result['value'][fitted_index], 
    302302                                      [p.value for p in fitness.computed_pars])) 
    303                 R.fitness = numpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
     303                R.fitness = np.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
    304304            else: 
    305                 R.stderr = numpy.NaN*numpy.ones(len(param_list)) 
    306                 R.pvec = numpy.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 
    307                 R.fitness = numpy.NaN 
     305                R.stderr = np.NaN*np.ones(len(param_list)) 
     306                R.pvec = np.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 
     307                R.fitness = np.NaN 
    308308            R.convergence = result['convergence'] 
    309309            if result['uncertainty'] is not None: 
     
    336336    max_step = steps + options.get('burn', 0) 
    337337    pars = [p.name for p in problem._parameters] 
    338     #x0 = numpy.asarray([p.value for p in problem._parameters]) 
     338    #x0 = np.asarray([p.value for p in problem._parameters]) 
    339339    options['monitors'] = [ 
    340340        BumpsMonitor(handler, max_step, pars, problem.dof), 
     
    351351        errors = [] 
    352352    except Exception as exc: 
    353         best, fbest = None, numpy.NaN 
     353        best, fbest = None, np.NaN 
    354354        errors = [str(exc), traceback.format_exc()] 
    355355    finally: 
     
    358358 
    359359    convergence_list = options['monitors'][-1].convergence 
    360     convergence = (2*numpy.asarray(convergence_list)/problem.dof 
    361                    if convergence_list else numpy.empty((0,1),'d')) 
     360    convergence = (2*np.asarray(convergence_list)/problem.dof 
     361                   if convergence_list else np.empty((0,1),'d')) 
    362362 
    363363    success = best is not None 
  • src/sas/sascalc/fit/Loader.py

    rb699768 r9a5097c  
    22#import wx 
    33#import string 
    4 import numpy 
     4import numpy as np 
    55 
    66class Load: 
     
    5252                    self.y.append(y) 
    5353                    self.dy.append(dy) 
    54                     self.dx = numpy.zeros(len(self.x)) 
     54                    self.dx = np.zeros(len(self.x)) 
    5555                except: 
    5656                    print "READ ERROR", line 
  • src/sas/sascalc/fit/MultiplicationModel.py

    r68669da r9a5097c  
    11import copy 
    22 
    3 import numpy 
     3import numpy as np 
    44 
    55from sas.sascalc.calculator.BaseComponent import BaseComponent 
     
    5252        ## Parameter details [units, min, max] 
    5353        self._set_details() 
    54         self.details['scale_factor'] = ['', 0.0, numpy.inf] 
    55         self.details['background'] = ['',-numpy.inf,numpy.inf] 
     54        self.details['scale_factor'] = ['', 0.0, np.inf] 
     55        self.details['background'] = ['',-np.inf,np.inf] 
    5656 
    5757        #list of parameter that can be fitted 
  • src/sas/sascalc/fit/expression.py

    rb699768 r9a5097c  
    271271 
    272272def test_deps(): 
    273     import numpy 
     273    import numpy as np 
    274274 
    275275    # Null case 
     
    279279    _check("test1",[(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)]) 
    280280    _check("test1 renumbered",[(6,1),(7,3),(7,4),(6,7),(5,7),(3,2)]) 
    281     _check("test1 numpy",numpy.array([(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)])) 
     281    _check("test1 numpy",np.array([(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)])) 
    282282 
    283283    # No dependencies 
     
    291291 
    292292    # large test for gross speed check 
    293     A = numpy.random.randint(4000,size=(1000,2)) 
     293    A = np.random.randint(4000,size=(1000,2)) 
    294294    A[:,1] += 4000  # Avoid cycles 
    295295    _check("test-large",A) 
     
    297297    # depth tests 
    298298    k = 200 
    299     A = numpy.array([range(0,k),range(1,k+1)]).T 
     299    A = np.array([range(0,k),range(1,k+1)]).T 
    300300    _check("depth-1",A) 
    301301 
    302     A = numpy.array([range(1,k+1),range(0,k)]).T 
     302    A = np.array([range(1,k+1),range(0,k)]).T 
    303303    _check("depth-2",A) 
    304304 
  • src/sas/sascalc/invariant/invariant.py

    rb699768 r9a5097c  
    1717""" 
    1818import math 
    19 import numpy 
     19import numpy as np 
    2020 
    2121from sas.sascalc.dataloader.data_info import Data1D as LoaderData1D 
     
    5050            dy = data.dy 
    5151        else: 
    52             dy = numpy.ones(len(data.y)) 
     52            dy = np.ones(len(data.y)) 
    5353 
    5454        # Transform the data 
     
    6363 
    6464        # Create Data1D object 
    65         x_out = numpy.asarray(x_out) 
    66         y_out = numpy.asarray(y_out) 
    67         dy_out = numpy.asarray(dy_out) 
     65        x_out = np.asarray(x_out) 
     66        y_out = np.asarray(y_out) 
     67        dy_out = np.asarray(dy_out) 
    6868        linear_data = LoaderData1D(x=x_out, y=y_out, dy=dy_out) 
    6969 
     
    158158        :param x: array of q-values 
    159159        """ 
    160         p1 = numpy.array([self.dscale * math.exp(-((self.radius * q) ** 2 / 3)) \ 
     160        p1 = np.array([self.dscale * math.exp(-((self.radius * q) ** 2 / 3)) \ 
    161161                          for q in x]) 
    162         p2 = numpy.array([self.scale * math.exp(-((self.radius * q) ** 2 / 3))\ 
     162        p2 = np.array([self.scale * math.exp(-((self.radius * q) ** 2 / 3))\ 
    163163                     * (-(q ** 2 / 3)) * 2 * self.radius * self.dradius for q in x]) 
    164164        diq2 = p1 * p1 + p2 * p2 
    165         return numpy.array([math.sqrt(err) for err in diq2]) 
     165        return np.array([math.sqrt(err) for err in diq2]) 
    166166 
    167167    def _guinier(self, x): 
     
    182182            msg = "Rg expected positive value, but got %s" % self.radius 
    183183            raise ValueError(msg) 
    184         value = numpy.array([math.exp(-((self.radius * i) ** 2 / 3)) for i in x]) 
     184        value = np.array([math.exp(-((self.radius * i) ** 2 / 3)) for i in x]) 
    185185        return self.scale * value 
    186186 
     
    232232        :param x: array of q-values 
    233233        """ 
    234         p1 = numpy.array([self.dscale * math.pow(q, -self.power) for q in x]) 
    235         p2 = numpy.array([self.scale * self.power * math.pow(q, -self.power - 1)\ 
     234        p1 = np.array([self.dscale * math.pow(q, -self.power) for q in x]) 
     235        p2 = np.array([self.scale * self.power * math.pow(q, -self.power - 1)\ 
    236236                           * self.dpower for q in x]) 
    237237        diq2 = p1 * p1 + p2 * p2 
    238         return numpy.array([math.sqrt(err) for err in diq2]) 
     238        return np.array([math.sqrt(err) for err in diq2]) 
    239239 
    240240    def _power_law(self, x): 
     
    259259            raise ValueError(msg) 
    260260 
    261         value = numpy.array([math.pow(i, -self.power) for i in x]) 
     261        value = np.array([math.pow(i, -self.power) for i in x]) 
    262262        return self.scale * value 
    263263 
     
    304304        idx = (self.data.x >= qmin) & (self.data.x <= qmax) 
    305305 
    306         fx = numpy.zeros(len(self.data.x)) 
     306        fx = np.zeros(len(self.data.x)) 
    307307 
    308308        # Uncertainty 
    309         if type(self.data.dy) == numpy.ndarray and \ 
     309        if type(self.data.dy) == np.ndarray and \ 
    310310            len(self.data.dy) == len(self.data.x) and \ 
    311             numpy.all(self.data.dy > 0): 
     311                np.all(self.data.dy > 0): 
    312312            sigma = self.data.dy 
    313313        else: 
    314             sigma = numpy.ones(len(self.data.x)) 
     314            sigma = np.ones(len(self.data.x)) 
    315315 
    316316        # Compute theory data f(x) 
     
    332332            sigma2 = linearized_data.dy * linearized_data.dy 
    333333            a = -(power) 
    334             b = (numpy.sum(linearized_data.y / sigma2) \ 
    335                  - a * numpy.sum(linearized_data.x / sigma2)) / numpy.sum(1.0 / sigma2) 
     334            b = (np.sum(linearized_data.y / sigma2) \ 
     335                 - a * np.sum(linearized_data.x / sigma2)) / np.sum(1.0 / sigma2) 
    336336 
    337337 
    338338            deltas = linearized_data.x * a + \ 
    339                     numpy.ones(len(linearized_data.x)) * b - linearized_data.y 
    340             residuals = numpy.sum(deltas * deltas / sigma2) 
    341  
    342             err = math.fabs(residuals) / numpy.sum(1.0 / sigma2) 
     339                     np.ones(len(linearized_data.x)) * b - linearized_data.y 
     340            residuals = np.sum(deltas * deltas / sigma2) 
     341 
     342            err = math.fabs(residuals) / np.sum(1.0 / sigma2) 
    343343            return [a, b], [0, math.sqrt(err)] 
    344344        else: 
    345             A = numpy.vstack([linearized_data.x / linearized_data.dy, 1.0 / linearized_data.dy]).T 
    346             (p, residuals, _, _) = numpy.linalg.lstsq(A, linearized_data.y / linearized_data.dy) 
     345            A = np.vstack([linearized_data.x / linearized_data.dy, 1.0 / linearized_data.dy]).T 
     346            (p, residuals, _, _) = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy) 
    347347 
    348348            # Get the covariance matrix, defined as inv_cov = a_transposed * a 
    349             err = numpy.zeros(2) 
     349            err = np.zeros(2) 
    350350            try: 
    351                 inv_cov = numpy.dot(A.transpose(), A) 
    352                 cov = numpy.linalg.pinv(inv_cov) 
     351                inv_cov = np.dot(A.transpose(), A) 
     352                cov = np.linalg.pinv(inv_cov) 
    353353                err_matrix = math.fabs(residuals) * cov 
    354354                err = [math.sqrt(err_matrix[0][0]), math.sqrt(err_matrix[1][1])] 
     
    434434        if new_data.dy is None or len(new_data.x) != len(new_data.dy) or \ 
    435435            (min(new_data.dy) == 0 and max(new_data.dy) == 0): 
    436             new_data.dy = numpy.ones(len(new_data.x)) 
     436            new_data.dy = np.ones(len(new_data.x)) 
    437437        return  new_data 
    438438 
     
    571571        """ 
    572572        #create new Data1D to compute the invariant 
    573         q = numpy.linspace(start=q_start, 
     573        q = np.linspace(start=q_start, 
    574574                           stop=q_end, 
    575575                           num=npts, 
     
    580580        result_data = LoaderData1D(x=q, y=iq, dy=diq) 
    581581        if self._smeared != None: 
    582             result_data.dxl = self._smeared * numpy.ones(len(q)) 
     582            result_data.dxl = self._smeared * np.ones(len(q)) 
    583583        return result_data 
    584584 
     
    691691 
    692692        if q_start >= q_end: 
    693             return numpy.zeros(0), numpy.zeros(0) 
     693            return np.zeros(0), np.zeros(0) 
    694694 
    695695        return self._get_extrapolated_data(\ 
     
    719719 
    720720        if q_start >= q_end: 
    721             return numpy.zeros(0), numpy.zeros(0) 
     721            return np.zeros(0), np.zeros(0) 
    722722 
    723723        return self._get_extrapolated_data(\ 
  • src/sas/sascalc/pr/fit/AbstractFitEngine.py

    rfc18690 r9a5097c  
    44import sys 
    55import math 
    6 import numpy 
     6import numpy as np 
    77 
    88from sas.sascalc.dataloader.data_info import Data1D 
     
    162162        # constant, or dy data 
    163163        if dy is None or dy == [] or dy.all() == 0: 
    164             self.dy = numpy.ones(len(y)) 
     164            self.dy = np.ones(len(y)) 
    165165        else: 
    166             self.dy = numpy.asarray(dy).copy() 
     166            self.dy = np.asarray(dy).copy() 
    167167 
    168168        ## Min Q-value 
    169169        #Skip the Q=0 point, especially when y(q=0)=None at x[0]. 
    170170        if min(self.x) == 0.0 and self.x[0] == 0 and\ 
    171                      not numpy.isfinite(self.y[0]): 
     171                     not np.isfinite(self.y[0]): 
    172172            self.qmin = min(self.x[self.x != 0]) 
    173173        else: 
     
    188188        # Skip Q=0 point, (especially for y(q=0)=None at x[0]). 
    189189        # ToDo: Find better way to do it. 
    190         if qmin == 0.0 and not numpy.isfinite(self.y[qmin]): 
     190        if qmin == 0.0 and not np.isfinite(self.y[qmin]): 
    191191            self.qmin = min(self.x[self.x != 0]) 
    192192        elif qmin != None: 
     
    239239        """ 
    240240        # Compute theory data f(x) 
    241         fx = numpy.zeros(len(self.x)) 
     241        fx = np.zeros(len(self.x)) 
    242242        fx[self.idx_unsmeared] = fn(self.x[self.idx_unsmeared]) 
    243243        
     
    247247                              self._last_unsmeared_bin) 
    248248        ## Sanity check 
    249         if numpy.size(self.dy) != numpy.size(fx): 
     249        if np.size(self.dy) != np.size(fx): 
    250250            msg = "FitData1D: invalid error array " 
    251             msg += "%d <> %d" % (numpy.shape(self.dy), numpy.size(fx)) 
     251            msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 
    252252            raise RuntimeError, msg 
    253253        return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 
     
    300300        ## new error image for fitting purpose 
    301301        if self.err_data == None or self.err_data == []: 
    302             self.res_err_data = numpy.ones(len(self.data)) 
     302            self.res_err_data = np.ones(len(self.data)) 
    303303        else: 
    304304            self.res_err_data = copy.deepcopy(self.err_data) 
    305305        #self.res_err_data[self.res_err_data==0]=1 
    306306         
    307         self.radius = numpy.sqrt(self.qx_data**2 + self.qy_data**2) 
     307        self.radius = np.sqrt(self.qx_data**2 + self.qy_data**2) 
    308308         
    309309        # Note: mask = True: for MASK while mask = False for NOT to mask 
     
    311311                            (self.radius <= self.qmax)) 
    312312        self.idx = (self.idx) & (self.mask) 
    313         self.idx = (self.idx) & (numpy.isfinite(self.data)) 
    314         self.num_points = numpy.sum(self.idx) 
     313        self.idx = (self.idx) & (np.isfinite(self.data)) 
     314        self.num_points = np.sum(self.idx) 
    315315 
    316316    def set_smearer(self, smearer): 
     
    334334        if qmax != None: 
    335335            self.qmax = qmax 
    336         self.radius = numpy.sqrt(self.qx_data**2 + self.qy_data**2) 
     336        self.radius = np.sqrt(self.qx_data**2 + self.qy_data**2) 
    337337        self.idx = ((self.qmin <= self.radius) &\ 
    338338                            (self.radius <= self.qmax)) 
    339339        self.idx = (self.idx) & (self.mask) 
    340         self.idx = (self.idx) & (numpy.isfinite(self.data)) 
     340        self.idx = (self.idx) & (np.isfinite(self.data)) 
    341341        self.idx = (self.idx) & (self.res_err_data != 0) 
    342342 
     
    351351        Number of measurement points in data set after masking, etc. 
    352352        """ 
    353         return numpy.sum(self.idx) 
     353        return np.sum(self.idx) 
    354354 
    355355    def residuals(self, fn): 
  • src/sas/sascalc/pr/fit/BumpsFitting.py

    rb699768 r9a5097c  
    55from datetime import timedelta, datetime 
    66 
    7 import numpy 
     7import numpy as np 
    88 
    99from bumps import fitters 
     
    9696        try: 
    9797            p = history.population_values[0] 
    98             n,p = len(p), numpy.sort(p) 
     98            n,p = len(p), np.sort(p) 
    9999            QI,Qmid, = int(0.2*n),int(0.5*n) 
    100100            self.convergence.append((best, p[0],p[QI],p[Qmid],p[-1-QI],p[-1])) 
     
    193193 
    194194    def numpoints(self): 
    195         return numpy.sum(self.data.idx) # number of fitted points 
     195        return np.sum(self.data.idx) # number of fitted points 
    196196 
    197197    def nllf(self): 
    198         return 0.5*numpy.sum(self.residuals()**2) 
     198        return 0.5*np.sum(self.residuals()**2) 
    199199 
    200200    def theory(self): 
     
    293293            R.success = result['success'] 
    294294            if R.success: 
    295                 R.stderr = numpy.hstack((result['stderr'][fitted_index], 
    296                                          numpy.NaN*numpy.ones(len(fitness.computed_pars)))) 
    297                 R.pvec = numpy.hstack((result['value'][fitted_index], 
     295                R.stderr = np.hstack((result['stderr'][fitted_index], 
     296                                      np.NaN*np.ones(len(fitness.computed_pars)))) 
     297                R.pvec = np.hstack((result['value'][fitted_index], 
    298298                                      [p.value for p in fitness.computed_pars])) 
    299                 R.fitness = numpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
     299                R.fitness = np.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
    300300            else: 
    301                 R.stderr = numpy.NaN*numpy.ones(len(param_list)) 
    302                 R.pvec = numpy.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 
    303                 R.fitness = numpy.NaN 
     301                R.stderr = np.NaN*np.ones(len(param_list)) 
     302                R.pvec = np.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 
     303                R.fitness = np.NaN 
    304304            R.convergence = result['convergence'] 
    305305            if result['uncertainty'] is not None: 
     
    331331    max_step = steps + options.get('burn', 0) 
    332332    pars = [p.name for p in problem._parameters] 
    333     #x0 = numpy.asarray([p.value for p in problem._parameters]) 
     333    #x0 = np.asarray([p.value for p in problem._parameters]) 
    334334    options['monitors'] = [ 
    335335        BumpsMonitor(handler, max_step, pars, problem.dof), 
     
    352352 
    353353    convergence_list = options['monitors'][-1].convergence 
    354     convergence = (2*numpy.asarray(convergence_list)/problem.dof 
    355                    if convergence_list else numpy.empty((0,1),'d')) 
     354    convergence = (2*np.asarray(convergence_list)/problem.dof 
     355                   if convergence_list else np.empty((0,1),'d')) 
    356356 
    357357    success = best is not None 
  • src/sas/sascalc/pr/fit/Loader.py

    rb699768 r9a5097c  
    22#import wx 
    33#import string 
    4 import numpy 
     4import numpy as np 
    55 
    66class Load: 
     
    5252                    self.y.append(y) 
    5353                    self.dy.append(dy) 
    54                     self.dx = numpy.zeros(len(self.x)) 
     54                    self.dx = np.zeros(len(self.x)) 
    5555                except: 
    5656                    print "READ ERROR", line 
  • src/sas/sascalc/pr/fit/expression.py

    rb699768 r9a5097c  
    271271 
    272272def test_deps(): 
    273     import numpy 
     273    import numpy as np 
    274274 
    275275    # Null case 
     
    279279    _check("test1",[(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)]) 
    280280    _check("test1 renumbered",[(6,1),(7,3),(7,4),(6,7),(5,7),(3,2)]) 
    281     _check("test1 numpy",numpy.array([(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)])) 
     281    _check("test1 numpy",np.array([(2,7),(1,5),(1,4),(2,1),(3,1),(5,6)])) 
    282282 
    283283    # No dependencies 
     
    291291 
    292292    # large test for gross speed check 
    293     A = numpy.random.randint(4000,size=(1000,2)) 
     293    A = np.random.randint(4000,size=(1000,2)) 
    294294    A[:,1] += 4000  # Avoid cycles 
    295295    _check("test-large",A) 
     
    297297    # depth tests 
    298298    k = 200 
    299     A = numpy.array([range(0,k),range(1,k+1)]).T 
     299    A = np.array([range(0,k),range(1,k+1)]).T 
    300300    _check("depth-1",A) 
    301301 
    302     A = numpy.array([range(1,k+1),range(0,k)]).T 
     302    A = np.array([range(1,k+1),range(0,k)]).T 
    303303    _check("depth-2",A) 
    304304 
  • src/sas/sascalc/pr/invertor.py

    r2c60f304 r9a5097c  
    77""" 
    88 
    9 import numpy 
     9import numpy as np 
    1010import sys 
    1111import math 
     
    189189        #import numpy 
    190190        if name == 'x': 
    191             out = numpy.ones(self.get_nx()) 
     191            out = np.ones(self.get_nx()) 
    192192            self.get_x(out) 
    193193            return out 
    194194        elif name == 'y': 
    195             out = numpy.ones(self.get_ny()) 
     195            out = np.ones(self.get_ny()) 
    196196            self.get_y(out) 
    197197            return out 
    198198        elif name == 'err': 
    199             out = numpy.ones(self.get_nerr()) 
     199            out = np.ones(self.get_nerr()) 
    200200            self.get_err(out) 
    201201            return out 
     
    325325            raise RuntimeError, msg 
    326326 
    327         p = numpy.ones(nfunc) 
     327        p = np.ones(nfunc) 
    328328        t_0 = time.time() 
    329329        out, cov_x, _, _, _ = optimize.leastsq(self.residuals, p, full_output=1) 
     
    341341 
    342342        if cov_x is None: 
    343             cov_x = numpy.ones([nfunc, nfunc]) 
     343            cov_x = np.ones([nfunc, nfunc]) 
    344344            cov_x *= math.fabs(chisqr) 
    345345        return out, cov_x 
     
    358358            raise RuntimeError, msg 
    359359 
    360         p = numpy.ones(nfunc) 
     360        p = np.ones(nfunc) 
    361361        t_0 = time.time() 
    362362        out, cov_x, _, _, _ = optimize.leastsq(self.pr_residuals, p, full_output=1) 
     
    435435        """ 
    436436        # Note: To make sure an array is contiguous: 
    437         # blah = numpy.ascontiguousarray(blah_original) 
     437        # blah = np.ascontiguousarray(blah_original) 
    438438        # ... before passing it to C 
    439439 
     
    456456            nfunc += 1 
    457457 
    458         a = numpy.zeros([npts + nq, nfunc]) 
    459         b = numpy.zeros(npts + nq) 
    460         err = numpy.zeros([nfunc, nfunc]) 
     458        a = np.zeros([npts + nq, nfunc]) 
     459        b = np.zeros(npts + nq) 
     460        err = np.zeros([nfunc, nfunc]) 
    461461 
    462462        # Construct the a matrix and b vector that represent the problem 
     
    476476        self.chi2 = chi2 
    477477 
    478         inv_cov = numpy.zeros([nfunc, nfunc]) 
     478        inv_cov = np.zeros([nfunc, nfunc]) 
    479479        # Get the covariance matrix, defined as inv_cov = a_transposed * a 
    480480        self._get_invcov_matrix(nfunc, nr, a, inv_cov) 
     
    490490 
    491491        try: 
    492             cov = numpy.linalg.pinv(inv_cov) 
     492            cov = np.linalg.pinv(inv_cov) 
    493493            err = math.fabs(chi2 / float(npts - nfunc)) * cov 
    494494        except: 
     
    505505            self.background = c[0] 
    506506 
    507             err_0 = numpy.zeros([nfunc, nfunc]) 
    508             c_0 = numpy.zeros(nfunc) 
     507            err_0 = np.zeros([nfunc, nfunc]) 
     508            c_0 = np.zeros(nfunc) 
    509509 
    510510            for i in range(nfunc_0): 
     
    662662                                                   str(self.cov[i][i]))) 
    663663        file.write("<r>  <Pr>  <dPr>\n") 
    664         r = numpy.arange(0.0, self.d_max, self.d_max / npts) 
     664        r = np.arange(0.0, self.d_max, self.d_max / npts) 
    665665 
    666666        for r_i in r: 
     
    694694                        toks = line.split('=') 
    695695                        self.nfunc = int(toks[1]) 
    696                         self.out = numpy.zeros(self.nfunc) 
    697                         self.cov = numpy.zeros([self.nfunc, self.nfunc]) 
     696                        self.out = np.zeros(self.nfunc) 
     697                        self.cov = np.zeros([self.nfunc, self.nfunc]) 
    698698                    elif line.startswith('#alpha='): 
    699699                        toks = line.split('=') 
  • src/sas/sascalc/pr/num_term.py

    rb699768 r9a5097c  
    11import math 
    2 import numpy 
     2import numpy as np 
    33import copy 
    44import sys 
     
    152152def load(path): 
    153153    # Read the data from the data file 
    154     data_x = numpy.zeros(0) 
    155     data_y = numpy.zeros(0) 
    156     data_err = numpy.zeros(0) 
     154    data_x = np.zeros(0) 
     155    data_y = np.zeros(0) 
     156    data_err = np.zeros(0) 
    157157    scale = None 
    158158    min_err = 0.0 
     
    176176                    #err = 0 
    177177 
    178                 data_x = numpy.append(data_x, test_x) 
    179                 data_y = numpy.append(data_y, test_y) 
    180                 data_err = numpy.append(data_err, err) 
     178                data_x = np.append(data_x, test_x) 
     179                data_y = np.append(data_y, test_y) 
     180                data_err = np.append(data_err, err) 
    181181            except: 
    182182                logging.error(sys.exc_value) 
Note: See TracChangeset for help on using the changeset viewer.