Import / Export API#
Timeline export#
export_timeline
#
- ptr.export_timeline(fname, ptr, subgroup='', source='GENERIC', **kwargs)[source]#
Export a PTR observation blocks into segments.
CSV and JSON files are natively compatible with the JUICE timeline tool:
https://juicesoc.esac.esa.int/tm/?trajectory=CREMA_5_0
- Parameters
fname (str or pathlib.Path) – Output filename. Currently, only
.json
and.csv
are supported.ptr (str or pathlib.Path) – PTR text or file name.
subgroup (str, optional) – Subgroup keyword (default:
<EMPTY>
).source (str, optional) – Source / working group entry (default:
GENERIC
).**kwargs – JSON output extra keywords, defaults: -
crema = 'CREMA_5_0'
-timeline = 'LOCAL'
-creation_date = None
-overwritten = False
- Returns
Output filename.
- Return type
pathlib.Path
- Raises
ValueError – If the provided filename does not end with
.json
or.csv
.
See also
extract_segments
,format_csv
,format_json
extract_segments
#
- ptr.esa.export.extract_segments(ptr, subgroup='', source='GENERIC')[source]#
Extract PTR observation blocks as segment windows.
Segment format:
[NAME, START_TIME, STOP_TIME, SUBGROUP, SOURCE]
- Parameters
ptr (PointingRequestMessage) – Parsed pointing request message.
subgroup (str, optional) – Subgroup keyword (default:
<EMPTY>
).source (str, optional) – Source / working group entry (default:
GENERIC
).
- Returns
List of segments.
- Return type
list
Note
The
NAME
keyword is extracted from the commentOBS_NAME
in the metadata comment properties if present or set toPTR_OBS_BLOCK
if not present. If aOBS_ID
comment property is present, if will be appended to theNAME
as{OBS_NAME}_{OBS_ID}
.START
andSTOP
times are return as ISO format:2032-07-08T15:53:52.350Z
The
SUBGROUP
is optional.The
SOURCE
can be empty. If a PTR block has thePRIME
property in the metadata,SOURCE
uses that value for the given block.
See also
export_timeline
format_csv
#
- ptr.esa.export.format_csv(segments, header='# name, t_start, t_end, subgroup, source')[source]#
Format segments as a CSV string.
- Parameters
segments (list) – List of events as:
[NAME, START_TIME, STOP_TIME, SUBGROUP, SOURCE]
header (str, optional) – Optional file header.
- Returns
Formatted CSV string.
- Return type
str
Note
The delimiter is a comma character (
,
).
format_json
#
- ptr.esa.export.format_json(segments, fname, crema='CREMA_5_0', timeline='LOCAL', creation_date=None, overwritten=False)[source]#
Format segments as a JSON string.
- Parameters
segments (list) – List of events as:
[NAME, START_TIME, STOP_TIME, SUBGROUP, SOURCE]
crema (str, optional) – Top level
crema
keyword.timeline (str, optional) – Top level
timeline
keyword.creation_date (str or datetime.datetime, optional) – File creation datetime in ISO format. If none provided (default), the current datetime will be used.
overwritten (bool, optional) – Segment event
overwritten
keyword.
- Returns
Formatted JSON string.
- Return type
str
Note
The
SUBGROUP
field is used to store the name that will be displayed in the JUICE timeline tool. If none is provided, theNAME
field will be used instead.