Ejemplo n.º 1
0
def test_orisel(): 
    "Check that dipolar models with orientation selection work"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)
    Vmodelorisel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1,orisel=lambda theta: np.ones_like(theta))

    Vref = Vmodel(mean=3,width=0.2,mod=0.3,reftime=0,conc=200,scale=1e2)
    Vorisel = Vmodelorisel(mean=3,width=0.2,mod=0.3,reftime=0,conc=200,scale=1e2)

    assert np.allclose(Vref,Vorisel,rtol=1e-4)
Ejemplo n.º 2
0
def test_preservation(): 
    "Check that the inputs models are not modified by the output model"

    model = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=2)
    model.mean.par0 = 15

    assert model.mean.par0==15 and dd_gauss.mean.par0!=15
Ejemplo n.º 3
0
def test_call_Pnonparametric(): 
    "Check that the model with one dipolar pathway is correct"

    Vmodel = dipolarmodel(t,r,Bmodel=bg_hom3d,npathways=1)
    Vsim = Vmodel(mod=0.3,reftime=0.0,conc=50,P=1e5*dd_gauss(r,3,0.2))

    assert np.allclose(Vsim,V1path)
Ejemplo n.º 4
0
def test_model_1harmonics(): 
    "Check that the model with one harmonic is correct"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1,harmonics=1)
    
    Vsim = Vmodel(mod=0.3,reftime=0.0,conc=50,mean=3,width=0.2,scale=1e5)

    assert np.allclose(Vsim,V1harm)
Ejemplo n.º 5
0
def test_fit_1pathways(): 
    "Check that the model can be correctly fitted with one dipolar pathway"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)
    
    result = fit(Vmodel,V1path,nonlin_tol=1e-3)

    assert np.allclose(result.model,V1path)
Ejemplo n.º 6
0
def test_call_keywords(): 
    "Check that the model called via keyword arguments responds correctly"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)
    
    Vsim = Vmodel(mod=0.3,reftime=0.0,conc=50,mean=3,width=0.2,scale=1e5)

    assert np.allclose(Vsim,V1path)
Ejemplo n.º 7
0
def test_fit_Pnonparametric(): 
    "Check that the model with one dipolar pathway is correct"

    Vmodel = dipolarmodel(t,r,Bmodel=bg_hom3d,npathways=1)
    
    result = fit(Vmodel,V1path,nonlin_tol=1e-5)

    assert ovl(result.P/1e5,Pr)>0.975
Ejemplo n.º 8
0
def test_names(): 
    "Check that the model has correct parameter names"

    model = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)
    parameters = ['mean','width','conc','mod','reftime','scale']
    
    for param in parameters:
        assert hasattr(model,param)
Ejemplo n.º 9
0
def test_phenomenological_Bmodel(): 
    "Check model generation of a dipolar signal with a phenomelogical background"

    Vmodel = dipolarmodel(t,r,dd_gauss,Bmodel=bg_exp,npathways=1)
    
    Vsim = Vmodel(mod=0.3,reftime=0.0,mean=3,width=0.2,decay=0.1,scale=1e5)

    assert np.allclose(Vsim,V1path_phenoB)
Ejemplo n.º 10
0
def test_ex_sifter_fit(): 
    "Check the SIFTER experimental model in fitting."

    experiment = ex_sifter(tau1,tau2)
    Vmodel = dipolarmodel(tsifter,r,Bmodel=bg_hom3d,experiment=experiment)
    result = fit(Vmodel,Vsifter,nonlin_tol=1e-3)

    assert np.allclose(Vsifter,result.model,atol=1e-2) and ovl(result.P/1e5,Pr)>0.975
Ejemplo n.º 11
0
def test_ex_ridme_fit(): 
    "Check the RIDME experimental model in fitting."

    experiment = ex_ridme(tau1,tau2, pathways=[1,2,3])
    Vmodel = dipolarmodel(tridme,r,Bmodel=bg_hom3d,experiment=experiment)
    result = fit(Vmodel,Vridme,nonlin_tol=1e-3)

    assert np.allclose(Vridme,result.model,atol=1e-2) and ovl(result.P/1e5,Pr)>0.975
Ejemplo n.º 12
0
def test_ex_fwd5pdeer_fit(): 
    "Check the forward 5-pulse DEER experimental model in fitting."

    experiment = ex_fwd5pdeer(tau1,tau2,tau3, pathways=[1,2,3])
    Vmodel = dipolarmodel(tdeer,r,Bmodel=bg_hom3d,experiment=experiment)
    result = fit(Vmodel,Vfwd5pdeer,nonlin_tol=1e-3)

    assert np.allclose(Vfwd5pdeer,result.model,atol=1e-2) and ovl(result.P/1e5,Pr)>0.975
Ejemplo n.º 13
0
def test_ex_4pdeer_fit(): 
    "Check the 4-pulse DEER experimental model."

    experiment = ex_4pdeer(tau1,tau2, pathways=[1,2])
    Vmodel = dipolarmodel(tdeer,r,Bmodel=bg_hom3d,experiment=experiment)
    result = fit(Vmodel,V4pdeer,nonlin_tol=1e-3)

    assert np.allclose(V4pdeer,result.model,atol=1e-2) and ovl(result.P/1e5,Pr)>0.975
Ejemplo n.º 14
0
def test_no_Bmodel(): 
    "Check model generation of a dipolar signal without background"

    Vmodel = dipolarmodel(t,r,dd_gauss,None,npathways=1)
    
    Vsim = Vmodel(mod=0.3,reftime=0.0,mean=3,width=0.2,scale=1e5)

    assert np.allclose(Vsim,V1path_noB)
Ejemplo n.º 15
0
def test_call_positional(): 
    "Check that the model called via positional arguments responds correctly"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)
    
    Vsim = Vmodel(0.3,0.0,50,3,0.2,1e5)

    assert np.allclose(Vsim,V1path)
Ejemplo n.º 16
0
def test_model_2harmonics(): 
    "Check that the model with two different harmonics is correct"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=2,harmonics=[1,2])
    
    Vsim = Vmodel(lam1=0.3,reftime1=0.0,lam2=0.1,
                    reftime2=2,conc=50,mean=3,width=0.2,scale=1e5)

    assert np.allclose(Vsim,V2harm)
Ejemplo n.º 17
0
def test_model_3pathways(): 
    "Check that the model with three dipolar pathways is correct"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=3)
    
    Vsim = Vmodel(lam1=0.3,reftime1=0.0,
                lam2=0.1,reftime2=2, lam3=0.1, reftime3=5,
                conc=50,mean=3,width=0.2,scale=1e5)

    assert np.allclose(Vsim,V3path)
Ejemplo n.º 18
0
def test_fit_2pathways(): 
    "Check that the model can be correctly fitted with two dipolar pathways"

    Vmodel = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=2)
    Vmodel.reftime1.freeze(0)
    Vmodel.reftime2.freeze(2)
    
    result = fit(Vmodel,V2path,nonlin_tol=1e-3)

    assert np.allclose(result.model,V2path)
Ejemplo n.º 19
0
def test_ex_5pdeer_fit():
    "Check the 5-pulse DEER experimental model in fitting."

    experiment = ex_5pdeer(tau1, tau2, tau3)
    Vmodel = dipolarmodel(t,
                          r,
                          Bmodel=bg_hom3d,
                          npathways=2,
                          experiment=experiment)
    result = fit(Vmodel, V5pulse, nonlin_tol=1e-3)

    assert np.allclose(V5pulse, result.model,
                       atol=1e-2) and ovl(result.P / 1e5, Pr) > 0.975
Ejemplo n.º 20
0
def test_Nparam_2(): 
    "Check that the function has the correct number of nonlinear parameters"

    model = dipolarmodel(t,r,dd_gauss2,bg_hom3d,npathways=2)

    assert model.Nnonlin==9 and model.Nlin==2 and model.Nparam==11
Ejemplo n.º 21
0
def test_type(): 
    "Check that the function returns a valid model type"

    model = dipolarmodel(t,r,dd_gauss,bg_hom3d,npathways=1)

    assert isinstance(model,Model)