Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/beta/sasfit_compare.py

    rcdd676e r01c8d9e  
    11from __future__ import division, print_function 
    22# Make sasmodels available on the path 
    3 import sys, os 
     3import sys,os 
    44BETA_DIR = os.path.dirname(os.path.realpath(__file__)) 
    5 SASMODELS_DIR = os.path.dirname(os.path.dirname(BETA_DIR)) 
     5#SASMODELS_DIR = os.path.dirname(os.path.dirname(BETA_DIR)) 
     6SASMODELS_DIR = r"C:\Source\sasmodels" 
    67sys.path.insert(0, SASMODELS_DIR) 
    7  
     8import os 
    89from collections import namedtuple 
    910 
     
    6162    calculator = DirectModel(data, model,cutoff=0) 
    6263    calculator.pars = pars.copy() 
    63     calculator.pars.setdefault('background', 1e-3) 
     64    calculator.pars.setdefault('background', 0) 
    6465    return calculator 
    6566 
     
    222223    if radius_effective is None: 
    223224        radius_effective = radius_eff/total_weight 
     225    print("this is the effective radius for pure python",radius_effective) 
    224226    if norm == 'sasfit': 
    225227        IQD = F2 
     
    230232        #     = F2/total_weight / total_volume/total_weight 
    231233        #     = F2/total_volume 
     234         
    232235        IQD = F2/average_volume*1e-4*volfraction 
     236        F1 *= 1e-2  # Yun is using sld in 1/A^2, not 1e-6/A^2 
     237        F2 *= 1e-4 
    233238    elif norm == 'yun': 
    234239        F1 *= 1e-6  # Yun is using sld in 1/A^2, not 1e-6/A^2 
     
    240245    IQSD = IQD*SQ 
    241246    IQBD = IQD*SQ_EFF 
     247    print("\n\n\n\n\n this is F1" + str(F1)) 
     248 
     249    print("\n\n\n\n\n this is F2" + str(F2)) 
     250    print("\n\n\n\n\n this is SQ" + str(SQ))    
    242251    return Theory(Q=q, F1=F1, F2=F2, P=IQD, S=SQ, I=IQSD, Seff=SQ_EFF, Ibeta=IQBD) 
    243252 
     
    331340            Ipars.setdefault(k.replace("_pd_type", "_pd_nsigma"), nsigmas) 
    332341 
     342     
    333343    #Ppars['scale'] = Spars.get('volfraction', 1) 
    334344    P = build_model(Pname, q) 
     
    336346    I = build_model(Pname+"@hardsphere", q) 
    337347    Pq = P(**Ppars)*pars.get('volfraction', 1) 
    338     #Sq = S(**Spars) 
     348    Sq = S(**Spars) 
    339349    Iq = I(**Ipars) 
    340350    #Iq = Pq*Sq*pars.get('volfraction', 1) 
    341     Sq = Iq/Pq 
    342     return Theory(Q=q, F1=None, F2=None, P=Pq, S=Sq, I=Iq, Seff=None, Ibeta=None) 
     351    #Sq = Iq/Pq 
     352    #Iq = None#= Sq = None 
     353    r=I._kernel.results 
     354    return Theory(Q=q, F1=None, F2=None, P=Pq, S=None, I=None, Seff=r[1], Ibeta=Iq) 
    343355 
    344356def compare(title, target, actual, fields='F1 F2 P S I Seff Ibeta'): 
     
    400412        radius_equatorial_pd=.1, radius_equatorial_pd_type=pd_type, 
    401413        volfraction=0.15, 
     414        radius_effective=270.7543927018, 
    402415        #radius_effective=12.59921049894873, 
    403416        ) 
    404     target = sasmodels_theory(q, model, **pars) 
     417    target = sasmodels_theory(q, model, beta_mode=1, **pars) 
    405418    actual = ellipsoid_pe(q, norm='sasview', **pars) 
     419    print(actual) 
    406420    title = " ".join(("sasmodels", model, pd_type)) 
    407421    compare(title, target, actual) 
     
    446460    Q = data[0] 
    447461    F1 = data[1] 
    448     F2 = data[2] 
    449462    P = data[3] 
    450463    S = data[5] 
    451464    Seff = data[6] 
    452     target = Theory(Q=Q, F1=F1, F2=F2, P=P, S=S, Seff=Seff) 
     465    target = Theory(Q=Q, F1=F1, P=P, S=S, Seff=Seff) 
    453466    actual = sphere_r(Q, norm='yun', **pars) 
    454467    title = " ".join(("yun", "sphere", "10% dispersion 10% Vf")) 
     
    458471    Q = data[0] 
    459472    F1 = data[1] 
    460     F2 = data[2] 
    461473    P = data[3] 
    462474    S = data[5] 
    463475    Seff = data[6] 
    464     target = Theory(Q=Q, F1=F1, F2=F2, P=P, S=S, Seff=Seff) 
     476    target = Theory(Q=Q, F1=F1, P=P, S=S, Seff=Seff) 
    465477    actual = sphere_r(Q, norm='yun', **pars) 
    466478    title = " ".join(("yun", "sphere", "15% dispersion 10% Vf")) 
Note: See TracChangeset for help on using the changeset viewer.