Source code for gfinder.commands.event
"""GFINDER CLI `event` command."""
import click
from .docstring import set_docstring
from gfinder.config import Config
from gfinder.datastore import DataStore
@click.command(name='event')
@click.argument('mission-event-id')
@click.option('--mission-scenario-id', type=click.STRING, help='Mission scenario ID (default: '+Config().default_mission_scenario_id+')')
def event_cmd(mission_event_id, mission_scenario_id):
"""Get information about a mission event for a given event identifier or synonym.
A mission event ID within MOS is defined as a unique string identifier allowing to retrieve an event defined in
events files. Identifier is formed as follows::
\b
MISSION_EVENT_ID: '<event_file_key>:<key1>[:<key2>]' (full) or '<synonym>'
where:
- <event_file_key> is the key of event file as defined in the Mission Scenario Index file, for example:
'phase', 'timeline', 'orbit', 'dl' and 'custom'.
- <key1> is the name of the event (eg: 'GCO500' or 'PERIJOVE_12PJ'), or the name of the events list (eg:
'FLYBY_EUROPA' or 'DL_').
- <key2> is the optional name of the event, when exists (eg: '7E1' for 'FLYBY_EUROPA' events list), or the
occurence number of the event in the events list (eg: '66' for 'IO_TRANSIT' events list).
For example:
\b
$ gfinder event phase:GCO500
$ gfinder event timeline:FLYBY_GANYMEDE:1G1
$ gfinder event orbit:54
$ gfinder event custom:TOUR
When only <event_file_key> is provided (no <key1> and <key2>), it is assumed to be a synonym and its corresponding
event ID is derived. Examples of synonyms, which can be used (not sensitive to the case):
\b
$ gfinder event TOUR # 'custom:TOUR'
$ gfinder event GCO500 # 'phase:GCO500'
$ gfinder event 7E1 # 'timeline:FLYBY_EUROPA:7E1'
$ gfinder event PJ12 # 'timeline:PERIJOVE_12PJ'
$ gfinder event AP12 # 'timeline:APOJOVE_12AP'
$ gfinder event orb54 # 'orbit:54'
$ gfinder event dl666 # 'dl:DL_:666'
"""
event(mission_event_id, mission_scenario_id=mission_scenario_id)
[docs]@set_docstring(event_cmd, {'mission_event_id': 'Mission event ID.'})
def event(mission_event_id, mission_scenario_id=None):
# Init data store
datastore = DataStore()
# Get selected mission scenario
if not mission_scenario_id:
mission_scenario_id = Config().default_mission_scenario_id
mission_scenario = datastore.getMissionScenario(mission_scenario_id)
if not mission_scenario:
print(f'Invalid {mission_scenario_id} mission scenario.\n'
f'Use `scenarios` command to list available mission scenarios, defined scenarios/mission_scenarios.json file.\n')
return
# load kernels
mission_scenario.loadKernels() # required for time conversion :/
event = mission_scenario.get_event(mission_event_id)
if event:
click.echo()
click.echo(event)
click.echo()
return event
else:
click.echo()
click.echo(f'Undefined input mission event ID or synonym: {mission_event_id}\n'
f'Use `events` command to list/filter available mission events ids.')