Changeset 353e899 in sasmodels
 Timestamp:
 Oct 4, 2018 4:39:39 AM (4 years ago)
 Branches:
 master, core_shell_microgels, magnetic_model, ticket1257vesicleproduct, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
 Children:
 e2592f0, c11d09f, fba9ca0, dcc51ee, 74bcfe9
 Parents:
 a1ec908 (diff), e39202b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.  gitauthor:
 Wojciech Potrzebowski <Wojciech.Potrzebowski@…> (10/04/18 04:39:39)
 gitcommitter:
 GitHub <noreply@…> (10/04/18 04:39:39)
 Location:
 sasmodels
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

sasmodels/compare.py
rbd7630d r610ef23 368 368 369 369 # 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'): 371 371 return np.random.uniform(0, 5) 372 372 … … 538 538 magnetic_pars = [] 539 539 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')): 541 541 continue 542 542 if p.id.startswith('up:'): … … 550 550 pdtype=pars.get(p.id+"_pd_type", 'gaussian'), 551 551 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.), 555 555 ) 556 556 lines.append(_format_par(p.name, **fields)) … … 618 618 if suppress: 619 619 for p in pars: 620 if p. startswith("M0:"):620 if p.endswith("_M0"): 621 621 pars[p] = 0 622 622 else: … … 624 624 first_mag = None 625 625 for p in pars: 626 if p. startswith("M0:"):626 if p.endswith("_M0"): 627 627 any_mag = (pars[p] != 0) 628 628 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
rd321747 rbd547d0 466 466 self.is_asymmetric = any(p.name == 'psi' for p in self.kernel_parameters) 467 467 self.magnetism_index = [k for k, p in enumerate(self.call_parameters) 468 if p.id. startswith('M0:')]468 if p.id.endswith('_M0')] 469 469 470 470 self.pd_1d = set(p.name for p in self.call_parameters … … 586 586 if self.nmagnetic > 0: 587 587 full_list.extend([ 588 Parameter('up :frac_i', '', 0., [0., 1.],588 Parameter('up_frac_i', '', 0., [0., 1.], 589 589 'magnetic', 'fraction of spin up incident'), 590 Parameter('up :frac_f', '', 0., [0., 1.],590 Parameter('up_frac_f', '', 0., [0., 1.], 591 591 'magnetic', 'fraction of spin up final'), 592 Parameter('up :angle', 'degrees', 0., [0., 360.],592 Parameter('up_angle', 'degrees', 0., [0., 360.], 593 593 'magnetic', 'spin up angle'), 594 594 ]) … … 596 596 for p in slds: 597 597 full_list.extend([ 598 Parameter( 'M0:'+p.id, '1e6/Ang^2', 0., [np.inf, np.inf],598 Parameter(p.id+'_M0', '1e6/Ang^2', 0., [np.inf, np.inf], 599 599 'magnetic', 'magnetic amplitude for '+p.description), 600 Parameter( 'mtheta:'+p.id, 'degrees', 0., [90., 90.],600 Parameter(p.id+'_mtheta', 'degrees', 0., [90., 90.], 601 601 'magnetic', 'magnetic latitude for '+p.description), 602 Parameter( 'mphi:'+p.id, 'degrees', 0., [180., 180.],602 Parameter(p.id+'_mphi', 'degrees', 0., [180., 180.], 603 603 'magnetic', 'magnetic longitude for '+p.description), 604 604 ]) … … 640 640 641 641 Parameters marked as sld will automatically have a set of associated 642 magnetic parameters ( m0:p, mtheta:p, mphi:p), as well as polarization643 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). 644 644 """ 645 645 # control parameters go first … … 668 668 result.append(expanded_pars[name]) 669 669 if is2d: 670 for tag in ' M0:', 'mtheta:', 'mphi:':671 if tag+namein 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]) 673 673 674 674 # Gather the user parameters in order … … 703 703 append_group(p.id) 704 704 705 if is2d and 'up :angle' in expanded_pars:705 if is2d and 'up_angle' in expanded_pars: 706 706 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'], 710 710 ]) 711 711 … … 1016 1016 for k in range(control+1, p.length+1) 1017 1017 if p.length > 1) 1018 for p in self.parameters.kernel_parameters: 1019 if p.length > 1 and p.type == "sld": 1020 for k in range(control+1, p.length+1): 1021 base = p.id+str(k) 1022 hidden.update((base+"_M0", base+"_mtheta", base+"_mphi")) 1018 1023 return hidden 
sasmodels/sasview_model.py
rd321747 rbd547d0 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 = {} … … 884 890 Model = _make_standard_model('sphere') 885 891 model = Model() 886 model.setParam(' M0:sld', 8)892 model.setParam('sld_M0', 8) 887 893 q = np.linspace(0.35, 0.35, 500) 888 894 qx, qy = np.meshgrid(q, q)
Note: See TracChangeset
for help on using the changeset viewer.