Changeset 610ef23 in sasmodels


Ignore:
Timestamp:
Oct 3, 2018 10:07:52 AM (5 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:
e39202b, bd547d0
Parents:
a1ec908
Message:

rename magnetic parameters to not contain colon. Refs #1188

Location:
sasmodels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rbd7630d r610ef23  
    368368 
    369369    # Limit magnetic SLDs to a smaller range, from zero to iron=5/A^2 
    370     if par.name.startswith('M0:'): 
     370    if par.name.endswith('_M0'): 
    371371        return np.random.uniform(0, 5) 
    372372 
     
    538538    magnetic_pars = [] 
    539539    for p in parameters.user_parameters(pars, is2d): 
    540         if any(p.id.startswith(x) for x in ('M0:', 'mtheta:', 'mphi:')): 
     540        if any(p.id.endswith(x) for x in ('_M0', '_mtheta', '_mphi')): 
    541541            continue 
    542542        if p.id.startswith('up:'): 
     
    550550            pdtype=pars.get(p.id+"_pd_type", 'gaussian'), 
    551551            relative_pd=p.relative_pd, 
    552             M0=pars.get('M0:'+p.id, 0.), 
    553             mphi=pars.get('mphi:'+p.id, 0.), 
    554             mtheta=pars.get('mtheta:'+p.id, 0.), 
     552            M0=pars.get(p.id+'_M0', 0.), 
     553            mphi=pars.get(p.id+'_mphi', 0.), 
     554            mtheta=pars.get(p.id+'_mtheta', 0.), 
    555555        ) 
    556556        lines.append(_format_par(p.name, **fields)) 
     
    618618    if suppress: 
    619619        for p in pars: 
    620             if p.startswith("M0:"): 
     620            if p.endswith("_M0"): 
    621621                pars[p] = 0 
    622622    else: 
     
    624624        first_mag = None 
    625625        for p in pars: 
    626             if p.startswith("M0:"): 
     626            if p.endswith("_M0"): 
    627627                any_mag |= (pars[p] != 0) 
    628628                if first_mag is None: 
  • sasmodels/convert.py

    ra69d8cd r610ef23  
    165165    if version == (3, 1, 2): 
    166166        oldpars = _hand_convert_3_1_2_to_4_1(name, oldpars) 
     167    if version < (4, 2, 0): 
     168        oldpars = _rename_magnetic_pars(oldpars) 
    167169    return oldpars 
     170 
     171def _rename_magnetic_pars(pars): 
     172    """ 
     173    Change from M0:par to par_M0, etc. 
     174    """ 
     175    keys = list(pars.items()) 
     176    for k in keys: 
     177        if k.startswith('M0:'): 
     178            pars[k[3:]+'_M0'] = pars.pop(k) 
     179        elif k.startswith('mtheta:'): 
     180            pars[k[7:]+'_mtheta'] = pars.pop(k) 
     181        elif k.startswith('mphi:'): 
     182            pars[k[5:]+'_mphi'] = pars.pop(k) 
     183        elif k.startswith('up:'): 
     184            pars['up_'+k[3:]] = pars.pop(k) 
     185    return pars 
    168186 
    169187def _hand_convert_3_1_2_to_4_1(name, oldpars): 
  • sasmodels/modelinfo.py

    rd321747 r610ef23  
    466466        self.is_asymmetric = any(p.name == 'psi' for p in self.kernel_parameters) 
    467467        self.magnetism_index = [k for k, p in enumerate(self.call_parameters) 
    468                                 if p.id.startswith('M0:')] 
     468                                if p.id.endswith('_M0')] 
    469469 
    470470        self.pd_1d = set(p.name for p in self.call_parameters 
     
    586586        if self.nmagnetic > 0: 
    587587            full_list.extend([ 
    588                 Parameter('up:frac_i', '', 0., [0., 1.], 
     588                Parameter('up_frac_i', '', 0., [0., 1.], 
    589589                          'magnetic', 'fraction of spin up incident'), 
    590                 Parameter('up:frac_f', '', 0., [0., 1.], 
     590                Parameter('up_frac_f', '', 0., [0., 1.], 
    591591                          'magnetic', 'fraction of spin up final'), 
    592                 Parameter('up:angle', 'degrees', 0., [0., 360.], 
     592                Parameter('up_angle', 'degrees', 0., [0., 360.], 
    593593                          'magnetic', 'spin up angle'), 
    594594            ]) 
     
    596596            for p in slds: 
    597597                full_list.extend([ 
    598                     Parameter('M0:'+p.id, '1e-6/Ang^2', 0., [-np.inf, np.inf], 
     598                    Parameter(p.id+'_M0', '1e-6/Ang^2', 0., [-np.inf, np.inf], 
    599599                              'magnetic', 'magnetic amplitude for '+p.description), 
    600                     Parameter('mtheta:'+p.id, 'degrees', 0., [-90., 90.], 
     600                    Parameter(p.id+'_mtheta', 'degrees', 0., [-90., 90.], 
    601601                              'magnetic', 'magnetic latitude for '+p.description), 
    602                     Parameter('mphi:'+p.id, 'degrees', 0., [-180., 180.], 
     602                    Parameter(p.id+'_mphi', 'degrees', 0., [-180., 180.], 
    603603                              'magnetic', 'magnetic longitude for '+p.description), 
    604604                ]) 
     
    640640 
    641641        Parameters marked as sld will automatically have a set of associated 
    642         magnetic parameters (m0:p, mtheta:p, mphi:p), as well as polarization 
    643         information (up:theta, up:frac_i, up:frac_f). 
     642        magnetic parameters (p_M0, p_mtheta, p_mphi), as well as polarization 
     643        information (up_theta, up_frac_i, up_frac_f). 
    644644        """ 
    645645        # control parameters go first 
     
    668668            result.append(expanded_pars[name]) 
    669669            if is2d: 
    670                 for tag in 'M0:', 'mtheta:', 'mphi:': 
    671                     if tag+name in expanded_pars: 
    672                         result.append(expanded_pars[tag+name]) 
     670                for tag in '_M0', '_mtheta', '_mphi': 
     671                    if name+tag in expanded_pars: 
     672                        result.append(expanded_pars[name+tag]) 
    673673 
    674674        # Gather the user parameters in order 
     
    703703                append_group(p.id) 
    704704 
    705         if is2d and 'up:angle' in expanded_pars: 
     705        if is2d and 'up_angle' in expanded_pars: 
    706706            result.extend([ 
    707                 expanded_pars['up:frac_i'], 
    708                 expanded_pars['up:frac_f'], 
    709                 expanded_pars['up:angle'], 
     707                expanded_pars['up_frac_i'], 
     708                expanded_pars['up_frac_f'], 
     709                expanded_pars['up_angle'], 
    710710            ]) 
    711711 
  • sasmodels/sasview_model.py

    rd321747 r610ef23  
    884884    Model = _make_standard_model('sphere') 
    885885    model = Model() 
    886     model.setParam('M0:sld', 8) 
     886    model.setParam('sld_M0', 8) 
    887887    q = np.linspace(-0.35, 0.35, 500) 
    888888    qx, qy = np.meshgrid(q, q) 
Note: See TracChangeset for help on using the changeset viewer.