Skip to content
Snippets Groups Projects
Commit 61855921 authored by Rafael Andres's avatar Rafael Andres
Browse files

command line tool: generate_scene

parent cf659fab
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,9 @@ python-kacl = "*"
pyupgrade = "*"
tryceratops = "*"
[tool.poetry.scripts]
generate_scene = "cesium_script.scene_generator:cli"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
......
"""The script creates the contextual information of the S/C (position and attitude) including:
3D visualization
ground-track information
Sun illumination
in CZML format suitable for its visualizacion in the JUICE SOC cesium tool
"""
import argparse
import logging
import spiceypy as sp
from cesium_script.czml.scene import generate_czml
from cesium_script.czml.utils import clean_utc
def generate(mk_path, start_utc, end_utc, step, body):
"""_summary_
Args:
mk_path (str): path to the metakernel
start_utc (str): scene start using UTC scale and ISO format (e.g. 2032-07-02T14:22:25Z)
end_utc (str): scene end using UTC scale and ISO format (e.g. 2032-07-02T14:22:25Z)
step (int): step used for scene calculations
body (str): Orbiting body
Returns:
filename (str): the path of the CZML file
"""
sp.kclear()
sp.furnsh(mk_path)
doc = generate_czml(start_utc, end_utc, step, body)
scene_id = f"jui_{body.lower()[:3]}_{clean_utc(start_utc)}_{clean_utc(end_utc)}"
filename = f"{scene_id}.czml"
with open(filename, "w") as file:
doc.dump(file, indent=2)
message = f"{filename} generated."
logging.info(message)
return filename
def cli(args=None):
"""Process command line arguments."""
parser = argparse.ArgumentParser(
description="Creates a CZML file containing the contextual information of the S/C (position and attitude)"
)
parser.add_argument(
"-mk", "--metakernel", type=str, help="the path to metakernel", required=True
)
parser.add_argument(
"-b", "--body", type=str, help="Central body name. eg: Europa", required=True
)
parser.add_argument(
"-st",
"--start_utc",
type=str,
help="Scene start using UTC scale and ISO format (e.g. 2032-07-02T14:22:25Z)",
required=True,
)
parser.add_argument(
"-et",
"--end_utc",
type=str,
help="Scene end using UTC scale and ISO format (e.g. 2032-07-02T19:32:17Z)",
required=True,
)
parser.add_argument(
"-s",
"--step",
type=int,
help="Step size for SPICE calculations in seconds",
required=True,
)
args = parser.parse_args()
logging.basicConfig()
generate(args.metakernel, args.start_utc, args.end_utc, args.step, args.body)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment