示例#1
0
import tweezer.plotting as plt
import tweezer.force_calc as forcecalc
import tweezer.calibration as cal

# Example of unpacking the data, and plotting all plot functios
# Get data from drive (under Vzorci/1 static particle) and save it in examples folder

#script_dir = os.path.dirname(__file__) # absolute dir the script is in
file_name = 'test.dat'  # name of the dat file
#path = os.path.join(script_dir, file_name)
path = file_name
particles = 1

time, traps, trajectories = plt.read_file(path, particles)
averaging_time = 0.1

for i in range(particles):
    data = trajectories[:, i * 2:(i + 1) * 2]
    trap = traps[:, i * 3:(i + 1) * 3]
    # Example of using trajectory plot
    plt.trajectory_plot(time, data, averaging_time)
    # Example of using calibration plots
    plt.calibration_plots(time, data, averaging_time)
    # Example of using potential plot
    plt.potential_plot(time, data, averaging_time)
    # Calculate forces
    k_estimated, phi_estimated, center_estimated = cal.calibrate(
        time, data, averaging_time)
    f, m = forcecalc.force_calculation(time, data, trap, k_estimated, 300)
    # Plot force
    plt.force_plot(time, f)
示例#2
0
    images = pims.ImageSequence(output_folder + "/*.png")
    
features = trackpy.batch(images, 7, minmass=50, invert=False)
tracks = trackpy.link_df(features, 15, memory=10)

all_traps = [trap_data,[0,0,-1],[0,0,-1],[0,0,-1]]

traps = [[all_traps[i][:] for j in range(num_points)]for i in range(4)]

tracking.save_tracked_data_pandas(output_folder + "/tracked_data.dat",images, tracks, times, laser_powers, traps)

#4: Read .dat file back into the program

times,traps,trajectory = plotting.read_file(output_folder + "/tracked_data.dat",1)

#5: Calibration, removing offset etc.

trap_offsets = offset.single_particle_offset(traps[:,0:2],trajectory[:,::-1]) #should be close to 0 since trap isn't shifted
coeffs_estimate,rotation_angle,_ = calibration.calibrate(times,trajectory,0.005)

#6: Force analysis

print("Trap offsets:", trap_offsets)
print("Estimate of trap coefficients:", coeffs_estimate)
print("Trap rotation angle", rotation_angle)

forces,mean_forces = force_calc.calculate(times,trajectory[:,1::-1],traps[:,0:2],coeffs_estimate,rotation_angle)

#7: Create graphs
plotting.trajectory_plot(times,trajectory[:,1::-1],0.005)
plotting.force_plot(times,forces,mean_forces)
示例#3
0
 def test_calibrate(self):
     trajectory = gen.generate([self.kx, self.ky], phi = self.phi)
     t = gen.generate_time()
     result = cal.calibrate(t, trajectory)
     self.assertTrue(np.allclose(result[0], self.expected_result[0], atol=1e-6) and
             np.allclose(-result[1], self.expected_result[1], atol=0.1))