Exemple #1
0
"""
------------------------------------------------------------------------
Program 9
------------------------------------------------------------------------
Author: Anshul Khatri
ID:     193313680
Email:  [email protected]
__updated__ = "2019-10-30"
------------------------------------------------------------------------
"""

from functions import get_int

val = get_int(0, 100)
print()

print('Value: {}'.format(val))
for n, file in enumerate(trackbin_files):

    # get reference-frequency
    A.append(file[10:13])
    B.append(file[15:18])

    # files
    datfile = trackbin_path + file

    # read dataframe
    df = pd.read_csv(datfile, sep="\t")
    headers = list(df)

    # get number of beads
    beads = headers[len(headers) - 1]
    beads = func.get_int(beads)

    # correct global drift
    time = np.array(df['Time (s)'])
    freq = 1 / np.median(np.diff(time))

    drift = []
    for i in range(beads):
        z_drift = np.array(df['Z' + str(i) + ' (um)'])
        amplitude_drift = np.array(df['Amp' + str(i) + ' (a.u.)'])

        rupt = func.rupture(time, amplitude_drift)
        if rupt == False:
            drift.append(func.drift_self(z_drift, time))

    drift = float(np.median(drift))
Exemple #3
0
import argparse
import glob
import functions as fn

## Init

# arguments
parser = argparse.ArgumentParser(description='Simple password generator')
parser.add_argument('--count',
                    type=int,
                    default='5',
                    help='number of password(s) to return')
args = parser.parse_args()

# var
wordlists = glob.glob('wordlists//*.txt')

## Main

for i in range(0, args.count):
    got_word = fn.get_word(wordlists)
    got_int = fn.get_int()
    print(got_word + '#' + got_int)
plt.figure(figsize=(12, 6))

for n, measurement in enumerate(measurements):
    file = measurement[1] + "_" + measurement[2] + "_" + measurement[3] + ".fit"
    df = pd.read_csv(folder + file, sep="\t")

    # columns
    time = np.array(df['t (s)'])
    force = np.array(df['F (pN)'])
    z = np.array(df['z (um)'])
    z_fit = np.array(df['z fit (um)'])

    # get rupture force
    df_pars = pd.read_csv(pars_file, sep="\t")
    f_rupt = df_pars.loc[(df_pars['date'] == int(measurement[1])) &
                         (df_pars['data'] == func.get_int((measurement[2]))) &
                         (df_pars['bead'] == float(measurement[3])),
                         "f_rupt_pN"]

    # split in pull & release
    dx = np.diff(time)
    dy = np.diff(force)
    diff_force = np.append([0], np.divide(dy,
                                          dx))  # add a zero as first element

    factor = max(diff_force / 1000)

    trajectory = "T1"

    if measurement[0] == "175x16" or measurement[0] == "177x16":
        trajectory = "T2"
Exemple #5
0
import pandas as pd
import matplotlib.cm as cm


data_path = r"C:\Users\tbrouwer\Desktop\TrackImages\post-processing\data_002"
save_path = data_path

dat_files = []
os.chdir(data_path)
for file in glob.glob("*.dat"):
    dat_files.append(file)


for n, file in enumerate(dat_files):

    freqs = str(func.get_int((file[15:])))[:-2]

    # files
    datfile = data_path + "\\" + file

    # read dataframe
    df = pd.read_csv(datfile, sep="\t")
    headers = list(df)

    # get number of beads
    beads = headers[len(headers) - 2]
    beads = func.get_int(beads) + 1

    # correct global drift
    time = np.array(df['Time (s)'])
    freq = 1 / np.median(np.diff(time))
Exemple #6
0
def read_analyze(measurement, pars, data_path):
    try:
        p = pars
    except:
        print('Error: no parameters')
        return

    global_drift = True

    # constants from parameters
    L_bp = p['L_bp']  # contour length (bp)
    S_pN = p['S_pN']  # stretch modulus (pN)
    P_nm = p['P_nm']  # persistence length (nm)

    # open data
    file_location = data_path
    file_name = "data_" + str(measurement[1])
    file_extension = ".dat"
    file_all = file_location + file_name + file_extension
    bead = int(measurement[2])

    # title
    title = int(func.get_num(file_location))

    # read DataFrame
    df = pd.read_csv(file_all, sep="\t")

    magnet = np.array(df['Stepper shift (mm)'])
    time = np.array(df['Time (s)'])
    force = func.calc_force(magnet)
    Z = np.array(df['Z' + str(bead) + ' (um)'])

    # number of beads
    file_log = file_location + file_name + ".log"
    f = open(file_log, 'r')
    try:
        beads = f.readlines()[9]
    except:
        headers = list(df)
        # get number of beads
        beads = headers[len(headers) - 1]
    f.close()

    try:
        beads = int(func.get_num(beads))
    except:
        beads = func.get_int(beads)

    drift = []
    for i in range(beads):
        z_drift = np.array(df['Z' + str(i) + ' (um)'])
        try:
            amplitude_drift = np.array(df['Amp' + str(i) + ' (a.u.)'])
        except:
            amplitude_drift = np.array(df['Amp a.u.'])

        # does the tether rupture?
        rupt, _ = func.rupture(time, amplitude_drift)

        if rupt == False:
            drift.append(func.drift_self(z_drift, time))

    if not drift:
        p['drift'] = 'uncorrected'
        drift_med = 0
    else:
        drift_med = float(np.median(drift))
        Z = Z - (drift_med / 1000) * time
        p['drift'] = str(round(drift_med, 3)) + " nm/s (global drift)"

    # calculating the first derivative of magnet
    dx = np.diff(time)
    dy = np.diff(magnet)
    diff_magnet = np.append([0], np.divide(dy, dx))  # add a zero as first element

    # split in pull & release
    factor = max(diff_magnet / 1000)
    time_pull = time[diff_magnet < factor]
    f_pull = force[diff_magnet < factor]
    f_release = force[diff_magnet > factor]
    z_pull = Z[diff_magnet < factor]
    z_release = Z[diff_magnet > factor]

    # select high-force data
    select_f = f_pull[np.where((f_pull > 50) & (f_pull < 55) & (time_pull > 60) & (time_pull < 140))]
    select_z = z_pull[np.where((f_pull > 50) & (f_pull < 55) & (time_pull > 60) & (time_pull < 140))]

    if select_f.size != 0:

        # fit the WLC in fashion (x,y) - only fit offset, fix everything else
        popt, pcov = curve_fit(lambda f, z0: func.WLC_fit(f, P_nm, L_bp * 0.34, S_pN, z0), select_f, select_z, p0=1)

        z_fit = popt[0]

        # subtract fitted offset from data
        z_pull -= z_fit
        z_release -= z_fit
        select_z -= z_fit

    else:
        z_fit = 0

    title = str(title) + '_' + str(measurement[1]) + '_' + str(measurement[2]) + '_' + str(measurement[3])

    return f_pull, z_pull, f_release, z_release, title, drift_med, z_fit