Example #1
0
# get run data for particular parameter value
Dt = 0
run_data = get_run_data_from_sweep_data(sweep_data, Dt)

# setup figure
ax = setup_trajectory_figure(Dt / 60. + 2)
ax[0].set_title(species + ' - ' + model + ', Dt: %02d min, T_dec>%02d min' %
                (Dt, thr_Tdec))

# select single (or multiple) trajectory index
#np.random.seed(20)
idx = np.random.randint(0, len(run_data), 1)
idx = np.arange(len(run_data))

# for the selected trajectories
for i in tqdm(idx):
    # get species data
    (t, ts) = get_species_data_from_sim_data(run_data[i]['sim_data'], species,
                                             save_species_list)

    # get T_decision
    (AC_id, T_dec, ind) = get_T_decision(t, ts, 0.3)
    if T_dec > thr_Tdec:

        # calculate and plot difference in D_i(t) for all three stages
        plot_single_trajectory(t, ts, ax, thr=0.3)
#        print('T_decision for trajectory %03d: %.4f'%(i,T_dec/60.))

plt.show()
Example #2
0
def plot_Tdec(model, color, fig, species):

    # sweep parameters
    save_species_list = ['M', 'D', 'MY', 'DY']
    sweep_data_dir = model + '_sweep'
    sweep_data_file = 'sweep'
    sweep_param_lbl = 'DT'
    sweep_param_list = [0., 10., 20., 30., 40., 50., 60., 70., 80., 90.]

    ### analyze sweep data

    # load sweep data
    infile = os.path.join(os.getcwd(), sweep_data_dir,
                          sweep_data_file + '_' + sweep_param_lbl + '.p')
    sweep_data = pickle.load(open(infile, "rb"))

    # initialize matrix for AC_id and T_dec
    AC_ids = np.array([np.zeros((len(i['run_data']))) for i in sweep_data])
    T_decs = np.array([np.zeros((len(i['run_data']))) for i in sweep_data])

    # for each sweep_parameter
    for i, sweep_param in enumerate(sweep_param_list):
        print(sweep_param)

        # get run data for particular parameter value
        run_data = get_run_data_from_sweep_data(sweep_data, sweep_param)

        # extract AC_id and T_dec
        # for each simulation in run_data
        for j in range(0, len(run_data)):
            # get species data
            (t, ts) = get_species_data_from_sim_data(run_data[j]['sim_data'],
                                                     species,
                                                     save_species_list)
            # print(t)
            # break
            # get T_decision
            (AC_id, T_dec, ind) = get_T_decision(t, ts, 0.3)
            # print(AC_id, T_dec)

            AC_ids[i, j] = AC_id
            T_decs[i, j] = T_dec

    frac = np.array([np.sum(AC_id) / AC_id.shape[0] for AC_id in AC_ids])
    mean_T_dec = np.array([np.mean(T_dec) for T_dec in T_decs])
    std_T_dec = np.array([np.std(T_dec) for T_dec in T_decs])

    print(mean_T_dec)
    print(np.sum(np.array(T_decs[0]) > 30) / len(T_decs[0]))
    print(T_decs.shape)

    [ax1, ax2, ax3] = fig.get_axes()
    ax1line = ax1.plot(sweep_param_list, frac, '-o', ms=3, color=color, lw=0.5)
    ax2line = ax2.plot(sweep_param_list,
                       mean_T_dec,
                       '-o',
                       ms=3,
                       color=color,
                       lw=0.5)
    ax3line = ax3.hist(
        T_decs[0],
        bins=48,
        range=[0, 480],
        orientation='horizontal',
        weights=[1. / len(T_decs[0]) for i in np.arange(len(T_decs[0]))],
        color=color,
        alpha=.5)

    return ax1line, ax2line, ax3line
Example #3
0
sweep_data = pickle.load(open(infile, "rb"))

# get run data for particular parameter value
run_data = get_run_data_from_sweep_data(sweep_data, 20)

# plot dynamics and T_dec
col = 'kcm'
# for each simulation in run_data
for i in range(0, len(run_data))[::10]:
    # get species data
    (t, D_vs_t) = get_species_data_from_sim_data(run_data[i]['sim_data'], 'D',
                                                 save_species_list)
    # calculate and plot difference in D_i(t) for all three stages
    diff_D = []
    for j in [0, 1, 2]:
        diff_D.append((D_vs_t[j][:, 0] - D_vs_t[j][:, 1]) /
                      (D_vs_t[j][:, 0] + D_vs_t[j][:, 1]))
        plt.plot(t[j] / 60., diff_D[j], '-' + col[j], lw=2)
    # get T_decision
    (AC_id, T_dec, ind) = get_T_decision(t, D_vs_t, 0.5)
    # and plot in figure
    if len(ind) > 0:
        plt.plot(t[ind[0]][ind[1]] / 60., diff_D[ind[0]][ind[1]], 'ok')

plt.plot([0, 12], [0, 0], '--k')
plt.ylim([-1.1, 1.1])
plt.xlabel('Time (hours)')
plt.ylabel('Normalized difference')

plt.show()
fig, ax = plt.subplots(figsize=(5, 5), nrows=1, ncols=1)
fig.suptitle(model + '- T_dec correlation')

# select single (or multiple) trajectory index
#np.random.seed(20)
idx = np.random.randint(0, len(run_data), 1)
idx = np.arange(len(run_data))

# for the selected trajectories
T_dec = [[], []]
for i in tqdm(idx):
    # get species data
    (t, ts) = get_species_data_from_sim_data(run_data[i]['sim_data'], 'D',
                                             save_species_list)
    # get T_decision
    (AC_id, td, ind) = get_T_decision(t, ts, 0.3)
    T_dec[0].append(td)
    # get species data
    (t, ts) = get_species_data_from_sim_data(run_data[i]['sim_data'], 'DY',
                                             save_species_list)
    # get T_decision
    (AC_id, td, ind) = get_T_decision(t, ts, 0.3)
    T_dec[1].append(td)

ax.plot(T_dec[0], T_dec[1], 'ok')
ax.set_ylim(0, 360)
ax.set_xlim(0, 360)
ax.set_xlabel('T_dec with LAG2 (min)')
ax.set_ylabel('T_dec with YFP (min)')

plt.show()