Changeset a769b54 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
Feb 8, 2017 2:58:46 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c
Parents:
1105286
Message:

allow sascomp with -data=filename to set q,dq from file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rfe25eda ra769b54  
    3030 
    3131import sys 
     32import os 
    3233import math 
    3334import datetime 
     
    4041from . import kerneldll 
    4142from . import exception 
    42 from .data import plot_theory, empty_data1D, empty_data2D 
     43from .data import plot_theory, empty_data1D, empty_data2D, load_data 
    4344from .direct_model import DirectModel 
    4445from .convert import revert_name, revert_pars, constrain_new_to_old 
     
    8586    -html shows the model docs instead of running the model 
    8687    -title="note" adds note to the plot title, after the model name 
     88    -data="path" uses q, dq from the data file 
    8789 
    8890Any two calculation engines can be selected for comparison: 
     
    747749    comp = opts['engines'][1] if have_comp else None 
    748750    data = opts['data'] 
     751    use_data = have_base ^ have_comp 
    749752 
    750753    # Plot if requested 
     
    763766    if have_base: 
    764767        if have_comp: plt.subplot(131) 
    765         plot_theory(data, base_value, view=view, use_data=False, limits=limits) 
     768        plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
    766769        plt.title("%s t=%.2f ms"%(base.engine, base_time)) 
    767770        #cbar_title = "log I" 
     
    769772        if have_base: plt.subplot(132) 
    770773        if not opts['is2d'] and have_base: 
    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) 
     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) 
    773776        plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 
    774777        #cbar_title = "log I" 
     
    784787            err[err>cutoff] = cutoff 
    785788        #err,errstr = base/comp,"ratio" 
    786         plot_theory(data, None, resid=err, view=errview, use_data=False) 
     789        plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
    787790        if view == 'linear': 
    788791            plt.xscale('linear') 
     
    834837VALUE_OPTIONS = [ 
    835838    # Note: random is both a name option and a value option 
    836     'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 
     839    'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 'data', 
    837840    ] 
    838841 
     
    951954        'html'      : False, 
    952955        'title'     : None, 
     956        'data'      : None, 
    953957    } 
    954958    engines = [] 
     
    971975        elif arg.startswith('-cutoff='):   opts['cutoff'] = float(arg[8:]) 
    972976        elif arg.startswith('-random='):   opts['seed'] = int(arg[8:]) 
    973         elif arg.startswith('-title'):     opts['title'] = arg[7:] 
     977        elif arg.startswith('-title='):    opts['title'] = arg[7:] 
     978        elif arg.startswith('-data='):     opts['data'] = arg[6:] 
    974979        elif arg == '-random':  opts['seed'] = np.random.randint(1000000) 
    975980        elif arg == '-preset':  opts['seed'] = -1 
     
    11121117 
    11131118    # Create the computational engines 
    1114     data, _ = make_data(opts) 
     1119    if opts['data'] is not None: 
     1120        data = load_data(os.path.expanduser(opts['data'])) 
     1121    else: 
     1122        data, _ = make_data(opts) 
    11151123    if n1: 
    11161124        base = make_engine(model_info, data, engines[0], opts['cutoff']) 
Note: See TracChangeset for help on using the changeset viewer.