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
.jsonand.csvare 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
.jsonor.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
NAMEkeyword is extracted from the commentOBS_NAMEin the metadata comment properties if present or set toPTR_OBS_BLOCKif not present. If aOBS_IDcomment property is present, if will be appended to theNAMEas{OBS_NAME}_{OBS_ID}.STARTandSTOPtimes are return as ISO format:2032-07-08T15:53:52.350ZThe
SUBGROUPis optional.The
SOURCEcan be empty. If a PTR block has thePRIMEproperty in the metadata,SOURCEuses 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
cremakeyword.timeline (str, optional) – Top level
timelinekeyword.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
overwrittenkeyword.
- Returns
Formatted JSON string.
- Return type
str
Note
The
SUBGROUPfield is used to store the name that will be displayed in the JUICE timeline tool. If none is provided, theNAMEfield will be used instead.