-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCircularRR_AOPS_S2_Fig_S02.py
60 lines (53 loc) · 2.76 KB
/
CircularRR_AOPS_S2_Fig_S02.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
"""
The code for the research presented in the paper titled "A deep learning method for empirical spectral prediction and inverse design of all-optical nonlinear plasmonic ring resonator switches
@authors: Ehsan Adibnia, Majid Ghadrdan and Mohammad Ali Mansouri-Birjandi
Corresponding author: [email protected]
This code is corresponding to the Section S2 (Dataset discussion) of the Supplementary Information of the article.
This code regenerates the Fig S2a and Fig S2b of the Supplementary Information of the paper.
Please cite the paper in any publication using this code.
"""
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
### Load the data from CSV file (the results of FDTD solver)
result1 = pd.read_csv("result_V.csv", header=None)
result1 = result1.to_numpy()
result1 = result1.astype(np.float16)
x = result1[0:result1.shape[0],0:6]
y = result1[0:result1.shape[0],6]
### Feature Scaling
sc = StandardScaler()
x = sc.fit_transform(x)
### plot histogram of input data
data1 = x[0:x.shape[0],1]
data2 = x[0:x.shape[0],2]
data3 = x[0:x.shape[0],3]
data4 = x[0:x.shape[0],4]
data5 = x[0:x.shape[0],5]
plt.hist([data1, data2, data3, data4, data5], linewidth=6)
plt.title('The input dataset used to train the neural network', fontname='Times New Roman', fontsize=16, loc='center')
plt.xlabel('Dataset', fontname='Times New Roman', fontsize=18)
plt.ylabel('Count', fontname='Times New Roman', fontsize=18)
plt.xticks(fontfamily='Times New Roman', fontsize=16)
plt.yticks(fontfamily='Times New Roman', fontsize=16)
font_prop = FontProperties(family="Times New Roman", size=16)
plt.legend(['G1', 'G2', 'G3', 'G4', 'G5'], prop=font_prop,bbox_to_anchor=(1.05, 1))
plt.savefig("figureS2a.eps", format="eps", dpi=300, bbox_inches="tight")
plt.savefig("figureS2a.png", format="png", dpi=300, bbox_inches="tight")
plt.show()
### plot histogram of output data
data6 = result1[0:result1.shape[0],6]
data7 = abs(result1[0:result1.shape[0],7])
plt.hist([data6, data7],label=['', ''])
plt.title('The input dataset used to train the neural network', fontname='Times New Roman', fontsize=16, loc='center')
plt.xlabel('Dataset', fontname='Times New Roman', fontsize=18)
plt.ylabel('Count', fontname='Times New Roman', fontsize=18)
plt.xticks(fontfamily='Times New Roman', fontsize=16)
plt.yticks(fontfamily='Times New Roman', fontsize=16)
font_prop = FontProperties(family="Times New Roman", size=16)
plt.legend(['Through port','Drop port'], prop=font_prop, loc='upper center')
plt.savefig("figureS2b.eps", format="eps", dpi=300, bbox_inches="tight")
plt.savefig("figureS2b.png", format="png", dpi=300, bbox_inches="tight")
plt.show()