Changes in / [e44432d:be43e39] in sasmodels
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
rfb7c176 r610ef23 367 367 368 368 # Limit magnetic SLDs to a smaller range, from zero to iron=5/A^2 369 if par.name. startswith('M0:'):369 if par.name.endswith('_M0'): 370 370 return np.random.uniform(0, 5) 371 371 … … 537 537 magnetic_pars = [] 538 538 for p in parameters.user_parameters(pars, is2d): 539 if any(p.id. startswith(x) for x in ('M0:', 'mtheta:', 'mphi:')):539 if any(p.id.endswith(x) for x in ('_M0', '_mtheta', '_mphi')): 540 540 continue 541 541 if p.id.startswith('up:'): … … 549 549 pdtype=pars.get(p.id+"_pd_type", 'gaussian'), 550 550 relative_pd=p.relative_pd, 551 M0=pars.get( 'M0:'+p.id, 0.),552 mphi=pars.get( 'mphi:'+p.id, 0.),553 mtheta=pars.get( 'mtheta:'+p.id, 0.),551 M0=pars.get(p.id+'_M0', 0.), 552 mphi=pars.get(p.id+'_mphi', 0.), 553 mtheta=pars.get(p.id+'_mtheta', 0.), 554 554 ) 555 555 lines.append(_format_par(p.name, **fields)) … … 617 617 if suppress: 618 618 for p in pars: 619 if p. startswith("M0:"):619 if p.endswith("_M0"): 620 620 pars[p] = 0 621 621 else: … … 623 623 first_mag = None 624 624 for p in pars: 625 if p. startswith("M0:"):625 if p.endswith("_M0"): 626 626 any_mag |= (pars[p] != 0) 627 627 if first_mag is None: -
sasmodels/convert.py
ra69d8cd r610ef23 165 165 if version == (3, 1, 2): 166 166 oldpars = _hand_convert_3_1_2_to_4_1(name, oldpars) 167 if version < (4, 2, 0): 168 oldpars = _rename_magnetic_pars(oldpars) 167 169 return oldpars 170 171 def _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 168 186 169 187 def _hand_convert_3_1_2_to_4_1(name, oldpars): -
sasmodels/modelinfo.py
re44432d re44432d 463 463 self.is_asymmetric = any(p.name == 'psi' for p in self.kernel_parameters) 464 464 self.magnetism_index = [k for k, p in enumerate(self.call_parameters) 465 if p.id.startswith('M0:')] 465 if p.id.endswith('_M0')] 466 466 467 self.pd_1d = set(p.name for p in self.call_parameters 467 468 if p.polydisperse and p.type not in ('orientation', 'magnetic')) … … 582 583 if self.nmagnetic > 0: 583 584 full_list.extend([ 584 Parameter('up :frac_i', '', 0., [0., 1.],585 Parameter('up_frac_i', '', 0., [0., 1.], 585 586 'magnetic', 'fraction of spin up incident'), 586 Parameter('up :frac_f', '', 0., [0., 1.],587 Parameter('up_frac_f', '', 0., [0., 1.], 587 588 'magnetic', 'fraction of spin up final'), 588 Parameter('up :angle', 'degrees', 0., [0., 360.],589 Parameter('up_angle', 'degrees', 0., [0., 360.], 589 590 'magnetic', 'spin up angle'), 590 591 ]) … … 592 593 for p in slds: 593 594 full_list.extend([ 594 Parameter( 'M0:'+p.id, '1e-6/Ang^2', 0., [-np.inf, np.inf],595 Parameter(p.id+'_M0', '1e-6/Ang^2', 0., [-np.inf, np.inf], 595 596 'magnetic', 'magnetic amplitude for '+p.description), 596 Parameter( 'mtheta:'+p.id, 'degrees', 0., [-90., 90.],597 Parameter(p.id+'_mtheta', 'degrees', 0., [-90., 90.], 597 598 'magnetic', 'magnetic latitude for '+p.description), 598 Parameter( 'mphi:'+p.id, 'degrees', 0., [-180., 180.],599 Parameter(p.id+'_mphi', 'degrees', 0., [-180., 180.], 599 600 'magnetic', 'magnetic longitude for '+p.description), 600 601 ]) … … 636 637 637 638 Parameters marked as sld will automatically have a set of associated 638 magnetic parameters ( m0:p, mtheta:p, mphi:p), as well as polarization639 information (up :theta, up:frac_i, up:frac_f).639 magnetic parameters (p_M0, p_mtheta, p_mphi), as well as polarization 640 information (up_theta, up_frac_i, up_frac_f). 640 641 """ 641 642 # control parameters go first … … 664 665 result.append(expanded_pars[name]) 665 666 if is2d: 666 for tag in ' M0:', 'mtheta:', 'mphi:':667 if tag+namein expanded_pars:668 result.append(expanded_pars[ tag+name])667 for tag in '_M0', '_mtheta', '_mphi': 668 if name+tag in expanded_pars: 669 result.append(expanded_pars[name+tag]) 669 670 670 671 # Gather the user parameters in order … … 699 700 append_group(p.id) 700 701 701 if is2d and 'up :angle' in expanded_pars:702 if is2d and 'up_angle' in expanded_pars: 702 703 result.extend([ 703 expanded_pars['up :frac_i'],704 expanded_pars['up :frac_f'],705 expanded_pars['up :angle'],704 expanded_pars['up_frac_i'], 705 expanded_pars['up_frac_f'], 706 expanded_pars['up_angle'], 706 707 ]) 707 708 … … 1023 1024 for k in range(control+1, p.length+1) 1024 1025 if p.length > 1) 1026 for p in self.parameters.kernel_parameters: 1027 if p.length > 1 and p.type == "sld": 1028 for k in range(control+1, p.length+1): 1029 base = p.id+str(k) 1030 hidden.update((base+"_M0", base+"_mtheta", base+"_mphi")) 1025 1031 return hidden -
sasmodels/sasview_model.py
re44432d re44432d 383 383 hidden.add('background') 384 384 self._model_info.parameters.defaults['background'] = 0. 385 386 # Update the parameter lists to exclude any hidden parameters 387 self.magnetic_params = tuple(pname for pname in self.magnetic_params 388 if pname not in hidden) 389 self.orientation_params = tuple(pname for pname in self.orientation_params 390 if pname not in hidden) 385 391 386 392 self._persistency_dict = {} … … 905 911 Model = _make_standard_model('sphere') 906 912 model = Model() 907 model.setParam(' M0:sld', 8)913 model.setParam('sld_M0', 8) 908 914 q = np.linspace(-0.35, 0.35, 500) 909 915 qx, qy = np.meshgrid(q, q)
Note: See TracChangeset
for help on using the changeset viewer.