예제 #1
0
def test_mode_close():
    #============================================================
    "Check the basic behaviour correcting a phased signal with phase closest to average"

    V = np.arange(100)
    Vphased = V * np.exp(-1j * 4 / 7 * pi)
    Vcorr = correctphase(Vphased, phase='close')

    assert max(np.real(V) - np.real(Vcorr)) < 1e-4
예제 #2
0
def test_mode_negrealint():
    #============================================================
    "Check the basic behaviour correcting a phased signal with maximal negative real integral"

    V = np.arange(100)
    Vphased = V * np.exp(-1j * 8 / 7 * pi)
    Vcorr = correctphase(Vphased, phase='negrealint')

    assert max(np.real(V) - np.real(-Vcorr)) < 1e-4
예제 #3
0
def test_basics():
    #============================================================
    "Check the basic behaviour correcting a phased signal"

    V = np.arange(100)
    Vphased = V * np.exp(-1j * 4 / 7 * pi)
    Vcorr = correctphase(Vphased)

    assert max(np.real(V) - np.real(Vcorr)) < 1e-4
예제 #4
0
def test_phase_fit():
    #============================================================
    "Check that the phase shift is correctly fitted"

    V = np.arange(100)
    phase = 4 / 7 * pi
    Vphased = V * np.exp(-1j * phase)
    _, _, phase_fit = correctphase(Vphased, full_output=True)

    assert abs(phase - phase_fit) < 1e-4
예제 #5
0
def test_multiple_datasets():
    #============================================================
    "Check that the phase correction works when passing multiple datasets"

    V = np.tile(np.arange(100), (20, 1)).T
    phases = np.mod(np.linspace(-3 * pi / 4, pi / 2, 20), pi)
    Vphased = V * np.exp(-1j * phases)

    Vcorr = correctphase(Vphased)

    assert np.max(np.real(V) - np.real(Vcorr)) < 1e-4
are narrower in comparison to the ones obtained via the curvature
matrices. This is because bootstrapping takes the nonnegativity constraint of P(r) into
account, whereas the curvature matrix CIs do not. 
"""

import numpy as np
import matplotlib.pyplot as plt
import deerlab as dl

# %%

# Load the experimental data
t, Vexp = np.load('../data/example_data_#1.npy')

# Pre-process
Vexp = dl.correctphase(Vexp)
Vexp = Vexp / np.max(Vexp)

# Distance vector
r = np.linspace(2, 5.5, 80)

# Construct the 4-pulse DEER dipolar model
Vmodel = dl.dipolarmodel(t, r)
Vmodel.reftime.set(par0=0.5, lb=0.0, ub=1.0)

# Fit the model to the data using covariane-based uncertainty
fit_cm = dl.fit(Vmodel, Vexp)

# Fit the model to the data using bootstrapped uncertainty
fit_bs = dl.fit(Vmodel, Vexp, bootstrap=10)
""" 
# %%

# Import the required libraries
import numpy as np
import matplotlib.pyplot as plt
import deerlab as dl


# %%
    
# Load the experimental dataset
t,V = np.load('../data/example_data_#1.npy')

# Pre-process
V = dl.correctphase(V)
V = V/np.max(V)

# Construct the dipolar signal model
r = np.linspace(1,7,100)
Vmodel = dl.dipolarmodel(t,r)

# Fit the model to the data
fit = dl.fit(Vmodel,V)
fit.plot(axis=t)
plt.ylabel('V(t)')
plt.xlabel('Time $t$ (μs)')
plt.show()

# From the fit results, extract the distribution and the covariance matrix
Pfit = fit.P