FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
AetherDocumentation/scripts/plot_sphere.py at main · AetherModel/AetherDocumentation · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AetherModel
/
AetherDocumentation
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
AetherDocumentation
/
scripts
/
plot_sphere.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (64 loc) · 3.22 KB
Breadcrumbs
AetherDocumentation
/
scripts
/
plot_sphere.py
Copy path
File metadata and controls
81 lines (64 loc) · 3.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/opt/local/bin/python
from
__future__
import
print_function
import
numpy
as
np
import
netCDF4
import
matplotlib
.
pyplot
as
plt
from
math
import
pi
directory
=
'../restarts/restartOut.Sphere.1member/'
files
=
[
directory
+
'grid_g'
+
str
(
side
).
zfill
(
4
)
+
'.nc'
for
side
in
range
(
0
,
4
)]
print
(
files
)
colors
=
[
'#0072b2'
,
'#e69f00'
,
'#cc79a7'
,
'#009e73'
]
radians_to_degrees
=
180.0
/
pi
plotting
=
False
# Plot the full extent of the latitudes and longitudes
if
plotting
:
fig
,
ax
=
plt
.
subplots
()
for
ifile
,
this_file
in
enumerate
(
files
):
f
=
netCDF4
.
Dataset
(
this_file
)
# Slice the longitude and latitude arrays to only include the lowest altitude
lons
=
f
.
variables
[
'Longitude'
][:, :,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][:, :,
0
]
*
radians_to_degrees
ax
.
scatter
(
lons
,
lats
,
c
=
colors
[
ifile
],
alpha
=
0.3
,
edgecolors
=
'none'
,
label
=
'Grid '
+
str
(
ifile
).
zfill
(
4
))
f
.
close
()
ax
.
legend
(
loc
=
'lower right'
)
plt
.
title
(
'Grid file correspondence to sphere'
)
plt
.
ylabel
(
'Latitude'
)
plt
.
xlabel
(
'Longitude'
)
plt
.
xlim
((
-
20
,
380
))
plt
.
ylim
((
-
100
,
100
))
plt
.
savefig
(
'../_static/sphere_scatter.png'
,
dpi
=
200
,
transparent
=
True
,
bbox_inches
=
'tight'
)
plt
.
clf
()
print
(
'+-----------+---------+---------+---------+---------+'
)
print
(
'| Grid file | Min lat | Max lat | Min lon | Max lon |'
)
print
(
'+-----------+---------+---------+---------+---------+'
)
for
ifile
,
this_file
in
enumerate
(
files
):
f
=
netCDF4
.
Dataset
(
this_file
)
if
ifile
==
0
:
lons
=
f
.
variables
[
'Longitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
elif
ifile
==
1
:
lons
=
f
.
variables
[
'Longitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
elif
ifile
==
2
:
lons
=
f
.
variables
[
'Longitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
elif
ifile
==
3
:
lons
=
f
.
variables
[
'Longitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
print
(
'| '
+
'{0: >9}'
.
format
(
str
(
ifile
).
zfill
(
4
))
+
' | '
+
'{0: >7}'
.
format
(
str
(
np
.
min
(
lats
))[
0
:
7
])
+
' | '
+
'{0: >7}'
.
format
(
str
(
np
.
max
(
lats
))[
0
:
7
])
+
' | '
+
'{0: >7}'
.
format
(
str
(
np
.
min
(
lons
))[
0
:
7
])
+
' | '
+
'{0: >7}'
.
format
(
str
(
np
.
max
(
lons
))[
0
:
7
])
+
' |'
)
print
(
'+-----------+---------+---------+---------+---------+'
)
# Truncate the latitudes and longitudes so there is no overlap
fig
,
ax
=
plt
.
subplots
()
for
ifile
,
this_file
in
enumerate
(
files
):
f
=
netCDF4
.
Dataset
(
this_file
)
# Slice the longitude and latitude arrays to only include the lowest altitude
lons
=
f
.
variables
[
'Longitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
lats
=
f
.
variables
[
'Latitude'
][
2
:
-
2
,
2
:
-
2
,
0
]
*
radians_to_degrees
ax
.
scatter
(
lons
,
lats
,
c
=
colors
[
ifile
],
alpha
=
0.3
,
edgecolors
=
'none'
,
label
=
'Grid '
+
str
(
ifile
).
zfill
(
4
))
f
.
close
()
ax
.
legend
(
loc
=
'lower right'
)
plt
.
title
(
'[2:-2, 2:-2] Truncated grid file correspondence to sphere'
)
plt
.
ylabel
(
'Latitude'
)
plt
.
xlabel
(
'Longitude'
)
plt
.
savefig
(
'../_static/sphere_scatter_truncated.png'
,
dpi
=
200
,
transparent
=
True
,
bbox_inches
=
'tight'
)
plt
.
clf
()
Back
|
FazBrowse Home
|
New Git URL