-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgb.py
executable file
·87 lines (75 loc) · 1.83 KB
/
gb.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
#
# Loads the data and plot a map of GB.
# Extra command-line arguments can be used to show only part of the data, e.g.
#
# python gb.py NY12
#
import os
import sys
import nevis
# Say hi
nevis.howdy()
# Zoom and boudnaries
boundaries = None
zoom = 1 / 27
# Show grid
big_grid = True
small_grid = False
# Zoom in on a grid square
try:
square = nevis.Coords.from_square_with_size(sys.argv[1])
except Exception:
square = None
if square:
x, y = square[0].grid
r = nevis.spacing()
boundaries = [x, x + square[1] - r, y, y + square[1] - r]
zoom = 1 if square[1] > 50000 else 1
small_grid = True
# Show some points
points = trajectory = None
if False:
import numpy as np
ben = nevis.ben()
points = []
trajectory = [np.array(ben.grid)]
for i in range(50):
trajectory.append(
trajectory[-1] + (np.random.random(2) - 0.5) * 5e2 * i**1.5)
for j in range(10):
points.append(
trajectory[-1] + (np.random.random(2) - 0.5) * 8e2 * i**1.5)
trajectory = np.array(trajectory)
points = np.array(points)
# Zoom in on an area
if False:
b = nevis.ben().grid
d = 20e3
boundaries = [b[0] - d, b[0] + d, b[1] - d, b[1] + d]
zoom = 1
small_grid = True
# Labels
labels = {
'Ben Nevis': nevis.ben(),
'Holme Fen': nevis.fen(),
}
# Load data
nevis.gb()
# Create plot
# zoom=1 / 27 makes the plot fit on my screen at 100% zoom.
fig, ax, heights, g = nevis.plot(
boundaries=boundaries,
labels=labels,
trajectory=trajectory,
points=points,
big_grid=big_grid,
small_grid=small_grid,
zoom=zoom,
headless=True,
verbose=True,
)
# Save plot, and check resulting image dimensions
if not os.path.isdir('results'):
os.makedirs('results')
nevis.save_plot('results/gb.png', fig, heights, verbose=True)