-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualization.py
40 lines (33 loc) · 1018 Bytes
/
visualization.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
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 25 13:21:17 2024
@author: mrkondratyev
"""
import matplotlib.pyplot as plt
import numpy as np
def visual(grid, var):
Ngc = grid.Ngc
rhomin = np.min(var[Ngc:-Ngc, Ngc:-Ngc])
rhomax = np.max(var[Ngc:-Ngc, Ngc:-Ngc])
plt.cla()
if grid.Nx2 == 1:
# 1D plot along x1 axis
plt.plot(grid.cx1[Ngc:-Ngc, Ngc], var[Ngc:-Ngc, Ngc])
plt.xlabel('x1')
plt.ylabel('var')
elif grid.Nx1 == 1:
# 1D plot along x2 axis
plt.plot(grid.cx2[Ngc, Ngc:-Ngc], var[Ngc, Ngc:-Ngc])
plt.xlabel('x2')
plt.ylabel('var')
else:
# 2D plot
plt.imshow(var[Ngc:-Ngc, Ngc:-Ngc], cmap='jet')
plt.clim(rhomin, rhomax)
ax = plt.gca()
ax.invert_yaxis()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
ax.set_aspect('equal')
plt.clim(rhomin, rhomax)
plt.pause(0.03)