Changeset 5d4777d in sasmodels for sasmodels/bumps_model.py


Ignore:
Timestamp:
Sep 2, 2014 1:24:38 AM (10 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
f4cf580
Parents:
ff7119b
Message:

reorganize, check and update models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/bumps_model.py

    rff7119b r5d4777d  
    140140    import matplotlib.pyplot as plt 
    141141    if hasattr(data, 'qx_data'): 
    142         img = masked_array(iq, data.mask) 
     142        iq = iq[:] 
     143        valid = np.isfinite(iq) 
    143144        if scale == 'log': 
    144             img[(img <= 0) | ~np.isfinite(img)] = masked 
    145             img = np.log10(img) 
     145            valid[valid] = (iq[valid] > 0) 
     146            iq[valid] = np.log10(iq[valid]) 
     147        iq[~valid|data.mask] = 0 
     148        #plottable = iq 
     149        plottable = masked_array(iq, ~valid|data.mask) 
    146150        xmin, xmax = min(data.qx_data), max(data.qx_data) 
    147151        ymin, ymax = min(data.qy_data), max(data.qy_data) 
    148         plt.imshow(img.reshape(128,128), 
     152        plt.imshow(plottable.reshape(128,128), 
    149153                   interpolation='nearest', aspect=1, origin='upper', 
    150154                   extent=[xmin, xmax, ymin, ymax], vmin=vmin, vmax=vmax) 
     
    154158            plt.plot(data.x[idx], iq[idx]) 
    155159        else: 
    156             idx = np.isfinite(iq) & (iq>0) 
     160            idx = np.isfinite(iq) 
     161            idx[idx] = (iq[idx]>0) 
    157162            plt.loglog(data.x[idx], iq[idx]) 
    158163 
     
    228233    def __init__(self, data, model, cutoff=1e-5, **kw): 
    229234        from bumps.names import Parameter 
     235        partype = model.info['partype'] 
    230236 
    231237        # interpret data 
     
    236242            self.diq = data.err_data[self.index] 
    237243            self._theory = np.zeros_like(data.data) 
    238             q_vectors = [data.qx_data, data.qy_data] 
     244            if not partype['orientation'] and not partype['magnetic']: 
     245                q_vectors = [np.sqrt(data.qx_data**2+data.qy_data**2)] 
     246            else: 
     247                q_vectors = [data.qx_data, data.qy_data] 
    239248        else: 
    240249            self.index = (data.x>=data.qmin) & (data.x<=data.qmax) & ~np.isnan(data.y) 
     
    258267            setattr(self, name, Parameter.default(value, name=name, limits=limits)) 
    259268            pars.append(name) 
    260         for name in model.info['partype']['pd-2d']: 
     269        for name in partype['pd-2d']: 
    261270            for xpart,xdefault,xlimits in [ 
    262271                    ('_pd', 0, limits), 
Note: See TracChangeset for help on using the changeset viewer.