Changeset 9a5097c in sasview for src/sas/sascalc/dataloader


Ignore:
Timestamp:
Mar 26, 2017 11:33:16 PM (7 years ago)
Author:
andyfaff
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:
ed2276f
Parents:
9146ed9
Message:

MAINT: import numpy as np

Location:
src/sas/sascalc/dataloader
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • 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/manipulations.py

    rb2b36932 r9a5097c  
    1414#TODO: copy the meta data from the 2D object to the resulting 1D object 
    1515import math 
    16 import numpy 
     16import numpy as np 
    1717 
    1818#from data_info import plottable_2D 
     
    8282    if data2d.data == None or data2d.x_bins == None or data2d.y_bins == None: 
    8383        raise ValueError, "Can't convert this data: data=None..." 
    84     new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
    85     new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1)) 
     84    new_x = np.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
     85    new_y = np.tile(data2d.y_bins, (len(data2d.x_bins), 1)) 
    8686    new_y = new_y.swapaxes(0, 1) 
    8787 
     
    8989    qx_data = new_x.flatten() 
    9090    qy_data = new_y.flatten() 
    91     q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
    92     if data2d.err_data == None or numpy.any(data2d.err_data <= 0): 
    93         new_err_data = numpy.sqrt(numpy.abs(new_data)) 
     91    q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
     92    if data2d.err_data == None or np.any(data2d.err_data <= 0): 
     93        new_err_data = np.sqrt(np.abs(new_data)) 
    9494    else: 
    9595        new_err_data = data2d.err_data.flatten() 
    96     mask = numpy.ones(len(new_data), dtype=bool) 
     96    mask = np.ones(len(new_data), dtype=bool) 
    9797 
    9898    #TODO: make sense of the following two lines... 
     
    149149 
    150150        # Get data 
    151         data = data2D.data[numpy.isfinite(data2D.data)] 
    152         err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    153         qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    154         qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
     151        data = data2D.data[np.isfinite(data2D.data)] 
     152        err_data = data2D.err_data[np.isfinite(data2D.data)] 
     153        qx_data = data2D.qx_data[np.isfinite(data2D.data)] 
     154        qy_data = data2D.qy_data[np.isfinite(data2D.data)] 
    155155 
    156156        # Build array of Q intervals 
     
    170170            raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj) 
    171171 
    172         x = numpy.zeros(nbins) 
    173         y = numpy.zeros(nbins) 
    174         err_y = numpy.zeros(nbins) 
    175         y_counts = numpy.zeros(nbins) 
     172        x = np.zeros(nbins) 
     173        y = np.zeros(nbins) 
     174        err_y = np.zeros(nbins) 
     175        y_counts = np.zeros(nbins) 
    176176 
    177177        # Average pixelsize in q space 
     
    225225        y = y / y_counts 
    226226        x = x / y_counts 
    227         idx = (numpy.isfinite(y) & numpy.isfinite(x)) 
     227        idx = (np.isfinite(y) & np.isfinite(x)) 
    228228 
    229229        if not idx.any(): 
     
    304304            raise RuntimeError, msg 
    305305        # Get data 
    306         data = data2D.data[numpy.isfinite(data2D.data)] 
    307         err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    308         qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    309         qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
     306        data = data2D.data[np.isfinite(data2D.data)] 
     307        err_data = data2D.err_data[np.isfinite(data2D.data)] 
     308        qx_data = data2D.qx_data[np.isfinite(data2D.data)] 
     309        qy_data = data2D.qy_data[np.isfinite(data2D.data)] 
    310310 
    311311        y = 0.0 
     
    414414        """ 
    415415        # Get data W/ finite values 
    416         data = data2D.data[numpy.isfinite(data2D.data)] 
    417         q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    418         err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    419         mask_data = data2D.mask[numpy.isfinite(data2D.data)] 
     416        data = data2D.data[np.isfinite(data2D.data)] 
     417        q_data = data2D.q_data[np.isfinite(data2D.data)] 
     418        err_data = data2D.err_data[np.isfinite(data2D.data)] 
     419        mask_data = data2D.mask[np.isfinite(data2D.data)] 
    420420 
    421421        dq_data = None 
     
    448448            dq_overlap_y *= dq_overlap_y 
    449449 
    450             dq_overlap = numpy.sqrt((dq_overlap_x + dq_overlap_y) / 2.0) 
     450            dq_overlap = np.sqrt((dq_overlap_x + dq_overlap_y) / 2.0) 
    451451            # Final protection of dq 
    452452            if dq_overlap < 0: 
    453453                dq_overlap = y_min 
    454             dqx_data = data2D.dqx_data[numpy.isfinite(data2D.data)] 
    455             dqy_data = data2D.dqy_data[numpy.isfinite(data2D.data)] - dq_overlap 
     454            dqx_data = data2D.dqx_data[np.isfinite(data2D.data)] 
     455            dqy_data = data2D.dqy_data[np.isfinite(data2D.data)] - dq_overlap 
    456456            # def; dqx_data = dq_r dqy_data = dq_phi 
    457457            # Convert dq 2D to 1D here 
    458458            dqx = dqx_data * dqx_data 
    459459            dqy = dqy_data * dqy_data 
    460             dq_data = numpy.add(dqx, dqy) 
    461             dq_data = numpy.sqrt(dq_data) 
    462  
    463         #q_data_max = numpy.max(q_data) 
     460            dq_data = np.add(dqx, dqy) 
     461            dq_data = np.sqrt(dq_data) 
     462 
     463        #q_data_max = np.max(q_data) 
    464464        if len(data2D.q_data) == None: 
    465465            msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 
     
    469469        nbins = int(math.ceil((self.r_max - self.r_min) / self.bin_width)) 
    470470 
    471         x = numpy.zeros(nbins) 
    472         y = numpy.zeros(nbins) 
    473         err_y = numpy.zeros(nbins) 
    474         err_x = numpy.zeros(nbins) 
    475         y_counts = numpy.zeros(nbins) 
     471        x = np.zeros(nbins) 
     472        y = np.zeros(nbins) 
     473        err_y = np.zeros(nbins) 
     474        err_x = np.zeros(nbins) 
     475        y_counts = np.zeros(nbins) 
    476476 
    477477        for npt in range(len(data)): 
     
    527527 
    528528        err_y = err_y / y_counts 
    529         err_y[err_y == 0] = numpy.average(err_y) 
     529        err_y[err_y == 0] = np.average(err_y) 
    530530        y = y / y_counts 
    531531        x = x / y_counts 
    532         idx = (numpy.isfinite(y)) & (numpy.isfinite(x)) 
     532        idx = (np.isfinite(y)) & (np.isfinite(x)) 
    533533 
    534534        if err_x != None: 
     
    585585 
    586586        # Get data 
    587         data = data2D.data[numpy.isfinite(data2D.data)] 
    588         q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    589         err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    590         qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    591         qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
     587        data = data2D.data[np.isfinite(data2D.data)] 
     588        q_data = data2D.q_data[np.isfinite(data2D.data)] 
     589        err_data = data2D.err_data[np.isfinite(data2D.data)] 
     590        qx_data = data2D.qx_data[np.isfinite(data2D.data)] 
     591        qy_data = data2D.qy_data[np.isfinite(data2D.data)] 
    592592 
    593593        # Set space for 1d outputs 
    594         phi_bins = numpy.zeros(self.nbins_phi) 
    595         phi_counts = numpy.zeros(self.nbins_phi) 
    596         phi_values = numpy.zeros(self.nbins_phi) 
    597         phi_err = numpy.zeros(self.nbins_phi) 
     594        phi_bins = np.zeros(self.nbins_phi) 
     595        phi_counts = np.zeros(self.nbins_phi) 
     596        phi_values = np.zeros(self.nbins_phi) 
     597        phi_err = np.zeros(self.nbins_phi) 
    598598 
    599599        # Shift to apply to calculated phi values in order 
     
    636636            phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i) 
    637637 
    638         idx = (numpy.isfinite(phi_bins)) 
     638        idx = (np.isfinite(phi_bins)) 
    639639 
    640640        if not idx.any(): 
     
    769769 
    770770        # Get the all data & info 
    771         data = data2D.data[numpy.isfinite(data2D.data)] 
    772         q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    773         err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    774         qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    775         qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
     771        data = data2D.data[np.isfinite(data2D.data)] 
     772        q_data = data2D.q_data[np.isfinite(data2D.data)] 
     773        err_data = data2D.err_data[np.isfinite(data2D.data)] 
     774        qx_data = data2D.qx_data[np.isfinite(data2D.data)] 
     775        qy_data = data2D.qy_data[np.isfinite(data2D.data)] 
    776776        dq_data = None 
    777777 
     
    803803            dq_overlap_y *= dq_overlap_y 
    804804 
    805             dq_overlap = numpy.sqrt((dq_overlap_x + dq_overlap_y) / 2.0) 
     805            dq_overlap = np.sqrt((dq_overlap_x + dq_overlap_y) / 2.0) 
    806806            if dq_overlap < 0: 
    807807                dq_overlap = y_min 
    808             dqx_data = data2D.dqx_data[numpy.isfinite(data2D.data)] 
    809             dqy_data = data2D.dqy_data[numpy.isfinite(data2D.data)] - dq_overlap 
     808            dqx_data = data2D.dqx_data[np.isfinite(data2D.data)] 
     809            dqy_data = data2D.dqy_data[np.isfinite(data2D.data)] - dq_overlap 
    810810            # def; dqx_data = dq_r dqy_data = dq_phi 
    811811            # Convert dq 2D to 1D here 
    812812            dqx = dqx_data * dqx_data 
    813813            dqy = dqy_data * dqy_data 
    814             dq_data = numpy.add(dqx, dqy) 
    815             dq_data = numpy.sqrt(dq_data) 
     814            dq_data = np.add(dqx, dqy) 
     815            dq_data = np.sqrt(dq_data) 
    816816 
    817817        #set space for 1d outputs 
    818         x = numpy.zeros(self.nbins) 
    819         y = numpy.zeros(self.nbins) 
    820         y_err = numpy.zeros(self.nbins) 
    821         x_err = numpy.zeros(self.nbins) 
    822         y_counts = numpy.zeros(self.nbins) 
     818        x = np.zeros(self.nbins) 
     819        y = np.zeros(self.nbins) 
     820        y_err = np.zeros(self.nbins) 
     821        x_err = np.zeros(self.nbins) 
     822        y_counts = np.zeros(self.nbins) 
    823823 
    824824        # Get the min and max into the region: 0 <= phi < 2Pi 
     
    923923                #x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2) 
    924924                x[i] = x[i] / y_counts[i] 
    925         y_err[y_err == 0] = numpy.average(y_err) 
    926         idx = (numpy.isfinite(y) & numpy.isfinite(y_err)) 
     925        y_err[y_err == 0] = np.average(y_err) 
     926        idx = (np.isfinite(y) & np.isfinite(y_err)) 
    927927        if x_err != None: 
    928928            d_x = x_err[idx] / y_counts[idx] 
     
    10121012        qx_data = data2D.qx_data 
    10131013        qy_data = data2D.qy_data 
    1014         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     1014        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    10151015 
    10161016        # check whether or not the data point is inside ROI 
     
    11131113 
    11141114        # get phi from data 
    1115         phi_data = numpy.arctan2(qy_data, qx_data) 
     1115        phi_data = np.arctan2(qy_data, qx_data) 
    11161116 
    11171117        # Get the min and max into the region: -pi <= phi < Pi 
  • src/sas/sascalc/dataloader/readers/IgorReader.py

    rb699768 r9a5097c  
    1313############################################################################# 
    1414import os 
    15 import numpy 
     15import numpy as np 
    1616import math 
    1717#import logging 
     
    118118        size_x = i_tot_row  # 192#128 
    119119        size_y = i_tot_row  # 192#128 
    120         output.data = numpy.zeros([size_x, size_y]) 
    121         output.err_data = numpy.zeros([size_x, size_y]) 
     120        output.data = np.zeros([size_x, size_y]) 
     121        output.err_data = np.zeros([size_x, size_y]) 
    122122      
    123123        #Read Header and 2D data 
  • 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 
Note: See TracChangeset for help on using the changeset viewer.