Import / Export PTR#

Export PTR as ESA timeline#

The JUICE Segment Harmonization Tool (a.k.a the JUICE timeline tool) is an online events visualization tool that can be used to display a collection of temporal events in different timelines. It allows the ESA-SOC to plan events computed with other planning tools.

It is possible to export a PTR file, PTR string or PointingRequestMessage object into CSV and JSON files compatible with the pointing tool. For example you can do:

from ptr import read_ptr, export_timeline

ptr = read_ptr('example.ptx')
<prm>
  <body>
    <segment>
      <data>
        <timeline frame="SC">
            <block ref="OBS">
               <metadata>
                  <comment> Occultation by star HD157056 </comment>
                  <comment>PRIME=JANUS</comment>
                  <solarArrays>
                     <fixedRotationAngle units="deg">-50</fixedRotationAngle>
                  </solarArrays>
               </metadata>
               <startTime> 2032-07-02T04:18:40 </startTime>
               <endTime> 2032-07-02T04:32:00 </endTime>
               <attitude ref="inertial">
                  <boresight ref="SC_Zaxis" />
                  <phaseAngle ref="align">
                     <SCAxis frame="SC">
                        <x> 0 </x>
                        <y> -1 </y>
                        <z> 0 </z>
                     </SCAxis>
                     <inertialAxis ref="EU2SC" />
                  </phaseAngle>
                  <target frame="EME2000">
                     <lon units="deg"> 260.504 </lon>
                     <lat units="deg"> -24.999 </lat>
                  </target>
               </attitude>
            </block>
        </timeline>
      </data>
    </segment>
  </body>
</prm>

Then:

export_timeline('example.csv', ptr)
PosixPath('example.csv')
# name,t_start,t_end,subgroup,source
JANUS_PRIME_OBSERVATION,2032-07-02T04:18:40Z,2032-07-02T04:32:00Z,,JANUS

Or, you can do it in your terminal:

!ptr2seg --help
usage: ptr2seg [-h] [-o FILENAME] [--json] [--subgroup SUBGROUP]
               [--source SOURCE] [--crema CREMA] [--timeline TIMELINE]
               ptr

Convert PTR to segmentation file.

positional arguments:
  ptr                   PTR/PTX input file.

optional arguments:
  -h, --help            show this help message and exit
  -o FILENAME, --output FILENAME
                        Custom output filename (default: PTR filename).
  --json                Export as JSON (default CSV if not provided).
  --subgroup SUBGROUP   Subgroup field (default: `<EMPTY>`).
  --source SOURCE       Source field (default: `GENERIC`).
  --crema CREMA         Trajectory crema keyword in JSON export (default:
                        `CREMA_5_0`).
  --timeline TIMELINE   Timeline keyword in JSON export (default: `LOCAL`).
!ptr2seg --json example.ptx
Segmentation saved in: example.json
{"creationDate": "2023-07-19T22:42:46.416Z", "name": "example", "segments": [{"start": "2032-07-02T04:18:40Z", "end": "2032-07-02T04:32:00Z", "segment_definition": "JANUS_PRIME_OBSERVATION", "name": "JANUS_PRIME_OBSERVATION", "overwritten": false, "timeline": "LOCAL", "source": "JANUS", "resources": []}], "segmentGroups": [], "trajectory": "CREMA_5_0", "localStoragePk": ""}

More details can be found here.