-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiFROG_dev6.py
172 lines (105 loc) · 4 KB
/
iFROG_dev6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 20 18:11:57 2019
@author: briansquires
"""
import numpy as np
import matplotlib.colors as colors
import matplotlib.pyplot as plt
import scipy.interpolate as interp
from matplotlib import ticker, cm
#%% Data Import
databbo = np.loadtxt("191231_BBO_840_20mW_10MHz_iRp_432GR_0000AE_10msE_8DIV_fine", delimiter="\t")
databbo = np.delete(databbo, databbo.shape[1]-1, axis=1)
datamos2 = np.loadtxt("191230_MOS2_840_20mW_10MHz_iRp_432GR_0966AE_1000msE_8DIV_fine", delimiter="\t")
datamos2 = np.delete(datamos2, datamos2.shape[1]-1, axis=1)
posb=np.loadtxt("191231_BBO_840_20mW_10MHz_iRp_432GR_0000AE_10msE_8DIV_fine_pos", delimiter="\t")
#posb=np.delete(posb,5000,axis=0)
posm=np.loadtxt("191230_MOS2_840_20mW_10MHz_iRp_432GR_0966AE_1000msE_8div_fine_pos", delimiter="\t")
#posm=np.delete(posm,5000,axis=0)
#%%
#truncation (data specific)
datamos2=datamos2[::,:6080]
posm=np.resize(posm,[6080,])
tzerob = -11704.60461
tzerom = -11707.53711
um2fs = 2*(10**-6)*(10**15)/(3*10**8)
xb=(posb-tzerob)*um2fs
yb=np.linspace(1,databbo.shape[0],num=databbo.shape[0])
xbg,ybg=np.meshgrid(xb,yb)
xm=(posm-tzerom)*um2fs
ym=np.linspace(10,datamos2.shape[0]+10,num=datamos2.shape[0])
xmg,ymg=np.meshgrid(xm,ym)
#%%Normalization
databbo = databbo/np.amax(databbo)
datamos2 = datamos2/np.amax(datamos2)
#%%
div=datamos2/(databbo)
#%% Plot Data
f , (ax1,ax2,ax3) =plt.subplots(1, 3, sharey=True)
f.suptitle('840nm')
bboplt = ax1.contourf(xbg,ybg,databbo,np.linspace(databbo.min(), databbo.max(), 10), cmap='jet')
ax1.set_title('BBO')
ax1.set_xlim(-500,500)
ax1.set_ylim(600,800)
cbar = f.colorbar(bboplt)
mos2plt = ax2.contourf(xmg,ymg,datamos2,np.linspace(datamos2.min(), datamos2.max(), 10),cmap='jet')
ax2.set_title('MoS2')
ax2.set_xlim(-500,500)
ax2.set_ylim(600,800)
divplt= ax3.contour(xbg,ybg,div,np.linspace(div.min(), div.max(), 10),cmap='jet')
ax3.set_title('MoS2/BBO')
ax3.set_xlim(-500,500)
ax3.set_ylim(600,800)
#%% Fourier Transform
timestep=0.66713 ##this is the time for one 100nm step. This returns the FFT
# x-axis in THz
bfft = np.fft.fft(databbo)
Wb = np.fft.fftfreq(posb.size,timestep)
mfft = np.fft.fft(datamos2)
Wm = np.fft.fftfreq(posm.size,timestep)
divfft=np.fft.fft(div)
#divfft=np.fft.fftfreq(div.size,timestep) #######
W=np.fft.fftfreq(div[1].size,timestep)
#W=np.fft.fftshift(W)
xfft=W
yfft=np.linspace(1,divfft.shape[0],num=divfft.shape[0])
xgfft, ygfft =np.meshgrid(xfft,yfft)
#%% Plot FFT
g, (gx1,gx2) = plt.subplots(1,2, sharey=True)
xlim1 = .32 ### Sets x min
xlim2 = .38 ### and max in THz
# =============================================================================
# xlim1 = W.min()
# xlim2 = W.max()
# =============================================================================
ylim1=650 ###Sets ymin
ylim2 = 720 ###and max in pixel number ---- need to convert to wavelength
RealFFT = gx1.contourf(xgfft,ygfft,(divfft.real),100,
cmap='jet')
gx1.set_title('Re{FFT}')
gx1.set_xlim(xlim1,xlim2)
gx1.set_ylim(ylim1,ylim2)
ImgFFT = gx2.contourf(xgfft,ygfft,(divfft.imag),100,
cmap='jet')
gx2.set_title('Im{FFT}')
gx2.set_xlim(xlim1,xlim2)
gx2.set_ylim(ylim1,ylim2)
#%% FFT Filtering
divfftfilt = divfft[ylim1:ylim2,1200:1650] ###magic numbers for 840
divfftfiltRe = divfftfilt.real
Wfilt = W[1200:1650]
divfilt = np.fft.ifft(divfftfilt)
xfilt=np.linspace(0,divfilt.shape[1],divfilt.shape[1])
yfilt=np.linspace(0,divfilt.shape[0],divfilt.shape[0])
xgfilt, ygfilt = np.meshgrid(xfilt, yfilt)
filtplt, (filtaxRe,filtaxIm) = plt.subplots(1,2, sharey=True)
CSre = filtaxRe.contourf(xfilt,yfilt,divfilt.real,500,cmap='jet',vmin=-10,vmax=40)
#filtaxRe.set_xlim(16,45)
CSim = filtaxIm.contourf(xfilt,yfilt,divfilt.imag,500,cmap='jet',vmin=5,vmax=10)
#filtaxIm.set_xlim(16,45)
#%% interpolate
xgrid, ygrid = np.meshgrid(256,1024)
grid_z0 = griddata((xfilt,yfilt), divfilt.real, (xgrid, ygrid), method='nearest')
plt.contourf(xgrid, ygrid, grid_z0)