Snippets API#
Snippets Elements#
Lon
#
- class ptr.snippets.Lon(lon_e, units='deg', description=None)[source]#
Bases:
ptr.element.Element
PTR east longitude element.
- Parameters
lon (float) – East longitude value.
units (str, optional) – Value units (default: ‘deg’).
description (str or list, optional) – Longitude description, put as a xml-comment on top of the element.
Lat
#
- class ptr.snippets.Lat(lat, units='deg', description=None)[source]#
Bases:
ptr.element.Element
PTR latitude element.
- Parameters
lon (float) – Latitude value.
units (str, optional) – Value units (default: ‘deg’).
description (str or list, optional) – Latitude description, put as a xml-comment on top of the element.
Target
#
- class ptr.snippets.Target(lon_e, lat, frame='EME2000', units='deg', **attrs)[source]#
Bases:
ptr.element.Element
PTR target element.
- Parameters
lon_e (float) – Target east longitude coordinate.
lat (float) – Target latitude coordinate.
frame (str, optional) – Target reference frame (default ‘EME2000’).
units (str, optional) – Value coordinates units (default: ‘deg’).
description (str or list, optional) – Target description, put as a xml-comment on top of the element.
**attrs (optional) – Targets attributes.
SolarArrays
#
- class ptr.snippets.SolarArrays(fixed_rotation_angle=None, description=None, **attrs)[source]#
Bases:
ptr.element.Element
PTR metadata solar array element.
- Parameters
fixed_rotation_angle (float, optional) – Solar array fixed rotation angle (in degrees).
description (str or list, optional) – Solar array description, put as a xml-comment on top of the element.
Snippets Axis#
xScAxis
#
- ptr.axis.xScAxis#
alias of <SCAxis frame=”SC”> <x> 1 </x> <y> 0 </y> <z> 0 </z> </SCAxis>
yScAxis
#
- ptr.axis.yScAxis#
alias of <SCAxis frame=”SC”> <x> 0 </x> <y> 1 </y> <z> 0 </z> </SCAxis>
zScAxis
#
- ptr.axis.zScAxis#
alias of <SCAxis frame=”SC”> <x> 0 </x> <y> 0 </y> <z> 1 </z> </SCAxis>
ScAxis
#
- class ptr.axis.ScAxis(*axis, description=None)[source]#
Bases:
ptr.axis.ElementAxis
PTR spacecraft axis element.
- Parameters
*xyz (tuple or str) – Spacecraft vector tuple or axis name (eg.
(1, 0, 0)
or ‘-Y’).description (str or list, optional) – Axis description, put as a xml-comment on top of the element.
ElementAxis
#
- class ptr.axis.ElementAxis(frame, *axis, description=None)[source]#
Bases:
ptr.element.Element
PTR axis element.
- Parameters
frame (str) – Element reference frame.
*axis (tuple or str) – Axis vector tuple or axis name (eg. ‘-Y’).
description (str or list, optional) – Axis description, put as a xml-comment on top of the element.
- property frame#
Axis frame attribute.
- property x#
X-axis value.
- property y#
Y-axis value.
- property z#
Z-axis value.
Block Elements#
ElementBlock
#
- class ptr.block.ElementBlock(ref, start, end, *elements, metadata=None, description=None, **attrs)[source]#
Bases:
ptr.element.Element
,ptr.datetime.window.WithDatetimeWindow
,ptr.metadata.WithMetadata
PTR block element.
- Parameters
ref (str) – Block reference attribute.
start (string, datetime.datetime or numpy.datetime64) – Block start time.
end (string, datetime.datetime or numpy.datetime64) – Block end time.
*elements – Other block elements.
metadata (str, int, float, ptr.Element, tuple or list, optional) – Block metadata element(s).
description (str or list, optional) – Block description, put as a xml-comment on top of the element.
**attrs – Block keywords attributes.
- edit(*, start=None, end=None)[source]#
Edit block temporal window boundaries.
- Parameters
start (str, datetime.datetime or datetime.timedelta) – Start time absolute or relative offset.
end (str, datetime.datetime or datetime.timedelta) – End time absolute or relative offset.
- Raises
BlockOverlapError – If the new block is not compatible with its parent timelines.
Warning
This operation change the duration of the block.
- offset(offset, *, ref='start')[source]#
Offset block temporal window.
- Parameters
offset (str datetime.timedelta or datetime.datetime) – Global or relative offset.
ref (str, optional) – Boundary reference for relative offset. Only
start|end|center
are accepted
- Raises
BlockOverlapError – If the new block is not compatible with its parent timelines.
Note
This operation does not change the duration of the block.
- split(time, *, gap=None, ref='start')[source]#
Split block in two blocks.
- Parameters
time (str or datetime.datetime) – Splitting datetime.
gap (str, optional) – Time delta gap between the blocks.
ref (str, optional) – Reference location of the gap with respect to provided time. Only
start|end|center
are accepted
- Returns
Two copy of the original block in each time window.
- Return type
- Raises
KeyError – If the reference keyword is invalid.
ValueError – If the gap is too large for the block.
Warning
This operation change the duration of the block.
SLEW_BLOCK
#
- ptr.block.SLEW_BLOCK#
alias of <block ref=”SLEW”/>
BlockOverlapError
#
Metadata Elements#
Comment
#
- class ptr.metadata.Comment(text, description=None)[source]#
Bases:
ptr.element.Element
PTR metadata comment element.
- Parameters
text (str) – Comment message.
description (str or list, optional) – Comment description, put as a xml-comment on top of the element.
File
#
- class ptr.metadata.File(text, description=None)[source]#
Bases:
ptr.element.Element
PTR include file comment element.
- Parameters
fname (str) – Filename to include message.
description (str or list, optional) – Element description, put as a xml-comment on top of the element.
Metadata
#
- class ptr.metadata.Metadata(*comments, description=None)[source]#
Bases:
ptr.element.Element
PTR metadata element.
- Parameters
*comments (str, list, tuple or ptr.Element) – Metadata comments.
description (str or list, optional) – Element description, put as a xml-comment on top of the element.
Note
If the comment provided is a pathlib.Path it will be converted as a File element.
If the comment provided is not an Element object it will be formatted as an Comment element.
- property properties#
Comments properties stored in the metadata field.
ElementMetadata
#
- class ptr.metadata.ElementMetadata(tag, *elements, metadata=None, description=None, **attrs)[source]#
Bases:
ptr.element.Element
,ptr.metadata.WithMetadata
Element with metadata properties.
Timeline Elements#
Timeline
#
- class ptr.timeline.Timeline(*blocks, frame='SC', **attrs)[source]#
Bases:
ptr.element.Element
Planning Timeline Request element.
- Parameters
*blocks (ObsBlock, optional) – Block element(s) (default: None).
frame (str, optional) – Timeline reference frame (default: ‘SC’).
description (str or list, optional) – Timeline description, put as a xml-comment on top of the element.
**attrs – Timeline attributes keywords.
Note
The blocks are automatically sorted. Overlaps is not allowed and will raise a BlockOverlapError. Slew blocks are automatically appended to fill the gaps between the blocks. They should not be included in the blocks input list (it will return a TypeError).
- property start#
Timeline start time.
- property end#
Timeline end time.
- property duration#
Timeline duration.
- property xml#
Element XML object.
- append(element)[source]#
Append a new block to the timeline.
Warning
The new block will be added chronologically in the list of elements. It must fit between the other blocks.
- offset(offset, *, ref='start')[source]#
Offset timeline blocks globally.
- Parameters
offset (str datetime.timedelta or datetime.datetime) – Global or relative offset.
ref (str, optional) – Boundary reference for relative offset (datetime). Only
start|end|center
are accepted
- Raises
KeyError – If the reference keyword is invalid.
Note
This operation does not change the duration of the timeline.