예제 #1
0
def metrastat_model(exp_data,
                    initial_conditions,
                    rate_constants,
                    refine_extended=False,
                    one_set_params=False):

    start = time()

    # refine data to remove faulty data points, and store in a single list
    all_times = []
    all_YI = []

    for data in exp_data:
        sample = pandas.read_csv(data, index_col='Time')
        sample = sample.dropna()

        if refine_extended:
            new_YI, new_time = refine_YI(sample, extended=True)
        else:
            new_YI, new_time = refine_YI(sample)

        # update the single list that will be used in the fitting
        all_times.append(new_time)
        all_YI.append(new_YI)

    # fit using only one set of parameters
    if one_set_params:
        quadratic, params, error = fit_experimental(all_times,
                                                    all_YI,
                                                    initial_conditions,
                                                    rate_constants,
                                                    one_set_params=True)

    # fit each curve individually
    else:
        params = []
        error = []
        quadratic = []

        for i in range(len(exp_data)):
            quadratic_temp, params_temp, error_temp = \
                fit_experimental(all_times[i], all_YI[i],
                                 initial_conditions[i], rate_constants[i])

            # update results
            params.append(params_temp)
            error.append(error_temp)
            quadratic.append(quadratic_temp)

    stop = time()
    print "elapsed time = %f min" % ((stop - start) / 60)
    return [params, error, quadratic, all_times, all_YI]
예제 #2
0
def metrastat_model(exp_data, initial_conditions, rate_constants,
                    refine_extended=False, one_set_params=False):

    start = time()

    # refine data to remove faulty data points, and store in a single list
    all_times = []
    all_YI = []

    for data in exp_data:
        sample = pandas.read_csv(data, index_col='Time')
        sample = sample.dropna()

        if refine_extended:
                new_YI, new_time = refine_YI(sample, extended=True)
        else:
            new_YI, new_time = refine_YI(sample)

        # update the single list that will be used in the fitting
        all_times.append(new_time)
        all_YI.append(new_YI)

    # fit using only one set of parameters
    if one_set_params:
        quadratic, params, error = fit_experimental(all_times, all_YI,
                                                    initial_conditions,
                                                    rate_constants,
                                                    one_set_params=True)

    # fit each curve individually
    else:
        params = []
        error = []
        quadratic = []

        for i in range(len(exp_data)):
            quadratic_temp, params_temp, error_temp = \
                fit_experimental(all_times[i], all_YI[i],
                                 initial_conditions[i], rate_constants[i])

            # update results
            params.append(params_temp)
            error.append(error_temp)
            quadratic.append(quadratic_temp)

    stop = time()
    print "elapsed time = %f min" % ((stop - start)/60)
    return [params, error, quadratic, all_times, all_YI]
예제 #3
0
# load initial conditions
all_initial = get_initial('Reinhard Fit/')

# load rate constants
all_constants = get_constants('Reinhard Fit/')

k12 = 0

Mg = [20.1, 110.4, 90.7, -39, -3.2]
Ca = [27.6, 101.6, 78.4, -34.1, 18.3]

for i, data in enumerate(exp_data):
    # simulate the metrastat
    sample = pd.read_csv(data, index_col='Time')
    sample.dropna()
    YI, time = refine_YI(sample)

    constants = all_constants[i]
    initial = all_initial[i]

    conc = odeint(metrastat, initial, time, args=(k12, constants))
    conc_mat = array(conc, dtype=float)

    fit = Mg[0]*conc_mat[:,1] + \
          Mg[1]*conc_mat[:,5] + \
          Mg[2]*conc_mat[:,6] + \
          Mg[3]*conc_mat[:,5]**2 + \
          Mg[4]

    # plot concentration profile
    _, fname = data.rsplit('/', 1)
예제 #4
0
from data_refine import refine_YI, get_file_names
from matplotlib import pyplot as plt

import pandas as pd

exp_data = get_file_names('Wimpie Data/Rheomix Results/', sample='Mg')

legend = []
evaluate = list(exp_data[i] for i in (0, 2, 6, 10))

for data in evaluate:
    sample = pd.read_csv(data, index_col='Time')
    sample = sample.dropna()

    YI, Time = refine_YI(sample)
    _, fname = data.rsplit('/', 1)
    name, _ = fname.split('.')
    legend.append(name)

    plt.plot(Time, YI, label=name)

plt.legend(legend, loc=0)