Changeset fbb9397 in sasmodels


Ignore:
Timestamp:
Oct 18, 2017 6:11:37 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3c24ccd
Parents:
32f87a5
Message:

fix handling of value limits on plots

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r8698a0d rfbb9397  
    827827    parameters. 
    828828    """ 
    829     limits = np.Inf, -np.Inf 
    830829    for k in range(opts['sets']): 
    831830        opts['pars'] = parse_pars(opts) 
     
    838837        import matplotlib.pyplot as plt 
    839838        plt.show() 
     839    return limits 
    840840 
    841841def run_models(opts, verbose=False): 
     
    912912 
    913913 
    914 def plot_models(opts, result, limits=(np.Inf, -np.Inf), setnum=0): 
     914def plot_models(opts, result, limits=None, setnum=0): 
    915915    # type: (Dict[str, Any], Dict[str, Any], Optional[Tuple[float, float]]) -> Tuple[float, float] 
     916    import matplotlib.pyplot as plt 
     917 
    916918    base_value, comp_value = result['base_value'], result['comp_value'] 
    917919    base_time, comp_time = result['base_time'], result['comp_time'] 
     
    925927    # Plot if requested 
    926928    view = opts['view'] 
    927     import matplotlib.pyplot as plt 
    928     vmin, vmax = limits 
    929     if have_base: 
    930         vmin = min(vmin, base_value.min()) 
    931         vmax = max(vmax, base_value.max()) 
    932     if have_comp: 
    933         vmin = min(vmin, comp_value.min()) 
    934         vmax = max(vmax, comp_value.max()) 
    935     limits = vmin, vmax 
     929    if limits is None: 
     930        vmin, vmax = np.inf, -np.inf 
     931        if have_base: 
     932            vmin = min(vmin, base_value.min()) 
     933            vmax = max(vmax, base_value.max()) 
     934        if have_comp: 
     935            vmin = min(vmin, comp_value.min()) 
     936            vmax = max(vmax, comp_value.max()) 
     937        limits = vmin, vmax 
    936938 
    937939    if have_base: 
     
    14231425        self.starting_values = dict((k, v.value) for k, v in pars.items()) 
    14241426        self.pd_types = pd_types 
    1425         self.limits = np.Inf, -np.Inf 
     1427        self.limits = None 
    14261428 
    14271429    def revert_values(self): 
  • sasmodels/data.py

    r09141ff rfbb9397  
    646646    ymin, ymax = min(data.qy_data), max(data.qy_data) 
    647647    if view == 'log': 
    648         vmin, vmax = np.log10(vmin), np.log10(vmax) 
     648        vmin_scaled, vmax_scaled= np.log10(vmin), np.log10(vmax) 
     649    else: 
     650        vmin_scaled, vmax_scaled = vmin, vmax 
    649651    plt.imshow(plottable.reshape(len(data.x_bins), len(data.y_bins)), 
    650652               interpolation='nearest', aspect=1, origin='lower', 
    651                extent=[xmin, xmax, ymin, ymax], vmin=vmin, vmax=vmax) 
     653               extent=[xmin, xmax, ymin, ymax], 
     654               vmin=vmin_scaled, vmax=vmax_scaled) 
    652655    plt.xlabel("$q_x$/A$^{-1}$") 
    653656    plt.ylabel("$q_y$/A$^{-1}$") 
Note: See TracChangeset for help on using the changeset viewer.