Repository navigation
Expand file tree
/
Copy pathPostProcessor.py
More file actions
53 lines (43 loc) · 1.79 KB
/
Copy pathPostProcessor.py
File metadata and controls
53 lines (43 loc) · 1.79 KB
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
import json
import matplotlib as mplt
from operator import add
import matplotlib.pyplot as plt
plt.rc('font', size=12)
folder = "Trial1"
def plot_losses():
with open(f".//{folder}//total_loss_lst", 'r') as tfile, open(f".//{folder}//physics_loss_lst", 'r') as phyfile,\
open(f".//{folder}//vel_loss_lst", 'r') as velfile, open(f".//{folder}//disp_loss_lst", 'r') as dispfile:
tlist = json.load(tfile)
phylst = json.load(phyfile)
vel_lst = json.load(velfile)
disp_lst = json.load(dispfile)
data_loss = list( map(add, vel_lst, disp_lst ) )
epoch_lst = [i for i in range(len(phylst))]
plt.figure(1,figsize=(6,6))
plt.semilogy(epoch_lst,tlist)
plt.grid(True, which="both",linestyle ='--')
plt.locator_params(axis='x', nbins=3)
plt.locator_params(axis='y', numticks=5)
plt.xlabel('epochs')
plt.gca().xaxis.set_major_formatter(mplt.ticker.StrMethodFormatter('{x:,.0f}'))
plt.ylabel('total loss')
plt.savefig('total_loss.eps', format='eps')
plt.figure(2,figsize=(6,6))
plt.semilogy(epoch_lst, phylst)
plt.grid(True, which="both",linestyle ='--')
plt.locator_params(axis='x', nbins=3)
plt.locator_params(axis='y', numticks=5)
plt.gca().xaxis.set_major_formatter(mplt.ticker.StrMethodFormatter('{x:,.0f}'))
plt.xlabel('epochs')
plt.ylabel('physics loss')
plt.savefig('phy_loss.eps', format='eps')
plt.figure(3, figsize=(6, 6))
plt.semilogy(epoch_lst, data_loss)
plt.grid(True, which="both",linestyle ='--')
plt.locator_params(axis='x', nbins=3)
plt.locator_params(axis='y', numticks=5)
plt.gca().xaxis.set_major_formatter(mplt.ticker.StrMethodFormatter('{x:,.0f}'))
plt.xlabel('epochs')
plt.ylabel('data loss')
plt.savefig('data_loss.eps', format='eps')
plot_losses()