diff --git a/make_timeline.py b/make_timeline.py index 45dd5cc..5b2fd69 100755 --- a/make_timeline.py +++ b/make_timeline.py @@ -39,6 +39,8 @@ cd .. rsync -av t_now/ /proj/sot/ska/www/ASPECT_ICXC/test_review_outputs/arc/${PR}/t_now/ + diff t_now/{flight,$COMMIT}/timeline_states.js + Local ----- Testing on a local machine (Mac) requires syncing the data files from kady. This tests @@ -62,11 +64,11 @@ Get the flight run date and convert that to a full date-format date (e.g. "317/1211z" => "2024:317:12:11:00"):: - tail -c 400 t_now/flight/timeline_states.js | grep now_date + DATE_NOW=`python utils/get_date_now.py t_now/flight` Run the script with the test option:: - python make_timeline.py --test --data-dir=t_now/$COMMIT --date-now= + python make_timeline.py --test --data-dir=t_now/$COMMIT --date-now=$DATE_NOW To view the output, open the directory in a browser:: @@ -75,7 +77,10 @@ Compare the timeline_states.js files:: - diff t_now/{flight,$COMMIT}/timeline_states.js + python utils/convert_states_to_yaml.py t_now/$COMMIT + python utils/convert_states_to_yaml.py t_now/flight + + diff t_now/{flight,$COMMIT}/timeline_states.yaml """ import argparse diff --git a/utils/convert_states_to_yaml.py b/utils/convert_states_to_yaml.py new file mode 100644 index 0000000..edc3c57 --- /dev/null +++ b/utils/convert_states_to_yaml.py @@ -0,0 +1,12 @@ +"""Convert timeline_states.js to YAML timeline_states.yaml for easier comparison.""" + +import json +import sys +from pathlib import Path + +import yaml + +data_dir = sys.argv[1] +text = Path(f"{data_dir}/timeline_states.js").read_text() +states = json.loads(text[11:]) +yaml.dump(states, open(f"{data_dir}/timeline_states.yaml", "w")) diff --git a/utils/get_date_now.py b/utils/get_date_now.py new file mode 100644 index 0000000..d8fa51a --- /dev/null +++ b/utils/get_date_now.py @@ -0,0 +1,19 @@ +"""Convert the now_date from timeline_states.js to a CxoTime date string.""" + +import json +import sys +from pathlib import Path + +from cxotime import CxoTime + +data_dir = sys.argv[1] +text = Path(f"{data_dir}/timeline_states.js").read_text() +data = json.loads(text[11:]) + +# Get date like "319/1215z" +now_date = data["now_date"] +year = CxoTime.now().date[:4] + +# Convert now_date to "{year}:319:12:15:00" +date = f"{year}:{now_date[0:3]}:{now_date[4:6]}:{now_date[6:8]}:00" +print(date)