Changes in / [6e5c0b7:933af72] in sasmodels


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • LICENSE.txt

    rf68e2a5 rc8de1bd  
    1 Copyright (c) 2009-2017, SasView Developers 
    2 All rights reserved. 
     1This program is in the public domain. 
    32 
    4 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
    5  
    6 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
    7  
    8 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
    9  
    10 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
    11  
    12 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     3Individual files may be copyright different authors, with licences that 
     4allow modification and redistribution in source or binary form with or 
     5without modification, and a disclaimer of warranty. 
  • sasmodels/compare.py

    rc4e3215 r01ea374  
    3030 
    3131import sys 
    32 import os 
    3332import math 
    3433import datetime 
     
    4140from . import kerneldll 
    4241from . import exception 
    43 from .data import plot_theory, empty_data1D, empty_data2D, load_data 
     42from .data import plot_theory, empty_data1D, empty_data2D 
    4443from .direct_model import DirectModel 
    4544from .convert import revert_name, revert_pars, constrain_new_to_old 
     
    8685    -help/-html shows the model docs instead of running the model 
    8786    -title="note" adds note to the plot title, after the model name 
    88     -data="path" uses q, dq from the data file 
    8987 
    9088Any two calculation engines can be selected for comparison: 
     
    749747    comp = opts['engines'][1] if have_comp else None 
    750748    data = opts['data'] 
    751     use_data = have_base ^ have_comp 
    752749 
    753750    # Plot if requested 
     
    766763    if have_base: 
    767764        if have_comp: plt.subplot(131) 
    768         plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
     765        plot_theory(data, base_value, view=view, use_data=False, limits=limits) 
    769766        plt.title("%s t=%.2f ms"%(base.engine, base_time)) 
    770767        #cbar_title = "log I" 
     
    772769        if have_base: plt.subplot(132) 
    773770        if not opts['is2d'] and have_base: 
    774             plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
    775         plot_theory(data, comp_value, view=view, use_data=use_data, limits=limits) 
     771            plot_theory(data, base_value, view=view, use_data=False, limits=limits) 
     772        plot_theory(data, comp_value, view=view, use_data=False, limits=limits) 
    776773        plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 
    777774        #cbar_title = "log I" 
     
    787784            err[err>cutoff] = cutoff 
    788785        #err,errstr = base/comp,"ratio" 
    789         plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
     786        plot_theory(data, None, resid=err, view=errview, use_data=False) 
    790787        if view == 'linear': 
    791788            plt.xscale('linear') 
     
    837834VALUE_OPTIONS = [ 
    838835    # Note: random is both a name option and a value option 
    839     'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 'data', 
     836    'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 
    840837    ] 
    841838 
     
    954951        'html'      : False, 
    955952        'title'     : None, 
    956         'data'      : None, 
    957953    } 
    958954    engines = [] 
     
    975971        elif arg.startswith('-cutoff='):   opts['cutoff'] = float(arg[8:]) 
    976972        elif arg.startswith('-random='):   opts['seed'] = int(arg[8:]) 
    977         elif arg.startswith('-title='):    opts['title'] = arg[7:] 
    978         elif arg.startswith('-data='):     opts['data'] = arg[6:] 
     973        elif arg.startswith('-title'):     opts['title'] = arg[7:] 
    979974        elif arg == '-random':  opts['seed'] = np.random.randint(1000000) 
    980975        elif arg == '-preset':  opts['seed'] = -1 
     
    11181113 
    11191114    # Create the computational engines 
    1120     if opts['data'] is not None: 
    1121         data = load_data(os.path.expanduser(opts['data'])) 
    1122     else: 
    1123         data, _ = make_data(opts) 
     1115    data, _ = make_data(opts) 
    11241116    if n1: 
    11251117        base = make_engine(model_info, data, engines[0], opts['cutoff']) 
     
    11511143    show html docs for the model 
    11521144    """ 
    1153     import os 
    1154     from .generate import make_html 
    1155     from . import rst2html 
    1156  
    1157     info = opts['def'][0] 
    1158     html = make_html(info) 
    1159     path = os.path.dirname(info.filename) 
    1160     url = "file://"+path.replace("\\","/")[2:]+"/" 
    1161     rst2html.view_html_qtapp(html, url) 
     1145    import wx  # type: ignore 
     1146    from .generate import view_html_from_info 
     1147    app = wx.App() if wx.GetApp() is None else None 
     1148    view_html_from_info(opts['def'][0]) 
     1149    if app: app.MainLoop() 
     1150 
    11621151 
    11631152def explore(opts): 
  • sasmodels/data.py

    ra769b54 r40a87fa  
    5454    if data is None: 
    5555        raise IOError("Data %r could not be loaded" % filename) 
    56     if hasattr(data, 'x'): 
    57         data.qmin, data.qmax = data.x.min(), data.x.max() 
    58         data.mask = (np.isnan(data.y) if data.y is not None 
    59                      else np.zeros_like(data.x, dtype='bool')) 
    6056    return data 
    6157 
     
    352348    # data, but they already handle the masking and graph markup already, so 
    353349    # do not repeat. 
    354     if hasattr(data, 'isSesans') and data.isSesans: 
     350    if hasattr(data, 'lam'): 
    355351        _plot_result_sesans(data, None, None, use_data=True, limits=limits) 
    356352    elif hasattr(data, 'qx_data'): 
     
    380376    *Iq_calc* is the raw theory values without resolution smearing 
    381377    """ 
    382     if hasattr(data, 'isSesans') and data.isSesans: 
     378    if hasattr(data, 'lam'): 
    383379        _plot_result_sesans(data, theory, resid, use_data=True, limits=limits) 
    384380    elif hasattr(data, 'qx_data'): 
  • sasmodels/direct_model.py

    ra769b54 rb397165  
    192192 
    193193        # interpret data 
    194         if hasattr(data, 'isSesans') and data.isSesans: 
     194        if hasattr(data, 'lam'): 
    195195            self.data_type = 'sesans' 
    196196        elif hasattr(data, 'qx_data'): 
  • sasmodels/generate.py

    rc4e3215 r1e7b0db0  
    928928    from . import rst2html 
    929929    url = "file://"+dirname(info.filename)+"/" 
    930     rst2html.view_html(make_html(info), url=url) 
     930    rst2html.wxview(make_html(info), url=url) 
    931931 
    932932def demo_time(): 
  • sasmodels/rst2html.py

    rc4e3215 r0890871  
    2929from docutils.writers.html4css1 import HTMLTranslator 
    3030from docutils.nodes import SkipNode 
     31 
     32def wxview(html, url="", size=(850, 540)): 
     33    import wx 
     34    from wx.html2 import WebView 
     35    frame = wx.Frame(None, -1, size=size) 
     36    view = WebView.New(frame) 
     37    view.SetPage(html, url) 
     38    frame.Show() 
     39    return frame 
     40 
     41def view_rst(filename): 
     42    from os.path import expanduser 
     43    with open(expanduser(filename)) as fid: 
     44        rst = fid.read() 
     45    html = rst2html(rst) 
     46    wxview(html) 
    3147 
    3248def rst2html(rst, part="whole", math_output="mathjax"): 
     
    139155    assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a" 
    140156 
    141 def load_rst_as_html(filename): 
    142     from os.path import expanduser 
    143     with open(expanduser(filename)) as fid: 
    144         rst = fid.read() 
    145     html = rst2html(rst) 
    146     return html 
    147  
    148 def wxview(html, url="", size=(850, 540)): 
    149     import wx 
    150     from wx.html2 import WebView 
    151     frame = wx.Frame(None, -1, size=size) 
    152     view = WebView.New(frame) 
    153     view.SetPage(html, url) 
    154     frame.Show() 
    155     return frame 
    156  
    157 def qtview(html, url=""): 
    158     try: 
    159         from PyQt5.QtWebKitWidgets import QWebView 
    160         from PyQt5.QtCore import QUrl 
    161     except ImportError: 
    162         from PyQt4.QtWebkit import QWebView 
    163         from PyQt4.QtCore import QUrl 
    164     helpView = QWebView() 
    165     helpView.setHtml(html, QUrl(url)) 
    166     helpView.show() 
    167     return helpView 
    168  
    169 def view_html_wxapp(html, url=""): 
     157def view_rst_app(filename): 
    170158    import wx  # type: ignore 
    171159    app = wx.App() 
    172     frame = wxview(html, url) 
     160    view_rst(filename) 
    173161    app.MainLoop() 
    174162 
    175 def view_html_qtapp(html, url=""): 
    176     import sys 
    177     try: 
    178         from PyQt5.QtWidgets import QApplication 
    179     except ImportError: 
    180         from PyQt4.QtGui import QApplication 
    181     app = QApplication([]) 
    182     frame = qtview(html, url) 
    183     sys.exit(app.exec_()) 
    184  
    185 def view_rst_app(filename, qt=False): 
    186     import os 
    187     html = load_rst_as_html(filename) 
    188     url="file://"+os.path.abspath(filename)+"/" 
    189     if qt: 
    190         view_html_qtapp(html, url) 
    191     else: 
    192         view_html_wxapp(html, url) 
    193163 
    194164if __name__ == "__main__": 
    195165    import sys 
    196     view_rst_app(sys.argv[1], qt=True) 
     166    view_rst_app(sys.argv[1]) 
    197167 
Note: See TracChangeset for help on using the changeset viewer.