Example #1
0
def create_corr():
    corr = Correlation()

    tau = np.exp(np.linspace(np.log(1e-3),np.log(1e6), 10))
    data = corr.fit_model(corr.fit_parameters, tau)
    noise = (np.random.random(data.shape[0])-.5)*.0005
    data += noise

    corr.correlation = np.dstack((tau, data))[0]
    return corr
Example #2
0
def create_corr():
    corr = Correlation()

    tau = np.exp(np.linspace(np.log(1e-3), np.log(1e6), 10))
    data = corr.fit_model(corr.fit_parameters, tau)
    noise = (np.random.random(data.shape[0]) - .5) * .0005
    data += noise

    corr.correlation = np.dstack((tau, data))[0]
    return corr
Example #3
0
def fit_single_parameter(modelid, fullparms, parmid, parmval, noise=False):
    """
    Use the full parameter set `fullparms` and leave a single parameter
    `parmid` variable during the fit.
    Returns the fitted value of the parameter with index `parmid`
    """
    corr = Correlation(fit_model=modelid, fit_algorithm=FITALG, verbose=0)
    tau = np.exp(np.linspace(np.log(TAUMIN),np.log(TAUMAX), TAULEN))
    # Create artificial data by using the current fit_model
    data = corr.fit_model(fullparms, tau)
    if noise:
        if noise is True:
            deltanoise = (np.max(data)-np.min(data))/20
        else:
            deltanoise = (np.max(data)-np.min(data))*noise
        anoise = (np.random.random(data.shape[0])-.5)*deltanoise
        data += anoise
    # Add artificial data to data set
    corr.correlation = np.dstack((tau, data))[0]
    # Set variable parameters
    fit_bool = np.zeros(fullparms.shape[0])
    fit_bool[parmid] = True
    corr.fit_parameters_variable = fit_bool
    fullparms_edit = fullparms.copy()
    fullparms_edit[parmid] = parmval
    corr.fit_parameters = fullparms_edit
    Fit(corr)
    return corr.fit_parameters[parmid]
Example #4
0
def create_corr():
    n = 2.4
    taud = 10
    SP = 3.3
    tau = np.exp(np.linspace(np.log(1e-3), np.log(1e6), 10))
    corr1 = Correlation(fit_model=6002)
    corr1.lag_time = tau
    # 0: n
    # 1: τ_diff [ms]
    p1a = corr1.fit_parameters.copy()
    p1b = p1a.copy()
    p1b[0] = n
    p1b[1] = taud
    # write values and return to original
    corr1.fit_parameters = p1b
    corr1.correlation = corr1.modeled_fit.copy()
    corr1.fit_parameters = p1a
    corr1.fit_parameters_variable = [True, True, False, False, False]

    corr2 = Correlation(fit_model=6011)
    corr2.lag_time = tau
    # 0: n
    # 3: τ_diff [ms]
    # 4: SP
    p2a = corr2.fit_parameters.copy()
    p2b = p2a.copy()
    p2b[0] = n
    p2b[3] = taud
    p2b[4] = SP
    # write values and return to original
    corr2.fit_parameters = p2b
    corr2.correlation = corr2.modeled_fit.copy()
    corr2.fit_parameters = p2a
    corr2.fit_parameters_variable = [True, False, False, True, True, False]

    corrs = [corr1, corr2]
    initparms = np.array([n, taud, SP])

    return corrs, initparms
def create_corr():
    n = 2.4
    taud = 10
    SP = 3.3
    tau = np.exp(np.linspace(np.log(1e-3), np.log(1e6), 10))
    corr1 = Correlation(fit_model=6002)
    corr1.lag_time = tau
    # 0: n
    # 1: τ_diff [ms]
    p1a = corr1.fit_parameters.copy()
    p1b = p1a.copy()
    p1b[0] = n
    p1b[1] = taud
    # write values and return to original
    corr1.fit_parameters = p1b
    corr1.correlation = corr1.modeled_fit.copy()
    corr1.fit_parameters = p1a
    corr1.fit_parameters_variable = [True, True, False, False, False]

    corr2 = Correlation(fit_model=6011)
    corr2.lag_time = tau
    # 0: n
    # 3: τ_diff [ms]
    # 4: SP
    p2a = corr2.fit_parameters.copy()
    p2b = p2a.copy()
    p2b[0] = n
    p2b[3] = taud
    p2b[4] = SP
    # write values and return to original
    corr2.fit_parameters = p2b
    corr2.correlation = corr2.modeled_fit.copy()
    corr2.fit_parameters = p2a
    corr2.fit_parameters_variable = [True, False, False, True, True, False]

    corrs = [corr1, corr2]
    initparms = np.array([n, taud, SP])

    return corrs, initparms