ITL submodule

ITL submodule#

ITL generic reader module.

majis.itl.reader.read_itl(fname: str | Path, refs: dict | str | list | None = None, flat: bool = False, only: str | list | bool | None = 'MAJIS', validation: bool = True) EventsDict | EventsList[source]

Read any ITL file.

Both, EPS/text (.itl or .txt) or JSON (.json) format are supported.

In the case of EPS format, relative datetime input is supported with references value(s) or file (.evf).

The result can be return as a nested dict of events (default) or as a flat list of events.

By default only the MAJIS events will be reported. This can be changed by providing an other instrument filter key, a list of keys or an explicit 'ALL', False or None value. Applicable only to JSON ITL.

ITL export module.

majis.itl.export.save_itl(fout: str | Path | None, *events: EventsList | EventsDict, ref: str | dict | None = None, overlap: bool = False, **kwargs) Path[source]

Save ITL events to a new ITL file.

Note

By default, ITL blocks must not overlap each other. This can be disable with overlap=True.

MAJIS ITL timeline sub-module.

majis.itl.timeline.ChangeLog

alias of Log

class majis.itl.timeline.Timeline(observations: str | Path | EventsList | EventsDict | None = None, timeline: str | Path | None = None, ca_ref: str | dict | None = None, refs: dict | str | list | None = None)[source]

MAJIS timeline from template.

You can either append an existing timeline template or use the default one.

Warning

Some extensions (Data Validation) are not included into the exported file. This is a openpyxl limitation.

append(observations: str | Path | EventsList | EventsDict, refs: dict | str | list | None = None) None[source]

Append ITL observations blocks.

property ca_ref: datetime

C/A reference for relative time.

property header

Timeline header size.

save(fout: str | Path | None = None) Path[source]

Save MAJIS timeline.

property science: TimelineChangeLog

Science change log.

Raises:

ValueError: – Only available for template β‰₯ 2.0

property version

Template version from changelog.

class majis.itl.timeline.TimelineChangeLog(template: Workbook, sheet_name='change log')[source]

MAJIS timeline change log.

read_changelog(rows: list) -> (<class 'list'>, <class 'list'>)[source]

Read changelog changes grouped by version, date and author.

Majis ITL in EPS format sub-module.

majis.itl.eps.reader.read_itl_eps(fname: str | Path, refs: dict | str | list | None = None) list[EventWindow][source]

Read ITL file in EPS (text) format.

Note

  • The blocks can be prefixed with additional instrument parameters.

  • Blocks must be continuous, ie. consecutive OBS_START and OBS_END lines should have the same instrument observation name. If not an ValueError will be raised

ITL EPS export module.

majis.itl.eps.export.fmt_eps_comments(event: dict | EventWindow, max_length: int = 90) list[str][source]

Format EPS comments.

Majis ITL in JSON format sub-module.

majis.itl.json.reader.parse_json(obs: dict, defaults: dict | None = None) dict[source]

Map ITL JSON timeline keys to EPS event dictionary.

majis.itl.json.reader.read_itl_json(fname: str | Path, fmt: str = 'ITL', only: str | list | bool | None = 'MAJIS', validation: bool = True) list[EventWindow][source]

Read ITL file in JSON format.

ITL are validated against Juice SOC and Majis schema.

By default only the MAJIS events will be reported. This can be changed by providing an other instrument filter key, a list of keys or an explicit β€˜ALL’, False or None value.

ITL JSON export module.

majis.itl.json.export.fmt_json(event: Event) dict[source]

Format an event into JSON timeline dictionary.

majis.itl.json.export.get_header(fout: str | Path | None = None, fmt='ITL') dict[source]

Get JSON header.

ITL CSV export module.

majis.itl.csv.export.fmt_csv(blocks: dict | EventsList | EventsDict, ref: str | None = None, sep: str = ';') str[source]

Format CSV format.

majis.itl.csv.export.get_header(blocks: list[list | dict] | EventsList | EventsDict, ref: str | dict | None = None) list[source]

Get CSV header.

The keys are unique and ordered with the following rules:

  • If OBS_NAME is present, it will be placed first.

  • t_start and t_end are required and replaced by OBS_START

    and OBS_END and placed after OBS_NAME (if present).

  • if ref time is provided OBS_START_REL and OBS_END_REL

    are appended after OBS_START and OBS_END.

  • COMMENTS is present, it will always put last.

majis.itl.csv.export.get_value(block: dict | Event | EventWindow, key: str, ref: str | None = None) str[source]

Format block value.

This method extract the block value for a given property and re-format the datetime if necessary.

Comments values are escaped with double quotes (”…”).

ITL CLI module.

majis.itl.cli.cli(argv: list | None = None)[source]

ITL command line interface.