-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.py
More file actions
279 lines (252 loc) · 8.69 KB
/
Copy pathrender.py
File metadata and controls
279 lines (252 loc) · 8.69 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
"""Single CLI entry point for all SOLSYS visualizations."""
from __future__ import annotations
import argparse
from typing import Literal
from animate import renderAllAnimations
from animate.scenes.alpha_centauri import renderAlphaCentauriAnimations
from animate.scenes.barnards_star import renderBarnardsStarAnimations
from animate.scenes.interstellar_objects import renderInterstellarObjectAnimations
from animate.scenes.sol_centauri_cinematic import renderSolCentauriCinematicAnimations
from animate.scenes.tabbys_star import renderTabbysStarAnimations
from animate.scenes.trappist_1 import renderTrappist1Animations
from static import renderAll as renderStatic
from static import renderNeighborhood
Dimension = Literal['2d', '3d']
# Output geometry lives here so README-friendly sizing is one place to tune.
# Pixel size ≈ inches × dpi.
ANIMATE_FIGURE_SIZE_INCHES = (12.0, 12.0)
ANIMATE_DPI_2D = 100 # original size
ANIMATE_DPI_3D = 50 # half of prior 100 for README
ANIMATE_DPI_CINEMATIC = 100 # Sol→Centauri path needs sharper labels
STATIC_FIGURE_SIZE_INCHES = (39.0, 39.0)
STATIC_DPI = 150 # was 300
NEIGHBORHOOD_FIGURE_SIZE_INCHES = (12.0, 12.0)
NEIGHBORHOOD_DPI = 150 # was 300
def _parseDimensions(choice: str) -> tuple[Dimension, ...]:
if choice == 'all':
return ('2d', '3d')
if choice in ('2d', '3d'):
return (choice,) # type: ignore[return-value]
raise ValueError(f'Unknown dimension choice: {choice!r}')
def buildParser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description='Render SOLSYS visualizations (animate=main, static=side).',
)
subparsers = parser.add_subparsers(dest='command', required=True)
staticParser = subparsers.add_parser('static', help='Side product: static 2D/3D zoom views')
staticParser.add_argument(
'--dimension',
choices=('2d', '3d', 'all'),
default='all',
help='Which projection to render (default: all)',
)
staticParser.add_argument(
'--stars',
default='data/nearby_stars_30.csv',
help='Path to nearby-stars CSV',
)
neighborhoodParser = subparsers.add_parser(
'neighborhood',
help='Side product: 3D interstellar neighborhood star map',
)
neighborhoodParser.add_argument(
'--stars',
default='data/nearby_stars_30.csv',
help='Path to nearby-stars CSV',
)
neighborhoodParser.add_argument(
'--ly',
type=float,
default=10.0,
help='Maximum distance in light years (default: 10)',
)
neighborhoodParser.add_argument(
'--output',
default=None,
help='Output JPG path (default: output/neighborhood/...)',
)
neighborhoodParser.add_argument(
'--show',
action='store_true',
help='Also open an interactive matplotlib window',
)
animateParser = subparsers.add_parser('animate', help='Main product: 2D/3D GIF animations')
animateParser.add_argument(
'--dimension',
choices=('2d', '3d', 'all'),
default='all',
help='Which Solar System animation to render (default: all)',
)
animateParser.add_argument(
'--system',
choices=(
'sol',
'alpha_centauri',
'sol_centauri',
'barnards_star',
'trappist_1',
'tabbys_star',
'oumuamua',
'interstellar',
'all',
),
default='sol',
help=(
'Which scene set to render (default: sol). '
'sol_centauri = Sol-to-Alpha Centauri cinematic; '
'interstellar = 1I/2I/3I GIFs; oumuamua = \u02bbOumuamua only (alias).'
),
)
animateParser.add_argument(
'--object',
default='all',
help=(
'For --system interstellar: object_id from data/interstellar_objects.csv '
'(oumuamua, borisov, atlas, or all). Ignored otherwise.'
),
)
animateParser.add_argument(
'--stars',
default='data/nearby_stars_30.csv',
help='Path to nearby-stars CSV (for multi-star systems)',
)
allParser = subparsers.add_parser(
'all',
help='Render main animations plus static/neighborhood side products',
)
allParser.add_argument(
'--dimension',
choices=('2d', '3d', 'all'),
default='all',
help='Which projection(s) to render (default: all)',
)
allParser.add_argument(
'--stars',
default='data/nearby_stars_30.csv',
help='Path to nearby-stars CSV',
)
allParser.add_argument(
'--ly',
type=float,
default=10.0,
help='Neighborhood map radius in light years (default: 10)',
)
allParser.add_argument(
'--system',
choices=(
'sol',
'alpha_centauri',
'sol_centauri',
'barnards_star',
'trappist_1',
'tabbys_star',
'oumuamua',
'interstellar',
'all',
),
default='all',
help='Which scene set(s) to include (default: all)',
)
allParser.add_argument(
'--object',
default='all',
help='For interstellar scenes: object_id or all (default: all)',
)
return parser
def _renderAnimations(
systemChoice: str,
dimensions: tuple[Dimension, ...],
starsCsvPath: str,
objectChoice: str,
) -> None:
if systemChoice in ('sol', 'all'):
for dimension in dimensions:
animateDpi = ANIMATE_DPI_2D if dimension == '2d' else ANIMATE_DPI_3D
renderAllAnimations(
dimension,
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=animateDpi,
)
if systemChoice in ('alpha_centauri', 'all'):
renderAlphaCentauriAnimations(
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
starsCsvPath=starsCsvPath,
)
if systemChoice in ('sol_centauri', 'all'):
renderSolCentauriCinematicAnimations(
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_CINEMATIC,
starsCsvPath=starsCsvPath,
)
if systemChoice in ('barnards_star', 'all'):
renderBarnardsStarAnimations(
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
starsCsvPath=starsCsvPath,
)
if systemChoice in ('trappist_1', 'all'):
renderTrappist1Animations(
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
starsCsvPath=starsCsvPath,
)
if systemChoice in ('tabbys_star', 'all'):
renderTabbysStarAnimations(
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
starsCsvPath=starsCsvPath,
)
if systemChoice == 'oumuamua':
renderInterstellarObjectAnimations(
objectIds=('oumuamua',),
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
)
elif systemChoice in ('interstellar', 'all'):
objectIds = None if objectChoice == 'all' else (objectChoice,)
renderInterstellarObjectAnimations(
objectIds=objectIds,
figureSizeInches=ANIMATE_FIGURE_SIZE_INCHES,
dpi=ANIMATE_DPI_2D,
)
def main(argv: list[str] | None = None) -> None:
parser = buildParser()
args = parser.parse_args(argv)
if args.command == 'neighborhood':
renderNeighborhood(
starsCsvPath=args.stars,
maxDistanceLightYears=args.ly,
outputPath=args.output,
showPlot=args.show,
figureSizeInches=NEIGHBORHOOD_FIGURE_SIZE_INCHES,
dpi=NEIGHBORHOOD_DPI,
)
return
dimensions = _parseDimensions(args.dimension)
systemChoice = getattr(args, 'system', 'sol')
# Main product first when rendering everything.
if args.command in ('animate', 'all'):
_renderAnimations(
systemChoice,
dimensions,
starsCsvPath=getattr(args, 'stars', 'data/nearby_stars_30.csv'),
objectChoice=getattr(args, 'object', 'all'),
)
if args.command in ('static', 'all'):
for dimension in dimensions:
renderStatic(
dimension,
starsCsvPath=args.stars,
figureSizeInches=STATIC_FIGURE_SIZE_INCHES,
dpi=STATIC_DPI,
)
if args.command == 'all':
renderNeighborhood(
starsCsvPath=args.stars,
maxDistanceLightYears=args.ly,
figureSizeInches=NEIGHBORHOOD_FIGURE_SIZE_INCHES,
dpi=NEIGHBORHOOD_DPI,
)
if __name__ == '__main__':
main()