Example #1
0
def plot_hist(entry_hist):
    '''
    Plot the number of users for different numbers of entries. 
    Ignore large numbers of entries where the number of users is only 1.
    '''
    
    num_entries = []
    num_users = []
    
    for n in entry_hist:
        num_entries.append(n['_id'])
        num_users.append(n['nusers'])
        
    num_entries = np.array(num_entries)
    num_users = np.array(num_users)
    percent_users_less = 100.0*np.cumsum(num_users)/np.sum(num_users)
    
    ind = np.where(num_users > 1)[0][-1]
    plt.plot(num_entries[0:ind+1], percent_users_less[0:ind+1], '.-')
    
    mpsa.axis_setup('x')
    mpsa.axis_setup('y')
    
    plt.xlabel(r'Number of entries', labelpad=mpsa.axeslabelpad)
    plt.ylabel(r'\% of users with $\le$ number of entries', 
               labelpad=mpsa.axeslabelpad)
    
    plt.title('Percentage of users with a given number of entries or fewer.\n\
    Numbers of entries are only shown for the largest number\n\
    of entries associated with 2 or more users.')

    mpsa.save_figure('entry_count.png')
    plt.close()
    
    print tabulate(np.column_stack((num_entries[0:21], num_users[0:21], 
                                    percent_users_less[0:21])), 
                   headers=['# Entries', '# Users', 
                            '% Users with # Entries or Fewer'])
Example #2
0
def plot_pmfs_same_dnmp(infile_prefix, infile_extension, nuc_name,
                        outfile_prefix, sys_list):

    nsysnames = len(sys_list)
    for isysname in range(nsysnames):

        sysname = sys_list[isysname]

        infile = infile_prefix + '_' + nuc_name + '_' + sysname + '.' + infile_extension

        data = read_xvg(infile)
        kbT = data[:, 1]
        ax = plt.subplot(111)
        if sysname == 'ch3':
            surf = data[:, 0] - 1.83 + 0.388
            plt.plot(surf, kbT, 'g', label='CH3-SAM')
            with open('pmf_table_ch3.dat', 'ab') as f:

                pmf_min = np.min(kbT)
                pmf_min_idx = np.argmin(kbT[:-10])
                surf_idx = int(np.argwhere(surf >= 0)[0])
                surf_idx_end = int(np.argwhere(surf >= 0.8)[0])
                Fads = integrate.simps(kbT[surf_idx:surf_idx_end],
                                       surf[surf_idx:surf_idx_end])
                dw_max = surf[pmf_min_idx:surf_idx_end][np.argmax(
                    kbT[pmf_min_idx:surf_idx_end])]

                table = np.column_stack((pmf_min, Fads, dw_max))
                np.savetxt(f,
                           table,
                           header="pmf_min|Fads|dw_max||--->" + nuc_name)

        elif sysname == 'cooch3':
            surf = data[:, 0] - 2.05 + 0.388
            plt.plot(surf, data[:, 1], 'b', label='COOCH3-SAM')
            with open('pmf_table_cooch3.dat', 'ab') as f:

                pmf_min = np.min(kbT)
                pmf_min_idx = np.argmin(kbT[:-10])
                surf_idx = int(np.argwhere(surf >= 0)[0])
                surf_idx_end = int(np.argwhere(surf >= 0.8)[0])
                Fads = integrate.simps(kbT[surf_idx:surf_idx_end],
                                       surf[surf_idx:surf_idx_end])
                dw_max = surf[pmf_min_idx:surf_idx_end][np.argmax(
                    kbT[pmf_min_idx:surf_idx_end])]

                table = np.column_stack((pmf_min, Fads, dw_max))
                np.savetxt(f,
                           table,
                           header="pmf_min|Fads|dw_max||--->" + nuc_name)

        else:
            surf = data[:, 0] - 2.18 + 0.388
            plt.plot(surf, data[:, 1], 'r', label='OC6H5-SAM')
            with open('pmf_table_poxy.dat', 'ab') as f:

                pmf_min = np.min(kbT)
                pmf_min_idx = np.argmin(kbT[:-10])
                surf_idx = int(np.argwhere(surf >= 0)[0])
                surf_idx_end = int(np.argwhere(surf >= 0.8)[0])
                Fads = integrate.simps(kbT[surf_idx:surf_idx_end],
                                       surf[surf_idx:surf_idx_end])
                dw_max = surf[pmf_min_idx:surf_idx_end][np.argmax(
                    kbT[pmf_min_idx:surf_idx_end])]

                table = np.column_stack((pmf_min, Fads, dw_max))
                np.savetxt(f,
                           table,
                           header="pmf_min|Fads|dw_max||--->" + nuc_name)

    plt.xlim(0.0, 0.8)
    plt.ylim(-8, 10)

    #mpsa.axis_setup('x')
    # mpsa.axis_setup('y')
    plt.xlabel("$d_w$ (nm)")
    plt.ylabel('PMF ($ k_B$T)')
    plt.legend()
    xmajorLocator = MultipleLocator(0.2)
    xminorLocator = MultipleLocator(0.05)

    ymajorLocator = MultipleLocator(4)
    yminorLocator = MultipleLocator(1)

    ax.xaxis.set_major_locator(xmajorLocator)
    ax.xaxis.set_minor_locator(xminorLocator)

    ax.yaxis.set_major_locator(ymajorLocator)
    ax.yaxis.set_minor_locator(yminorLocator)
    #  plt.rcParams['xtick.labelsize']=12
    # plt.rcParams['ytick.labelsize']=12

    mpsa.save_figure(outfile_prefix + '_' + nuc_name + '.png')
xvg_files = args.xvg_files

# P atom coodinates on each leaflet
P_upper = read_xvg(xvg_files[0])

P_lower = read_xvg(xvg_files[1])

bilayer_thickness = np.column_stack(
    (P_upper[:, 0], P_upper[:, 1] - P_lower[:, 1]))

np.savetxt('thickness_' + sys_name + '.xvg', bilayer_thickness)

#bilayer_thickness_filtered= savgol_filter(bilayer_thickness[:,1], 101, 2)

Temp = np.linspace(int(T_start), int(T_end), num=len(P_upper))

plt.plot(Temp, bilayer_thickness)

plt.xlim(250, 360)

plt.ylim(3.3, 3.6)

mpsa.axis_setup('x')
mpsa.axis_setup('y')

plt.legend()
plt.xlabel('T (K)', labelpad=mpsa.axeslabelpad)
plt.ylabel('Bilayer Thickness (nm)', labelpad=mpsa.axeslabelpad)
mpsa.save_figure('thickness_' + sys_name + '.png')
plt.show()
def cmpr_noneq_eq(infile_extension, sysname, nuc_list, outfile_prefix):

    nnucs = len(nuc_list)

    for inuc in range(nnucs):

        nuc = nuc_list[inuc]

        infile = 'pmf_shift' + '_' + nuc + '_' + sysname + '.' + infile_extension
        infile2 = nuc + '_zcoord_to_prob.dat'
        nonequil_zcoord = np.loadtxt(infile2)

        shift_pmf = np.loadtxt(infile)

        energy = shift_pmf[:, 1]
        dw = shift_pmf[:, 0] - dsurf + r_probe
        Q = np.sum(np.exp(-energy))

        ads_prob = np.exp(-energy) / Q
        density = ads_prob / (dw[20] - dw[19])
        #    print(len(ads_prob))

        ax = plt.subplot(111)

        if nuc == 'dCMP':
            #plt.plot(dw,ads_prob,'g',label='equil')
            plt.plot(dw, density, 'g', label='equil')
            plt.plot(nonequil_zcoord[:, 0],
                     nonequil_zcoord[:, 1],
                     'k',
                     label='non-equil')
            if sysname == 'cooch3':
                smooth = np.loadtxt('dCMP_zcoord_to_prob_smoothcooch3.dat')
                plt.plot(smooth[:, 0], smooth[:, 1], 'c--', label='smooth')
        elif nuc == 'dTMP':
            #plt.plot(dw,ads_prob,'b',label='equil')
            plt.plot(dw, density, 'b', label='equil')
            plt.plot(nonequil_zcoord[:, 0],
                     nonequil_zcoord[:, 1],
                     'k',
                     label='non-equil')
            if sysname == 'cooch3':
                smooth = np.loadtxt('dTMP_zcoord_to_prob_smoothcooch3.dat')
                plt.plot(smooth[:, 0], smooth[:, 1], 'c--', label='smooth')
        elif nuc == 'dGMP':
            #plt.plot(dw,ads_prob,'m',label='equil')
            plt.plot(dw, density, 'm', label='equil')
            plt.plot(nonequil_zcoord[:, 0],
                     nonequil_zcoord[:, 1],
                     'k',
                     label='non-equil')
            if sysname == 'cooch3':
                smooth = np.loadtxt('dGMP_zcoord_to_prob_smoothcooch3.dat')
                plt.plot(smooth[:, 0], smooth[:, 1], 'c--', label='smooth')
        else:
            #plt.plot(dw,ads_prob,'r',label='equil')
            plt.plot(dw, density, 'r', label='equil')
            plt.plot(nonequil_zcoord[:, 0],
                     nonequil_zcoord[:, 1],
                     'k',
                     label='non-equil')
            if sysname == 'cooch3':
                smooth = np.loadtxt('dAMP_zcoord_to_prob_smoothcooch3.dat')
                plt.plot(smooth[:, 0], smooth[:, 1], 'c--', label='smooth')

        plt.xlim(0.0, 0.6)

        if sysname == 'ch3':
            plt.ylim(0, 12)
            ymajor = 4
            yminor = 1
        elif sysname == 'cooch3':
            plt.ylim(0, 2.8)
            ymajor = 0.5
            yminor = 0.1
        else:
            plt.ylim(0, 18)
            ymajor = 3
            yminor = 1

        xmajorLocator = MultipleLocator(0.2)
        xminorLocator = MultipleLocator(0.05)

        ymajorLocator = MultipleLocator(ymajor)
        yminorLocator = MultipleLocator(yminor)

        ax.xaxis.set_major_locator(xmajorLocator)
        ax.xaxis.set_minor_locator(xminorLocator)

        ax.yaxis.set_major_locator(ymajorLocator)
        ax.yaxis.set_minor_locator(yminorLocator)

        plt.xlabel("$d_w $(nm)")
        plt.ylabel('Pd ($nm^{-1}$)')
        plt.legend()
        mpsa.save_figure(nuc + '_' + outfile_prefix + '_' + sysname + '.png')
        plt.close()
Example #5
0
    kbT = read_xvg(profile)[:195, 1]
    wids = read_xvg(profile)[:195, 0]
    j = -1
    for i in wids >= 3.4:
        if i == False:

            j += 1
        ave = np.mean(kbT[j:])
        kbT[:] = kbT[:] - ave
        data = np.column_stack((wids, kbT))
        np.savetxt('pmf_shift_' + outfile_prefix + '.dat', data)

#sbstct=substract(traj1,traj2)
#ave_dist=np.mean(sbstct[100:,1])

#np.savetxt(dnmp+'_edgrp_SH_'+'dist'+ '.dat',ave_dist.reshape(1,))

    plt.plot(wids, kbT, 'r', linewidth=2)
    plt.axhline(y=0, ls='--')
    plt.xlim(0, 4.2)
    plt.ylim(-25, 10)

    mpsa.axis_setup('x')
    mpsa.axis_setup('y')
    plt.xlabel("$d_w$ (nm)", labelpad=mpsa.axeslabelpad)
    #plt.tick_params(labelsize=15)
    plt.ylabel('PMF ($k_B$T)', labelpad=mpsa.axeslabelpad)
    mpsa.save_figure(outfile_prefix + '.png')
#  plt.show()