Changeset cfc6f3c7 in sasview


Ignore:
Timestamp:
Apr 5, 2017 5:21:31 AM (8 years ago)
Author:
krzywon
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:
69400ec
Parents:
270c882b (diff), a2e980b (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.
Message:

Merge branch 'master' into ticket-876

Files:
3 added
81 edited
1 moved

Legend:

Unmodified
Added
Removed
  • TabularUnified .travis.yml

    red8f27e7 r4636f57  
    22 
    33language: python 
    4 python: 
    5   - "2.7" 
     4 
     5matrix: 
     6  include: 
     7    - os: linux 
     8      env: 
     9        - PY=2.7 
     10        - NUMPYSPEC=numpy 
     11    - os: osx 
     12      language: generic 
     13      env: 
     14        - PY=2.7 
     15        - NUMPYSPEC=numpy 
     16 
    617# whitelist 
    718branches: 
    819  only: 
    920    - master 
    10 # command to install dependencies 
    11 virtualenv: 
    12   system_site_packages: true 
     21 
     22addons: 
     23  apt: 
     24    packages: 
     25      - opencl-headers 
     26      - fglrx 
     27      - libblas-dev 
     28      - libatlas-dev 
     29      - libatlas-base-dev 
     30      - liblapack-dev 
     31      - gfortran 
     32      - libhdf5-serial-dev 
     33 
    1334before_install: 
    14   - 'if [ $TRAVIS_PYTHON_VERSION == "2.7" ]; then sudo apt-get update;sudo apt-get install python-matplotlib libhdf5-serial-dev python-h5py fglrx opencl-headers python-pyopencl gfortran libblas-dev liblapack-dev libatlas-dev; fi' 
     35  - echo $TRAVIS_OS_NAME 
     36  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 
     37        wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; 
     38        sudo apt-get update; sudo apt-get install python-pyopencl; 
     39    elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 
     40        wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh; 
     41    fi 
     42 
     43  - bash miniconda.sh -b -p $HOME/miniconda 
     44  - export PATH="$HOME/miniconda/bin:$PATH" 
     45  - hash -r 
     46  - conda update --yes conda 
     47 
     48  # Useful for debugging any issues with conda 
     49  - conda info -a 
     50 
     51  # could install other dependencies, but they're locked to specific 
     52  # versions in build/requirements.txt 
     53  - conda install --yes python=$PY $NUMPYSPEC scipy cython pylint wxpython 
    1554 
    1655install: 
    1756  - pip install -r build_tools/requirements.txt 
     57  - pip install matplotlib 
    1858 
    19 before_script: 
    20   - "export DISPLAY=:99.0" 
    21   - "sh -e /etc/init.d/xvfb start" 
    22   - sleep 3 # give xvfb some time to start 
    23    
     59#before_script: 
     60#  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 
     61#        "export DISPLAY=:99.0"; "sh -e /etc/init.d/xvfb start"; sleep 3; # give xvfb some time to start 
     62#    fi 
     63 
    2464script: 
    25   - export WORKSPACE=/home/travis/build/SasView/ 
    26   - cd $WORKSPACE 
     65  - cd .. 
     66  # this should be the directory above the sasview directory, where we want to 
     67  # clone the sasmodels 
     68  - export WORKSPACE=$(pwd) 
    2769  - git clone --depth=50 --branch=master https://github.com/SasView/sasmodels.git sasmodels 
    28   - export PYTHONPATH=$WORKSPACE/sasview-install:$WORKSPACE/utils:$PYTHONPATH 
    29   - cd $WORKSPACE 
     70 
     71  # required for documentation 
     72  - git clone --depth=50 --branch=master https://github.com/bumps/bumps.git 
     73 
    3074  - ls -ltr 
    3175  - if [ ! -d "utils" ]; then mkdir utils; fi 
    3276  - /bin/sh -xe sasview/build_tools/travis_build.sh 
    33 #  - /bin/sh -xe sasview/build_tools/jenkins_linux_test.sh 
    3477  - export LC_ALL=en_US.UTF-8 
    3578  - export LANG=en_US.UTF-8 
  • TabularUnified INSTALL.txt

    rd09f0ae1 r26c9b85  
    22================================ 
    33 
     4Note - at the current time sasview will only run in gui form under Python 2. 
    45 
    5 The build works in the usualy pythonic way: 
     6Before trying to install and run sasview you'll need to check what 
     7dependencies are required: 
     8 
     9$ python check_packages.py 
     10 
     11Many of these are available from PyPi, but some (e.g. h5py) may require more 
     12involvement to build and install. If you use the conda package manager then 
     13many of the pre-built dependencies are available there. This may be the easiest 
     14route if you are on windows. 
     15 
     16The build works in the pythonic way: 
    617 
    718$ python setup.py build      # will build the package underneath 'build/' 
    8 $ python setup.py install    # will install the package 
    9  
     19$ python setup.py install    # will install the package into site-packages 
    1020 
    1121 
     
    1424$ python run.py              # will run the code in place (building the C code once, if required) 
    1525 
     26On OSX or windows you may need to use: 
    1627 
    17  
    18 To check all dependencies are met: 
    19  
    20 $ python deps.py 
    21 $ python check_packages.py  
    22  
    23 Both tell you different parts of the story, unfortunately. 
    24  
     28$ pythonw run.py 
    2529 
    2630 
  • TabularUnified LICENSE.TXT

    r7c05b63 ra3e3ef5  
    1 Copyright (c) 2009-2016, SasView Developers 
     1Copyright (c) 2009-2017, SasView Developers 
    22All rights reserved. 
    33 
  • TabularUnified build_tools/travis_build.sh

    r68e6ac8 r8374dc0  
    1 # Simplified build for Travic CI 
     1# Simplified build for Travis CI 
    22# No documentation is built 
    33export PATH=$PATH:/usr/local/bin/ 
     
    3838cd $WORKSPACE/sasview 
    3939$PYTHON setup.py clean 
    40 $PYTHON setup.py build docs bdist_egg 
     40# $PYTHON setup.py build docs bdist_egg 
     41$PYTHON setup.py bdist_egg 
    4142 
    4243# INSTALL SASVIEW 
  • TabularUnified check_packages.py

    r131d94b rf433e6a  
    22Checking and reinstalling the external packages 
    33""" 
    4 import os 
     4from __future__ import print_function 
     5 
    56import sys 
    67 
     
    1415    sys.modules['Image'] = PIL.Image 
    1516 
     17if sys.version_info[0] > 2: 
     18    print("To use the sasview GUI you must use Python 2\n") 
    1619 
    1720common_required_package_list = { 
    18     'setuptools':{'version':'0.6c11','import_name':'setuptools','test':'__version__'}, 
    19     'pyparsing':{'version':'1.5.5','import_name':'pyparsing','test':'__version__'}, 
    20     'html5lib':{'version':'0.95','import_name':'html5lib','test':'__version__'}, 
    21     'reportlab':{'version':'2.5','import_name':'reportlab','test':'Version'}, 
    22     'h5py':{'version':'2.5','import_name':'h5py','test':'__version__'}, 
    23     'lxml':{'version':'2.3','import_name':'lxml.etree','test':'LXML_VERSION'}, 
    24     'PIL':{'version':'1.1.7','import_name':'Image','test':'VERSION'}, 
    25     'pylint':{'version':None,'import_name':'pylint','test':None}, 
    26     'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, 
    27     'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, 
    28     'numpy':{'version':'1.7.1','import_name':'numpy','test':'__version__'}, 
    29     'scipy':{'version':'0.18.0','import_name':'scipy','test':'__version__'}, 
    30     'wx':{'version':'2.8.12.1','import_name':'wx','test':'__version__'}, 
    31     'matplotlib':{'version':'1.1.0','import_name':'matplotlib','test':'__version__'}, 
    32     'xhtml2pdf':{'version':'3.0.33','import_name':'xhtml2pdf','test':'__version__'}, 
    33     'sphinx':{'version':'1.2.1','import_name':'sphinx','test':'__version__'}, 
    34     'unittest-xml-reporting':{'version':'1.10.0','import_name':'xmlrunner','test':'__version__'}, 
    35     'pyopencl':{'version':'2015.1','import_name':'pyopencl','test':'VERSION_TEXT'}, 
     21    'setuptools': {'version': '0.6c11', 'import_name': 'setuptools', 'test': '__version__'}, 
     22    'pyparsing': {'version': '1.5.5', 'import_name': 'pyparsing', 'test': '__version__'}, 
     23    'html5lib': {'version': '0.95', 'import_name': 'html5lib', 'test': '__version__'}, 
     24    'reportlab': {'version': '2.5', 'import_name': 'reportlab', 'test': 'Version'}, 
     25    'h5py': {'version': '2.5', 'import_name': 'h5py', 'test': '__version__'}, 
     26    'lxml': {'version': '2.3', 'import_name': 'lxml.etree', 'test': 'LXML_VERSION'}, 
     27    'PIL': {'version': '1.1.7', 'import_name': 'Image', 'test': 'VERSION'}, 
     28    'pylint': {'version': None, 'import_name': 'pylint', 'test': None}, 
     29    'periodictable': {'version': '1.3.0', 'import_name': 'periodictable', 'test': '__version__'}, 
     30    'bumps': {'version': '0.7.5.9', 'import_name': 'bumps', 'test': '__version__'}, 
     31    'numpy': {'version': '1.7.1', 'import_name': 'numpy', 'test': '__version__'}, 
     32    'scipy': {'version': '0.18.0', 'import_name': 'scipy', 'test': '__version__'}, 
     33    'wx': {'version': '2.8.12.1', 'import_name': 'wx', 'test': '__version__'}, 
     34    'matplotlib': {'version': '1.1.0', 'import_name': 'matplotlib', 'test': '__version__'}, 
     35    'xhtml2pdf': {'version': '3.0.33', 'import_name': 'xhtml2pdf', 'test': '__version__'}, 
     36    'sphinx': {'version': '1.2.1', 'import_name': 'sphinx', 'test': '__version__'}, 
     37    'unittest-xml-reporting': {'version': '1.10.0', 'import_name': 'xmlrunner', 'test': '__version__'}, 
     38    'pyopencl': {'version': '2015.1', 'import_name': 'pyopencl', 'test': 'VERSION_TEXT'}, 
    3639} 
    3740win_required_package_list = { 
    38     'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, 
    39     'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, 
    40     'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'}, 
     41    'comtypes': {'version': '0.6.2', 'import_name': 'comtypes', 'test': '__version__'}, 
     42    'pywin': {'version': '217', 'import_name': 'pywin', 'test': '__version__'}, 
     43    'py2exe': {'version': '0.6.9', 'import_name': 'py2exe', 'test': '__version__'}, 
    4144} 
    4245mac_required_package_list = { 
    43     'py2app':{'version':None,'import_name':'py2app','test':'__version__'}, 
     46    'py2app': {'version': None, 'import_name': 'py2app', 'test': '__version__'}, 
    4447} 
    4548 
    4649deprecated_package_list = { 
    47     'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}, 
     50    'pyPdf': {'version': '1.13', 'import_name': 'pyPdf', 'test': '__version__'}, 
    4851} 
    4952 
    50 print "Checking Required Package Versions...." 
    51 print 
    52 print "Common Packages" 
    53 for package_name,test_vals in common_required_package_list.iteritems(): 
     53print("Checking Required Package Versions....\n") 
     54print("Common Packages") 
     55 
     56for package_name, test_vals in common_required_package_list.items(): 
    5457    try: 
    55         i = __import__(test_vals['import_name'],fromlist=['']) 
     58        i = __import__(test_vals['import_name'], fromlist=['']) 
    5659        if test_vals['test'] == None: 
    57             print "%s Installed (Unknown version)" % package_name 
     60            print("%s Installed (Unknown version)" % package_name) 
    5861        elif package_name == 'lxml': 
    59             verstring = str(getattr(i,'LXML_VERSION')) 
    60             print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) 
     62            verstring = str(getattr(i, 'LXML_VERSION')) 
     63            print("%s Version Installed: %s"% (package_name, verstring.replace(', ', '.').lstrip('(').rstrip(')'))) 
    6164        else: 
    62             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    63     except: 
    64         print '%s NOT INSTALLED'% package_name 
     65            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     66    except ImportError: 
     67        print('%s NOT INSTALLED'% package_name) 
    6568 
    6669if sys.platform == 'win32': 
    67     print 
    68     print "Windows Specific Packages:" 
    69     for package_name,test_vals in win_required_package_list.iteritems(): 
     70    print("") 
     71    print("Windows Specific Packages:") 
     72    for package_name, test_vals in win_required_package_list.items(): 
    7073        try: 
    7174            if package_name == "pywin": 
    7275                import win32api 
    73                 fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') 
    74                 print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) 
     76                fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\') 
     77                print("%s Version Installed: %s"% (package_name, fixed_file_info['FileVersionLS'] >> 16)) 
    7578            else: 
    76                 i = __import__(test_vals['import_name'],fromlist=['']) 
    77                 print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    78         except: 
    79             print '%s NOT INSTALLED'% package_name 
     79                i = __import__(test_vals['import_name'], fromlist=['']) 
     80                print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     81        except ImportError: 
     82            print('%s NOT INSTALLED'% package_name) 
    8083 
    8184if sys.platform == 'darwin': 
    82     print 
    83     print "MacOS Specific Packages:" 
    84     for package_name,test_vals in mac_required_package_list.iteritems(): 
     85    print("") 
     86    print("MacOS Specific Packages:") 
     87    for package_name, test_vals in mac_required_package_list.items(): 
    8588        try: 
    86             i = __import__(test_vals['import_name'],fromlist=['']) 
    87             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    88         except: 
    89             print '%s NOT INSTALLED'% package_name 
     89            i = __import__(test_vals['import_name'], fromlist=['']) 
     90            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     91        except ImportError: 
     92            print('%s NOT INSTALLED'% package_name) 
    9093 
    9194 
    92 print 
    93 print "Deprecated Packages" 
    94 print "You can remove these unless you need them for other reasons!" 
    95 for package_name,test_vals in deprecated_package_list.iteritems(): 
     95print("") 
     96print("Deprecated Packages") 
     97print("You can remove these unless you need them for other reasons!") 
     98for package_name, test_vals in deprecated_package_list.items(): 
    9699    try: 
    97         i = __import__(test_vals['import_name'],fromlist=['']) 
     100        i = __import__(test_vals['import_name'], fromlist=['']) 
    98101        if package_name == 'pyPdf': 
    99             #pyPdf doesn't have the version number internally 
    100             print 'pyPDF Installed (Version unknown)' 
     102            # pyPdf doesn't have the version number internally 
     103            print('pyPDF Installed (Version unknown)') 
    101104        else: 
    102             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    103     except: 
    104         print '%s NOT INSTALLED'% package_name 
     105            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     106    except ImportError: 
     107        print('%s NOT INSTALLED'% package_name) 
  • TabularUnified run.py

    r18e7309 r05a9d29  
    2020from os.path import abspath, dirname, join as joinpath 
    2121 
     22class TeeStream: 
     23    def __init__(self, filename): 
     24        self.logfile = open(filename, 'a') 
     25        self.console = sys.stderr 
     26    def write(self, buf): 
     27        self.logfile.write(buf) 
     28        self.console.write(buf) 
     29 
     30def tee_logging(): 
     31    import logging 
     32    stream = TeeStream(os.path.join(os.path.expanduser("~"), 'sasview.log')) 
     33    logging.basicConfig(level=logging.INFO, 
     34                        format='%(asctime)s %(levelname)s %(message)s', 
     35                        stream=stream) 
    2236 
    2337def addpath(path): 
     
    139153if __name__ == "__main__": 
    140154    prepare() 
     155    tee_logging() 
    141156    from sas.sasview.sasview import run 
    142157    run() 
  • TabularUnified sasview/README.txt

    r220b1e7 r9146ed9  
    441- Features 
    55=========== 
     6    - New in Version 4.1.0 
     7      ------------------ 
     8      This incremental release brings a series of new features and improvements, 
     9      and a host of bug fixes. Of particular note are: 
     10       
     11      - Correlation Function Analysis (Corfunc) 
     12        This performs a correlation function analysis of one-dimensional SAXS/SANS data,  
     13        or generates a model-independent volume fraction profile from the SANS from an  
     14        adsorbed polymer/surfactant layer. 
     15 
     16        A correlation function may be interpreted in terms of an imaginary rod moving  
     17        through the structure of the material. Γ1D(R) is the probability that a rod of  
     18        length R moving through the material has equal electron/neutron scattering  
     19        length density at either end. Hence a frequently occurring spacing within a  
     20        structure manifests itself as a peak. 
     21 
     22        A volume fraction profile \Phi(z) describes how the density of polymer  
     23        segments/surfactant molecules varies with distance from an (assumed locally flat) 
     24        interface. 
     25 
     26      - Fitting of SESANS Data 
     27        Data from Spin-Echo SANS measurements can now be loaded and fitted. The data will  
     28        be plotted against the correct axes and models will automatically perform a Hankel  
     29        transform in order to calculate SESANS from a SANS model. 
     30 
     31      - Documentation 
     32        The documentation has undergone significant checking and updating. 
     33 
     34      - Improvements 
     35        - Correlation function (corfunc) analysis of 1D SAS data added from CCP13 
     36        - File converter tool for multi-file single column data sets 
     37        - SESANS data loading and direct fitting using the Hankel transformation 
     38        - Saving and loading of simultaneous and constrained fits now supported 
     39        - Save states from SasView v3.x.y now loaded using sasmodel model names 
     40        - Saving and loading of projects with 2D fits now supported 
     41        - Loading a project removes all existing data, fits, and plots 
     42        - Structure factor and form factor can be plotted independently 
     43        - OpenCL is disabled by default and can be enabled through a fit menu 
     44        - Data and theory fields are now independently expandable 
     45      - Bug Fixes 
     46        - Fixes #667: Models computed multiple times on parameters changes 
     47        - Fixes #673: Custom models override built in models of same name 
     48        - Fixes #678: Hard crash when running complex models on GPU 
     49        - Fixes $774: Old style plugin models unloadable 
     50        - Fixes #789: stacked disk scale doesn't match cylinder model 
     51        - Fixes #792: core_shell_fractal uses wrong effective radius 
     52        - Fixes #800: Plot range reset on plot redraws 
     53        - Fixes #811 and #825: 2D smearing broken 
     54        - Fixes #815: Integer model parameter handling 
     55        - Fixes #824: Cannot apply sector averaging when no detector data present 
     56        - Fixes #830: Cansas HDF5 reader fully compliant with NXCanSAS v1.0 format 
     57        - Fixes #835: Fractal model breaks with negative Q values 
     58        - Fixes #843: Multilayer vesicle does not define effective radius 
     59        - Fixes #858: Hayter MSA S(Q) returns errors 
     60        - Numerous grammatical and contexual errors in documention 
     61 
     62 
    663    - New in Version 4.0.1 
    764      ------------------ 
     
    426483=============== 
    427484 
     485 
     486   4.1- All systems: 
     487      The conversion to sasmodels infrastructure is ongoing and should be 
     488      completed in the next release. In the meantime this leads to a few known 
     489      issues: 
     490        - The way that orientation is defined is being refactored to address 
     491        long standing issues and comments.  In release 4.1 however only models 
     492        with symmetry (e.g. a=b) have been converted to the new definitions. 
     493        The rest (a <> b <> c - e.g. parellelepiped) maintain the same 
     494        definition as before and will be converted in 4.2.  Note that 
     495        orientational distribution also makes much more sense in the new 
     496        framework.  The documentation should indicate which definition is being 
     497        used for a given model. 
     498        - The infrastructure currently handles internal conversion of old style 
     499        models so that user created models in previous versions should continue 
     500        to work for now. At some point in the future such support will go away. 
     501        Everyone is encouraged to convert to the new structure which should be 
     502        relatively straight forward and provides a number of benefits.  
     503        - In that vein, the distributed models and those generated by the new 
     504        plugin model editor are in the new format, however those generated by 
     505        sum|multiply models are the old style sum|multiply models. This should 
     506        also disappear in the near future  
     507        - The on the fly discovery of plugin models and changes thereto behave 
     508        inconsistently.  If a change to a plugin model does not seem to 
     509        register, the Load Plugin Models (under fitting -> Plugin Model 
     510        Operations) can be used.  However, after calling Load Plugin Models, the 
     511        active plugin will no longer be loaded (even though the GUI looks like 
     512        it is) unless it is a sum|multiply model which works properly.  All 
     513        others will need to be recalled from the model dropdown menu to reload 
     514        the model into the calculation engine.  While it might be annoying it 
     515        does not appear to prevent SasView from working.. 
     516        - The model code and documentation review is ongoing. At this time the 
     517        core shell parellelepiped is known to have the C shell effectively fixed 
     518        at 0 (noted in documentation) while the triaxial ellipsoid does not seem 
     519        to reproduce the limit of the oblate or prolate ellipsoid. If errors are 
     520        found and corrected, corrected versions will be uploaded to the 
     521        marketplace.  
     522    
    428523   3.1- All systems: 
    429524        - The documentation window may take a few seconds to load the first time 
  • TabularUnified sasview/local_config.py

    r73cbeec r1779e72  
    3333''' remember to:''' 
    3434_acknowledgement_preamble_bullet1 =\ 
    35 '''Acknowledge its use in your publications as suggested below;''' 
     35'''Acknowledge its use in your publications as :''' 
    3636_acknowledgement_preamble_bullet2 =\ 
    37 '''Reference SasView as : M. Doucet, et al. SasView Version 4.0, Zenodo''' +\ 
    38 ''', http://doi.org/10.5281/zenodo.159083;''' 
     37'''Reference SasView as:''' 
    3938_acknowledgement_preamble_bullet3 =\ 
    40 '''Reference the model you used if appropriate (see documentation for refs);''' 
     39'''Reference the model you used if appropriate (see documentation for refs)''' 
    4140_acknowledgement_preamble_bullet4 =\ 
    4241'''Send us your reference for our records: developers@sasview.org''' 
    4342_acknowledgement_publications = \ 
    44 '''This work benefited from the use of the SasView application, originally developed under NSF Award  
    45 DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme  
    46 under the SINE2020 project Grant No 654000, and by Patrick O'Brien & Adam Washington.''' 
     43'''This work benefited from the use of the SasView application, originally developed under NSF Award DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000.''' 
     44_acknowledgement_citation = \ 
     45'''M. Doucet et al. SasView Version 4.1, Zenodo, 10.5281/zenodo.438138''' 
    4746 
    4847_acknowledgement =  \ 
    49 '''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547, but is currently maintained  
    50 by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO and TU Delft. SasView also contains code developed with funding from the  
    51 EU Horizon 2020 programme under the SINE2020 project (Grant No 654000), and by Patrick O'Brien (pycrust) and Adam Washington (corfunc-py).''' 
     48'''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547,\n but is currently maintained by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS, and the scattering community.\n\n SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project (Grant No 654000).\nA list of individual contributors can be found at: https://github.com/orgs/SasView/people 
     49''' 
    5250 
    5351_homepage = "http://www.sasview.org" 
     
    7270_ansto_logo = os.path.join(icon_path, "ansto_logo.png") 
    7371_tudelft_logo = os.path.join(icon_path, "tudelft_logo.png") 
     72_dls_logo = os.path.join(icon_path, "dls_logo.png") 
    7473_nsf_logo = os.path.join(icon_path, "nsf_logo.png") 
    7574_danse_logo = os.path.join(icon_path, "danse_logo.png") 
     
    8584_ansto_url = "http://www.ansto.gov.au/" 
    8685_tudelft_url = "http://www.tnw.tudelft.nl/en/cooperation/facilities/reactor-instituut-delft/" 
     86_dls_url = "http://www.diamond.ac.uk/" 
    8787_danse_url = "http://www.cacr.caltech.edu/projects/danse/release/index.html" 
    8888_inst_url = "http://www.utk.edu" 
    8989_corner_image = os.path.join(icon_path, "angles_flat.png") 
    9090_welcome_image = os.path.join(icon_path, "SVwelcome.png") 
    91 _copyright = "(c) 2009 - 2016, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO and TU Delft" 
     91_copyright = "(c) 2009 - 2017, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft and DLS" 
    9292marketplace_url = "http://marketplace.sasview.org/" 
    9393 
  • TabularUnified setup.py

    r1e13b53 red2276f  
    99from distutils.command.build_ext import build_ext 
    1010from distutils.core import Command 
    11 import numpy 
     11import numpy as np 
    1212 
    1313# Manage version number ###################################### 
     
    225225ext_modules.append( Extension("sas.sascalc.file_converter.core.bsl_loader", 
    226226                              sources = [os.path.join(mydir, "bsl_loader.c")], 
    227                               include_dirs=[numpy.get_include()], 
     227                              include_dirs=[np.get_include()], 
    228228                              ) ) 
    229229 
     
    315315                               'test/1d_data/*', 
    316316                               'test/2d_data/*', 
     317                               'test/convertible_files/*', 
     318                               'test/coordinate_data/*', 
     319                               'test/image_data/*', 
     320                               'test/media/*', 
     321                               'test/other_files/*', 
    317322                               'test/save_states/*', 
    318                                'test/upcoming_formats/*', 
    319                                  'default_categories.json'] 
     323                               'test/sesans_data/*' 
     324                               ] 
    320325packages.append("sas.sasview") 
    321326 
  • TabularUnified src/examples/test_chisq_panel.py

    rc10d9d6c r9a5097c  
    3030from sas.sasgui.plottools.plottables import Plottable, Graph, Data1D, Theory1D 
    3131import  sys 
    32 import numpy 
     32import numpy as np 
    3333 
    3434 
     
    7878    # Construct a simple graph 
    7979    if False: 
    80         x = numpy.array([1,2,3,4,5,6],'d') 
    81         y = numpy.array([4,5,26,5,4,-1],'d') 
    82         dy = numpy.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
     80        x = np.array([1,2,3,4,5,6],'d') 
     81        y = np.array([4,5,26,5,4,-1],'d') 
     82        dy = np.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
    8383    else: 
    84         x = numpy.linspace(0,2.0, 50) 
    85         y = numpy.sin(2*numpy.pi*x*2.8) 
    86         dy = numpy.sqrt(100*numpy.abs(y))/100 
     84        x = np.linspace(0,2.0, 50) 
     85        y = np.sin(2*np.pi*x*2.8) 
     86        dy = np.sqrt(100*np.abs(y))/100 
    8787 
    8888    from sas.sasgui.plottools.plottables import Data1D, Theory1D, Chisq , Graph 
  • TabularUnified src/examples/test_copy_print.py

    rd7bb526 r9a5097c  
    3030import  sys 
    3131sys.platform = 'win95' 
    32 import numpy 
     32import numpy as np 
    3333 
    3434 
     
    8181def sample_graph(): 
    8282    # Construct a simple graph 
    83     x = numpy.linspace(0,2.0, 50) 
    84     y = numpy.sin(2*numpy.pi*x*2.8) 
    85     dy = numpy.sqrt(100*numpy.abs(y))/100 
     83    x = np.linspace(0,2.0, 50) 
     84    y = np.sin(2*np.pi*x*2.8) 
     85    dy = np.sqrt(100*np.abs(y))/100 
    8686     
    8787    data = Data1D(x,y,dy=dy) 
  • TabularUnified src/examples/test_panel.py

    rd7bb526 r9a5097c  
    3939from sas.sasgui.plottools.PlotPanel import PlotPanel 
    4040from sas.sasgui.plottools.plottables import Data1D 
    41 import  sys 
    42 import numpy 
     41import sys 
     42import numpy as np 
    4343import random, math 
    4444 
     
    157157    def _add_data(self, event): 
    158158        data_len = 50 
    159         x  = numpy.zeros(data_len) 
    160         y  = numpy.zeros(data_len) 
    161         x2  = numpy.zeros(data_len) 
    162         y2  = numpy.zeros(data_len) 
    163         dy2  = numpy.zeros(data_len) 
    164         x3  = numpy.zeros(data_len) 
    165         y3  = numpy.zeros(data_len) 
    166         dy3  = numpy.zeros(data_len) 
     159        x  = np.zeros(data_len) 
     160        y  = np.zeros(data_len) 
     161        x2  = np.zeros(data_len) 
     162        y2  = np.zeros(data_len) 
     163        dy2  = np.zeros(data_len) 
     164        x3  = np.zeros(data_len) 
     165        y3  = np.zeros(data_len) 
     166        dy3  = np.zeros(data_len) 
    167167        for i in range(len(x)): 
    168168            x[i] = i 
  • TabularUnified src/examples/test_panel2D.py

    rd7bb526 r9a5097c  
    4040from sas.sasgui.plottools.plottables import Data1D, Theory1D, Data2D 
    4141import  sys,os 
    42 import numpy 
     42import numpy as np 
    4343import random, math 
    4444 
     
    226226    def _add_data(self, event): 
    227227        data_len = 50 
    228         x  = numpy.zeros(data_len) 
    229         y  = numpy.zeros(data_len) 
    230         x2  = numpy.zeros(data_len) 
    231         y2  = numpy.zeros(data_len) 
    232         dy2  = numpy.zeros(data_len) 
    233         x3  = numpy.zeros(data_len) 
    234         y3  = numpy.zeros(data_len) 
    235         dy3  = numpy.zeros(data_len) 
     228        x  = np.zeros(data_len) 
     229        y  = np.zeros(data_len) 
     230        x2  = np.zeros(data_len) 
     231        y2  = np.zeros(data_len) 
     232        dy2  = np.zeros(data_len) 
     233        x3  = np.zeros(data_len) 
     234        y3  = np.zeros(data_len) 
     235        dy3  = np.zeros(data_len) 
    236236        for i in range(len(x)): 
    237237            x[i] = i 
  • TabularUnified 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 
  • TabularUnified 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], 
  • TabularUnified 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 
  • TabularUnified 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 
  • TabularUnified src/sas/sascalc/calculator/slit_length_calculator.py

    rb699768 rbfba720  
    1616        # y data 
    1717        self.y = None 
    18         #default slit length 
     18        # default slit length 
    1919        self.slit_length = 0.0 
    2020 
     
    4242        """ 
    4343        # None data do nothing 
    44         if self.y == None or self.x == None: 
     44        if self.y is None or self.x is None: 
    4545            return 
    4646        # set local variable 
     
    5454        y_sum = 0.0 
    5555        y_max = 0.0 
    56         ind = 0.0 
     56        ind = 0 
    5757 
    5858        # sum 10 or more y values until getting max_y, 
     
    7070        # defaults 
    7171        y_half_d = 0.0 
    72         ind = 0.0 
     72        ind = 0 
    7373        # find indices where it crosses y = y_half. 
    7474        while True: 
     
    8181 
    8282        # y value and ind just before passed the spot of the half height 
    83         y_half_u = y[ind-1] 
     83        y_half_u = y[ind - 1] 
    8484 
    8585        # get corresponding x values 
    8686        x_half_d = x[ind] 
    87         x_half_u = x[ind-1] 
     87        x_half_u = x[ind - 1] 
    8888 
    8989        # calculate x at y = y_half using linear interpolation 
     
    9191            x_half = (x_half_d + x_half_u)/2.0 
    9292        else: 
    93             x_half = (x_half_u * (y_half - y_half_d)  \ 
    94                        + x_half_d * (y_half_u - y_half)) \ 
    95                         / (y_half_u - y_half_d) 
     93            x_half = ((x_half_u * (y_half - y_half_d) 
     94                       + x_half_d * (y_half_u - y_half)) 
     95                       / (y_half_u - y_half_d)) 
    9696 
    9797        # Our slit length is half width, so just give half beam value 
  • TabularUnified 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# 
  • TabularUnified 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(): 
  • TabularUnified 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 
  • TabularUnified 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. 
  • TabularUnified 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 
  • TabularUnified src/sas/sascalc/dataloader/manipulations.py

    rb2b36932 rdd11014  
    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 = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
     
    9090    qy_data = new_y.flatten() 
    9191    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): 
     92    if data2d.err_data is None or numpy.any(data2d.err_data <= 0): 
    9393        new_err_data = numpy.sqrt(numpy.abs(new_data)) 
    9494    else: 
  • TabularUnified src/sas/sascalc/dataloader/readers/IgorReader.py

    rb699768 rdd11014  
    1313############################################################################# 
    1414import os 
    15 import numpy 
    16 import math 
    17 #import logging 
     15 
    1816from sas.sascalc.dataloader.data_info import Data2D 
    1917from sas.sascalc.dataloader.data_info import Detector 
    2018from sas.sascalc.dataloader.manipulations import reader2D_converter 
     19import numpy as np 
    2120 
    2221# Look for unit converter 
     
    4039        """ Read file """ 
    4140        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 
     41            raise ValueError("Specified file %s is not a regular " 
     42                             "file" % filename) 
     43         
    5044        output = Data2D() 
     45 
    5146        output.filename = os.path.basename(filename) 
    5247        detector = Detector() 
    53         if len(output.detector) > 0: 
    54             print str(output.detector[0]) 
     48        if len(output.detector): 
     49            print(str(output.detector[0])) 
    5550        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': 
     51 
     52        data_conv_q = data_conv_i = None 
     53         
     54        if has_converter and output.Q_unit != '1/A': 
    8355            data_conv_q = Converter('1/A') 
    8456            # Test it 
    8557            data_conv_q(1.0, output.Q_unit) 
    8658             
    87         if has_converter == True and output.I_unit != '1/cm': 
     59        if has_converter and output.I_unit != '1/cm': 
    8860            data_conv_i = Converter('1/cm') 
    8961            # Test it 
    9062            data_conv_i(1.0, output.I_unit) 
    91           
    92         for line in lines: 
    93              
    94             # Find setup info line 
    95             if isInfo: 
    96                 isInfo = False 
    97                 line_toks = line.split() 
    98                 # Wavelength in Angstrom 
    99                 try: 
    100                     wavelength = float(line_toks[1]) 
    101                 except: 
    102                     msg = "IgorReader: can't read this file, missing wavelength" 
    103                     raise ValueError, msg 
    104                  
    105             #Find # of bins in a row assuming the detector is square. 
    106             if dataStarted == True: 
    107                 try: 
    108                     value = float(line) 
    109                 except: 
    110                     # Found a non-float entry, skip it 
    111                     continue 
    112                  
    113                 # Get total bin number 
    114                  
    115             i_tot_row += 1 
    116         i_tot_row = math.ceil(math.sqrt(i_tot_row)) - 1 
    117         #print "i_tot", i_tot_row 
    118         size_x = i_tot_row  # 192#128 
    119         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]) 
    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                    
     63 
     64        data_row = 0 
     65        wavelength = distance = center_x = center_y = None 
     66        dataStarted = isInfo = isCenter = False 
     67 
     68        with open(filename, 'r') as f: 
     69            for line in f: 
     70                data_row += 1 
     71                # Find setup info line 
     72                if isInfo: 
     73                    isInfo = False 
     74                    line_toks = line.split() 
     75                    # Wavelength in Angstrom 
     76                    try: 
     77                        wavelength = float(line_toks[1]) 
     78                    except ValueError: 
     79                        msg = "IgorReader: can't read this file, missing wavelength" 
     80                        raise ValueError(msg) 
     81                    # Distance in meters 
     82                    try: 
     83                        distance = float(line_toks[3]) 
     84                    except ValueError: 
     85                        msg = "IgorReader: can't read this file, missing distance" 
     86                        raise ValueError(msg) 
     87 
     88                    # Distance in meters 
     89                    try: 
     90                        transmission = float(line_toks[4]) 
     91                    except: 
     92                        msg = "IgorReader: can't read this file, " 
     93                        msg += "missing transmission" 
     94                        raise ValueError(msg) 
     95 
     96                if line.count("LAMBDA"): 
     97                    isInfo = True 
     98 
     99                # Find center info line 
     100                if isCenter: 
     101                    isCenter = False 
     102                    line_toks = line.split() 
     103 
     104                    # Center in bin number: Must subtract 1 because 
     105                    # the index starts from 1 
     106                    center_x = float(line_toks[0]) - 1 
     107                    center_y = float(line_toks[1]) - 1 
     108 
     109                if line.count("BCENT"): 
     110                    isCenter = True 
     111 
     112                # Find data start 
     113                if line.count("***"): 
     114                    # now have to continue to blank line 
     115                    dataStarted = True 
     116 
     117                    # Check that we have all the info 
     118                    if (wavelength is None 
     119                            or distance is None 
     120                            or center_x is None 
     121                            or center_y is None): 
     122                        msg = "IgorReader:Missing information in data file" 
     123                        raise ValueError(msg) 
     124 
     125                if dataStarted: 
     126                    if len(line.rstrip()): 
     127                        continue 
     128                    else: 
     129                        break 
     130 
     131        # The data is loaded in row major order (last index changing most 
     132        # rapidly). However, the original data is in column major order (first 
     133        # index changing most rapidly). The swap to column major order is done 
     134        # in reader2D_converter at the end of this method. 
     135        data = np.loadtxt(filename, skiprows=data_row) 
     136        size_x = size_y = int(np.rint(np.sqrt(data.size))) 
     137        output.data = np.reshape(data, (size_x, size_y)) 
     138        output.err_data = np.zeros_like(output.data) 
     139 
     140        # Det 640 x 640 mm 
     141        # Q = 4 * pi/lambda * sin(theta/2) 
     142        # Bin size is 0.5 cm 
     143        # Removed +1 from theta = (i_x - center_x + 1)*0.5 / distance 
     144        # / 100.0 and 
     145        # Removed +1 from theta = (i_y - center_y + 1)*0.5 / 
     146        # distance / 100.0 
     147        # ToDo: Need  complete check if the following 
     148        # convert process is consistent with fitting.py. 
     149 
     150        # calculate qx, qy bin centers of each pixel in the image 
     151        theta = (np.arange(size_x) - center_x) * 0.5 / distance / 100. 
     152        qx = 4 * np.pi / wavelength * np.sin(theta/2) 
     153 
     154        theta = (np.arange(size_y) - center_y) * 0.5 / distance / 100. 
     155        qy = 4 * np.pi / wavelength * np.sin(theta/2) 
     156 
     157        if has_converter and output.Q_unit != '1/A': 
     158            qx = data_conv_q(qx, units=output.Q_unit) 
     159            qy = data_conv_q(qx, units=output.Q_unit) 
     160 
     161        xmax = np.max(qx) 
     162        xmin = np.min(qx) 
     163        ymax = np.max(qy) 
     164        ymin = np.min(qy) 
     165 
     166        # calculate edge offset in q. 
    234167        theta = 0.25 / distance / 100.0 
    235         xstep = 4.0 * math.pi / wavelength * math.sin(theta / 2.0) 
     168        xstep = 4.0 * np.pi / wavelength * np.sin(theta / 2.0) 
    236169         
    237170        theta = 0.25 / distance / 100.0 
    238         ystep = 4.0 * math.pi/ wavelength * math.sin(theta / 2.0) 
     171        ystep = 4.0 * np.pi/ wavelength * np.sin(theta / 2.0) 
    239172         
    240173        # Store all data ###################################### 
    241174        # Store wavelength 
    242         if has_converter == True and output.source.wavelength_unit != 'A': 
     175        if has_converter and output.source.wavelength_unit != 'A': 
    243176            conv = Converter('A') 
    244177            wavelength = conv(wavelength, units=output.source.wavelength_unit) 
     
    246179 
    247180        # Store distance 
    248         if has_converter == True and detector.distance_unit != 'm': 
     181        if has_converter and detector.distance_unit != 'm': 
    249182            conv = Converter('m') 
    250183            distance = conv(distance, units=detector.distance_unit) 
     
    254187        output.sample.transmission = transmission 
    255188         
    256         # Store pixel size 
     189        # Store pixel size (mm) 
    257190        pixel = 5.0 
    258         if has_converter == True and detector.pixel_size_unit != 'mm': 
     191        if has_converter and detector.pixel_size_unit != 'mm': 
    259192            conv = Converter('mm') 
    260193            pixel = conv(pixel, units=detector.pixel_size_unit) 
     
    267200         
    268201        # 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': 
     202        xmin -= xstep / 2.0 
     203        xmax += xstep / 2.0 
     204        ymin -= ystep / 2.0 
     205        ymax += ystep / 2.0 
     206        if has_converter and output.Q_unit != '1/A': 
    274207            xmin = data_conv_q(xmin, units=output.Q_unit) 
    275208            xmax = data_conv_q(xmax, units=output.Q_unit) 
     
    282215         
    283216        # Store x and y axis bin centers 
    284         output.x_bins = x 
    285         output.y_bins = y 
     217        output.x_bins = qx.tolist() 
     218        output.y_bins = qy.tolist() 
    286219         
    287220        # Units 
  • TabularUnified 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: 
  • TabularUnified 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}') 
  • TabularUnified 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) 
  • TabularUnified src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py

    rd0764bf rc94280c  
    99import sys 
    1010 
    11 from sas.sascalc.dataloader.data_info import plottable_1D, plottable_2D, Data1D, Data2D, DataInfo, Process, Aperture 
    12 from sas.sascalc.dataloader.data_info import Collimation, TransmissionSpectrum, Detector 
     11from sas.sascalc.dataloader.data_info import plottable_1D, plottable_2D,\ 
     12    Data1D, Data2D, DataInfo, Process, Aperture, Collimation, \ 
     13    TransmissionSpectrum, Detector 
    1314from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable 
    14  
    1515 
    1616 
    1717class Reader(): 
    1818    """ 
    19     A class for reading in CanSAS v2.0 data files. The existing iteration opens Mantid generated HDF5 formatted files 
    20     with file extension .h5/.H5. Any number of data sets may be present within the file and any dimensionality of data 
    21     may be used. Currently 1D and 2D SAS data sets are supported, but future implementations will include 1D and 2D 
    22     SESANS data. 
    23  
    24     Any number of SASdata sets may be present in a SASentry and the data within can be either 1D I(Q) or 2D I(Qx, Qy). 
     19    A class for reading in CanSAS v2.0 data files. The existing iteration opens 
     20    Mantid generated HDF5 formatted files with file extension .h5/.H5. Any 
     21    number of data sets may be present within the file and any dimensionality 
     22    of data may be used. Currently 1D and 2D SAS data sets are supported, but 
     23    future implementations will include 1D and 2D SESANS data. 
     24 
     25    Any number of SASdata sets may be present in a SASentry and the data within 
     26    can be either 1D I(Q) or 2D I(Qx, Qy). 
    2527 
    2628    Also supports reading NXcanSAS formatted HDF5 files 
     
    3032    """ 
    3133 
    32     ## CanSAS version 
     34    # CanSAS version 
    3335    cansas_version = 2.0 
    34     ## Logged warnings or messages 
     36    # Logged warnings or messages 
    3537    logging = None 
    36     ## List of errors for the current data set 
     38    # List of errors for the current data set 
    3739    errors = None 
    38     ## Raw file contents to be processed 
     40    # Raw file contents to be processed 
    3941    raw_data = None 
    40     ## Data info currently being read in 
     42    # Data info currently being read in 
    4143    current_datainfo = None 
    42     ## SASdata set currently being read in 
     44    # SASdata set currently being read in 
    4345    current_dataset = None 
    44     ## List of plottable1D objects that should be linked to the current_datainfo 
     46    # List of plottable1D objects that should be linked to the current_datainfo 
    4547    data1d = None 
    46     ## List of plottable2D objects that should be linked to the current_datainfo 
     48    # List of plottable2D objects that should be linked to the current_datainfo 
    4749    data2d = None 
    48     ## Data type name 
     50    # Data type name 
    4951    type_name = "CanSAS 2.0" 
    50     ## Wildcards 
     52    # Wildcards 
    5153    type = ["CanSAS 2.0 HDF5 Files (*.h5)|*.h5"] 
    52     ## List of allowed extensions 
     54    # List of allowed extensions 
    5355    ext = ['.h5', '.H5'] 
    54     ## Flag to bypass extension check 
     56    # Flag to bypass extension check 
    5557    allow_all = True 
    56     ## List of files to return 
     58    # List of files to return 
    5759    output = None 
    5860 
     
    6466        :return: List of Data1D/2D objects and/or a list of errors. 
    6567        """ 
    66         ## Reinitialize the class when loading a new data file to reset all class variables 
     68        # Reinitialize when loading a new data file to reset all class variables 
    6769        self.reset_class_variables() 
    68         ## Check that the file exists 
     70        # Check that the file exists 
    6971        if os.path.isfile(filename): 
    7072            basename = os.path.basename(filename) 
     
    7274            # If the file type is not allowed, return empty list 
    7375            if extension in self.ext or self.allow_all: 
    74                 ## Load the data file 
     76                # Load the data file 
    7577                self.raw_data = h5py.File(filename, 'r') 
    76                 ## Read in all child elements of top level SASroot 
     78                # Read in all child elements of top level SASroot 
    7779                self.read_children(self.raw_data, []) 
    78                 ## Add the last data set to the list of outputs 
     80                # Add the last data set to the list of outputs 
    7981                self.add_data_set() 
    80                 ## Close the data file 
     82                # Close the data file 
    8183                self.raw_data.close() 
    82         ## Return data set(s) 
     84        # Return data set(s) 
    8385        return self.output 
    8486 
     
    110112        """ 
    111113 
    112         ## Loop through each element of the parent and process accordingly 
     114        # Loop through each element of the parent and process accordingly 
    113115        for key in data.keys(): 
    114             ## Get all information for the current key 
     116            # Get all information for the current key 
    115117            value = data.get(key) 
    116118            if value.attrs.get(u'canSAS_class') is not None: 
     
    126128                self.parent_class = class_name 
    127129                parent_list.append(key) 
    128                 ## If this is a new sasentry, store the current data sets and create a fresh Data1D/2D object 
     130                # If a new sasentry, store the current data sets and create 
     131                # a fresh Data1D/2D object 
    129132                if class_prog.match(u'SASentry'): 
    130133                    self.add_data_set(key) 
    131134                elif class_prog.match(u'SASdata'): 
    132135                    self._initialize_new_data_set(parent_list) 
    133                 ## Recursion step to access data within the group 
     136                # Recursion step to access data within the group 
    134137                self.read_children(value, parent_list) 
    135138                self.add_intermediate() 
     
    137140 
    138141            elif isinstance(value, h5py.Dataset): 
    139                 ## If this is a dataset, store the data appropriately 
     142                # If this is a dataset, store the data appropriately 
    140143                data_set = data[key][:] 
    141144                unit = self._get_unit(value) 
    142145 
    143                 ## I and Q Data 
     146                # I and Q Data 
    144147                if key == u'I': 
    145                     if type(self.current_dataset) is plottable_2D: 
     148                    if isinstance(self.current_dataset, plottable_2D): 
    146149                        self.current_dataset.data = data_set 
    147150                        self.current_dataset.zaxis("Intensity", unit) 
     
    151154                    continue 
    152155                elif key == u'Idev': 
    153                     if type(self.current_dataset) is plottable_2D: 
     156                    if isinstance(self.current_dataset, plottable_2D): 
    154157                        self.current_dataset.err_data = data_set.flatten() 
    155158                    else: 
     
    158161                elif key == u'Q': 
    159162                    self.current_dataset.xaxis("Q", unit) 
    160                     if type(self.current_dataset) is plottable_2D: 
     163                    if isinstance(self.current_dataset, plottable_2D): 
    161164                        self.current_dataset.q = data_set.flatten() 
    162165                    else: 
     
    166169                    self.current_dataset.dx = data_set.flatten() 
    167170                    continue 
     171                elif key == u'dQw': 
     172                    self.current_dataset.dxw = data_set.flatten() 
     173                    continue 
     174                elif key == u'dQl': 
     175                    self.current_dataset.dxl = data_set.flatten() 
     176                    continue 
    168177                elif key == u'Qy': 
    169178                    self.current_dataset.yaxis("Q_y", unit) 
     
    183192                    self.current_dataset.mask = data_set.flatten() 
    184193                    continue 
     194                # Transmission Spectrum 
     195                elif (key == u'T' 
     196                      and self.parent_class == u'SAStransmission_spectrum'): 
     197                    self.trans_spectrum.transmission = data_set.flatten() 
     198                    continue 
     199                elif (key == u'Tdev' 
     200                      and self.parent_class == u'SAStransmission_spectrum'): 
     201                    self.trans_spectrum.transmission_deviation = \ 
     202                        data_set.flatten() 
     203                    continue 
     204                elif (key == u'lambda' 
     205                      and self.parent_class == u'SAStransmission_spectrum'): 
     206                    self.trans_spectrum.wavelength = data_set.flatten() 
     207                    continue 
    185208 
    186209                for data_point in data_set: 
    187                     ## Top Level Meta Data 
     210                    # Top Level Meta Data 
    188211                    if key == u'definition': 
    189212                        self.current_datainfo.meta_data['reader'] = data_point 
     
    201224                        self.current_datainfo.notes.append(data_point) 
    202225 
    203                     ## Sample Information 
    204                     elif key == u'Title' and self.parent_class == u'SASsample': # CanSAS 2.0 format 
     226                    # Sample Information 
     227                    # CanSAS 2.0 format 
     228                    elif key == u'Title' and self.parent_class == u'SASsample': 
    205229                        self.current_datainfo.sample.name = data_point 
    206                     elif key == u'ID' and self.parent_class == u'SASsample': # NXcanSAS format 
     230                    # NXcanSAS format 
     231                    elif key == u'name' and self.parent_class == u'SASsample': 
    207232                        self.current_datainfo.sample.name = data_point 
    208                     elif key == u'thickness' and self.parent_class == u'SASsample': 
     233                    # NXcanSAS format 
     234                    elif key == u'ID' and self.parent_class == u'SASsample': 
     235                        self.current_datainfo.sample.name = data_point 
     236                    elif (key == u'thickness' 
     237                          and self.parent_class == u'SASsample'): 
    209238                        self.current_datainfo.sample.thickness = data_point 
    210                     elif key == u'temperature' and self.parent_class == u'SASsample': 
     239                    elif (key == u'temperature' 
     240                          and self.parent_class == u'SASsample'): 
    211241                        self.current_datainfo.sample.temperature = data_point 
    212                     elif key == u'transmission' and self.parent_class == u'SASsample': 
     242                    elif (key == u'transmission' 
     243                          and self.parent_class == u'SASsample'): 
    213244                        self.current_datainfo.sample.transmission = data_point 
    214                     elif key == u'x_position' and self.parent_class == u'SASsample': 
     245                    elif (key == u'x_position' 
     246                          and self.parent_class == u'SASsample'): 
    215247                        self.current_datainfo.sample.position.x = data_point 
    216                     elif key == u'y_position' and self.parent_class == u'SASsample': 
     248                    elif (key == u'y_position' 
     249                          and self.parent_class == u'SASsample'): 
    217250                        self.current_datainfo.sample.position.y = data_point 
    218                     elif key == u'polar_angle' and self.parent_class == u'SASsample': 
     251                    elif key == u'pitch' and self.parent_class == u'SASsample': 
    219252                        self.current_datainfo.sample.orientation.x = data_point 
    220                     elif key == u'azimuthal_angle' and self.parent_class == u'SASsample': 
     253                    elif key == u'yaw' and self.parent_class == u'SASsample': 
     254                        self.current_datainfo.sample.orientation.y = data_point 
     255                    elif key == u'roll' and self.parent_class == u'SASsample': 
    221256                        self.current_datainfo.sample.orientation.z = data_point 
    222                     elif key == u'details' and self.parent_class == u'SASsample': 
     257                    elif (key == u'details' 
     258                          and self.parent_class == u'SASsample'): 
    223259                        self.current_datainfo.sample.details.append(data_point) 
    224260 
    225                     ## Instrumental Information 
    226                     elif key == u'name' and self.parent_class == u'SASinstrument': 
     261                    # Instrumental Information 
     262                    elif (key == u'name' 
     263                          and self.parent_class == u'SASinstrument'): 
    227264                        self.current_datainfo.instrument = data_point 
    228265                    elif key == u'name' and self.parent_class == u'SASdetector': 
     
    231268                        self.detector.distance = float(data_point) 
    232269                        self.detector.distance_unit = unit 
    233                     elif key == u'slit_length' and self.parent_class == u'SASdetector': 
     270                    elif (key == u'slit_length' 
     271                          and self.parent_class == u'SASdetector'): 
    234272                        self.detector.slit_length = float(data_point) 
    235273                        self.detector.slit_length_unit = unit 
    236                     elif key == u'x_position' and self.parent_class == u'SASdetector': 
     274                    elif (key == u'x_position' 
     275                          and self.parent_class == u'SASdetector'): 
    237276                        self.detector.offset.x = float(data_point) 
    238277                        self.detector.offset_unit = unit 
    239                     elif key == u'y_position' and self.parent_class == u'SASdetector': 
     278                    elif (key == u'y_position' 
     279                          and self.parent_class == u'SASdetector'): 
    240280                        self.detector.offset.y = float(data_point) 
    241281                        self.detector.offset_unit = unit 
    242                     elif key == u'polar_angle' and self.parent_class == u'SASdetector': 
     282                    elif (key == u'pitch' 
     283                          and self.parent_class == u'SASdetector'): 
    243284                        self.detector.orientation.x = float(data_point) 
    244285                        self.detector.orientation_unit = unit 
    245                     elif key == u'azimuthal_angle' and self.parent_class == u'SASdetector': 
     286                    elif key == u'roll' and self.parent_class == u'SASdetector': 
    246287                        self.detector.orientation.z = float(data_point) 
    247288                        self.detector.orientation_unit = unit 
    248                     elif key == u'beam_center_x' and self.parent_class == u'SASdetector': 
     289                    elif key == u'yaw' and self.parent_class == u'SASdetector': 
     290                        self.detector.orientation.y = float(data_point) 
     291                        self.detector.orientation_unit = unit 
     292                    elif (key == u'beam_center_x' 
     293                          and self.parent_class == u'SASdetector'): 
    249294                        self.detector.beam_center.x = float(data_point) 
    250295                        self.detector.beam_center_unit = unit 
    251                     elif key == u'beam_center_y' and self.parent_class == u'SASdetector': 
     296                    elif (key == u'beam_center_y' 
     297                          and self.parent_class == u'SASdetector'): 
    252298                        self.detector.beam_center.y = float(data_point) 
    253299                        self.detector.beam_center_unit = unit 
    254                     elif key == u'x_pixel_size' and self.parent_class == u'SASdetector': 
     300                    elif (key == u'x_pixel_size' 
     301                          and self.parent_class == u'SASdetector'): 
    255302                        self.detector.pixel_size.x = float(data_point) 
    256303                        self.detector.pixel_size_unit = unit 
    257                     elif key == u'y_pixel_size' and self.parent_class == u'SASdetector': 
     304                    elif (key == u'y_pixel_size' 
     305                          and self.parent_class == u'SASdetector'): 
    258306                        self.detector.pixel_size.y = float(data_point) 
    259307                        self.detector.pixel_size_unit = unit 
    260                     elif key == u'SSD' and self.parent_class == u'SAScollimation': 
     308                    elif (key == u'distance' 
     309                          and self.parent_class == u'SAScollimation'): 
    261310                        self.collimation.length = data_point 
    262311                        self.collimation.length_unit = unit 
    263                     elif key == u'name' and self.parent_class == u'SAScollimation': 
     312                    elif (key == u'name' 
     313                          and self.parent_class == u'SAScollimation'): 
    264314                        self.collimation.name = data_point 
    265  
    266                     ## Process Information 
    267                     elif key == u'name' and self.parent_class == u'SASprocess': 
     315                    elif (key == u'shape' 
     316                          and self.parent_class == u'SASaperture'): 
     317                        self.aperture.shape = data_point 
     318                    elif (key == u'x_gap' 
     319                          and self.parent_class == u'SASaperture'): 
     320                        self.aperture.size.x = data_point 
     321                    elif (key == u'y_gap' 
     322                          and self.parent_class == u'SASaperture'): 
     323                        self.aperture.size.y = data_point 
     324 
     325                    # Process Information 
     326                    elif (key == u'Title' 
     327                          and self.parent_class == u'SASprocess'): # CanSAS 2.0 
    268328                        self.process.name = data_point 
    269                     elif key == u'Title' and self.parent_class == u'SASprocess': # CanSAS 2.0 format 
     329                    elif (key == u'name' 
     330                          and self.parent_class == u'SASprocess'): # NXcanSAS 
    270331                        self.process.name = data_point 
    271                     elif key == u'name' and self.parent_class == u'SASprocess': # NXcanSAS format 
    272                         self.process.name = data_point 
    273                     elif key == u'description' and self.parent_class == u'SASprocess': 
     332                    elif (key == u'description' 
     333                          and self.parent_class == u'SASprocess'): 
    274334                        self.process.description = data_point 
    275335                    elif key == u'date' and self.parent_class == u'SASprocess': 
    276336                        self.process.date = data_point 
     337                    elif key == u'term' and self.parent_class == u'SASprocess': 
     338                        self.process.term = data_point 
    277339                    elif self.parent_class == u'SASprocess': 
    278340                        self.process.notes.append(data_point) 
    279341 
    280                     ## Transmission Spectrum 
    281                     elif key == u'T' and self.parent_class == u'SAStransmission_spectrum': 
    282                         self.trans_spectrum.transmission.append(data_point) 
    283                     elif key == u'Tdev' and self.parent_class == u'SAStransmission_spectrum': 
    284                         self.trans_spectrum.transmission_deviation.append(data_point) 
    285                     elif key == u'lambda' and self.parent_class == u'SAStransmission_spectrum': 
    286                         self.trans_spectrum.wavelength.append(data_point) 
    287  
    288                     ## Source 
    289                     elif key == u'wavelength' and self.parent_class == u'SASdata': 
     342                    # Source 
     343                    elif (key == u'wavelength' 
     344                          and self.parent_class == u'SASdata'): 
    290345                        self.current_datainfo.source.wavelength = data_point 
    291346                        self.current_datainfo.source.wavelength_unit = unit 
    292                     elif key == u'incident_wavelength' and self.parent_class == u'SASsource': 
     347                    elif (key == u'incident_wavelength' 
     348                          and self.parent_class == 'SASsource'): 
    293349                        self.current_datainfo.source.wavelength = data_point 
    294350                        self.current_datainfo.source.wavelength_unit = unit 
    295                     elif key == u'wavelength_max' and self.parent_class == u'SASsource': 
     351                    elif (key == u'wavelength_max' 
     352                          and self.parent_class == u'SASsource'): 
    296353                        self.current_datainfo.source.wavelength_max = data_point 
    297354                        self.current_datainfo.source.wavelength_max_unit = unit 
    298                     elif key == u'wavelength_min' and self.parent_class == u'SASsource': 
     355                    elif (key == u'wavelength_min' 
     356                          and self.parent_class == u'SASsource'): 
    299357                        self.current_datainfo.source.wavelength_min = data_point 
    300358                        self.current_datainfo.source.wavelength_min_unit = unit 
    301                     elif key == u'wavelength_spread' and self.parent_class == u'SASsource': 
    302                         self.current_datainfo.source.wavelength_spread = data_point 
    303                         self.current_datainfo.source.wavelength_spread_unit = unit 
    304                     elif key == u'beam_size_x' and self.parent_class == u'SASsource': 
     359                    elif (key == u'incident_wavelength_spread' 
     360                          and self.parent_class == u'SASsource'): 
     361                        self.current_datainfo.source.wavelength_spread = \ 
     362                            data_point 
     363                        self.current_datainfo.source.wavelength_spread_unit = \ 
     364                            unit 
     365                    elif (key == u'beam_size_x' 
     366                          and self.parent_class == u'SASsource'): 
    305367                        self.current_datainfo.source.beam_size.x = data_point 
    306368                        self.current_datainfo.source.beam_size_unit = unit 
    307                     elif key == u'beam_size_y' and self.parent_class == u'SASsource': 
     369                    elif (key == u'beam_size_y' 
     370                          and self.parent_class == u'SASsource'): 
    308371                        self.current_datainfo.source.beam_size.y = data_point 
    309372                        self.current_datainfo.source.beam_size_unit = unit 
    310                     elif key == u'beam_shape' and self.parent_class == u'SASsource': 
     373                    elif (key == u'beam_shape' 
     374                          and self.parent_class == u'SASsource'): 
    311375                        self.current_datainfo.source.beam_shape = data_point 
    312                     elif key == u'radiation' and self.parent_class == u'SASsource': 
     376                    elif (key == u'radiation' 
     377                          and self.parent_class == u'SASsource'): 
    313378                        self.current_datainfo.source.radiation = data_point 
    314                     elif key == u'transmission' and self.parent_class == u'SASdata': 
     379                    elif (key == u'transmission' 
     380                          and self.parent_class == u'SASdata'): 
    315381                        self.current_datainfo.sample.transmission = data_point 
    316382 
    317                     ## Everything else goes in meta_data 
     383                    # Everything else goes in meta_data 
    318384                    else: 
    319                         new_key = self._create_unique_key(self.current_datainfo.meta_data, key) 
     385                        new_key = self._create_unique_key( 
     386                            self.current_datainfo.meta_data, key) 
    320387                        self.current_datainfo.meta_data[new_key] = data_point 
    321388 
    322389            else: 
    323                 ## I don't know if this reachable code 
     390                # I don't know if this reachable code 
    324391                self.errors.add("ShouldNeverHappenException") 
    325392 
    326393    def add_intermediate(self): 
    327394        """ 
    328         This method stores any intermediate objects within the final data set after fully reading the set. 
    329  
    330         :param parent: The NXclass name for the h5py Group object that just finished being processed 
     395        This method stores any intermediate objects within the final data set 
     396        after fully reading the set. 
     397 
     398        :param parent: The NXclass name for the h5py Group object that just 
     399                       finished being processed 
    331400        """ 
    332401 
     
    347416            self.aperture = Aperture() 
    348417        elif self.parent_class == u'SASdata': 
    349             if type(self.current_dataset) is plottable_2D: 
     418            if isinstance(self.current_dataset, plottable_2D): 
    350419                self.data2d.append(self.current_dataset) 
    351             elif type(self.current_dataset) is plottable_1D: 
     420            elif isinstance(self.current_dataset, plottable_1D): 
    352421                self.data1d.append(self.current_dataset) 
    353422 
    354423    def final_data_cleanup(self): 
    355424        """ 
    356         Does some final cleanup and formatting on self.current_datainfo and all data1D and data2D objects and then 
    357         combines the data and info into Data1D and Data2D objects 
    358         """ 
    359  
    360         ## Type cast data arrays to float64 
     425        Does some final cleanup and formatting on self.current_datainfo and 
     426        all data1D and data2D objects and then combines the data and info into 
     427        Data1D and Data2D objects 
     428        """ 
     429 
     430        # Type cast data arrays to float64 
    361431        if len(self.current_datainfo.trans_spectrum) > 0: 
    362432            spectrum_list = [] 
     
    364434                spectrum.transmission = np.delete(spectrum.transmission, [0]) 
    365435                spectrum.transmission = spectrum.transmission.astype(np.float64) 
    366                 spectrum.transmission_deviation = np.delete(spectrum.transmission_deviation, [0]) 
    367                 spectrum.transmission_deviation = spectrum.transmission_deviation.astype(np.float64) 
     436                spectrum.transmission_deviation = np.delete( 
     437                    spectrum.transmission_deviation, [0]) 
     438                spectrum.transmission_deviation = \ 
     439                    spectrum.transmission_deviation.astype(np.float64) 
    368440                spectrum.wavelength = np.delete(spectrum.wavelength, [0]) 
    369441                spectrum.wavelength = spectrum.wavelength.astype(np.float64) 
     
    372444            self.current_datainfo.trans_spectrum = spectrum_list 
    373445 
    374         ## Append errors to dataset and reset class errors 
     446        # Append errors to dataset and reset class errors 
    375447        self.current_datainfo.errors = self.errors 
    376448        self.errors.clear() 
    377449 
    378         ## Combine all plottables with datainfo and append each to output 
    379         ## Type cast data arrays to float64 and find min/max as appropriate 
     450        # Combine all plottables with datainfo and append each to output 
     451        # Type cast data arrays to float64 and find min/max as appropriate 
    380452        for dataset in self.data2d: 
    381453            dataset.data = dataset.data.astype(np.float64) 
     
    397469            zeros = np.ones(dataset.data.size, dtype=bool) 
    398470            try: 
    399                 for i in range (0, dataset.mask.size - 1): 
     471                for i in range(0, dataset.mask.size - 1): 
    400472                    zeros[i] = dataset.mask[i] 
    401473            except: 
    402474                self.errors.add(sys.exc_value) 
    403475            dataset.mask = zeros 
    404             ## Calculate the actual Q matrix 
     476            # Calculate the actual Q matrix 
    405477            try: 
    406478                if dataset.q_data.size <= 1: 
    407                     dataset.q_data = np.sqrt(dataset.qx_data * dataset.qx_data + dataset.qy_data * dataset.qy_data) 
     479                    dataset.q_data = np.sqrt(dataset.qx_data 
     480                                             * dataset.qx_data 
     481                                             + dataset.qy_data 
     482                                             * dataset.qy_data) 
    408483            except: 
    409484                dataset.q_data = None 
     
    415490                dataset.data = dataset.data.flatten() 
    416491 
    417             final_dataset = combine_data_info_with_plottable(dataset, self.current_datainfo) 
     492            final_dataset = combine_data_info_with_plottable( 
     493                dataset, self.current_datainfo) 
    418494            self.output.append(final_dataset) 
    419495 
     
    435511            if dataset.dy is not None: 
    436512                dataset.dy = dataset.dy.astype(np.float64) 
    437             final_dataset = combine_data_info_with_plottable(dataset, self.current_datainfo) 
     513            final_dataset = combine_data_info_with_plottable( 
     514                dataset, self.current_datainfo) 
    438515            self.output.append(final_dataset) 
    439516 
    440517    def add_data_set(self, key=""): 
    441518        """ 
    442         Adds the current_dataset to the list of outputs after preforming final processing on the data and then calls a 
    443         private method to generate a new data set. 
     519        Adds the current_dataset to the list of outputs after preforming final 
     520        processing on the data and then calls a private method to generate a 
     521        new data set. 
    444522 
    445523        :param key: NeXus group name for current tree level 
     
    453531 
    454532 
    455     def _initialize_new_data_set(self, parent_list = None): 
    456         """ 
    457         A private class method to generate a new 1D or 2D data object based on the type of data within the set. 
    458         Outside methods should call add_data_set() to be sure any existing data is stored properly. 
     533    def _initialize_new_data_set(self, parent_list=None): 
     534        """ 
     535        A private class method to generate a new 1D or 2D data object based on 
     536        the type of data within the set. Outside methods should call 
     537        add_data_set() to be sure any existing data is stored properly. 
    459538 
    460539        :param parent_list: List of names of parent elements 
     
    473552    def _find_intermediate(self, parent_list, basename=""): 
    474553        """ 
    475         A private class used to find an entry by either using a direct key or knowing the approximate basename. 
    476  
    477         :param parent_list: List of parents to the current level in the HDF5 file 
     554        A private class used to find an entry by either using a direct key or 
     555        knowing the approximate basename. 
     556 
     557        :param parent_list: List of parents nodes in the HDF5 file 
    478558        :param basename: Approximate name of an entry to search for 
    479559        :return: 
     
    486566            top = top.get(parent) 
    487567        for key in top.keys(): 
    488             if (key_prog.match(key)): 
     568            if key_prog.match(key): 
    489569                entry = True 
    490570                break 
     
    516596        """ 
    517597        unit = value.attrs.get(u'units') 
    518         if unit == None: 
     598        if unit is None: 
    519599            unit = value.attrs.get(u'unit') 
    520         ## Convert the unit formats 
     600        # Convert the unit formats 
    521601        if unit == "1/A": 
    522602            unit = "A^{-1}" 
  • TabularUnified 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 
  • TabularUnified 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  
  • TabularUnified 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) * \ 
  • TabularUnified 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                ] 
  • TabularUnified 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 
  • TabularUnified 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): 
  • TabularUnified src/sas/sascalc/fit/BumpsFitting.py

    r345e7e4 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 
    354         errors = [str(exc), traceback.traceback.format_exc()] 
     353        best, fbest = None, np.NaN 
     354        errors = [str(exc), traceback.format_exc()] 
    355355    finally: 
    356356        mapper.stop_mapper(fitdriver.mapper) 
     
    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 
  • TabularUnified 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 
  • TabularUnified 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 
  • TabularUnified 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 
  • TabularUnified 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(\ 
  • TabularUnified 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): 
  • TabularUnified 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 
  • TabularUnified 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 
  • TabularUnified 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 
  • TabularUnified 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('=') 
  • TabularUnified 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) 
  • TabularUnified src/sas/sasgui/guiframe/aboutbox.py

    r49e000b r1779e72  
    118118        self.bitmap_button_ansto = wx.BitmapButton(self, -1, wx.NullBitmap) 
    119119        self.bitmap_button_tudelft = wx.BitmapButton(self, -1, wx.NullBitmap) 
     120        self.bitmap_button_dls = wx.BitmapButton(self, -1, wx.NullBitmap) 
    120121         
    121122        self.static_line_3 = wx.StaticLine(self, -1) 
     
    137138        self.Bind(wx.EVT_BUTTON, self.onAnstoLogo, self.bitmap_button_ansto) 
    138139        self.Bind(wx.EVT_BUTTON, self.onTudelftLogo, self.bitmap_button_tudelft) 
     140        self.Bind(wx.EVT_BUTTON, self.onDlsLogo, self.bitmap_button_dls) 
    139141        # end wxGlade 
    140142        # fill in acknowledgements 
     
    229231        logo = wx.Bitmap(image) 
    230232        self.bitmap_button_tudelft.SetBitmapLabel(logo) 
     233         
     234        image = file_dir + "/images/dls_logo.png" 
     235        if os.path.isfile(config._dls_logo): 
     236            image = config._dls_logo 
     237        logo = wx.Bitmap(image) 
     238        self.bitmap_button_dls.SetBitmapLabel(logo) 
    231239                 
    232240        # resize dialog window to fit version number nicely 
     
    260268        self.bitmap_button_ansto.SetSize(self.bitmap_button_ansto.GetBestSize()) 
    261269        self.bitmap_button_tudelft.SetSize(self.bitmap_button_tudelft.GetBestSize()) 
     270        self.bitmap_button_dls.SetSize(self.bitmap_button_dls.GetBestSize()) 
    262271        # end wxGlade 
    263272 
     
    325334        sizer_logos.Add(self.bitmap_button_tudelft, 0,  
    326335                        wx.LEFT|wx.ADJUST_MINSIZE, 2) 
     336        sizer_logos.Add(self.bitmap_button_dls, 0,  
     337                        wx.LEFT|wx.ADJUST_MINSIZE, 2) 
    327338                 
    328339        sizer_logos.Add((10, 50), 0, wx.ADJUST_MINSIZE, 0) 
     
    423434        event.Skip() 
    424435 
     436    def onDlsLogo(self, event): 
     437        """ 
     438        """  
     439        # wxGlade: DialogAbout.<event_handler> 
     440        launchBrowser(config._dls_url) 
     441        event.Skip() 
     442 
    425443# end of class DialogAbout 
    426444 
  • TabularUnified src/sas/sasgui/guiframe/acknowledgebox.py

    rc1fdf84 r74c8cd0  
    1111import wx.richtext 
    1212import wx.lib.hyperlink 
     13from wx.lib.expando import ExpandoTextCtrl 
    1314import random 
    1415import os.path 
     
    3637    Shows the current method for acknowledging SasView in 
    3738    scholarly publications. 
    38  
    3939    """ 
    4040 
     
    4444        wx.Dialog.__init__(self, *args, **kwds) 
    4545 
    46         self.ack = wx.TextCtrl(self, style=wx.TE_LEFT|wx.TE_MULTILINE|wx.TE_BESTWRAP|wx.TE_READONLY|wx.TE_NO_VSCROLL) 
     46        self.ack = ExpandoTextCtrl(self, style=wx.TE_LEFT|wx.TE_MULTILINE|wx.TE_BESTWRAP|wx.TE_READONLY|wx.TE_NO_VSCROLL) 
    4747        self.ack.SetValue(config._acknowledgement_publications) 
    48         self.ack.SetMinSize((-1, 55)) 
     48        #self.ack.SetMinSize((-1, 55)) 
     49        self.citation = ExpandoTextCtrl(self, style=wx.TE_LEFT|wx.TE_MULTILINE|wx.TE_BESTWRAP|wx.TE_READONLY|wx.TE_NO_VSCROLL) 
     50        self.citation.SetValue(config._acknowledgement_citation) 
    4951        self.preamble = wx.StaticText(self, -1, config._acknowledgement_preamble) 
    5052        items = [config._acknowledgement_preamble_bullet1, 
     
    5254                 config._acknowledgement_preamble_bullet3, 
    5355                 config._acknowledgement_preamble_bullet4] 
    54         self.list1 = wx.StaticText(self, -1, "\t(1) " + items[0]) 
    55         self.list2 = wx.StaticText(self, -1, "\t(2) " + items[1]) 
    56         self.list3 = wx.StaticText(self, -1, "\t(3) " + items[2]) 
    57         self.list4 = wx.StaticText(self, -1, "\t(4) " + items[3]) 
     56        self.list1 = wx.StaticText(self, -1, "(1) " + items[0]) 
     57        self.list2 = wx.StaticText(self, -1, "(2) " + items[1]) 
     58        self.list3 = wx.StaticText(self, -1, "(3) " + items[2]) 
     59        self.list4 = wx.StaticText(self, -1, "(4) " + items[3]) 
    5860        self.static_line = wx.StaticLine(self, 0) 
    5961        self.__set_properties() 
     
    6971        self.SetTitle("Acknowledging SasView") 
    7072        #Increased size of box from (525, 225), SMK, 04/10/16 
    71         self.SetSize((600, 300)) 
     73        self.SetClientSize((600, 320)) 
    7274        # end wxGlade 
    7375 
     
    8183        sizer_titles.Add(self.preamble, 0, wx.ALL|wx.EXPAND, 5) 
    8284        sizer_titles.Add(self.list1, 0, wx.ALL|wx.EXPAND, 5) 
     85        sizer_titles.Add(self.ack, 0, wx.ALL|wx.EXPAND, 5) 
    8386        sizer_titles.Add(self.list2, 0, wx.ALL|wx.EXPAND, 5) 
     87        sizer_titles.Add(self.citation, 0, wx.ALL|wx.EXPAND, 5) 
    8488        sizer_titles.Add(self.list3, 0, wx.ALL|wx.EXPAND, 5) 
     89        #sizer_titles.Add(self.static_line, 0, wx.ALL|wx.EXPAND, 0) 
    8590        sizer_titles.Add(self.list4, 0, wx.ALL|wx.EXPAND, 5) 
    86         sizer_titles.Add(self.static_line, 0, wx.ALL|wx.EXPAND, 0) 
    87         sizer_titles.Add(self.ack, 0, wx.ALL|wx.EXPAND, 5) 
    8891        sizer_main.Add(sizer_titles, -1, wx.ALL|wx.EXPAND, 5) 
    8992        self.SetAutoLayout(True) 
     
    9194        self.Layout() 
    9295        self.Centre() 
     96        #self.SetClientSize(sizer_main.GetSize()) 
    9397        # end wxGlade 
    9498 
  • TabularUnified src/sas/sasgui/guiframe/config.py

    rd85c194 r1779e72  
    11""" 
    2 Application settings 
     2    Application settings 
    33""" 
     4import time 
    45import os 
    5 import time 
    66from sas.sasgui.guiframe.gui_style import GUIFRAME 
     7import sas.sasview 
     8import logging 
     9 
    710# Version of the application 
    8 __appname__ = "DummyView" 
    9 __version__ = '0.0.0' 
    10 __build__ = '1' 
     11__appname__ = "SasView" 
     12__version__ = sas.sasview.__version__ 
     13__build__ = sas.sasview.__build__ 
    1114__download_page__ = 'https://github.com/SasView/sasview/releases' 
    1215__update_URL__ = 'http://www.sasview.org/latestversion.json' 
    1316 
    14  
    1517# Debug message flag 
    16 __EVT_DEBUG__ = True 
     18__EVT_DEBUG__ = False 
    1719 
    1820# Flag for automated testing 
     
    2931_acknowledgement_preamble =\ 
    3032'''To ensure the long term support and development of this software please''' +\ 
    31 ''' remember to do the following.''' 
     33''' remember to:''' 
    3234_acknowledgement_preamble_bullet1 =\ 
    33 '''Acknowledge its use in your publications as suggested below''' 
     35'''Acknowledge its use in your publications as :''' 
    3436_acknowledgement_preamble_bullet2 =\ 
    35 '''Reference the following website: http://www.sasview.org''' 
     37'''Reference SasView as:''' 
    3638_acknowledgement_preamble_bullet3 =\ 
    3739'''Reference the model you used if appropriate (see documentation for refs)''' 
     
    3941'''Send us your reference for our records: developers@sasview.org''' 
    4042_acknowledgement_publications = \ 
    41 '''This work benefited from the use of the SasView application, originally 
    42 developed under NSF award DMR-0520547. 
     43'''This work benefited from the use of the SasView application, originally developed under NSF Award DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000.''' 
     44_acknowledgement_citation = \ 
     45'''M. Doucet et al. SasView Version 4.1, Zenodo, 10.5281/zenodo.438138''' 
     46 
     47_acknowledgement =  \ 
     48'''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547,\n but is currently maintained by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS, and the scattering community.\n\n SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project (Grant No 654000).\nA list of individual contributors can be found at: https://github.com/orgs/SasView/people 
    4349''' 
    44 _acknowledgement =  \ 
    45 '''This work originally developed as part of the DANSE project funded by the NSF 
    46 under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS 
    47 and ILL. 
    4850 
    49 ''' 
    5051_homepage = "http://www.sasview.org" 
    51 _download = "http://sourceforge.net/projects/sasview/files/" 
     52_download = __download_page__ 
    5253_authors = [] 
    5354_paper = "http://sourceforge.net/p/sasview/tickets/" 
    5455_license = "mailto:help@sasview.org" 
    55 _nsf_logo = "images/nsf_logo.png" 
    56 _danse_logo = "images/danse_logo.png" 
    57 _inst_logo = "images/utlogo.gif" 
    58 _nist_logo = "images/nist_logo.png" 
    59 _umd_logo = "images/umd_logo.png" 
    60 _sns_logo = "images/sns_logo.png" 
    61 _isis_logo = "images/isis_logo.png" 
    62 _ess_logo = "images/ess_logo.png" 
    63 _ill_logo = "images/ill_logo.png" 
     56 
     57 
     58icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "images")) 
     59logging.info("icon path: %s" % icon_path) 
     60media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media")) 
     61test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test")) 
     62 
     63_nist_logo = os.path.join(icon_path, "nist_logo.png") 
     64_umd_logo = os.path.join(icon_path, "umd_logo.png") 
     65_sns_logo = os.path.join(icon_path, "sns_logo.png") 
     66_ornl_logo = os.path.join(icon_path, "ornl_logo.png") 
     67_isis_logo = os.path.join(icon_path, "isis_logo.png") 
     68_ess_logo = os.path.join(icon_path, "ess_logo.png") 
     69_ill_logo = os.path.join(icon_path, "ill_logo.png") 
     70_ansto_logo = os.path.join(icon_path, "ansto_logo.png") 
     71_tudelft_logo = os.path.join(icon_path, "tudelft_logo.png") 
     72_nsf_logo = os.path.join(icon_path, "nsf_logo.png") 
     73_danse_logo = os.path.join(icon_path, "danse_logo.png") 
     74_inst_logo = os.path.join(icon_path, "utlogo.gif") 
    6475_nist_url = "http://www.nist.gov/" 
    6576_umd_url = "http://www.umd.edu/" 
    6677_sns_url = "http://neutrons.ornl.gov/" 
     78_ornl_url = "http://neutrons.ornl.gov/" 
    6779_nsf_url = "http://www.nsf.gov" 
    68 _danse_url = "http://www.cacr.caltech.edu/projects/danse/release/index.html" 
    69 _inst_url = "http://www.utk.edu" 
    7080_isis_url = "http://www.isis.stfc.ac.uk/" 
    7181_ess_url = "http://ess-scandinavia.eu/" 
    7282_ill_url = "http://www.ill.eu/" 
    73 _corner_image = "images/angles_flat.png" 
    74 _welcome_image = "images/SVwelcome.png" 
    75 _copyright = "(c) 2008, University of Tennessee" 
    76 #edit the lists below of file state your plugin can read 
    77 #for sasview this how you can edit these lists 
    78 #PLUGIN_STATE_EXTENSIONS = ['.prv','.fitv', '.inv'] 
    79 #APPLICATION_STATE_EXTENSION = '.svs' 
    80 #PLUGINS_WLIST = ['P(r) files (*.prv)|*.prv', 
    81 #                  'Fitting files (*.fitv)|*.fitv', 
    82 #                  'Invariant files (*.inv)|*.inv'] 
    83 #APPLICATION_WLIST = 'SasView files (*.svs)|*.svs' 
    84 APPLICATION_WLIST = '' 
    85 APPLICATION_STATE_EXTENSION = None 
    86 PLUGINS_WLIST = [] 
    87 PLUGIN_STATE_EXTENSIONS = [] 
    88 SPLASH_SCREEN_PATH = "images/danse_logo.png" 
    89 DEFAULT_STYLE = GUIFRAME.SINGLE_APPLICATION 
    90 SPLASH_SCREEN_WIDTH = 500 
    91 SPLASH_SCREEN_HEIGHT = 300 
    92 WELCOME_PANEL_ON = False 
    93 TUTORIAL_PATH = None 
    94 SS_MAX_DISPLAY_TIME = 1500 
    95 PLOPANEL_WIDTH = 350 
    96 PLOPANEL_HEIGTH = 350 
    97 GUIFRAME_WIDTH = 1000 
    98 GUIFRAME_HEIGHT = 800 
    99 CONTROL_WIDTH = -1 
    100 CONTROL_HEIGHT = -1 
    101 SetupIconFile_win = os.path.join("images", "ball.ico") 
    102 SetupIconFile_mac = os.path.join("images", "ball.icns") 
    103 DefaultGroupName = "DANSE" 
    104 OutputBaseFilename = "setupGuiFrame" 
     83_ansto_url = "http://www.ansto.gov.au/" 
     84_tudelft_url = "http://www.tnw.tudelft.nl/en/cooperation/facilities/reactor-instituut-delft/" 
     85_dls_url = "http://www.diamond.ac.uk/" 
     86_danse_url = "http://www.cacr.caltech.edu/projects/danse/release/index.html" 
     87_inst_url = "http://www.utk.edu" 
     88_corner_image = os.path.join(icon_path, "angles_flat.png") 
     89_welcome_image = os.path.join(icon_path, "SVwelcome.png") 
     90_copyright = "(c) 2009 - 2017, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS" 
     91marketplace_url = "http://marketplace.sasview.org/" 
     92 
     93#edit the list of file state your plugin can read 
     94APPLICATION_WLIST = 'SasView files (*.svs)|*.svs' 
     95APPLICATION_STATE_EXTENSION = '.svs' 
     96GUIFRAME_WIDTH = 1150 
     97GUIFRAME_HEIGHT = 840 
     98PLUGIN_STATE_EXTENSIONS = ['.fitv', '.inv', '.prv', '.crf'] 
     99PLUGINS_WLIST = ['Fitting files (*.fitv)|*.fitv', 
     100                 'Invariant files (*.inv)|*.inv', 
     101                 'P(r) files (*.prv)|*.prv', 
     102                 'Corfunc files (*.crf)|*.crf'] 
     103PLOPANEL_WIDTH = 415 
     104PLOPANEL_HEIGTH = 370 
    105105DATAPANEL_WIDTH = 235 
    106106DATAPANEL_HEIGHT = 700 
     107SPLASH_SCREEN_PATH = os.path.join(icon_path, "SVwelcome_mini.png") 
     108TUTORIAL_PATH = os.path.join(media_path, "Tutorial.pdf") 
     109DEFAULT_STYLE = GUIFRAME.MULTIPLE_APPLICATIONS|GUIFRAME.MANAGER_ON\ 
     110                    |GUIFRAME.CALCULATOR_ON|GUIFRAME.TOOLBAR_ON 
     111SPLASH_SCREEN_WIDTH = 512 
     112SPLASH_SCREEN_HEIGHT = 366 
     113SS_MAX_DISPLAY_TIME = 2000 
     114WELCOME_PANEL_ON = True 
     115WELCOME_PANEL_SHOW = False 
     116CLEANUP_PLOT = False 
     117# OPEN and SAVE project menu 
     118OPEN_SAVE_PROJECT_MENU = True 
     119#VIEW MENU 
     120VIEW_MENU = True 
     121#EDIT MENU 
     122EDIT_MENU = True 
     123 
     124SetupIconFile_win = os.path.join(icon_path, "ball.ico") 
     125SetupIconFile_mac = os.path.join(icon_path, "ball.icns") 
     126DefaultGroupName = "." 
     127OutputBaseFilename = "setupSasView" 
     128 
    107129FIXED_PANEL = True 
    108130DATALOADER_SHOW = True 
     
    113135# set a default perspective 
    114136DEFAULT_PERSPECTIVE = 'None' 
    115 # OPEN and SAVE project menu 
    116 OPEN_SAVE_PROJECT_MENU = True 
    117 CLEANUP_PLOT = False 
    118 # OPEN and SAVE project menu 
    119 OPEN_SAVE_PROJECT_MENU = False 
    120 #VIEW MENU 
    121 VIEW_MENU = False 
    122 #EDIT MENU 
    123 EDIT_MENU = False 
    124 import wx.lib.newevent 
    125 (StatusBarEvent, EVT_STATUS) = wx.lib.newevent.NewEvent() 
     137 
     138# Time out for updating sasview 
     139UPDATE_TIMEOUT = 2 
     140 
     141#OpenCL option 
     142SAS_OPENCL = None 
    126143 
    127144def printEVT(message): 
    128     """ 
    129     :TODO - need method documentation 
    130     """ 
    131145    if __EVT_DEBUG__: 
     146        """ 
     147        :TODO - Need method doc string 
     148        """ 
    132149        print "%g:  %s" % (time.clock(), message) 
    133      
     150 
    134151        if __EVT_DEBUG_2_FILE__: 
    135152            out = open(__EVT_DEBUG_FILENAME__, 'a') 
    136153            out.write("%10g:  %s\n" % (time.clock(), message)) 
    137154            out.close() 
    138              
  • TabularUnified src/sas/sasgui/guiframe/dataFitting.py

    r68adf86 r9a5097c  
    33""" 
    44import copy 
    5 import numpy 
     5import numpy as np 
    66import math 
    77from sas.sascalc.data_util.uncertainty import Uncertainty 
     
    8181            result.dxw = None 
    8282        else: 
    83             result.dxw = numpy.zeros(len(self.x)) 
     83            result.dxw = np.zeros(len(self.x)) 
    8484        if self.dxl == None: 
    8585            result.dxl = None 
    8686        else: 
    87             result.dxl = numpy.zeros(len(self.x)) 
     87            result.dxl = np.zeros(len(self.x)) 
    8888 
    8989        for i in range(len(self.x)): 
     
    128128            result.dlam = None 
    129129        else: 
    130             result.dlam = numpy.zeros(tot_length) 
     130            result.dlam = np.zeros(tot_length) 
    131131        if self.dy == None or other.dy is None: 
    132132            result.dy = None 
    133133        else: 
    134             result.dy = numpy.zeros(tot_length) 
     134            result.dy = np.zeros(tot_length) 
    135135        if self.dx == None or other.dx is None: 
    136136            result.dx = None 
    137137        else: 
    138             result.dx = numpy.zeros(tot_length) 
     138            result.dx = np.zeros(tot_length) 
    139139        if self.dxw == None or other.dxw is None: 
    140140            result.dxw = None 
    141141        else: 
    142             result.dxw = numpy.zeros(tot_length) 
     142            result.dxw = np.zeros(tot_length) 
    143143        if self.dxl == None or other.dxl is None: 
    144144            result.dxl = None 
    145145        else: 
    146             result.dxl = numpy.zeros(tot_length) 
    147  
    148         result.x = numpy.append(self.x, other.x) 
     146            result.dxl = np.zeros(tot_length) 
     147 
     148        result.x = np.append(self.x, other.x) 
    149149        #argsorting 
    150         ind = numpy.argsort(result.x) 
     150        ind = np.argsort(result.x) 
    151151        result.x = result.x[ind] 
    152         result.y = numpy.append(self.y, other.y) 
     152        result.y = np.append(self.y, other.y) 
    153153        result.y = result.y[ind] 
    154         result.lam = numpy.append(self.lam, other.lam) 
     154        result.lam = np.append(self.lam, other.lam) 
    155155        result.lam = result.lam[ind] 
    156156        if result.dlam != None: 
    157             result.dlam = numpy.append(self.dlam, other.dlam) 
     157            result.dlam = np.append(self.dlam, other.dlam) 
    158158            result.dlam = result.dlam[ind] 
    159159        if result.dy != None: 
    160             result.dy = numpy.append(self.dy, other.dy) 
     160            result.dy = np.append(self.dy, other.dy) 
    161161            result.dy = result.dy[ind] 
    162162        if result.dx is not None: 
    163             result.dx = numpy.append(self.dx, other.dx) 
     163            result.dx = np.append(self.dx, other.dx) 
    164164            result.dx = result.dx[ind] 
    165165        if result.dxw is not None: 
    166             result.dxw = numpy.append(self.dxw, other.dxw) 
     166            result.dxw = np.append(self.dxw, other.dxw) 
    167167            result.dxw = result.dxw[ind] 
    168168        if result.dxl is not None: 
    169             result.dxl = numpy.append(self.dxl, other.dxl) 
     169            result.dxl = np.append(self.dxl, other.dxl) 
    170170            result.dxl = result.dxl[ind] 
    171171        return result 
     
    230230            result.dxw = None 
    231231        else: 
    232             result.dxw = numpy.zeros(len(self.x)) 
     232            result.dxw = np.zeros(len(self.x)) 
    233233        if self.dxl == None: 
    234234            result.dxl = None 
    235235        else: 
    236             result.dxl = numpy.zeros(len(self.x)) 
    237  
    238         for i in range(numpy.size(self.x)): 
     236            result.dxl = np.zeros(len(self.x)) 
     237 
     238        for i in range(np.size(self.x)): 
    239239            result.x[i] = self.x[i] 
    240240            if self.dx is not None and len(self.x) == len(self.dx): 
     
    282282            result.dlam = None 
    283283        else: 
    284             result.dlam = numpy.zeros(tot_length) 
     284            result.dlam = np.zeros(tot_length) 
    285285        if self.dy == None or other.dy is None: 
    286286            result.dy = None 
    287287        else: 
    288             result.dy = numpy.zeros(tot_length) 
     288            result.dy = np.zeros(tot_length) 
    289289        if self.dx == None or other.dx is None: 
    290290            result.dx = None 
    291291        else: 
    292             result.dx = numpy.zeros(tot_length) 
     292            result.dx = np.zeros(tot_length) 
    293293        if self.dxw == None or other.dxw is None: 
    294294            result.dxw = None 
    295295        else: 
    296             result.dxw = numpy.zeros(tot_length) 
     296            result.dxw = np.zeros(tot_length) 
    297297        if self.dxl == None or other.dxl is None: 
    298298            result.dxl = None 
    299299        else: 
    300             result.dxl = numpy.zeros(tot_length) 
    301         result.x = numpy.append(self.x, other.x) 
     300            result.dxl = np.zeros(tot_length) 
     301        result.x = np.append(self.x, other.x) 
    302302        #argsorting 
    303         ind = numpy.argsort(result.x) 
     303        ind = np.argsort(result.x) 
    304304        result.x = result.x[ind] 
    305         result.y = numpy.append(self.y, other.y) 
     305        result.y = np.append(self.y, other.y) 
    306306        result.y = result.y[ind] 
    307         result.lam = numpy.append(self.lam, other.lam) 
     307        result.lam = np.append(self.lam, other.lam) 
    308308        result.lam = result.lam[ind] 
    309309        if result.dy != None: 
    310             result.dy = numpy.append(self.dy, other.dy) 
     310            result.dy = np.append(self.dy, other.dy) 
    311311            result.dy = result.dy[ind] 
    312312        if result.dx is not None: 
    313             result.dx = numpy.append(self.dx, other.dx) 
     313            result.dx = np.append(self.dx, other.dx) 
    314314            result.dx = result.dx[ind] 
    315315        if result.dxw is not None: 
    316             result.dxw = numpy.append(self.dxw, other.dxw) 
     316            result.dxw = np.append(self.dxw, other.dxw) 
    317317            result.dxw = result.dxw[ind] 
    318318        if result.dxl is not None: 
    319             result.dxl = numpy.append(self.dxl, other.dxl) 
     319            result.dxl = np.append(self.dxl, other.dxl) 
    320320            result.dxl = result.dxl[ind] 
    321321        return result 
     
    409409            result.dqy_data = None 
    410410        else: 
    411             result.dqx_data = numpy.zeros(len(self.data)) 
    412             result.dqy_data = numpy.zeros(len(self.data)) 
    413         for i in range(numpy.size(self.data)): 
     411            result.dqx_data = np.zeros(len(self.data)) 
     412            result.dqy_data = np.zeros(len(self.data)) 
     413        for i in range(np.size(self.data)): 
    414414            result.data[i] = self.data[i] 
    415415            if self.err_data is not None and \ 
    416                 numpy.size(self.data) == numpy.size(self.err_data): 
     416                            np.size(self.data) == np.size(self.err_data): 
    417417                result.err_data[i] = self.err_data[i]     
    418418            if self.dqx_data is not None: 
     
    473473            result.dqy_data = None 
    474474        else: 
    475             result.dqx_data = numpy.zeros(len(self.data) + \ 
    476                                          numpy.size(other.data)) 
    477             result.dqy_data = numpy.zeros(len(self.data) + \ 
    478                                          numpy.size(other.data)) 
    479          
    480         result.data = numpy.append(self.data, other.data) 
    481         result.qx_data = numpy.append(self.qx_data, other.qx_data) 
    482         result.qy_data = numpy.append(self.qy_data, other.qy_data) 
    483         result.q_data = numpy.append(self.q_data, other.q_data) 
    484         result.mask = numpy.append(self.mask, other.mask) 
     475            result.dqx_data = np.zeros(len(self.data) + \ 
     476                                       np.size(other.data)) 
     477            result.dqy_data = np.zeros(len(self.data) + \ 
     478                                       np.size(other.data)) 
     479         
     480        result.data = np.append(self.data, other.data) 
     481        result.qx_data = np.append(self.qx_data, other.qx_data) 
     482        result.qy_data = np.append(self.qy_data, other.qy_data) 
     483        result.q_data = np.append(self.q_data, other.q_data) 
     484        result.mask = np.append(self.mask, other.mask) 
    485485        if result.err_data is not None: 
    486             result.err_data = numpy.append(self.err_data, other.err_data)  
     486            result.err_data = np.append(self.err_data, other.err_data) 
    487487        if self.dqx_data is not None: 
    488             result.dqx_data = numpy.append(self.dqx_data, other.dqx_data) 
     488            result.dqx_data = np.append(self.dqx_data, other.dqx_data) 
    489489        if self.dqy_data is not None: 
    490             result.dqy_data = numpy.append(self.dqy_data, other.dqy_data) 
     490            result.dqy_data = np.append(self.dqy_data, other.dqy_data) 
    491491 
    492492        return result 
  • TabularUnified src/sas/sasgui/guiframe/data_processor.py

    r468c253 r9a5097c  
    10911091            # When inputs are from an external file 
    10921092            return inputs, outputs 
    1093         inds = numpy.lexsort((to_be_sort, to_be_sort)) 
     1093        inds = np.lexsort((to_be_sort, to_be_sort)) 
    10941094        for key in outputs.keys(): 
    10951095            key_list = outputs[key] 
     
    13791379            return 
    13801380        if dy == None: 
    1381             dy = numpy.zeros(len(y)) 
     1381            dy = np.zeros(len(y)) 
    13821382        #plotting 
    13831383        new_plot = Data1D(x=x, y=y, dy=dy) 
  • TabularUnified src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r29e872e r9a5097c  
    1414import sys 
    1515import math 
    16 import numpy 
     16import numpy as np 
    1717import logging 
    1818from sas.sasgui.plottools.PlotPanel import PlotPanel 
     
    288288        :Param value: float 
    289289        """ 
    290         idx = (numpy.abs(array - value)).argmin() 
     290        idx = (np.abs(array - value)).argmin() 
    291291        return int(idx)  # array.flat[idx] 
    292292 
  • TabularUnified src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    rb2b36932 r9a5097c  
    1414import sys 
    1515import math 
    16 import numpy 
     16import numpy as np 
    1717import logging 
    1818from sas.sasgui.plottools.PlotPanel import PlotPanel 
     
    567567        """ 
    568568        # Find the best number of bins 
    569         npt = math.sqrt(len(self.data2D.data[numpy.isfinite(self.data2D.data)])) 
     569        npt = math.sqrt(len(self.data2D.data[np.isfinite(self.data2D.data)])) 
    570570        npt = math.floor(npt) 
    571571        from sas.sascalc.dataloader.manipulations import CircularAverage 
  • TabularUnified src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py

    rd85c194 r9a5097c  
    11import wx 
    22import math 
    3 import numpy 
     3import numpy as np 
    44from sas.sasgui.guiframe.events import NewPlotEvent 
    55from sas.sasgui.guiframe.events import StatusEvent 
     
    358358        # # Reset x, y- coordinates if send as parameters 
    359359        if x != None: 
    360             self.x = numpy.sign(self.x) * math.fabs(x) 
     360            self.x = np.sign(self.x) * math.fabs(x) 
    361361        if y != None: 
    362             self.y = numpy.sign(self.y) * math.fabs(y) 
     362            self.y = np.sign(self.y) * math.fabs(y) 
    363363        # # Draw lines and markers 
    364364        self.inner_marker.set(xdata=[0], ydata=[self.y]) 
     
    465465        # # reset x, y -coordinates if given as parameters 
    466466        if x != None: 
    467             self.x = numpy.sign(self.x) * math.fabs(x) 
     467            self.x = np.sign(self.x) * math.fabs(x) 
    468468        if y != None: 
    469             self.y = numpy.sign(self.y) * math.fabs(y) 
     469            self.y = np.sign(self.y) * math.fabs(y) 
    470470        # # draw lines and markers 
    471471        self.inner_marker.set(xdata=[self.x], ydata=[0]) 
  • TabularUnified src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py

    rd85c194 r9a5097c  
    2424import math 
    2525import copy 
    26 import numpy 
     26import numpy as np 
    2727from sas.sasgui.plottools.PlotPanel import PlotPanel 
    2828from sas.sasgui.plottools.plottables import Graph 
     
    298298        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    299299        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
    300         mask = numpy.ones(len(self.data.mask), dtype=bool) 
     300        mask = np.ones(len(self.data.mask), dtype=bool) 
    301301        self.data.mask = mask 
    302302        # update mask plot 
     
    343343            self.mask = mask 
    344344        # make temperary data to plot 
    345         temp_mask = numpy.zeros(len(mask)) 
     345        temp_mask = np.zeros(len(mask)) 
    346346        temp_data = copy.deepcopy(self.data) 
    347347        # temp_data default is None 
  • TabularUnified src/sas/sasgui/perspectives/calculator/data_operator.py

    r61780e3 r9a5097c  
    55import sys 
    66import time 
    7 import numpy 
     7import numpy as np 
    88from sas.sascalc.dataloader.data_info import Data1D 
    99from sas.sasgui.plottools.PlotPanel import PlotPanel 
     
    541541                    theory, _ = theory_list.values()[0] 
    542542                    dnames.append(theory.name) 
    543         ind = numpy.argsort(dnames) 
     543        ind = np.argsort(dnames) 
    544544        if len(ind) > 0: 
    545             val_list = numpy.array(self._data.values())[ind] 
     545            val_list = np.array(self._data.values())[ind] 
    546546            for datastate in val_list: 
    547547                data = datastate.data 
  • TabularUnified src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py

    r0f7c930 r9a5097c  
    77import sys 
    88import os 
    9 import numpy 
     9import numpy as np 
    1010#import math 
    1111import wx.aui as aui 
     
    741741            marker = 'o' 
    742742            m_size = 3.5 
    743         sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 
    744                    numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 
     743        sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) + \ 
     744                   np.fabs(sld_mz) + np.fabs(output.sld_n)) 
    745745        is_nonzero = sld_tot > 0.0 
    746746        is_zero = sld_tot == 0.0 
     
    757757            pix_symbol = output.pix_symbol[is_nonzero] 
    758758        # II. Plot selective points in color 
    759         other_color = numpy.ones(len(pix_symbol), dtype='bool') 
     759        other_color = np.ones(len(pix_symbol), dtype='bool') 
    760760        for key in color_dic.keys(): 
    761761            chosen_color = pix_symbol == key 
    762             if numpy.any(chosen_color): 
     762            if np.any(chosen_color): 
    763763                other_color = other_color & (chosen_color != True) 
    764764                color = color_dic[key] 
     
    767767                        markeredgecolor=color, markersize=m_size, label=key) 
    768768        # III. Plot All others         
    769         if numpy.any(other_color): 
     769        if np.any(other_color): 
    770770            a_name = '' 
    771771            if output.pix_type == 'atom': 
     
    795795                draw magnetic vectors w/arrow 
    796796                """ 
    797                 max_mx = max(numpy.fabs(sld_mx)) 
    798                 max_my = max(numpy.fabs(sld_my)) 
    799                 max_mz = max(numpy.fabs(sld_mz)) 
     797                max_mx = max(np.fabs(sld_mx)) 
     798                max_my = max(np.fabs(sld_my)) 
     799                max_mz = max(np.fabs(sld_mz)) 
    800800                max_m = max(max_mx, max_my, max_mz) 
    801801                try: 
     
    812812                        unit_z2 = sld_mz / max_m 
    813813                        # 0.8 is for avoiding the color becomes white=(1,1,1)) 
    814                         color_x = numpy.fabs(unit_x2 * 0.8) 
    815                         color_y = numpy.fabs(unit_y2 * 0.8) 
    816                         color_z = numpy.fabs(unit_z2 * 0.8) 
     814                        color_x = np.fabs(unit_x2 * 0.8) 
     815                        color_y = np.fabs(unit_y2 * 0.8) 
     816                        color_z = np.fabs(unit_z2 * 0.8) 
    817817                        x2 = pos_x + unit_x2 * max_step 
    818818                        y2 = pos_y + unit_y2 * max_step 
    819819                        z2 = pos_z + unit_z2 * max_step 
    820                         x_arrow = numpy.column_stack((pos_x, x2)) 
    821                         y_arrow = numpy.column_stack((pos_y, y2)) 
    822                         z_arrow = numpy.column_stack((pos_z, z2)) 
    823                         colors = numpy.column_stack((color_x, color_y, color_z)) 
     820                        x_arrow = np.column_stack((pos_x, x2)) 
     821                        y_arrow = np.column_stack((pos_y, y2)) 
     822                        z_arrow = np.column_stack((pos_z, z2)) 
     823                        colors = np.column_stack((color_x, color_y, color_z)) 
    824824                        arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 
    825825                                        colors, mutation_scale=10, lw=1, 
     
    880880            if self.is_avg or self.is_avg == None: 
    881881                self._create_default_1d_data() 
    882                 i_out = numpy.zeros(len(self.data.y)) 
     882                i_out = np.zeros(len(self.data.y)) 
    883883                inputs = [self.data.x, [], i_out] 
    884884            else: 
    885885                self._create_default_2d_data() 
    886                 i_out = numpy.zeros(len(self.data.data)) 
     886                i_out = np.zeros(len(self.data.data)) 
    887887                inputs = [self.data.qx_data, self.data.qy_data, i_out] 
    888888 
     
    989989        :Param input: input list [qx_data, qy_data, i_out] 
    990990        """ 
    991         out = numpy.empty(0) 
     991        out = np.empty(0) 
    992992        #s = time.time() 
    993993        for ind in range(len(input[0])): 
     
    998998                inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 
    999999                outi = self.model.run(inputi) 
    1000                 out = numpy.append(out, outi) 
     1000                out = np.append(out, outi) 
    10011001            else: 
    10021002                if ind % 50 == 0  and update != None: 
     
    10061006                          input[2][ind:ind + 1]] 
    10071007                outi = self.model.runXY(inputi) 
    1008                 out = numpy.append(out, outi) 
     1008                out = np.append(out, outi) 
    10091009        #print time.time() - s 
    10101010        if self.is_avg or self.is_avg == None: 
     
    10271027        self.npts_x = int(float(self.npt_ctl.GetValue())) 
    10281028        self.data = Data2D() 
    1029         qmax = self.qmax_x #/ numpy.sqrt(2) 
     1029        qmax = self.qmax_x #/ np.sqrt(2) 
    10301030        self.data.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    10311031        self.data.yaxis('\\rm{Q_{y}}', '\AA^{-1}') 
     
    10481048        qstep = self.npts_x 
    10491049 
    1050         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    1051         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
     1050        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     1051        y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    10521052        ## use data info instead 
    1053         new_x = numpy.tile(x, (len(y), 1)) 
    1054         new_y = numpy.tile(y, (len(x), 1)) 
     1053        new_x = np.tile(x, (len(y), 1)) 
     1054        new_y = np.tile(y, (len(x), 1)) 
    10551055        new_y = new_y.swapaxes(0, 1) 
    10561056        # all data reuire now in 1d array 
    10571057        qx_data = new_x.flatten() 
    10581058        qy_data = new_y.flatten() 
    1059         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     1059        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    10601060        # set all True (standing for unmasked) as default 
    1061         mask = numpy.ones(len(qx_data), dtype=bool) 
     1061        mask = np.ones(len(qx_data), dtype=bool) 
    10621062        # store x and y bin centers in q space 
    10631063        x_bins = x 
    10641064        y_bins = y 
    10651065        self.data.source = Source() 
    1066         self.data.data = numpy.ones(len(mask)) 
    1067         self.data.err_data = numpy.ones(len(mask)) 
     1066        self.data.data = np.ones(len(mask)) 
     1067        self.data.err_data = np.ones(len(mask)) 
    10681068        self.data.qx_data = qx_data 
    10691069        self.data.qy_data = qy_data 
     
    10841084        :warning: This data is never plotted. 
    10851085                    residuals.x = data_copy.x[index] 
    1086             residuals.dy = numpy.ones(len(residuals.y)) 
     1086            residuals.dy = np.ones(len(residuals.y)) 
    10871087            residuals.dx = None 
    10881088            residuals.dxl = None 
     
    10911091        self.qmax_x = float(self.qmax_ctl.GetValue()) 
    10921092        self.npts_x = int(float(self.npt_ctl.GetValue())) 
    1093         qmax = self.qmax_x #/ numpy.sqrt(2) 
     1093        qmax = self.qmax_x #/ np.sqrt(2) 
    10941094        ## Default values 
    10951095        xmax = qmax 
    10961096        xmin = qmax * _Q1D_MIN 
    10971097        qstep = self.npts_x 
    1098         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     1098        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    10991099        # store x and y bin centers in q space 
    11001100        #self.data.source = Source() 
    1101         y = numpy.ones(len(x)) 
    1102         dy = numpy.zeros(len(x)) 
    1103         dx = numpy.zeros(len(x)) 
     1101        y = np.ones(len(x)) 
     1102        dy = np.zeros(len(x)) 
     1103        dx = np.zeros(len(x)) 
    11041104        self.data = Data1D(x=x, y=y) 
    11051105        self.data.dx = dx 
     
    11711171        state = None 
    11721172 
    1173         numpy.nan_to_num(image) 
     1173        np.nan_to_num(image) 
    11741174        new_plot = Data2D(image=image, err_image=data.err_data) 
    11751175        new_plot.name = model.name + '2d' 
     
    16401640            for key in sld_list.keys(): 
    16411641                if ctr_list[0] == key: 
    1642                     min_val = numpy.min(sld_list[key]) 
    1643                     max_val = numpy.max(sld_list[key]) 
    1644                     mean_val = numpy.mean(sld_list[key]) 
     1642                    min_val = np.min(sld_list[key]) 
     1643                    max_val = np.max(sld_list[key]) 
     1644                    mean_val = np.mean(sld_list[key]) 
    16451645                    enable = (min_val == max_val) and \ 
    16461646                             sld_data.pix_type == 'pixel' 
     
    17331733                    npts = -1 
    17341734                    break 
    1735                 if numpy.isfinite(n_val): 
     1735                if np.isfinite(n_val): 
    17361736                    npts *= int(n_val) 
    17371737            if npts > 0: 
     
    17701770                        ctl.Refresh() 
    17711771                        return 
    1772                     if numpy.isfinite(s_val): 
     1772                    if np.isfinite(s_val): 
    17731773                        s_size *= s_val 
    17741774                self.sld_data.set_pixel_volumes(s_size) 
     
    17871787        try: 
    17881788            sld_data = self.parent.get_sld_from_omf() 
    1789             #nop = (nop * numpy.pi) / 6 
     1789            #nop = (nop * np.pi) / 6 
    17901790            nop = len(sld_data.sld_n) 
    17911791        except: 
  • TabularUnified src/sas/sasgui/perspectives/fitting/basepage.py

    r7a5aedd red2276f  
    55import os 
    66import wx 
    7 import numpy 
     7import numpy as np 
    88import time 
    99import copy 
     
    100100        self.graph_id = None 
    101101        # Q range for data set 
    102         self.qmin_data_set = numpy.inf 
     102        self.qmin_data_set = np.inf 
    103103        self.qmax_data_set = None 
    104104        self.npts_data_set = 0 
     
    120120        self.dxw = None 
    121121        # pinhole smear 
    122         self.dx_min = None 
    123         self.dx_max = None 
     122        self.dx_percent = None 
    124123        # smear attrbs 
    125124        self.enable_smearer = None 
     
    279278 
    280279        """ 
    281         x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
     280        x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 
    282281                           num=self.npts_x, endpoint=True) 
    283282        self.data = Data1D(x=x) 
     
    296295        """ 
    297296        if self.qmin_x >= 1.e-10: 
    298             qmin = numpy.log10(self.qmin_x) 
     297            qmin = np.log10(self.qmin_x) 
    299298        else: 
    300299            qmin = -10. 
    301300 
    302301        if self.qmax_x <= 1.e10: 
    303             qmax = numpy.log10(self.qmax_x) 
     302            qmax = np.log10(self.qmax_x) 
    304303        else: 
    305304            qmax = 10. 
    306305 
    307         x = numpy.logspace(start=qmin, stop=qmax, 
     306        x = np.logspace(start=qmin, stop=qmax, 
    308307                           num=self.npts_x, endpoint=True, base=10.0) 
    309308        self.data = Data1D(x=x) 
     
    342341        qstep = self.npts_x 
    343342 
    344         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    345         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
     343        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     344        y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    346345        # use data info instead 
    347         new_x = numpy.tile(x, (len(y), 1)) 
    348         new_y = numpy.tile(y, (len(x), 1)) 
     346        new_x = np.tile(x, (len(y), 1)) 
     347        new_y = np.tile(y, (len(x), 1)) 
    349348        new_y = new_y.swapaxes(0, 1) 
    350349        # all data reuire now in 1d array 
    351350        qx_data = new_x.flatten() 
    352351        qy_data = new_y.flatten() 
    353         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     352        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    354353        # set all True (standing for unmasked) as default 
    355         mask = numpy.ones(len(qx_data), dtype=bool) 
     354        mask = np.ones(len(qx_data), dtype=bool) 
    356355        # store x and y bin centers in q space 
    357356        x_bins = x 
     
    359358 
    360359        self.data.source = Source() 
    361         self.data.data = numpy.ones(len(mask)) 
    362         self.data.err_data = numpy.ones(len(mask)) 
     360        self.data.data = np.ones(len(mask)) 
     361        self.data.err_data = np.ones(len(mask)) 
    363362        self.data.qx_data = qx_data 
    364363        self.data.qy_data = qy_data 
     
    784783                    # Skip non-data lines 
    785784                    logging.error(traceback.format_exc()) 
    786             return numpy.array(angles), numpy.array(weights) 
     785            return np.array(angles), np.array(weights) 
    787786        except: 
    788787            raise 
     
    849848        self.state.pinhole_smearer = \ 
    850849                                copy.deepcopy(self.pinhole_smearer.GetValue()) 
    851         self.state.dx_max = copy.deepcopy(self.dx_max) 
    852         self.state.dx_min = copy.deepcopy(self.dx_min) 
     850        self.state.dx_percent = copy.deepcopy(self.dx_percent) 
    853851        self.state.dxl = copy.deepcopy(self.dxl) 
    854852        self.state.dxw = copy.deepcopy(self.dxw) 
     
    12471245        # we have two more options for smearing 
    12481246        if self.pinhole_smearer.GetValue(): 
    1249             self.dx_min = state.dx_min 
    1250             self.dx_max = state.dx_max 
    1251             if self.dx_min is not None: 
    1252                 self.smear_pinhole_min.SetValue(str(self.dx_min)) 
    1253             if self.dx_max is not None: 
    1254                 self.smear_pinhole_max.SetValue(str(self.dx_max)) 
     1247            self.dx_percent = state.dx_percent 
     1248            if self.dx_percent is not None: 
     1249                if state.dx_old: 
     1250                    self.dx_percent = 100 * (self.dx_percent / self.data.x[0]) 
     1251                self.smear_pinhole_percent.SetValue("%.2f" % self.dx_percent) 
    12551252            self.onPinholeSmear(event=None) 
    12561253        elif self.slit_smearer.GetValue(): 
     
    14521449                self.state_change = True 
    14531450                self._draw_model() 
    1454                 # Time delay has been introduced to prevent _handle error 
    1455                 # on Windows 
    1456                 # This part of code is executed when model is selected and 
    1457                 # it's parameters are changed (with respect to previously 
    1458                 # selected model). There are two Iq evaluations occuring one 
    1459                 # after another and therefore there may be compilation error 
    1460                 # if model is calculated for the first time. 
    1461                 # This seems to be Windows only issue - haven't tested on Linux 
    1462                 # though.The proper solution (other than time delay) requires 
    1463                 # more fundemental code refatoring 
    1464                 # Wojtek P. Nov 7, 2016 
    1465                 if not ON_MAC: 
    1466                     time.sleep(0.1) 
    14671451                self.Refresh() 
    14681452 
     
    21232107        for data in self.data_list: 
    21242108            # q value from qx and qy 
    2125             radius = numpy.sqrt(data.qx_data * data.qx_data + 
     2109            radius = np.sqrt(data.qx_data * data.qx_data + 
    21262110                                data.qy_data * data.qy_data) 
    21272111            # get unmasked index 
     
    21292113                         (radius <= float(self.qmax.GetValue())) 
    21302114            index_data = (index_data) & (data.mask) 
    2131             index_data = (index_data) & (numpy.isfinite(data.data)) 
     2115            index_data = (index_data) & (np.isfinite(data.data)) 
    21322116 
    21332117            if len(index_data[index_data]) < 10: 
     
    21642148            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    21652149                         (radius <= float(self.qmax.GetValue())) 
    2166             index_data = (index_data) & (numpy.isfinite(data.y)) 
     2150            index_data = (index_data) & (np.isfinite(data.y)) 
    21672151 
    21682152            if len(index_data[index_data]) < 5: 
     
    22362220 
    22372221                # Check that min is less than max 
    2238                 low = -numpy.inf if min_str == "" else float(min_str) 
    2239                 high = numpy.inf if max_str == "" else float(max_str) 
     2222                low = -np.inf if min_str == "" else float(min_str) 
     2223                high = np.inf if max_str == "" else float(max_str) 
    22402224                if high < low: 
    22412225                    min_ctrl.SetBackgroundColour("pink") 
     
    26122596            Layout is called after fitting. 
    26132597        """ 
    2614         self._sleep4sec() 
    26152598        self.Layout() 
    26162599        return 
    2617  
    2618     def _sleep4sec(self): 
    2619         """ 
    2620             sleep for 1 sec only applied on Mac 
    2621             Note: This 1sec helps for Mac not to crash on self. 
    2622             Layout after self._draw_model 
    2623         """ 
    2624         if ON_MAC: 
    2625             time.sleep(1) 
    26262600 
    26272601    def _find_polyfunc_selection(self, disp_func=None): 
     
    26572631            self.qmin_x = data_min 
    26582632            self.qmax_x = math.sqrt(x * x + y * y) 
    2659             # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2633            # self.data.mask = np.ones(len(self.data.data),dtype=bool) 
    26602634            # check smearing 
    26612635            if not self.disable_smearer.GetValue(): 
     
    33693343 
    33703344            if value[1] == 'array': 
    3371                 pd_vals = numpy.array(value[2]) 
    3372                 pd_weights = numpy.array(value[3]) 
     3345                pd_vals = np.array(value[2]) 
     3346                pd_weights = np.array(value[3]) 
    33733347                if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 
    33743348                    msg = ("bad array distribution parameters for %s" 
  • TabularUnified src/sas/sasgui/perspectives/fitting/fitpage.py

    r8c0d9eb red2276f  
    66import wx 
    77import wx.lib.newevent 
    8 import numpy 
     8import numpy as np 
    99import copy 
    1010import math 
     
    2929_BOX_WIDTH = 76 
    3030_DATA_BOX_WIDTH = 300 
    31 SMEAR_SIZE_L = 0.00 
    3231SMEAR_SIZE_H = 0.00 
    3332CUSTOM_MODEL = 'Plugin Models' 
     
    210209              "Please enter only the value of interest to customize smearing..." 
    211210        smear_message_new_psmear = \ 
    212               "Please enter both; the dQ will be generated by interpolation..." 
     211              "Please enter a fixed percentage to be applied to all Q values..." 
    213212        smear_message_2d_x_title = "<dQp>[1/A]:" 
    214213        smear_message_2d_y_title = "<dQs>[1/A]:" 
    215         smear_message_pinhole_min_title = "dQ_low[1/A]:" 
    216         smear_message_pinhole_max_title = "dQ_high[1/A]:" 
     214        smear_message_pinhole_percent_title = "dQ[%]:" 
    217215        smear_message_slit_height_title = "Slit height[1/A]:" 
    218216        smear_message_slit_width_title = "Slit width[1/A]:" 
     
    307305         
    308306        # textcntrl for custom resolution 
    309         self.smear_pinhole_max = ModelTextCtrl(self, wx.ID_ANY, 
    310                             size=(_BOX_WIDTH - 25, 20), 
    311                             style=wx.TE_PROCESS_ENTER, 
    312                             text_enter_callback=self.onPinholeSmear) 
    313         self.smear_pinhole_min = ModelTextCtrl(self, wx.ID_ANY, 
    314                             size=(_BOX_WIDTH - 25, 20), 
    315                             style=wx.TE_PROCESS_ENTER, 
    316                             text_enter_callback=self.onPinholeSmear) 
     307        self.smear_pinhole_percent = ModelTextCtrl(self, wx.ID_ANY, 
     308                                                   size=(_BOX_WIDTH - 25, 20), 
     309                                                   style=wx.TE_PROCESS_ENTER, 
     310                                                   text_enter_callback= 
     311                                                   self.onPinholeSmear) 
    317312        self.smear_slit_height = ModelTextCtrl(self, wx.ID_ANY, 
    318313                            size=(_BOX_WIDTH - 25, 20), 
     
    333328 
    334329        # set default values for smear 
    335         self.smear_pinhole_max.SetValue(str(self.dx_max)) 
    336         self.smear_pinhole_min.SetValue(str(self.dx_min)) 
     330        self.smear_pinhole_percent.SetValue(str(self.dx_percent)) 
    337331        self.smear_slit_height.SetValue(str(self.dxl)) 
    338332        self.smear_slit_width.SetValue(str(self.dxw)) 
     
    426420        self.smear_description_2d_y.SetToolTipString( 
    427421                                    " dQs(perpendicular) in q_phi direction.") 
    428         self.smear_description_pin_min = wx.StaticText(self, wx.ID_ANY, 
    429                         smear_message_pinhole_min_title, style=wx.ALIGN_LEFT) 
    430         self.smear_description_pin_max = wx.StaticText(self, wx.ID_ANY, 
    431                         smear_message_pinhole_max_title, style=wx.ALIGN_LEFT) 
     422        self.smear_description_pin_percent = wx.StaticText(self, wx.ID_ANY, 
     423                                            smear_message_pinhole_percent_title, 
     424                                            style=wx.ALIGN_LEFT) 
    432425        self.smear_description_slit_height = wx.StaticText(self, wx.ID_ANY, 
    433426                        smear_message_slit_height_title, style=wx.ALIGN_LEFT) 
     
    453446        self.sizer_new_smear.Add((15, -1)) 
    454447        self.sizer_new_smear.Add(self.smear_description_2d_x, 0, wx.CENTER, 10) 
    455         self.sizer_new_smear.Add(self.smear_description_pin_min, 
    456                                  0, wx.CENTER, 10) 
    457448        self.sizer_new_smear.Add(self.smear_description_slit_height, 
    458449                                 0, wx.CENTER, 10) 
    459450 
    460         self.sizer_new_smear.Add(self.smear_pinhole_min, 0, wx.CENTER, 10) 
    461451        self.sizer_new_smear.Add(self.smear_slit_height, 0, wx.CENTER, 10) 
    462452        self.sizer_new_smear.Add(self.smear_data_left, 0, wx.CENTER, 10) 
     
    464454        self.sizer_new_smear.Add(self.smear_description_2d_y, 
    465455                                 0, wx.CENTER, 10) 
    466         self.sizer_new_smear.Add(self.smear_description_pin_max, 
     456        self.sizer_new_smear.Add(self.smear_description_pin_percent, 
    467457                                 0, wx.CENTER, 10) 
    468458        self.sizer_new_smear.Add(self.smear_description_slit_width, 
    469459                                 0, wx.CENTER, 10) 
    470460 
    471         self.sizer_new_smear.Add(self.smear_pinhole_max, 0, wx.CENTER, 10) 
     461        self.sizer_new_smear.Add(self.smear_pinhole_percent, 0, wx.CENTER, 10) 
    472462        self.sizer_new_smear.Add(self.smear_slit_width, 0, wx.CENTER, 10) 
    473463        self.sizer_new_smear.Add(self.smear_data_right, 0, wx.CENTER, 10) 
     
    11251115            if item.GetValue(): 
    11261116                if button_list.index(item) == 0: 
    1127                     flag = 0  # dy = numpy.ones_like(dy_data) 
     1117                    flag = 0  # dy = np.ones_like(dy_data) 
    11281118                elif button_list.index(item) == 1: 
    11291119                    flag = 1  # dy = dy_data 
    11301120                elif button_list.index(item) == 2: 
    1131                     flag = 2  # dy = numpy.sqrt(numpy.abs(data)) 
     1121                    flag = 2  # dy = np.sqrt(np.abs(data)) 
    11321122                elif button_list.index(item) == 3: 
    1133                     flag = 3  # dy = numpy.abs(data) 
     1123                    flag = 3  # dy = np.abs(data) 
    11341124                break 
    11351125        return flag 
     
    14321422        key = event.GetKeyCode() 
    14331423        length = len(self.data.x) 
    1434         indx = (numpy.abs(self.data.x - x_data)).argmin() 
     1424        indx = (np.abs(self.data.x - x_data)).argmin() 
    14351425        # return array.flat[idx] 
    14361426        if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: 
     
    14871477                    self.enable2D: 
    14881478                # set mask 
    1489                 radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     1479                radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    14901480                                    self.data.qy_data * self.data.qy_data) 
    14911481                index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x)) 
    14921482                index_data = (index_data) & (self.data.mask) 
    1493                 index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     1483                index_data = (index_data) & (np.isfinite(self.data.data)) 
    14941484                if len(index_data[index_data]) < 10: 
    14951485                    msg = "Cannot Plot :No or too little npts in" 
     
    15811571        if self.dxw is None: 
    15821572            self.dxw = "" 
    1583         if self.dx_min is None: 
    1584             self.dx_min = SMEAR_SIZE_L 
    1585         if self.dx_max is None: 
    1586             self.dx_max = SMEAR_SIZE_H 
     1573        if self.dx_percent is None: 
     1574            self.dx_percent = SMEAR_SIZE_H 
    15871575 
    15881576    def _get_smear_info(self): 
     
    16101598                and data.dqx_data.any() != 0: 
    16111599                self.smear_type = "Pinhole2d" 
    1612                 self.dq_l = format_number(numpy.average(data.dqx_data)) 
    1613                 self.dq_r = format_number(numpy.average(data.dqy_data)) 
     1600                self.dq_l = format_number(np.average(data.dqx_data)) 
     1601                self.dq_r = format_number(np.average(data.dqy_data)) 
    16141602                return 
    16151603            else: 
    16161604                return 
    16171605        # check if it is pinhole smear and get min max if it is. 
    1618         if data.dx is not None and numpy.any(data.dx): 
     1606        if data.dx is not None and np.any(data.dx): 
    16191607            self.smear_type = "Pinhole" 
    16201608            self.dq_l = data.dx[0] 
     
    16241612        elif data.dxl is not None or data.dxw is not None: 
    16251613            self.smear_type = "Slit" 
    1626             if data.dxl is not None and numpy.all(data.dxl, 0): 
     1614            if data.dxl is not None and np.all(data.dxl, 0): 
    16271615                self.dq_l = data.dxl[0] 
    1628             if data.dxw is not None and numpy.all(data.dxw, 0): 
     1616            if data.dxw is not None and np.all(data.dxw, 0): 
    16291617                self.dq_r = data.dxw[0] 
    16301618        # return self.smear_type,self.dq_l,self.dq_r 
     
    16461634            self.smear_description_2d_y.Show(True) 
    16471635            if self.pinhole_smearer.GetValue(): 
    1648                 self.smear_pinhole_min.Show(True) 
    1649                 self.smear_pinhole_max.Show(True) 
     1636                self.smear_pinhole_percent.Show(True) 
    16501637        # smear from data 
    16511638        elif self.enable_smearer.GetValue(): 
     
    16581645                    self.smear_description_slit_width.Show(True) 
    16591646                elif self.smear_type == 'Pinhole': 
    1660                     self.smear_description_pin_min.Show(True) 
    1661                     self.smear_description_pin_max.Show(True) 
     1647                    self.smear_description_pin_percent.Show(True) 
    16621648                self.smear_description_smear_type.Show(True) 
    16631649                self.smear_description_type.Show(True) 
     
    16681654            if self.smear_type == 'Pinhole': 
    16691655                self.smear_message_new_p.Show(True) 
    1670                 self.smear_description_pin_min.Show(True) 
    1671                 self.smear_description_pin_max.Show(True) 
    1672  
    1673             self.smear_pinhole_min.Show(True) 
    1674             self.smear_pinhole_max.Show(True) 
     1656                self.smear_description_pin_percent.Show(True) 
     1657 
     1658            self.smear_pinhole_percent.Show(True) 
    16751659        # custom slit smear 
    16761660        elif self.slit_smearer.GetValue(): 
     
    16971681        self.smear_data_left.Hide() 
    16981682        self.smear_data_right.Hide() 
    1699         self.smear_description_pin_min.Hide() 
    1700         self.smear_pinhole_min.Hide() 
    1701         self.smear_description_pin_max.Hide() 
    1702         self.smear_pinhole_max.Hide() 
     1683        self.smear_description_pin_percent.Hide() 
     1684        self.smear_pinhole_percent.Hide() 
    17031685        self.smear_description_slit_height.Hide() 
    17041686        self.smear_slit_height.Hide() 
     
    18261808        if not flag: 
    18271809            self.onSmear(None) 
    1828  
    1829     def _mac_sleep(self, sec=0.2): 
    1830         """ 
    1831         Give sleep to MAC 
    1832         """ 
    1833         if self.is_mac: 
    1834             time.sleep(sec) 
    18351810 
    18361811    def get_view_mode(self): 
     
    19391914                self.default_mask = copy.deepcopy(self.data.mask) 
    19401915                if self.data.err_data is not None \ 
    1941                         and numpy.any(self.data.err_data): 
     1916                        and np.any(self.data.err_data): 
    19421917                    di_flag = True 
    19431918                if self.data.dqx_data is not None \ 
    1944                         and numpy.any(self.data.dqx_data): 
     1919                        and np.any(self.data.dqx_data): 
    19451920                    dq_flag = True 
    19461921            else: 
    19471922                self.slit_smearer.Enable(True) 
    19481923                self.pinhole_smearer.Enable(True) 
    1949                 if self.data.dy is not None and numpy.any(self.data.dy): 
     1924                if self.data.dy is not None and np.any(self.data.dy): 
    19501925                    di_flag = True 
    1951                 if self.data.dx is not None and numpy.any(self.data.dx): 
     1926                if self.data.dx is not None and np.any(self.data.dx): 
    19521927                    dq_flag = True 
    1953                 elif self.data.dxl is not None and numpy.any(self.data.dxl): 
     1928                elif self.data.dxl is not None and np.any(self.data.dxl): 
    19541929                    dq_flag = True 
    19551930 
     
    20852060        if self.data.__class__.__name__ == "Data2D" or \ 
    20862061                        self.enable2D: 
    2087             radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     2062            radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    20882063                                self.data.qy_data * self.data.qy_data) 
    20892064            index_data = (self.qmin_x <= radius) & (radius <= self.qmax_x) 
    20902065            index_data = (index_data) & (self.data.mask) 
    2091             index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     2066            index_data = (index_data) & (np.isfinite(self.data.data)) 
    20922067            npts2fit = len(self.data.data[index_data]) 
    20932068        else: 
     
    21222097        # make sure stop button to fit button all the time 
    21232098        self._on_fit_complete() 
    2124         if out is None or not numpy.isfinite(chisqr): 
     2099        if out is None or not np.isfinite(chisqr): 
    21252100            raise ValueError, "Fit error occured..." 
    21262101 
     
    21332108 
    21342109        # Check if chi2 is finite 
    2135         if chisqr is not None and numpy.isfinite(chisqr): 
     2110        if chisqr is not None and np.isfinite(chisqr): 
    21362111            # format chi2 
    21372112            chi2 = format_number(chisqr, True) 
     
    21852160 
    21862161                        if cov[ind] is not None: 
    2187                             if numpy.isfinite(float(cov[ind])): 
     2162                            if np.isfinite(float(cov[ind])): 
    21882163                                val_err = format_number(cov[ind], True) 
    21892164                                item[4].SetForegroundColour(wx.BLACK) 
     
    22062181        self.save_current_state() 
    22072182 
    2208         if not self.is_mac: 
    2209             self.Layout() 
    2210             self.Refresh() 
    2211         self._mac_sleep(0.1) 
    22122183        # plot model ( when drawing, do not update chisqr value again) 
    22132184        self._draw_model(update_chisqr=False, source='fit') 
     
    22492220            # event case of radio button 
    22502221            if tcrtl.GetValue(): 
    2251                 self.dx_min = 0.0 
    2252                 self.dx_max = 0.0 
     2222                self.dx_percent = 0.0 
    22532223                is_new_pinhole = True 
    22542224            else: 
     
    22872257        """ 
    22882258        # get the values 
    2289         pin_min = self.smear_pinhole_min.GetValue() 
    2290         pin_max = self.smear_pinhole_max.GetValue() 
    2291  
    2292         # Check changes in slit width 
     2259        pin_percent = self.smear_pinhole_percent.GetValue() 
     2260 
     2261        # Check changes in slit heigth 
    22932262        try: 
    2294             dx_min = float(pin_min) 
     2263            dx_percent = float(pin_percent) 
    22952264        except: 
    22962265            return True 
    2297         if self.dx_min != dx_min: 
    2298             return True 
    2299  
    2300         # Check changes in slit heigth 
    2301         try: 
    2302             dx_max = float(pin_max) 
    2303         except: 
    2304             return True 
    2305         if self.dx_max != dx_max: 
     2266        if self.dx_percent != dx_percent: 
    23062267            return True 
    23072268        return False 
     
    23192280            self.smear_type = 'Pinhole2d' 
    23202281            len_data = len(data.data) 
    2321             data.dqx_data = numpy.zeros(len_data) 
    2322             data.dqy_data = numpy.zeros(len_data) 
     2282            data.dqx_data = np.zeros(len_data) 
     2283            data.dqy_data = np.zeros(len_data) 
    23232284        else: 
    23242285            self.smear_type = 'Pinhole' 
    23252286            len_data = len(data.x) 
    2326             data.dx = numpy.zeros(len_data) 
     2287            data.dx = np.zeros(len_data) 
    23272288            data.dxl = None 
    23282289            data.dxw = None 
    23292290        msg = None 
    23302291 
    2331         get_pin_min = self.smear_pinhole_min 
    2332         get_pin_max = self.smear_pinhole_max 
    2333  
    2334         if not check_float(get_pin_min): 
    2335             get_pin_min.SetBackgroundColour("pink") 
    2336             msg = "Model Error:wrong value entered!!!" 
    2337         elif not check_float(get_pin_max): 
    2338             get_pin_max.SetBackgroundColour("pink") 
     2292        get_pin_percent = self.smear_pinhole_percent 
     2293 
     2294        if not check_float(get_pin_percent): 
     2295            get_pin_percent.SetBackgroundColour("pink") 
    23392296            msg = "Model Error:wrong value entered!!!" 
    23402297        else: 
    23412298            if len_data < 2: 
    23422299                len_data = 2 
    2343             self.dx_min = float(get_pin_min.GetValue()) 
    2344             self.dx_max = float(get_pin_max.GetValue()) 
    2345             if self.dx_min < 0: 
    2346                 get_pin_min.SetBackgroundColour("pink") 
     2300            self.dx_percent = float(get_pin_percent.GetValue()) 
     2301            if self.dx_percent < 0: 
     2302                get_pin_percent.SetBackgroundColour("pink") 
    23472303                msg = "Model Error:This value can not be negative!!!" 
    2348             elif self.dx_max < 0: 
    2349                 get_pin_max.SetBackgroundColour("pink") 
    2350                 msg = "Model Error:This value can not be negative!!!" 
    2351             elif self.dx_min is not None and self.dx_max is not None: 
     2304            elif self.dx_percent is not None: 
     2305                percent = self.dx_percent/100 
    23522306                if self._is_2D(): 
    2353                     data.dqx_data[data.dqx_data == 0] = self.dx_min 
    2354                     data.dqy_data[data.dqy_data == 0] = self.dx_max 
    2355                 elif self.dx_min == self.dx_max: 
    2356                     data.dx[data.dx == 0] = self.dx_min 
     2307                    data.dqx_data[data.dqx_data == 0] = percent * data.qx_data 
     2308                    data.dqy_data[data.dqy_data == 0] = percent * data.qy_data 
    23572309                else: 
    2358                     step = (self.dx_max - self.dx_min) / (len_data - 1) 
    2359                     data.dx = numpy.arange(self.dx_min, 
    2360                                            self.dx_max + step / 1.1, 
    2361                                            step) 
    2362             elif self.dx_min is not None: 
    2363                 if self._is_2D(): 
    2364                     data.dqx_data[data.dqx_data == 0] = self.dx_min 
    2365                 else: 
    2366                     data.dx[data.dx == 0] = self.dx_min 
    2367             elif self.dx_max is not None: 
    2368                 if self._is_2D(): 
    2369                     data.dqy_data[data.dqy_data == 0] = self.dx_max 
    2370                 else: 
    2371                     data.dx[data.dx == 0] = self.dx_max 
     2310                    data.dx = percent * data.x 
    23722311            self.current_smearer = smear_selection(data, self.model) 
    23732312            # 2D need to set accuracy 
     
    23792318            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    23802319        else: 
    2381             get_pin_min.SetBackgroundColour("white") 
    2382             get_pin_max.SetBackgroundColour("white") 
     2320            get_pin_percent.SetBackgroundColour("white") 
    23832321        # set smearing value whether or not the data contain the smearing info 
    23842322 
     
    25202458        try: 
    25212459            self.dxl = float(self.smear_slit_height.GetValue()) 
    2522             data.dxl = self.dxl * numpy.ones(data_len) 
     2460            data.dxl = self.dxl * np.ones(data_len) 
    25232461            self.smear_slit_height.SetBackgroundColour(wx.WHITE) 
    25242462        except: 
    25252463            self.dxl = None 
    2526             data.dxl = numpy.zeros(data_len) 
     2464            data.dxl = np.zeros(data_len) 
    25272465            if self.smear_slit_height.GetValue().lstrip().rstrip() != "": 
    25282466                self.smear_slit_height.SetBackgroundColour("pink") 
     
    25332471            self.dxw = float(self.smear_slit_width.GetValue()) 
    25342472            self.smear_slit_width.SetBackgroundColour(wx.WHITE) 
    2535             data.dxw = self.dxw * numpy.ones(data_len) 
     2473            data.dxw = self.dxw * np.ones(data_len) 
    25362474        except: 
    25372475            self.dxw = None 
    2538             data.dxw = numpy.zeros(data_len) 
     2476            data.dxw = np.zeros(data_len) 
    25392477            if self.smear_slit_width.GetValue().lstrip().rstrip() != "": 
    25402478                self.smear_slit_width.SetBackgroundColour("pink") 
     
    26632601            if event is None: 
    26642602                output = "-" 
    2665             elif not numpy.isfinite(event.output): 
     2603            elif not np.isfinite(event.output): 
    26662604                output = "-" 
    26672605            else: 
  • TabularUnified src/sas/sasgui/perspectives/fitting/fitting.py

    rddbac66 red2276f  
    1616import wx 
    1717import logging 
    18 import numpy 
     18import numpy as np 
    1919import time 
    2020from copy import deepcopy 
     
    876876                qmin=qmin, qmax=qmax, weight=weight) 
    877877 
    878     def _mac_sleep(self, sec=0.2): 
    879         """ 
    880         Give sleep to MAC 
    881         """ 
    882         if ON_MAC: 
    883             time.sleep(sec) 
    884  
    885878    def draw_model(self, model, page_id, data=None, smearer=None, 
    886879                   enable1D=True, enable2D=False, 
     
    10301023                                manager=self, 
    10311024                                improvement_delta=0.1) 
    1032         self._mac_sleep(0.2) 
    10331025 
    10341026        # batch fit 
     
    12701262        :param elapsed: time spent at the fitting level 
    12711263        """ 
    1272         self._mac_sleep(0.2) 
    12731264        uid = page_id[0] 
    12741265        if uid in self.fit_thread_list.keys(): 
     
    13321323                    new_theory = copy_data.data 
    13331324                    new_theory[res.index] = res.theory 
    1334                     new_theory[res.index == False] = numpy.nan 
     1325                    new_theory[res.index == False] = np.nan 
    13351326                    correct_result = True 
    13361327                #get all fittable parameters of the current model 
     
    13411332                        param_list.remove(param) 
    13421333                if not correct_result or res.fitness is None or \ 
    1343                     not numpy.isfinite(res.fitness) or \ 
    1344                     numpy.any(res.pvec == None) or not \ 
    1345                     numpy.all(numpy.isfinite(res.pvec)): 
     1334                    not np.isfinite(res.fitness) or \ 
     1335                        np.any(res.pvec == None) or not \ 
     1336                        np.all(np.isfinite(res.pvec)): 
    13461337                    data_name = str(None) 
    13471338                    if data is not None: 
     
    13521343                    msg += "Data %s and Model %s did not fit.\n" % (data_name, 
    13531344                                                                    model_name) 
    1354                     ERROR = numpy.NAN 
     1345                    ERROR = np.NAN 
    13551346                    cell = BatchCell() 
    13561347                    cell.label = res.fitness 
     
    13661357                            batch_inputs["error on %s" % str(param)].append(ERROR) 
    13671358                else: 
    1368                     # TODO: Why sometimes res.pvec comes with numpy.float64? 
     1359                    # TODO: Why sometimes res.pvec comes with np.float64? 
    13691360                    # probably from scipy lmfit 
    1370                     if res.pvec.__class__ == numpy.float64: 
     1361                    if res.pvec.__class__ == np.float64: 
    13711362                        res.pvec = [res.pvec] 
    13721363 
     
    15201511            page_id = [] 
    15211512        ## fit more than 1 model at the same time 
    1522         self._mac_sleep(0.2) 
    15231513        try: 
    15241514            index = 0 
     
    15331523                fit_msg = res.mesg 
    15341524                if res.fitness is None or \ 
    1535                     not numpy.isfinite(res.fitness) or \ 
    1536                     numpy.any(res.pvec == None) or \ 
    1537                     not numpy.all(numpy.isfinite(res.pvec)): 
     1525                    not np.isfinite(res.fitness) or \ 
     1526                        np.any(res.pvec == None) or \ 
     1527                    not np.all(np.isfinite(res.pvec)): 
    15381528                    fit_msg += "\nFitting did not converge!!!" 
    15391529                    wx.CallAfter(self._update_fit_button, page_id) 
    15401530                else: 
    15411531                    #set the panel when fit result are float not list 
    1542                     if res.pvec.__class__ == numpy.float64: 
     1532                    if res.pvec.__class__ == np.float64: 
    15431533                        pvec = [res.pvec] 
    15441534                    else: 
    15451535                        pvec = res.pvec 
    1546                     if res.stderr.__class__ == numpy.float64: 
     1536                    if res.stderr.__class__ == np.float64: 
    15471537                        stderr = [res.stderr] 
    15481538                    else: 
     
    16921682        if dy is None: 
    16931683            new_plot.is_data = False 
    1694             new_plot.dy = numpy.zeros(len(y)) 
     1684            new_plot.dy = np.zeros(len(y)) 
    16951685            # If this is a theory curve, pick the proper symbol to make it a curve 
    16961686            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
     
    17411731        """ 
    17421732        try: 
    1743             numpy.nan_to_num(y) 
     1733            np.nan_to_num(y) 
    17441734            new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 
    17451735                                             data_description=model.name, 
     
    17551745                                          data_id="Data  " + data.name + " unsmeared", 
    17561746                                          dy=unsmeared_error) 
    1757                  
    1758             if sq_model is not None and pq_model is not None: 
    1759                 self.create_theory_1D(x, sq_model, page_id, model, data, state, 
    1760                                       data_description=model.name + " S(q)", 
    1761                                       data_id=str(page_id) + " " + data.name + " S(q)") 
    1762                 self.create_theory_1D(x, pq_model, page_id, model, data, state, 
    1763                                       data_description=model.name + " P(q)", 
    1764                                       data_id=str(page_id) + " " + data.name + " P(q)") 
    1765  
     1747            # Comment this out until we can get P*S models with correctly populated parameters 
     1748            #if sq_model is not None and pq_model is not None: 
     1749            #    self.create_theory_1D(x, sq_model, page_id, model, data, state, 
     1750            #                          data_description=model.name + " S(q)", 
     1751            #                          data_id=str(page_id) + " " + data.name + " S(q)") 
     1752            #    self.create_theory_1D(x, pq_model, page_id, model, data, state, 
     1753            #                          data_description=model.name + " P(q)", 
     1754            #                          data_id=str(page_id) + " " + data.name + " P(q)") 
    17661755 
    17671756            current_pg = self.fit_panel.get_page_by_id(page_id) 
     
    18261815        that can be plot. 
    18271816        """ 
    1828         numpy.nan_to_num(image) 
     1817        np.nan_to_num(image) 
    18291818        new_plot = Data2D(image=image, err_image=data.err_data) 
    18301819        new_plot.name = model.name + '2d' 
     
    20182007        if data_copy.__class__.__name__ == "Data2D": 
    20192008            if index == None: 
    2020                 index = numpy.ones(len(data_copy.data), dtype=bool) 
     2009                index = np.ones(len(data_copy.data), dtype=bool) 
    20212010            if weight != None: 
    20222011                data_copy.err_data = weight 
    20232012            # get rid of zero error points 
    20242013            index = index & (data_copy.err_data != 0) 
    2025             index = index & (numpy.isfinite(data_copy.data)) 
     2014            index = index & (np.isfinite(data_copy.data)) 
    20262015            fn = data_copy.data[index] 
    20272016            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
     
    20332022            # 1 d theory from model_thread is only in the range of index 
    20342023            if index == None: 
    2035                 index = numpy.ones(len(data_copy.y), dtype=bool) 
     2024                index = np.ones(len(data_copy.y), dtype=bool) 
    20362025            if weight != None: 
    20372026                data_copy.dy = weight 
    20382027            if data_copy.dy == None or data_copy.dy == []: 
    2039                 dy = numpy.ones(len(data_copy.y)) 
     2028                dy = np.ones(len(data_copy.y)) 
    20402029            else: 
    20412030                ## Set consistently w/AbstractFitengine: 
     
    20582047            return 
    20592048 
    2060         residuals = res[numpy.isfinite(res)] 
     2049        residuals = res[np.isfinite(res)] 
    20612050        # get chisqr only w/finite 
    2062         chisqr = numpy.average(residuals * residuals) 
     2051        chisqr = np.average(residuals * residuals) 
    20632052 
    20642053        self._plot_residuals(page_id=page_id, data=data_copy, 
     
    20972086            residuals.qy_data = data_copy.qy_data 
    20982087            residuals.q_data = data_copy.q_data 
    2099             residuals.err_data = numpy.ones(len(residuals.data)) 
     2088            residuals.err_data = np.ones(len(residuals.data)) 
    21002089            residuals.xmin = min(residuals.qx_data) 
    21012090            residuals.xmax = max(residuals.qx_data) 
     
    21112100            # 1 d theory from model_thread is only in the range of index 
    21122101            if data_copy.dy == None or data_copy.dy == []: 
    2113                 dy = numpy.ones(len(data_copy.y)) 
     2102                dy = np.ones(len(data_copy.y)) 
    21142103            else: 
    21152104                if weight == None: 
    2116                     dy = numpy.ones(len(data_copy.y)) 
     2105                    dy = np.ones(len(data_copy.y)) 
    21172106                ## Set consitently w/AbstractFitengine: 
    21182107                ## But this should be corrected later. 
     
    21332122                residuals.y = (fn - gn[index]) / en 
    21342123            residuals.x = data_copy.x[index] 
    2135             residuals.dy = numpy.ones(len(residuals.y)) 
     2124            residuals.dy = np.ones(len(residuals.y)) 
    21362125            residuals.dx = None 
    21372126            residuals.dxl = None 
  • TabularUnified src/sas/sasgui/perspectives/fitting/media/plugin.rst

    r5295cf5 r984f3fc  
    364364  - the limits will show up as the default limits for the fit making it easy, 
    365365    for example, to force the radius to always be greater than zero. 
     366 
     367  - these are hard limits defining the valid range of parameter values; 
     368    polydisperity distributions will be truncated at the limits. 
    366369 
    367370- **"type"** can be one of: "", "sld", "volume", or "orientation". 
  • TabularUnified src/sas/sasgui/perspectives/fitting/model_thread.py

    rc1c9929 r9a5097c  
    44 
    55import time 
    6 import numpy 
     6import numpy as np 
    77import math 
    88from sas.sascalc.data_util.calcthread import CalcThread 
     
    6868 
    6969        # Define matrix where data will be plotted 
    70         radius = numpy.sqrt((self.data.qx_data * self.data.qx_data) + \ 
     70        radius = np.sqrt((self.data.qx_data * self.data.qx_data) + \ 
    7171                    (self.data.qy_data * self.data.qy_data)) 
    7272 
     
    7575        index_model = (self.qmin <= radius) & (radius <= self.qmax) 
    7676        index_model = index_model & self.data.mask 
    77         index_model = index_model & numpy.isfinite(self.data.data) 
     77        index_model = index_model & np.isfinite(self.data.data) 
    7878 
    7979        if self.smearer is not None: 
     
    9191                self.data.qy_data[index_model] 
    9292            ]) 
    93         output = numpy.zeros(len(self.data.qx_data)) 
     93        output = np.zeros(len(self.data.qx_data)) 
    9494        # output default is None 
    9595        # This method is to distinguish between masked 
     
    163163        """ 
    164164        self.starttime = time.time() 
    165         output = numpy.zeros((len(self.data.x))) 
     165        output = np.zeros((len(self.data.x))) 
    166166        index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 
    167167 
     
    175175                                                             self.qmax) 
    176176            mask = self.data.x[first_bin:last_bin+1] 
    177             unsmeared_output = numpy.zeros((len(self.data.x))) 
     177            unsmeared_output = np.zeros((len(self.data.x))) 
    178178            unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 
    179179            self.smearer.model = self.model 
     
    183183            # Check that the arrays are compatible. If we only have a model but no data, 
    184184            # the length of data.y will be zero. 
    185             if isinstance(self.data.y, numpy.ndarray) and output.shape == self.data.y.shape: 
    186                 unsmeared_data = numpy.zeros((len(self.data.x))) 
    187                 unsmeared_error = numpy.zeros((len(self.data.x))) 
     185            if isinstance(self.data.y, np.ndarray) and output.shape == self.data.y.shape: 
     186                unsmeared_data = np.zeros((len(self.data.x))) 
     187                unsmeared_error = np.zeros((len(self.data.x))) 
    188188                unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 
    189189                                                        * unsmeared_output[first_bin:last_bin+1]\ 
     
    209209 
    210210        if p_model is not None and s_model is not None: 
    211             sq_values = numpy.zeros((len(self.data.x))) 
    212             pq_values = numpy.zeros((len(self.data.x))) 
     211            sq_values = np.zeros((len(self.data.x))) 
     212            pq_values = np.zeros((len(self.data.x))) 
    213213            sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
    214214            pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
  • TabularUnified src/sas/sasgui/perspectives/fitting/pagestate.py

    r71601312 red2276f  
    1818import copy 
    1919import logging 
    20 import numpy 
     20import numpy as np 
    2121import traceback 
    2222 
     
    7474                            ["dq_l", "dq_l", "float"], 
    7575                            ["dq_r", "dq_r", "float"], 
    76                             ["dx_max", "dx_max", "float"], 
    77                             ["dx_min", "dx_min", "float"], 
     76                            ["dx_percent", "dx_percent", "float"], 
    7877                            ["dxl", "dxl", "float"], 
    7978                            ["dxw", "dxw", "float"]] 
     
    215214        self.dq_l = None 
    216215        self.dq_r = None 
    217         self.dx_max = None 
    218         self.dx_min = None 
     216        self.dx_percent = None 
     217        self.dx_old = False 
    219218        self.dxl = None 
    220219        self.dxw = None 
     
    343342        obj.dq_l = copy.deepcopy(self.dq_l) 
    344343        obj.dq_r = copy.deepcopy(self.dq_r) 
    345         obj.dx_max = copy.deepcopy(self.dx_max) 
    346         obj.dx_min = copy.deepcopy(self.dx_min) 
     344        obj.dx_percent = copy.deepcopy(self.dx_percent) 
     345        obj.dx_old = copy.deepcopy(self.dx_old) 
    347346        obj.dxl = copy.deepcopy(self.dxl) 
    348347        obj.dxw = copy.deepcopy(self.dxw) 
     
    411410        for fittable, name, value, _, uncert, lower, upper, units in params: 
    412411            if not value: 
    413                 value = numpy.nan 
     412                value = np.nan 
    414413            if not uncert or uncert[1] == '' or uncert[1] == 'None': 
    415414                uncert[0] = False 
    416                 uncert[1] = numpy.nan 
     415                uncert[1] = np.nan 
    417416            if not upper or upper[1] == '' or upper[1] == 'None': 
    418417                upper[0] = False 
    419                 upper[1] = numpy.nan 
     418                upper[1] = np.nan 
    420419            if not lower or lower[1] == '' or lower[1] == 'None': 
    421420                lower[0] = False 
    422                 lower[1] = numpy.nan 
     421                lower[1] = np.nan 
    423422            if is_string: 
    424423                p[name] = str(value) 
     
    450449                lower = params.get(name + ".lower", '-inf') 
    451450                units = params.get(name + ".units") 
    452                 if std is not None and std is not numpy.nan: 
     451                if std is not None and std is not np.nan: 
    453452                    std = [True, str(std)] 
    454453                else: 
    455454                    std = [False, ''] 
    456                 if lower is not None and lower is not numpy.nan: 
     455                if lower is not None and lower is not np.nan: 
    457456                    lower = [True, str(lower)] 
    458457                else: 
    459458                    lower = [True, '-inf'] 
    460                 if upper is not None and upper is not numpy.nan: 
     459                if upper is not None and upper is not np.nan: 
    461460                    upper = [True, str(upper)] 
    462461                else: 
     
    562561        rep += "dq_l  : %s\n" % self.dq_l 
    563562        rep += "dq_r  : %s\n" % self.dq_r 
    564         rep += "dx_max  : %s\n" % str(self.dx_max) 
    565         rep += "dx_min : %s\n" % str(self.dx_min) 
     563        rep += "dx_percent  : %s\n" % str(self.dx_percent) 
    566564        rep += "dxl  : %s\n" % str(self.dxl) 
    567565        rep += "dxw : %s\n" % str(self.dxw) 
     
    821819 
    822820        attr = newdoc.createAttribute("version") 
    823         import sasview 
     821        from sas import sasview 
    824822        attr.nodeValue = sasview.__version__ 
    825823        # attr.nodeValue = '1.0' 
     
    10481046                    setattr(self, item[0], parse_entry_helper(node, item)) 
    10491047 
     1048                dx_old_node = get_content('ns:%s' % 'dx_min', entry) 
    10501049                for item in LIST_OF_STATE_ATTRIBUTES: 
    1051                     node = get_content('ns:%s' % item[0], entry) 
    1052                     setattr(self, item[0], parse_entry_helper(node, item)) 
     1050                    if item[0] == "dx_percent" and dx_old_node is not None: 
     1051                        dxmin = ["dx_min", "dx_min", "float"] 
     1052                        setattr(self, item[0], parse_entry_helper(dx_old_node, 
     1053                                                                  dxmin)) 
     1054                        self.dx_old = True 
     1055                    else: 
     1056                        node = get_content('ns:%s' % item[0], entry) 
     1057                        setattr(self, item[0], parse_entry_helper(node, item)) 
    10531058 
    10541059                for item in LIST_OF_STATE_PARAMETERS: 
     
    10951100                                       % (line, tagname, name)) 
    10961101                                logging.error(msg + traceback.format_exc()) 
    1097                         dic[name] = numpy.array(value_list) 
     1102                        dic[name] = np.array(value_list) 
    10981103                    setattr(self, varname, dic) 
    10991104 
  • TabularUnified src/sas/sasgui/perspectives/fitting/utils.py

    rd85c194 r9a5097c  
    22Module contains functions frequently used in this package 
    33""" 
    4 import numpy 
     4import numpy as np 
    55 
    66 
     
    1919        data = data.y 
    2020    if flag == 0: 
    21         weight = numpy.ones_like(data) 
     21        weight = np.ones_like(data) 
    2222    elif flag == 1: 
    2323        weight = dy_data 
    2424    elif flag == 2: 
    25         weight = numpy.sqrt(numpy.abs(data)) 
     25        weight = np.sqrt(np.abs(data)) 
    2626    elif flag == 3: 
    27         weight = numpy.abs(data) 
     27        weight = np.abs(data) 
    2828    return weight 
  • TabularUnified src/sas/sasgui/perspectives/pr/explore_dialog.py

    rd85c194 r9a5097c  
    1919 
    2020import wx 
    21 import numpy 
     21import numpy as np 
    2222import logging 
    2323import sys 
     
    6565 
    6666        step = (self.max - self.min) / (self.npts - 1) 
    67         self.x = numpy.arange(self.min, self.max + step * 0.01, step) 
    68         dx = numpy.zeros(len(self.x)) 
    69         y = numpy.ones(len(self.x)) 
    70         dy = numpy.zeros(len(self.x)) 
     67        self.x = np.arange(self.min, self.max + step * 0.01, step) 
     68        dx = np.zeros(len(self.x)) 
     69        y = np.ones(len(self.x)) 
     70        dy = np.zeros(len(self.x)) 
    7171 
    7272        # Plot area 
  • TabularUnified src/sas/sasgui/perspectives/pr/pr.py

    ra69a967 r9a5097c  
    2121import time 
    2222import math 
    23 import numpy 
     23import numpy as np 
    2424import pylab 
    2525from sas.sasgui.guiframe.gui_manager import MDIFrame 
     
    207207        r = pylab.arange(0.01, d_max, d_max / 51.0) 
    208208        M = len(r) 
    209         y = numpy.zeros(M) 
    210         pr_err = numpy.zeros(M) 
     209        y = np.zeros(M) 
     210        pr_err = np.zeros(M) 
    211211 
    212212        total = 0.0 
     
    253253        """ 
    254254        # Show P(r) 
    255         y_true = numpy.zeros(len(x)) 
     255        y_true = np.zeros(len(x)) 
    256256 
    257257        sum_true = 0.0 
     
    307307 
    308308        x = pylab.arange(minq, maxq, maxq / 301.0) 
    309         y = numpy.zeros(len(x)) 
    310         err = numpy.zeros(len(x)) 
     309        y = np.zeros(len(x)) 
     310        err = np.zeros(len(x)) 
    311311        for i in range(len(x)): 
    312312            value = pr.iq(out, x[i]) 
     
    337337        if pr.slit_width > 0 or pr.slit_height > 0: 
    338338            x = pylab.arange(minq, maxq, maxq / 301.0) 
    339             y = numpy.zeros(len(x)) 
    340             err = numpy.zeros(len(x)) 
     339            y = np.zeros(len(x)) 
     340            err = np.zeros(len(x)) 
    341341            for i in range(len(x)): 
    342342                value = pr.iq_smeared(out, x[i]) 
     
    382382        x = pylab.arange(0.0, pr.d_max, pr.d_max / self._pr_npts) 
    383383 
    384         y = numpy.zeros(len(x)) 
    385         dy = numpy.zeros(len(x)) 
    386         y_true = numpy.zeros(len(x)) 
     384        y = np.zeros(len(x)) 
     385        dy = np.zeros(len(x)) 
     386        y_true = np.zeros(len(x)) 
    387387 
    388388        total = 0.0 
    389389        pmax = 0.0 
    390         cov2 = numpy.ascontiguousarray(cov) 
     390        cov2 = np.ascontiguousarray(cov) 
    391391 
    392392        for i in range(len(x)): 
     
    480480        """ 
    481481        # Read the data from the data file 
    482         data_x = numpy.zeros(0) 
    483         data_y = numpy.zeros(0) 
    484         data_err = numpy.zeros(0) 
     482        data_x = np.zeros(0) 
     483        data_y = np.zeros(0) 
     484        data_err = np.zeros(0) 
    485485        scale = None 
    486486        min_err = 0.0 
     
    504504                        #err = 0 
    505505 
    506                     data_x = numpy.append(data_x, x) 
    507                     data_y = numpy.append(data_y, y) 
    508                     data_err = numpy.append(data_err, err) 
     506                    data_x = np.append(data_x, x) 
     507                    data_y = np.append(data_y, y) 
     508                    data_err = np.append(data_err, err) 
    509509                except: 
    510510                    logging.error(sys.exc_value) 
     
    528528        """ 
    529529        # Read the data from the data file 
    530         data_x = numpy.zeros(0) 
    531         data_y = numpy.zeros(0) 
    532         data_err = numpy.zeros(0) 
     530        data_x = np.zeros(0) 
     531        data_y = np.zeros(0) 
     532        data_err = np.zeros(0) 
    533533        scale = None 
    534534        min_err = 0.0 
     
    555555                            #err = 0 
    556556 
    557                         data_x = numpy.append(data_x, x) 
    558                         data_y = numpy.append(data_y, y) 
    559                         data_err = numpy.append(data_err, err) 
     557                        data_x = np.append(data_x, x) 
     558                        data_y = np.append(data_y, y) 
     559                        data_err = np.append(data_err, err) 
    560560                    except: 
    561561                        logging.error(sys.exc_value) 
     
    640640        # Now replot the original added data 
    641641        for plot in self._added_plots: 
    642             self._added_plots[plot].y = numpy.copy(self._default_Iq[plot]) 
     642            self._added_plots[plot].y = np.copy(self._default_Iq[plot]) 
    643643            wx.PostEvent(self.parent, 
    644644                         NewPlotEvent(plot=self._added_plots[plot], 
     
    664664        # Now scale the added plots too 
    665665        for plot in self._added_plots: 
    666             total = numpy.sum(self._added_plots[plot].y) 
     666            total = np.sum(self._added_plots[plot].y) 
    667667            npts = len(self._added_plots[plot].x) 
    668668            total *= self._added_plots[plot].x[npts - 1] / npts 
     
    814814        # Save Pr invertor 
    815815        self.pr = pr 
    816         cov = numpy.ascontiguousarray(cov) 
     816        cov = np.ascontiguousarray(cov) 
    817817 
    818818        # Show result on control panel 
     
    982982        all_zeros = True 
    983983        if err == None: 
    984             err = numpy.zeros(len(pr.y)) 
     984            err = np.zeros(len(pr.y)) 
    985985        else: 
    986986            for i in range(len(err)): 
     
    10881088        # If we have not errors, add statistical errors 
    10891089        if y is not None: 
    1090             if err == None or numpy.all(err) == 0: 
    1091                 err = numpy.zeros(len(y)) 
     1090            if err == None or np.all(err) == 0: 
     1091                err = np.zeros(len(y)) 
    10921092                scale = None 
    10931093                min_err = 0.0 
  • TabularUnified src/sas/sasgui/perspectives/simulation/simulation.py

    rd85c194 r9a5097c  
    1010import wx 
    1111import os 
    12 import numpy 
     12import numpy as np 
    1313import time 
    1414import logging 
     
    4646    def compute(self): 
    4747        x = self.x 
    48         output = numpy.zeros(len(x)) 
    49         error = numpy.zeros(len(x)) 
     48        output = np.zeros(len(x)) 
     49        error = np.zeros(len(x)) 
    5050         
    5151        self.starttime = time.time() 
     
    123123        # Q-values for plotting simulated I(Q) 
    124124        step = (self.q_max-self.q_min)/(self.q_npts-1) 
    125         self.x = numpy.arange(self.q_min, self.q_max+step*0.01, step)         
     125        self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 
    126126         
    127127        # Set the list of panels that are part of the simulation perspective 
     
    187187        # Q-values for plotting simulated I(Q) 
    188188        step = (self.q_max-self.q_min)/(self.q_npts-1) 
    189         self.x = numpy.arange(self.q_min, self.q_max+step*0.01, step)     
     189        self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 
    190190          
    191191        # Compute the simulated I(Q) 
  • TabularUnified src/sas/sasgui/plottools/PlotPanel.py

    r198fa76 r9a5097c  
    2929DEFAULT_CMAP = pylab.cm.jet 
    3030import copy 
    31 import numpy 
     31import numpy as np 
    3232 
    3333from sas.sasgui.guiframe.events import StatusEvent 
     
    14521452                if  self.zmin_2D <= 0  and len(output[output > 0]) > 0: 
    14531453                    zmin_temp = self.zmin_2D 
    1454                     output[output > 0] = numpy.log10(output[output > 0]) 
     1454                    output[output > 0] = np.log10(output[output > 0]) 
    14551455                    #In log scale Negative values are not correct in general 
    1456                     #output[output<=0] = math.log(numpy.min(output[output>0])) 
     1456                    #output[output<=0] = math.log(np.min(output[output>0])) 
    14571457                elif self.zmin_2D <= 0: 
    14581458                    zmin_temp = self.zmin_2D 
    1459                     output[output > 0] = numpy.zeros(len(output)) 
     1459                    output[output > 0] = np.zeros(len(output)) 
    14601460                    output[output <= 0] = -32 
    14611461                else: 
    14621462                    zmin_temp = self.zmin_2D 
    1463                     output[output > 0] = numpy.log10(output[output > 0]) 
     1463                    output[output > 0] = np.log10(output[output > 0]) 
    14641464                    #In log scale Negative values are not correct in general 
    1465                     #output[output<=0] = math.log(numpy.min(output[output>0])) 
     1465                    #output[output<=0] = math.log(np.min(output[output>0])) 
    14661466            except: 
    14671467                #Too many problems in 2D plot with scale 
     
    14921492            X = self.x_bins[0:-1] 
    14931493            Y = self.y_bins[0:-1] 
    1494             X, Y = numpy.meshgrid(X, Y) 
     1494            X, Y = np.meshgrid(X, Y) 
    14951495 
    14961496            try: 
     
    15551555        # 1d array to use for weighting the data point averaging 
    15561556        #when they fall into a same bin. 
    1557         weights_data = numpy.ones([self.data.size]) 
     1557        weights_data = np.ones([self.data.size]) 
    15581558        # get histogram of ones w/len(data); this will provide 
    15591559        #the weights of data on each bins 
    1560         weights, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
     1560        weights, xedges, yedges = np.histogram2d(x=self.qy_data, 
    15611561                                                    y=self.qx_data, 
    15621562                                                    bins=[self.y_bins, self.x_bins], 
    15631563                                                    weights=weights_data) 
    15641564        # get histogram of data, all points into a bin in a way of summing 
    1565         image, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
     1565        image, xedges, yedges = np.histogram2d(x=self.qy_data, 
    15661566                                                  y=self.qx_data, 
    15671567                                                  bins=[self.y_bins, self.x_bins], 
     
    15811581        # do while loop until all vacant bins are filled up up 
    15821582        #to loop = max_loop 
    1583         while not(numpy.isfinite(image[weights == 0])).all(): 
     1583        while not(np.isfinite(image[weights == 0])).all(): 
    15841584            if loop >= max_loop:  # this protects never-ending loop 
    15851585                break 
     
    16301630 
    16311631        # store x and y bin centers in q space 
    1632         x_bins = numpy.linspace(xmin, xmax, npix_x) 
    1633         y_bins = numpy.linspace(ymin, ymax, npix_y) 
     1632        x_bins = np.linspace(xmin, xmax, npix_x) 
     1633        y_bins = np.linspace(ymin, ymax, npix_y) 
    16341634 
    16351635        #set x_bins and y_bins 
     
    16501650        """ 
    16511651        # No image matrix given 
    1652         if image == None or numpy.ndim(image) != 2 \ 
    1653                 or numpy.isfinite(image).all() \ 
     1652        if image == None or np.ndim(image) != 2 \ 
     1653                or np.isfinite(image).all() \ 
    16541654                or weights == None: 
    16551655            return image 
     
    16571657        len_y = len(image) 
    16581658        len_x = len(image[1]) 
    1659         temp_image = numpy.zeros([len_y, len_x]) 
    1660         weit = numpy.zeros([len_y, len_x]) 
     1659        temp_image = np.zeros([len_y, len_x]) 
     1660        weit = np.zeros([len_y, len_x]) 
    16611661        # do for-loop for all pixels 
    16621662        for n_y in range(len(image)): 
    16631663            for n_x in range(len(image[1])): 
    16641664                # find only null pixels 
    1665                 if weights[n_y][n_x] > 0 or numpy.isfinite(image[n_y][n_x]): 
     1665                if weights[n_y][n_x] > 0 or np.isfinite(image[n_y][n_x]): 
    16661666                    continue 
    16671667                else: 
    16681668                    # find 4 nearest neighbors 
    16691669                    # check where or not it is at the corner 
    1670                     if n_y != 0 and numpy.isfinite(image[n_y - 1][n_x]): 
     1670                    if n_y != 0 and np.isfinite(image[n_y - 1][n_x]): 
    16711671                        temp_image[n_y][n_x] += image[n_y - 1][n_x] 
    16721672                        weit[n_y][n_x] += 1 
    1673                     if n_x != 0 and numpy.isfinite(image[n_y][n_x - 1]): 
     1673                    if n_x != 0 and np.isfinite(image[n_y][n_x - 1]): 
    16741674                        temp_image[n_y][n_x] += image[n_y][n_x - 1] 
    16751675                        weit[n_y][n_x] += 1 
    1676                     if n_y != len_y - 1 and numpy.isfinite(image[n_y + 1][n_x]): 
     1676                    if n_y != len_y - 1 and np.isfinite(image[n_y + 1][n_x]): 
    16771677                        temp_image[n_y][n_x] += image[n_y + 1][n_x] 
    16781678                        weit[n_y][n_x] += 1 
    1679                     if n_x != len_x - 1 and numpy.isfinite(image[n_y][n_x + 1]): 
     1679                    if n_x != len_x - 1 and np.isfinite(image[n_y][n_x + 1]): 
    16801680                        temp_image[n_y][n_x] += image[n_y][n_x + 1] 
    16811681                        weit[n_y][n_x] += 1 
    16821682                    # go 4 next nearest neighbors when no non-zero 
    16831683                    # neighbor exists 
    1684                     if n_y != 0 and n_x != 0 and\ 
    1685                          numpy.isfinite(image[n_y - 1][n_x - 1]): 
     1684                    if n_y != 0 and n_x != 0 and \ 
     1685                            np.isfinite(image[n_y - 1][n_x - 1]): 
    16861686                        temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 
    16871687                        weit[n_y][n_x] += 1 
    16881688                    if n_y != len_y - 1 and n_x != 0 and \ 
    1689                         numpy.isfinite(image[n_y + 1][n_x - 1]): 
     1689                            np.isfinite(image[n_y + 1][n_x - 1]): 
    16901690                        temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 
    16911691                        weit[n_y][n_x] += 1 
    16921692                    if n_y != len_y and n_x != len_x - 1 and \ 
    1693                         numpy.isfinite(image[n_y - 1][n_x + 1]): 
     1693                            np.isfinite(image[n_y - 1][n_x + 1]): 
    16941694                        temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 
    16951695                        weit[n_y][n_x] += 1 
    16961696                    if n_y != len_y - 1 and n_x != len_x - 1 and \ 
    1697                         numpy.isfinite(image[n_y + 1][n_x + 1]): 
     1697                            np.isfinite(image[n_y + 1][n_x + 1]): 
    16981698                        temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 
    16991699                        weit[n_y][n_x] += 1 
  • TabularUnified src/sas/sasgui/plottools/fitDialog.py

    rdd5bf63 r9a5097c  
    22from plottables import Theory1D 
    33import math 
    4 import numpy 
     4import numpy as np 
    55import fittings 
    66import transform 
     
    482482 
    483483                if self.xLabel.lower() == "log10(x)": 
    484                     tempdy = numpy.asarray(tempdy) 
     484                    tempdy = np.asarray(tempdy) 
    485485                    tempdy[tempdy == 0] = 1 
    486486                    chisqr, out, cov = fittings.sasfit(self.model, 
     
    491491                                                       math.log10(xmax)) 
    492492                else: 
    493                     tempdy = numpy.asarray(tempdy) 
     493                    tempdy = np.asarray(tempdy) 
    494494                    tempdy[tempdy == 0] = 1 
    495495                    chisqr, out, cov = fittings.sasfit(self.model, 
     
    572572        if self.rg_on: 
    573573            if self.Rg_tctr.IsShown(): 
    574                 rg = numpy.sqrt(-3 * float(cstA)) 
     574                rg = np.sqrt(-3 * float(cstA)) 
    575575                value = format_number(rg) 
    576576                self.Rg_tctr.SetValue(value) 
    577577                if self.I0_tctr.IsShown(): 
    578                     val = numpy.exp(cstB) 
     578                    val = np.exp(cstB) 
    579579                    self.I0_tctr.SetValue(format_number(val)) 
    580580            if self.Rgerr_tctr.IsShown(): 
     
    585585                self.Rgerr_tctr.SetValue(value) 
    586586                if self.I0err_tctr.IsShown(): 
    587                     val = numpy.abs(numpy.exp(cstB) * errB) 
     587                    val = np.abs(np.exp(cstB) * errB) 
    588588                    self.I0err_tctr.SetValue(format_number(val)) 
    589589            if self.Diameter_tctr.IsShown(): 
    590                 rg = numpy.sqrt(-2 * float(cstA)) 
    591                 _diam = 4 * numpy.sqrt(-float(cstA)) 
     590                rg = np.sqrt(-2 * float(cstA)) 
     591                _diam = 4 * np.sqrt(-float(cstA)) 
    592592                value = format_number(_diam) 
    593593                self.Diameter_tctr.SetValue(value) 
  • TabularUnified src/sas/sasgui/plottools/plottables.py

    ra9f579c r9a5097c  
    4343# Support for ancient python versions 
    4444import copy 
    45 import numpy 
     45import numpy as np 
    4646import sys 
    4747import logging 
     
    706706                self.dy = None 
    707707            if not has_err_x: 
    708                 dx = numpy.zeros(len(x)) 
     708                dx = np.zeros(len(x)) 
    709709            if not has_err_y: 
    710                 dy = numpy.zeros(len(y)) 
     710                dy = np.zeros(len(y)) 
    711711            for i in range(len(x)): 
    712712                try: 
     
    796796        tempdy = [] 
    797797        if self.dx == None: 
    798             self.dx = numpy.zeros(len(self.x)) 
     798            self.dx = np.zeros(len(self.x)) 
    799799        if self.dy == None: 
    800             self.dy = numpy.zeros(len(self.y)) 
     800            self.dy = np.zeros(len(self.y)) 
    801801        if self.xLabel == "log10(x)": 
    802802            for i in range(len(self.x)): 
     
    826826        tempdy = [] 
    827827        if self.dx == None: 
    828             self.dx = numpy.zeros(len(self.x)) 
     828            self.dx = np.zeros(len(self.x)) 
    829829        if self.dy == None: 
    830             self.dy = numpy.zeros(len(self.y)) 
     830            self.dy = np.zeros(len(self.y)) 
    831831        if self.yLabel == "log10(y)": 
    832832            for i in range(len(self.x)): 
     
    859859        tempdy = [] 
    860860        if self.dx == None: 
    861             self.dx = numpy.zeros(len(self.x)) 
     861            self.dx = np.zeros(len(self.x)) 
    862862        if self.dy == None: 
    863             self.dy = numpy.zeros(len(self.y)) 
     863            self.dy = np.zeros(len(self.y)) 
    864864        if xmin != None and xmax != None: 
    865865            for i in range(len(self.x)): 
     
    12281228 
    12291229def sample_graph(): 
    1230     import numpy as nx 
     1230    import numpy as np 
    12311231 
    12321232    # Construct a simple graph 
    12331233    if False: 
    1234         x = nx.array([1, 2, 3, 4, 5, 6], 'd') 
    1235         y = nx.array([4, 5, 6, 5, 4, 5], 'd') 
    1236         dy = nx.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
     1234        x = np.array([1, 2, 3, 4, 5, 6], 'd') 
     1235        y = np.array([4, 5, 6, 5, 4, 5], 'd') 
     1236        dy = np.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
    12371237    else: 
    1238         x = nx.linspace(0, 1., 10000) 
    1239         y = nx.sin(2 * nx.pi * x * 2.8) 
    1240         dy = nx.sqrt(100 * nx.abs(y)) / 100 
     1238        x = np.linspace(0, 1., 10000) 
     1239        y = np.sin(2 * np.pi * x * 2.8) 
     1240        dy = np.sqrt(100 * np.abs(y)) / 100 
    12411241    data = Data1D(x, y, dy=dy) 
    12421242    data.xaxis('distance', 'm') 
  • TabularUnified test/corfunc/test/utest_corfunc.py

    racefa2b r253eb6c6  
    88from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 
    99from sas.sascalc.dataloader.data_info import Data1D 
    10 import matplotlib.pyplot as plt 
     10 
    1111 
    1212class TestCalculator(unittest.TestCase): 
     
    6969        self.assertLess(abs(params['max']-75), 2.5) # L_p ~= 75 
    7070 
    71  
    7271    # Ensure tests are ran in correct order; 
    7372    # Each test depends on the one before it 
  • TabularUnified test/pr_inversion/test/utest_invertor.py

    rb699768 r9a5097c  
    568568     
    569569def load(path = "sphere_60_q0_2.txt"): 
    570     import numpy, math, sys 
     570    import numpy as np 
     571    import math 
     572    import sys 
    571573    # Read the data from the data file 
    572     data_x   = numpy.zeros(0) 
    573     data_y   = numpy.zeros(0) 
    574     data_err = numpy.zeros(0) 
     574    data_x   = np.zeros(0) 
     575    data_y   = np.zeros(0) 
     576    data_err = np.zeros(0) 
    575577    scale    = None 
    576578    if not path == None: 
     
    589591                        scale = 0.15*math.sqrt(y) 
    590592                    err = scale*math.sqrt(y) 
    591                 data_x = numpy.append(data_x, x) 
    592                 data_y = numpy.append(data_y, y) 
    593                 data_err = numpy.append(data_err, err) 
     593                data_x = np.append(data_x, x) 
     594                data_y = np.append(data_y, y) 
     595                data_err = np.append(data_err, err) 
    594596            except: 
    595597                pass 
  • TabularUnified test/sascalculator/test/utest_sas_gen.py

    ref908db r9a5097c  
    88from sas.sascalc.calculator import sas_gen 
    99 
    10 import numpy 
    11   
    12 import os.path 
    1310 
    1411class sas_gen_test(unittest.TestCase): 
     
    5148        self.assertEqual(output.pos_z[0], 0.0) 
    5249 
     50 
    5351if __name__ == '__main__': 
    5452    unittest.main() 
    55     
     53 
  • TabularUnified test/sasdataloader/plugins/test_reader.py

    rb699768 r9a5097c  
    88copyright 2008, University of Tennessee 
    99""" 
    10 import numpy, os 
     10import os 
     11import numpy as np 
    1112from sas.sascalc.dataloader.data_info import Data1D 
    1213 
     
    4041                buff = input_f.read() 
    4142                lines = buff.split('\n') 
    42                 x  = numpy.zeros(0) 
    43                 y  = numpy.zeros(0) 
    44                 dy = numpy.zeros(0) 
     43                x  = np.zeros(0) 
     44                y  = np.zeros(0) 
     45                dy = np.zeros(0) 
    4546                output = Data1D(x, y, dy=dy) 
    4647                self.filename = output.filename = basename 
    4748            
    4849                for line in lines: 
    49                     x  = numpy.append(x,  float(line))  
     50                    x  = np.append(x,  float(line)) 
    5051                     
    5152                output.x = x 
  • TabularUnified test/sasdataloader/test/utest_abs_reader.py

    r5f26aa4 rdd11014  
    44 
    55import unittest 
    6 import numpy, math 
    7 from sas.sascalc.dataloader.loader import  Loader 
     6import math 
     7import numpy as np 
     8from sas.sascalc.dataloader.loader import Loader 
     9from sas.sascalc.dataloader.readers.IgorReader import Reader as IgorReader 
    810from sas.sascalc.dataloader.data_info import Data1D 
    911  
     
    8688     
    8789    def setUp(self): 
    88         self.data = Loader().load("MAR07232_rest.ASC") 
    89          
     90        # the IgorReader should be able to read this filetype 
     91        # if it can't, stop here. 
     92        reader = IgorReader() 
     93        self.data = reader.read("MAR07232_rest.ASC") 
     94 
    9095    def test_igor_checkdata(self): 
    9196        """ 
     
    108113         
    109114        self.assertEqual(self.data.detector[0].beam_center_unit, 'mm') 
    110         center_x = (68.76-1)*5.0 
    111         center_y = (62.47-1)*5.0 
     115        center_x = (68.76 - 1)*5.0 
     116        center_y = (62.47 - 1)*5.0 
    112117        self.assertEqual(self.data.detector[0].beam_center.x, center_x) 
    113118        self.assertEqual(self.data.detector[0].beam_center.y, center_y) 
    114119         
    115120        self.assertEqual(self.data.I_unit, '1/cm') 
    116         self.assertEqual(self.data.data[0], 0.279783) 
    117         self.assertEqual(self.data.data[1], 0.28951) 
    118         self.assertEqual(self.data.data[2], 0.167634) 
    119          
     121        # 3 points should be suffcient to check that the data is in column 
     122        # major order. 
     123        np.testing.assert_almost_equal(self.data.data[0:3], 
     124                                       [0.279783, 0.28951, 0.167634]) 
     125        np.testing.assert_almost_equal(self.data.qx_data[0:3], 
     126                                       [-0.01849072, -0.01821785, -0.01794498]) 
     127        np.testing.assert_almost_equal(self.data.qy_data[0:3], 
     128                                       [-0.01677435, -0.01677435, -0.01677435]) 
     129 
     130    def test_generic_loader(self): 
     131        # the generic loader should direct the file to IgorReader as well 
     132        data = Loader().load("MAR07232_rest.ASC") 
     133        self.assertEqual(data.meta_data['loader'], "IGOR 2D") 
     134 
     135 
    120136class danse_reader(unittest.TestCase): 
    121137     
     
    313329        from sas.sascalc.dataloader.readers.cansas_reader import Reader 
    314330        r = Reader() 
    315         x = numpy.ones(5) 
    316         y = numpy.ones(5) 
    317         dy = numpy.ones(5) 
     331        x = np.ones(5) 
     332        y = np.ones(5) 
     333        dy = np.ones(5) 
    318334         
    319335        filename = "write_test.xml" 
  • TabularUnified test/sasdataloader/test/utest_averaging.py

    rb699768 r9a5097c  
    11 
    22import unittest 
     3import math 
    34 
    45from sas.sascalc.dataloader.loader import  Loader 
    56from sas.sascalc.dataloader.manipulations import Ring, CircularAverage, SectorPhi, get_q,reader2D_converter 
    6   
    7 import os.path 
    8 import numpy, math 
     7 
     8import numpy as np 
    99import sas.sascalc.dataloader.data_info as data_info 
    1010 
     
    1818            should return the predefined height of the distribution (1.0). 
    1919        """ 
    20         x_0  = numpy.ones([100,100]) 
    21         dx_0 = numpy.ones([100,100]) 
     20        x_0  = np.ones([100,100]) 
     21        dx_0 = np.ones([100,100]) 
    2222         
    2323        self.data = data_info.Data2D(data=x_0, err_data=dx_0) 
     
    4242         
    4343        self.qstep = len(x_0) 
    44         x=  numpy.linspace(start= -1*self.qmax, 
     44        x=  np.linspace(start= -1*self.qmax, 
    4545                               stop= self.qmax, 
    4646                               num= self.qstep, 
    4747                               endpoint=True )   
    48         y = numpy.linspace(start= -1*self.qmax, 
     48        y = np.linspace(start= -1*self.qmax, 
    4949                               stop= self.qmax, 
    5050                               num= self.qstep, 
  • TabularUnified test/sasdataloader/test/utest_cansas.py

    r1686a333 r9a5097c  
    1515import pylint as pylint 
    1616import unittest 
    17 import numpy 
     17import numpy as np 
    1818import logging 
    1919import warnings 
  • TabularUnified test/sasguiframe/test/utest_manipulations.py

    rd85c194 r9a5097c  
    55 
    66import unittest 
    7 import numpy, math 
     7import math 
     8import numpy as np 
    89from sas.sascalc.dataloader.loader import  Loader 
    910from sas.sasgui.guiframe.dataFitting import Data1D, Data2D 
     
    5253    def setUp(self): 
    5354        # Create two data sets to play with 
    54         x_0 = numpy.ones(5) 
     55        x_0 = np.ones(5) 
    5556        for i in range(5): 
    5657            x_0[i] = x_0[i]*(i+1.0) 
    5758             
    58         y_0 = 2.0*numpy.ones(5) 
    59         dy_0 = 0.5*numpy.ones(5) 
     59        y_0 = 2.0*np.ones(5) 
     60        dy_0 = 0.5*np.ones(5) 
    6061        self.data = Data1D(x_0, y_0, dy=dy_0) 
    6162         
    6263        x = self.data.x 
    63         y = numpy.ones(5) 
    64         dy = numpy.ones(5) 
     64        y = np.ones(5) 
     65        dy = np.ones(5) 
    6566        self.data2 = Data1D(x, y, dy=dy) 
    6667         
     
    155156    def setUp(self): 
    156157        # Create two data sets to play with 
    157         x_0 = 2.0*numpy.ones(25) 
    158         dx_0 = 0.5*numpy.ones(25) 
    159         qx_0 = numpy.arange(25) 
    160         qy_0 = numpy.arange(25) 
    161         mask_0 = numpy.zeros(25) 
    162         dqx_0 = numpy.arange(25)/100 
    163         dqy_0 = numpy.arange(25)/100 
    164         q_0 = numpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 
     158        x_0 = 2.0*np.ones(25) 
     159        dx_0 = 0.5*np.ones(25) 
     160        qx_0 = np.arange(25) 
     161        qy_0 = np.arange(25) 
     162        mask_0 = np.zeros(25) 
     163        dqx_0 = np.arange(25)/100 
     164        dqy_0 = np.arange(25)/100 
     165        q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 
    165166        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0,  
    166167                           qy_data=qy_0, q_data=q_0, mask=mask_0,  
    167168                           dqx_data=dqx_0, dqy_data=dqy_0) 
    168169         
    169         y = numpy.ones(25) 
    170         dy = numpy.ones(25) 
    171         qx = numpy.arange(25) 
    172         qy = numpy.arange(25) 
    173         mask = numpy.zeros(25) 
    174         q = numpy.sqrt(qx * qx + qy * qy) 
     170        y = np.ones(25) 
     171        dy = np.ones(25) 
     172        qx = np.arange(25) 
     173        qy = np.arange(25) 
     174        mask = np.zeros(25) 
     175        q = np.sqrt(qx * qx + qy * qy) 
    175176        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy,  
    176177                            q_data=q, mask=mask) 
     
    182183        """ 
    183184        # There should be 5 entries in the file 
    184         self.assertEqual(numpy.size(self.data.data), 25) 
     185        self.assertEqual(np.size(self.data.data), 25) 
    185186         
    186187        for i in range(25): 
     
    263264    def setUp(self): 
    264265        # Create two data sets to play with 
    265         x_0 = 2.0*numpy.ones(25) 
    266         dx_0 = 0.5*numpy.ones(25) 
    267         qx_0 = numpy.arange(25) 
    268         qy_0 = numpy.arange(25) 
    269         mask_0 = numpy.zeros(25) 
    270         dqx_0 = numpy.arange(25)/100 
    271         dqy_0 = numpy.arange(25)/100 
    272         q_0 = numpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 
     266        x_0 = 2.0*np.ones(25) 
     267        dx_0 = 0.5*np.ones(25) 
     268        qx_0 = np.arange(25) 
     269        qy_0 = np.arange(25) 
     270        mask_0 = np.zeros(25) 
     271        dqx_0 = np.arange(25)/100 
     272        dqy_0 = np.arange(25)/100 
     273        q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 
    273274        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0,  
    274275                           qy_data=qy_0, q_data=q_0, mask=mask_0,  
    275276                           dqx_data=dqx_0, dqy_data=dqy_0) 
    276277         
    277         y = numpy.ones(25) 
    278         dy = numpy.ones(25) 
    279         qx = numpy.arange(25) 
    280         qy = numpy.arange(25) 
    281         mask = numpy.zeros(25) 
    282         q = numpy.sqrt(qx * qx + qy * qy) 
     278        y = np.ones(25) 
     279        dy = np.ones(25) 
     280        qx = np.arange(25) 
     281        qy = np.arange(25) 
     282        mask = np.zeros(25) 
     283        q = np.sqrt(qx * qx + qy * qy) 
    283284        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy,  
    284285                            q_data=q, mask=mask) 
     
    290291        """ 
    291292        # There should be 5 entries in the file 
    292         self.assertEqual(numpy.size(self.data.data), 25) 
     293        self.assertEqual(np.size(self.data.data), 25) 
    293294         
    294295        for i in range(25): 
  • TabularUnified test/sasinvariant/test/utest_data_handling.py

    rb699768 r9a5097c  
    99""" 
    1010import unittest 
    11 import numpy, math 
     11import math 
     12import numpy as np 
    1213from sas.sascalc.dataloader.loader import  Loader 
    1314from sas.sascalc.dataloader.data_info import Data1D 
     
    2021    """ 
    2122    def setUp(self): 
    22         x = numpy.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 
    23         y = numpy.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 
     23        x = np.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 
     24        y = np.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 
    2425        dy = y/10.0 
    2526         
     
    135136         
    136137    def test_error_treatment(self): 
    137         x = numpy.asarray(numpy.asarray([0,1,2,3])) 
    138         y = numpy.asarray(numpy.asarray([1,1,1,1])) 
     138        x = np.asarray(np.asarray([0,1,2,3])) 
     139        y = np.asarray(np.asarray([1,1,1,1])) 
    139140         
    140141        # These are all the values of the dy array that would cause 
     
    340341        self.scale = 1.5 
    341342        self.rg = 30.0 
    342         x = numpy.arange(0.0001, 0.1, 0.0001) 
    343         y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
     343        x = np.arange(0.0001, 0.1, 0.0001) 
     344        y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
    344345        dy = y*.1 
    345346        self.data = Data1D(x=x, y=y, dy=dy) 
     
    383384        self.scale = 1.5 
    384385        self.m = 3.0 
    385         x = numpy.arange(0.0001, 0.1, 0.0001) 
    386         y = numpy.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x])                 
     386        x = np.arange(0.0001, 0.1, 0.0001) 
     387        y = np.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x]) 
    387388        dy = y*.1 
    388389        self.data = Data1D(x=x, y=y, dy=dy) 
     
    427428            that can't be transformed 
    428429        """ 
    429         x = numpy.asarray(numpy.asarray([0,1,2,3])) 
    430         y = numpy.asarray(numpy.asarray([1,1,1,1])) 
     430        x = np.asarray(np.asarray([0,1,2,3])) 
     431        y = np.asarray(np.asarray([1,1,1,1])) 
    431432        g = invariant.Guinier() 
    432433        data_in = Data1D(x=x, y=y) 
     
    438439         
    439440    def test_allowed_bins(self): 
    440         x = numpy.asarray(numpy.asarray([0,1,2,3])) 
    441         y = numpy.asarray(numpy.asarray([1,1,1,1])) 
    442         dy = numpy.asarray(numpy.asarray([1,1,1,1])) 
     441        x = np.asarray(np.asarray([0,1,2,3])) 
     442        y = np.asarray(np.asarray([1,1,1,1])) 
     443        dy = np.asarray(np.asarray([1,1,1,1])) 
    443444        g = invariant.Guinier() 
    444445        data = Data1D(x=x, y=y, dy=dy) 
     
    465466        self.scale = 1.5 
    466467        self.rg = 30.0 
    467         x = numpy.arange(0.0001, 0.1, 0.0001) 
    468         y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
     468        x = np.arange(0.0001, 0.1, 0.0001) 
     469        y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
    469470        dy = y*.1 
    470471        self.data = Data1D(x=x, y=y, dy=dy) 
     
    513514        self.scale = 1.5 
    514515        self.rg = 30.0 
    515         x = numpy.arange(0.0001, 0.1, 0.0001) 
    516         y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
     516        x = np.arange(0.0001, 0.1, 0.0001) 
     517        y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 
    517518        dy = y*.1 
    518519        self.data = Data1D(x=x, y=y, dy=dy) 
     
    600601        self.scale = 1.5 
    601602        self.m = 3.0 
    602         x = numpy.arange(0.0001, 0.1, 0.0001) 
    603         y = numpy.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x])                 
     603        x = np.arange(0.0001, 0.1, 0.0001) 
     604        y = np.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x]) 
    604605        dy = y*.1 
    605606        self.data = Data1D(x=x, y=y, dy=dy) 
  • TabularUnified test/sasinvariant/test/utest_use_cases.py

    rb699768 r9a5097c  
    55#TODO: there's no test for smeared extrapolation 
    66import unittest 
    7 import numpy 
    87from sas.sascalc.dataloader.loader import  Loader 
    98 
  • TabularUnified src/sas/sascalc/data_util/registry.py

    rb699768 r270c882b  
    77""" 
    88 
    9 import os.path 
     9from sas.sascalc.dataloader.loader_exceptions import NoKnownLoaderException 
     10 
    1011 
    1112class ExtensionRegistry(object): 
     
    6162    def __init__(self, **kw): 
    6263        self.loaders = {} 
     64 
    6365    def __setitem__(self, ext, loader): 
    6466        if ext not in self.loaders: 
    6567            self.loaders[ext] = [] 
    6668        self.loaders[ext].insert(0,loader) 
     69 
    6770    def __getitem__(self, ext): 
    6871        return self.loaders[ext] 
     72 
    6973    def __contains__(self, ext): 
    7074        return ext in self.loaders 
     75 
    7176    def formats(self): 
    7277        """ 
     
    7681        names.sort() 
    7782        return names 
     83 
    7884    def extensions(self): 
    7985        """ 
     
    8389        exts.sort() 
    8490        return exts 
     91 
    8592    def lookup(self, path): 
    8693        """ 
     
    105112        # Raise an error if there are no matching extensions 
    106113        if len(loaders) == 0: 
    107             raise ValueError, "Unknown file type for "+path 
     114            raise ValueError("Unknown file type for "+path) 
    108115        # All done 
    109116        return loaders 
     117 
    110118    def load(self, path, format=None): 
    111119        """ 
     
    117125        """ 
    118126        if format is None: 
    119             loaders = self.lookup(path) 
     127            try: 
     128                loaders = self.lookup(path) 
     129            except ValueError as e: 
     130                pass 
    120131        else: 
    121             loaders = self.loaders[format] 
     132            try: 
     133                loaders = self.loaders[format] 
     134            except KeyError as e: 
     135                pass 
    122136        for fn in loaders: 
    123137            try: 
    124138                return fn(path) 
    125             except: 
    126                 pass # give other loaders a chance to succeed 
     139            except Exception as e: 
     140                pass  # give other loaders a chance to succeed 
    127141        # If we get here it is because all loaders failed 
    128         raise # reraises last exception 
     142        raise NoKnownLoaderException(e.message)  # raise generic exception 
    129143 
     144 
     145# TODO: Move this to the unit test folder 
    130146def test(): 
    131147    reg = ExtensionRegistry() 
     
    163179    try: reg.load('hello.missing') 
    164180    except ValueError,msg: 
    165         assert str(msg)=="Unknown file type for hello.missing",'Message: <%s>'%(msg) 
     181        assert str(msg)=="Unknown file type for hello.missing",\ 
     182            'Message: <%s>'%(msg) 
    166183    else: raise AssertError,"No error raised for missing extension" 
    167184    assert reg.formats() == ['new_cx'] 
  • TabularUnified src/sas/sascalc/dataloader/loader.py

    rb699768 r270c882b  
    11""" 
    22    File handler to support different file extensions. 
    3     Uses reflectometry's registry utility. 
     3    Uses reflectometer registry utility. 
    44 
    55    The default readers are found in the 'readers' sub-module 
     
    2929# Default readers are defined in the readers sub-module 
    3030import readers 
     31from loader_exceptions import NoKnownLoaderException, FileContentsException 
    3132from readers import ascii_reader 
    3233from readers import cansas_reader 
     34from readers import cansas_reader_HDF5 
     35 
    3336 
    3437class Registry(ExtensionRegistry): 
     
    3740    Readers and writers are supported. 
    3841    """ 
    39  
    4042    def __init__(self): 
    4143        super(Registry, self).__init__() 
    4244 
    43         ## Writers 
     45        # Writers 
    4446        self.writers = {} 
    4547 
    46         ## List of wildcards 
     48        # List of wildcards 
    4749        self.wildcards = ['All (*.*)|*.*'] 
    4850 
    49         ## Creation time, for testing 
     51        # Creation time, for testing 
    5052        self._created = time.time() 
    5153 
     
    6163            of a particular reader 
    6264 
    63         Defaults to the ascii (multi-column) reader 
    64         if no reader was registered for the file's 
    65         extension. 
     65        Defaults to the ascii (multi-column), cansas XML, and cansas NeXuS 
     66        readers if no reader was registered for the file's extension. 
    6667        """ 
    6768        try: 
    6869            return super(Registry, self).load(path, format=format) 
    69         except: 
    70             try: 
    71                 # No reader was found. Default to the ascii reader. 
    72                 ascii_loader = ascii_reader.Reader() 
    73                 return ascii_loader.read(path) 
    74             except: 
    75                 cansas_loader = cansas_reader.Reader() 
    76                 return cansas_loader.read(path) 
     70        except NoKnownLoaderException as e: 
     71            pass  # try the ASCII reader 
     72        except FileContentsException as e: 
     73            pass 
     74        try: 
     75            ascii_loader = ascii_reader.Reader() 
     76            return ascii_loader.read(path) 
     77        except FileContentsException: 
     78            pass  # try the cansas XML reader 
     79        try: 
     80            cansas_loader = cansas_reader.Reader() 
     81            return cansas_loader.read(path) 
     82        except FileContentsException: 
     83            pass  # try the cansas NeXuS reader 
     84        try: 
     85            cansas_nexus_loader = cansas_reader_HDF5.Reader() 
     86            return cansas_nexus_loader.read(path) 
     87        except FileContentsException: 
     88            # No known reader available. Give up and throw an error 
     89            msg = "\n\tUnknown data format: %s.\n\tThe file is not a " % path 
     90            msg += "known format that can be loaded by SasView." 
     91            raise NoKnownLoaderException(msg) 
    7792 
    7893    def find_plugins(self, dir): 
Note: See TracChangeset for help on using the changeset viewer.