Ejemplo n.º 1
0
nr = np.array([1.0, 1.52, 1.0])  # real part
ni = np.array([0.0, 0.015, 0.0])  # imaginary part (attenuation)
n_layers = 1  # the number of layers in the structure
d = np.array([0.1016])  # thickness of the layers in mm

slice_loc = 400  # index which to remove front blip

theta0 = 17.5 * np.pi / 180  # the incoming angle of the THz scanner in radians

c = 0.2998  # speed of light in mm/ps

n = nr - 1j * ni  # make the complex n

ref_file = 'C:\\Work\\Signal Modelling\\References\\ref 12JUN2017\\60 ps waveform.txt'
sample_file = 'C:\\Work\\Signal Modelling\\THz Data\\HDPE Lens\\60 ps waveform.txt'
ref_time, ref_amp = sm.read_reference_data(ref_file)
time, sample_amp = sm.read_reference_data(sample_file)

ref_time -= ref_time[0]  # shift time so initial value is zero
ref_amp[:slice_loc] = 0
ref_amp[slice_loc - 1] = ref_amp[slice_loc] / 2  # add ramp for FFT
sample_amp[:slice_loc] = 0
sample_amp[slice_loc - 1] = sample_amp[slice_loc] / 2

dt = ref_time[-1] / (len(ref_time) - 1)
df = 1 / (len(ref_time) * dt)
freq = np.linspace(0, len(ref_time) / 2 * df, len(ref_time) // 22)

# calculate theta in each angle
theta = np.zeros(n_layers + 2, dtype=complex)
theta[0] = theta0  # first theta is just the angle of the THz scanner
Ejemplo n.º 2
0
# indices to slice the waveform, gate the front and back surface echos
# this removes the initial "blip" and cuts out the water vapor noise in the middle
# produces a much smoother spectrum
gate0 = 615

# list of colors to use for plotting
colors = ['r', 'b', 'g', 'k', 'm', 'c', 'y']

# ==============================================================================
# END SETTINGS
# START PREPROCESSING

extent = (ni_guess[0], ni_guess[-1], nr_guess[-1], nr_guess[0])

ref_time, ref_amp = sm.read_reference_data(ref_file)
data = THzData.THzData(tvl_file, basedir, gate=thz_gate, follow_gate_on=True)

# adjust time arrays so initial data point is zero
ref_time -= ref_time[0]

# assume both have the same dt
dt = ref_time[-1] / (len(ref_time) - 1)
df = 1 / (len(ref_time) * dt)
freq = np.linspace(0, len(ref_time)/2*df, len(ref_time)//2+1)

e0 = copy.deepcopy(ref_amp)  # e0 will be the negative of reference from aluminum plate
e0[:gate0] = 0  # make everything before cut index zero to remove blip
e0[gate0-1] = e0[gate0] / 2  # add ramp up factor to help FFT

e0_gated = copy.deepcopy(e0)