-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot.py
executable file
·62 lines (42 loc) · 1.85 KB
/
snapshot.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
#!/usr/bin/env python3
"""This script uses an existing linear covariance analysis as
input. Suppose you have covariances saved at 0, 600, 1200, and 1800
seconds (mission elapsed time), but you want one at 300 seconds. You
can run this script with the arguments 'label 300 three_hundred' and
it will generate a time, covariance, and metadata snapshot named
three_hundred.
Probably you want to do something like this:
./start.py my_lincov f9 init
which will start the analysis named 'my_lincov' from an analysis named
'f9' that has a snapshot called 'init'. When that's finished,
./snapshot.py my_lincov 360021.0 loi
to create a snapshot of the covariance at LOI.
The only thing you can't really do with this script is to create a
snapshot a few seconds after another snapshot. For that you'd need to
write a custom script that combines start.py with snapshot.py.
"""
import numpy as np
from scipy.linalg import norm
from lincov import LinCov, progress_bar
from lincov.spice_loader import SpiceLoader
from lincov.yaml_loader import YamlLoader
from lincov.reader import find_block
import sys
if __name__ == '__main__':
if len(sys.argv) < 2:
raise SyntaxError("expected run name")
label = sys.argv[1]
mission_elapsed_time = float(sys.argv[2])
snapshot_label = sys.argv[3]
config = YamlLoader(label)
count = find_block(mission_elapsed_time, config.block_dt) - 1
loader = SpiceLoader('spacecraft')
l = LinCov.start_from(loader, label, count)
while not l.finished:
for step, mode in l.run():
if step.time >= loader.start + mission_elapsed_time:
LinCov.save_covariance(label, step.P, step.time, snapshot_label = snapshot_label)
step.save_metadata(snapshot_label)
print("Snapshot saved.")
l.finished = True
break