In [1]:
from scipy.signal import argrelextrema as arg
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
data_dir = "../Data/"
pi2pulse = np.loadtxt(data_dir+"20171107_NMR_trial_ch1.isf", delimiter=",")
pipulse = np.loadtxt(data_dir+"20171107_NMR_trial_ch3.isf", delimiter=",")
signal = np.loadtxt(data_dir+"20171107_NMR_trial_ch4.isf", delimiter=",")

In [3]:
# how_many = 1000
how_many = np.argmax(signal[:,0])
order = 300

# max_inds = arg(signal[:,1], np.greater, order=800)
# min_inds = arg(signal[:,1], np.less, order=400)

max_inds = arg(signal[:how_many,1], np.greater, order=order)
min_inds = arg(signal[:how_many,1], np.less, order=order)

# plt.plot(signal[:,0], 100*signal[:,1], 'g')
# plt.plot(pi2pulse[:,0], pi2pulse[:,1], linewidth = 3)

plt.plot(signal[:how_many,0], 100*signal[:how_many,1], 'g')
plt.plot(pi2pulse[:how_many,0], pi2pulse[:how_many,1], linewidth = 3)


plt.plot(signal[max_inds,0], 100*signal[max_inds,1], 'rd')
plt.plot(signal[min_inds,0], 100*signal[min_inds,1], 'bd');



In [4]:
max_inds


Out[4]:
(array([ 453, 1722, 2531, 3127, 4107, 5298, 5898, 6264, 7103, 7878]),)

In [5]:
min_inds


Out[5]:
(array([   4,  434, 1189, 1816, 2244, 3208, 3583, 4085, 5174, 6193, 6769,
        8370, 9340, 9948]),)

In [6]:
end_of_pi2pulse = 524
beg_of_pipulse = 4085
echo = 7878

In [7]:
time_between_pulse = signal[beg_of_pipulse,0] - signal[end_of_pi2pulse, 0] 
echo_location = signal[echo,0] - signal[end_of_pi2pulse, 0] 
echo_location/time_between_pulse


Out[7]:
2.0651502386969951

In [8]:
time_between_pulse


Out[8]:
0.00071220000000000007

In [9]:
echo_location


Out[9]:
0.0014708

In [ ]: