Events API#
read_events#
- planetary_coverage.read_events(fname, **kwargs)[source]#
Read events file.
- Parameters:
fname (str or pathlib.Path) – File name to parse
**kwargs – Parsing properties.
- Returns:
Parsed events list from the provided file.
- Return type:
CsvEventFile, EvfEventFile, ItlEventFile or OrbitEventsFile
- Raises:
FileNotFoundError – If the filename provided does not exist.
BufferError – When it’s not possible to parse the provided file.
Note
The function will try to guess the layout of the file based on the filename extension.
Event#
- class planetary_coverage.events.Event(key, *args, **kwargs)[source]#
Bases:
AbstractEventSingle time event object.
- property start: datetime64#
Event start time.
- property stop: datetime64#
Event stop time (same as start time).
- trim(*, before=None, after=None, by_event=None)[source]#
Discard the event if outside the time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
Event – Same event if the event is inside the time window considered.
None – If the event is outside the time window considered.
EventWindow#
- class planetary_coverage.events.EventWindow(key, *args, **kwargs)[source]#
Bases:
AbstractEventWindow time event object.
- property start: datetime64#
Event start time.
- property stop: datetime64#
Event stop time.
- trim(*, before=None, after=None, by_event=None)[source]#
Trim the event with time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
EventWindow – Same event if the event is inside the time window considered.
EventWindow – A trimmed event if the event cross one or both boundaries.
None – If the event is outside the time window considered.
EventsDict#
- class planetary_coverage.events.EventsDict(events, **kwargs)[source]#
Bases:
AbstractEventsCollection,UserDictList of events items with different keys.
Warning
The iteration is performed on the values and not the dict keys.
- find(*regex, as_dict=False)[source]#
Find the events matching a regex expression.
- Parameters:
- Returns:
Event(s) matching the provided regex expression(s).
- Return type:
- Raises:
KeyError – If none of the provided key was found.
Note
When multiple keys are provided, the duplicates will be discarded.
- startswith(*keys, as_dict=False)[source]#
Find the events starting with a given key
- Parameters:
See also
- endswith(*keys, as_dict=False)[source]#
Find the events ending with a given key
- Parameters:
See also
- trim(*, before=None, after=None, by_event=None)[source]#
Trim the events dict within time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
EventsDict – Same events if the event is inside the time window considered.
EventsDict – Trimmed events if the event cross one or both boundaries.
None – The events is outside the time window considered.
EventsList#
- class planetary_coverage.events.EventsList(initlist=None)[source]#
Bases:
AbstractEventsCollection,UserListList of events with the same key.
- property key#
Events key.
- trim(*, before=None, after=None, by_event=None)[source]#
Trim the events list within time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
EventsList – Same events if the event is inside the time window considered.
EventsList – Trimmed events if the event cross one or both boundaries.
None – The events is outside the time window considered.
CsvEventsFile#
- class planetary_coverage.events.CsvEventsFile(fname, primary_key='name', header=None)[source]#
Bases:
AbstractEventsFileCSV events file object.
- Parameters:
fname (str or pathlib.Path) – Input CSV event filename.
primary_key (str, optional) – Header primary key (default: name)
header (str, optional) – Optional header definition (to be appended at the beginning of the file).
versionadded: (..) – 1.2.0: CSV reader now support uncommented header.
- property csv#
Formatted CSV content.
EvfEventsFile#
- class planetary_coverage.events.EvfEventsFile(fname)[source]#
Bases:
AbstractEventsFileEVF event file object.
EVF are in MAPPS format.
- Parameters:
fname (str or pathlib.Path) – EVF filename to parse.
ItlEventsFile#
- class planetary_coverage.events.ItlEventsFile(fname, evf=None)[source]#
Bases:
AbstractEventsFileITL event file object.
Instrument timeline.
- Parameters:
fname (str or pathlib.Path) – ITL filename to parse.
evf (str or pathlib.Path) – Supporting EVF events file (for relative timelines).
- property observations#
List of observation windows.
OrbitEventsFile#
- class planetary_coverage.events.OrbitEventsFile(fname)[source]#
Bases:
AbstractEventsFileOrbit event file object.
- Parameters:
fname (str or pathlib.Path) – ORB filename to parse.
AbstractEvent#
- class planetary_coverage.events.event.AbstractEvent(key, *args, **kwargs)[source]#
Bases:
UserDictSingle time event object.
- property start: datetime64#
Event start time.
- property stop: datetime64#
Event stop time.
- property start_date#
Event start date.
- property stop_date#
Event stop date.
- contains(pts)[source]#
Check if points are inside the temporal windows.
- Parameters:
pts (numpy.ndarray) – List of temporal UTC point(s):
utcor[utc_0, …]. If an object withutcattribute/property is provided, the intersection will be performed on these points.- Returns:
Return
Trueif the point is inside the pixel corners, andFalseoverwise.- Return type:
Note
If the point is on the edge of the window it will be included.
- trim(*, before=None, after=None, by_event=None)[source]#
Trim the event with time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
AbstractEvent – Same event if the event is inside the time window considered.
AbstractEvent – A trimmed event if the event cross one or both boundaries.
None – If the event is outside the time window considered.
AbstractEventsCollection#
- class planetary_coverage.events.event.AbstractEventsCollection[source]#
Bases:
objectAbstract collection of events.
- property start: datetime64#
Global events start time.
- property stop: datetime64#
Global events stop time.
- property start_date#
global events start date.
- property stop_date#
Global events stop date.
- contains(pts)[source]#
Check if points are inside any temporal window.
- Parameters:
pts (numpy.ndarray) – List of temporal UTC point(s):
utcor[utc_0, …]. If an object withutcattribute/property is provided, the intersection will be performed on these points.- Returns:
Return
Trueif the point is inside the pixel corners, andFalseoverwise.- Return type:
Note
If the point is on the edge of the window it will be included.
- before(date_stop, strict=False, as_dict=False)[source]#
Select all the events before the given date.
- between(date_start, date_stop, strict=False, as_dict=False)[source]#
Select all the events between the given dates.
Danger
The parenthesis in the comparison are mandatory here. Comparison operator chains (
a < b < c) will break due to short-circuit chain evaluation (a < b and b < c) where onlya < bif the result is not False andb < cotherwise, not the intersection ((a < b) & (b < c)).
- trim(*, before=None, after=None, by_event=None)[source]#
Trim the events within time boundaries.
- Parameters:
before (str, datetime.datetime or numpy.datetime64) – Start time window to consider.
after (str, datetime.datetime or numpy.datetime64) – Stop time window to consider.
by_event (AbstractEvent or AbstractEventsCollection) – Event(s) that can be used as an time window range.
- Returns:
AbstractEventsCollection – Same events if the event is inside the time window considered.
AbstractEventsCollection – Trimmed events if the event cross one or both boundaries.
None – The events is outside the time window considered.
AbstractEventsFile#
- class planetary_coverage.events.event.AbstractEventsFile(fname, primary_key, header=None)[source]#
Bases:
EventsDictAbstract Events File object.
- Parameters:
fname (str or pathlib.Path) – Input event filename.
primary_key (str, optional) – Header primary key (default: name)
header (str, optional) – Optional header definition (to be appended at the beginning of the file).
- property fname#
Events filename.
timedelta()#
- planetary_coverage.events.timedelta(step)[source]#
Parse step as
numpy.timedelta64object.The value must be a
intfollowed by an optional space and a valid unit.Examples of valid units:
ms,msec,milliseconds,sec,secondm,min,minuteh,hourD,dayM,monthY,year
- Parameters:
step (str) – Step to parse.
- Returns:
Parsed numpy.timedelta64 step.
- Return type:
- Raises:
ValueError – If the provided step format or unit is invalid.