-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplot_harmonic_spectra.py
119 lines (96 loc) · 2.88 KB
/
plot_harmonic_spectra.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
# This is a code for creating fourier-transforms our time-dependent dipole, largely inspired by Lukas Medisauskas from the Max-Born Institute of Berlin
# August 8, 2016
# Written by: Clayton Blythe, Vanderbilt university: email: blythec1@central.edu
###################################################################################
import numpy as np
from numpy import fft
import math
import matplotlib
from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap
from matplotlib.colors import LinearSegmentedColormap
import os
cwd = os.getcwd()
matplotlib.rcParams.update({'font.size': 8})
cMap = plt.get_cmap('RdYlBu')
filename = 'dipoleXY'
ld = np.loadtxt(filename)
filename2 = 'laser_manual.dat'
laser = np.loadtxt(filename2)
time = laser[:,1]
laserx = laser[:,2]
lasery = laser[:,3]
###converting to atomic units from time in femtoseconds and eV* Angstrom/V
t = ld[:, 0] * 1e-15 / 2.418884326505e-17
n = len(t)
window = np.hamming(n)
dx = np.multiply(window, ld[:, 1])# / .529177
dy = np.multiply(window, ld[:, 2])# / .529177
sample_spacing = t[1] - t[0]
##
fourierx = np.abs(np.fft.rfft(dx))
fouriery = np.abs(np.fft.rfft(dy))
freq = (np.fft.rfftfreq(n, d=sample_spacing)) * (2 * math.pi / .056939228)
##
plt.figure(1, figsize=(14,12),dpi=128)
plt.subplot(331)
plt.plot(time,laserx)
plt.title('X Component of Laser vs Time')
plt.xlabel('Time in Femtoseconds')
plt.ylabel('Amplitude (a.u.)')
plt.subplot(332)
plt.plot(time,lasery)
plt.title('Y Component of Laser vs Time')
plt.xlabel('Time in Femtoseconds')
plt.ylabel('Amplitude (a.u.)')
plt.subplot(333)
plt.plot(laserx,lasery)
plt.title('Y vs X Component of Laser')
plt.xlabel('X Component (a.u)')
plt.ylabel('Y Component (a.u)')
plt.subplot(334)
plt.plot(ld[:,0],dx)
plt.title('Dipole in X')
plt.xlabel('Time in fs')
plt.ylabel('Amplitude')
plt.subplot(335)
plt.plot(ld[:,0],dy)
plt.title('Dipole in Y')
plt.xlabel('Time in fs')
plt.ylabel('Amplitude')
plt.subplot(336)
plt.plot(dx,dy)
plt.title('Dipole Y vs Dipole X')
plt.xlabel('Dipole X (a.u)')
plt.ylabel('Dipole Y (a.u)')
plt.subplot(337)
plt.plot(freq,fourierx)
plt.title('|Y| for X Transform')
plt.xlabel('Multiples of Fundamental')
plt.ylabel('abs |Y|')
plt.xlim(0,70)
plt.yscale('log')
plt.subplot(338)
plt.plot(freq,fouriery)
plt.title('|Y| for Y Transform')
plt.xlabel('Multiples of Fundamental')
plt.ylabel('abs |Y|')
plt.xlim(0,70)
plt.yscale('log')
plt.subplot(339)
plt.plot(freq,fourierx + fouriery)
plt.title('Summed Transforms')
plt.xlabel('Multiples of Fundamental')
plt.ylabel('abs |Y|')
plt.xlim(0,70)
plt.yscale('log')
##plt.subplot(4310)
##plt.plot(freq,(fourierx + fouriery)**2)
##plt.title('Power of Summed Transform')
##plt.xlabel('Multiples of Fundamental')
##plt.ylabel('abs |Y|^2')
##plt.xlim(0,70)
##plt.yscale('log')
current_dir = os.path.basename(cwd)
plt.savefig('clay_spectra_'+current_dir + '_.pdf', dpi=1200, Transparent=True)
print(current_dir +' completed')