Changeset ced5bd2 in sasmodels


Ignore:
Timestamp:
Oct 4, 2017 6:26:41 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:
2573fa1
Parents:
18a2bfc
Message:

allow -q=min:max on the sascomp command line

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rb76191e rced5bd2  
    7373    -res=0 sets the resolution width dQ/Q if calculating with resolution 
    7474    -lowq*/-midq/-highq/-exq use q values up to 0.05, 0.2, 1.0, 10.0 
     75    -q=min:max alternative specification of qrange 
    7576    -nq=128 sets the number of Q points in the data set 
    7677    -1d*/-2d computes 1d or 2d data 
     
    768769    'accuracy', 'is2d' and 'view' parsed from the command line. 
    769770    """ 
    770     qmax, nq, res = opts['qmax'], opts['nq'], opts['res'] 
     771    qmin, qmax, nq, res = opts['qmin'], opts['qmax'], opts['nq'], opts['res'] 
    771772    if opts['is2d']: 
    772773        q = np.linspace(-qmax, qmax, nq)  # type: np.ndarray 
     
    777778    else: 
    778779        if opts['view'] == 'log' and not opts['zero']: 
    779             qmax = math.log10(qmax) 
    780             q = np.logspace(qmax-3, qmax, nq) 
     780            q = np.logspace(math.log10(qmin), math.log10(qmax), nq) 
    781781        else: 
    782             q = np.linspace(0.001*qmax, qmax, nq) 
     782            q = np.linspace(qmin, qmax, nq) 
    783783        if opts['zero']: 
    784784            q = np.hstack((0, q)) 
     
    955955        else: 
    956956            err, errstr, errview = abs(relerr), "rel err", "log" 
     957            if (err == 0.).all(): 
     958                errview = 'linear' 
    957959        if 0:  # 95% cutoff 
    958960            sorted = np.sort(err.flatten()) 
     
    960962            err[err > cutoff] = cutoff 
    961963        #err,errstr = base/comp,"ratio" 
    962         plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
    963         if view == 'linear': 
    964             plt.xscale('linear') 
     964        plot_theory(data, None, resid=err, view=view, use_data=use_data) 
     965        plt.yscale(errview) 
    965966        plt.title("max %s = %.3g"%(errstr, abs(err).max())) 
    966967        #cbar_title = errstr if errview=="linear" else "log "+errstr 
     
    10011002 
    10021003    # Data generation 
    1003     'data=', 'noise=', 'res=', 
    1004     'nq=', 'lowq', 'midq', 'highq', 'exq', 'zero', 
     1004    'data=', 'noise=', 'res=', 'nq=', 'q=', 
     1005    'lowq', 'midq', 'highq', 'exq', 'zero', 
    10051006    '2d', '1d', 
    10061007 
     
    11221123        'view'      : 'log', 
    11231124        'is2d'      : False, 
     1125        'qmin'      : None, 
    11241126        'qmax'      : 0.05, 
    11251127        'nq'        : 128, 
     
    11591161        elif arg == '-zero':    opts['zero'] = True 
    11601162        elif arg.startswith('-nq='):       opts['nq'] = int(arg[4:]) 
     1163        elif arg.startswith('-q='): 
     1164            opts['qmin'], opts['qmax'] = [float(v) for v in arg[3:].split(':')] 
    11611165        elif arg.startswith('-res='):      opts['res'] = float(arg[5:]) 
    11621166        elif arg.startswith('-noise='):    opts['noise'] = float(arg[7:]) 
     
    12071211 
    12081212    # Create the computational engines 
     1213    if opts['qmin'] is None: 
     1214        opts['qmin'] = 0.001*opts['qmax'] 
    12091215    if opts['datafile'] is not None: 
    12101216        data = load_data(os.path.expanduser(opts['datafile'])) 
  • sasmodels/data.py

    r630156b rced5bd2  
    438438 
    439439    scale = data.x**4 if view == 'q4' else 1.0 
     440    xscale = yscale = 'linear' if view == 'linear' else 'log' 
    440441 
    441442    if use_data or use_theory: 
     
    470471            plt.ylim(*limits) 
    471472 
    472         plt.xscale('linear' if not some_present or non_positive_x 
    473                    else view if view is not None 
    474                    else 'log') 
    475         plt.yscale('linear' 
    476                    if view == 'q4' or not some_present or not all_positive 
    477                    else view if view is not None 
    478                    else 'log') 
     473 
     474        xscale = ('linear' if not some_present or non_positive_x 
     475                  else view if view is not None 
     476                  else 'log') 
     477        yscale = ('linear' 
     478                  if view == 'q4' or not some_present or not all_positive 
     479                  else view if view is not None 
     480                  else 'log') 
     481        plt.xscale(xscale) 
    479482        plt.xlabel("$q$/A$^{-1}$") 
     483        plt.yscale(yscale) 
    480484        plt.ylabel('$I(q)$') 
    481485        title = ("data and model" if use_theory and use_data 
     
    505509        plt.xlabel("$q$/A$^{-1}$") 
    506510        plt.ylabel('residuals') 
    507         plt.xscale('linear') 
    508511        plt.title('(model - Iq)/dIq') 
     512        plt.xscale(xscale) 
     513        plt.yscale('linear') 
    509514 
    510515 
Note: See TracChangeset for help on using the changeset viewer.