-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotgrid.py
More file actions
54 lines (40 loc) · 1.66 KB
/
Copy pathplotgrid.py
File metadata and controls
54 lines (40 loc) · 1.66 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
54
from __future__ import annotations
import numpy as np
from matplotlib.pyplot import figure
import typing as T
import argparse
import typing as T
def plotoutline2D(xg: dict[str, T.Any]):
"""plot an outline of a 2D grid in mlat and altitude"""
mlat = np.degrees(np.pi/2.0 - xg["theta"])
alt = xg["alt"]
fg = figure(dpi=100)
ax = fg.gca()
ax.plot(mlat[0, :, 0], alt[0, :, 0] / 1e3)
ax.plot(mlat[-1, :, 0], alt[-1, :, 0] / 1e3)
ax.plot(mlat[:, 0, 0], alt[:, 0, 0] / 1e3)
ax.plot(mlat[:, -1, 0], alt[:, -1, 0] / 1e3)
ax.set_xlabel("mlat")
ax.set_ylabel("alt")
def plotoutline3D(xg: dict[str, T.Any]):
"""plot 3D grid outline"""
mlon = np.degrees(xg["phi"])
mlat = np.degrees(np.pi/2.0 - xg["theta"])
alt = xg["alt"]
fg = figure(dpi=150)
ax = fg.gca(projection="3d")
ax.plot(mlon[0, :, 0], mlat[0, :, 0], alt[0, :, 0] / 1e3)
ax.plot(mlon[-1, :, 0], mlat[-1, :, 0], alt[-1, :, 0] / 1e3)
ax.plot(mlon[:, 0, 0], mlat[:, 0, 0], alt[:, 0, 0] / 1e3)
ax.plot(mlon[:, -1, 0], mlat[:, -1, 0], alt[:, -1, 0] / 1e3)
ax.plot(mlon[0, :, -1], mlat[0, :, 0], alt[0, :, -1] / 1e3)
ax.plot(mlon[-1, :, -1], mlat[-1, :, 0], alt[-1, :, -1] / 1e3)
ax.plot(mlon[:, 0, -1], mlat[:, 0, 0], alt[:, 0, -1] / 1e3)
ax.plot(mlon[:, -1, -1], mlat[:, -1, 0], alt[:, -1, -1] / 1e3)
ax.plot(mlon[0, 0, :], mlat[0, 0, :], alt[0, 0, :] / 1e3)
ax.plot(mlon[0, -1, :], mlat[0, -1, :], alt[0, -1, :] / 1e3)
ax.plot(mlon[-1, -1, :], mlat[-1, -1, :], alt[-1, -1, :] / 1e3)
ax.plot(mlon[-1, 0, :], mlat[-1, 0, :], alt[-1, 0, :] / 1e3)
ax.set_xlabel("mlon")
ax.set_ylabel("mlat")
ax.set_zlabel("alt")