OPL submodule

OPL submodule#

OPL generic reader module.

majis.opl.reader.parse_opl_csv(key, start, end, obs_key, instrument) dict[source]

OPL CSV line parser.

Warning

Currently the OPL CSV don’t have an explicit header. Here we assume that the header is as follow”

# key, start, end, obs_key, instrument

The initial key is composed of the following parameters:

<instrument>_<observation_type>_<type>

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

Read OPL file.

Both, CSV (.csv) and JSON (.json) format are supported.

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 OPL.

majis.opl.reader.read_opl_csv(fname: str | Path) list[EventWindow][source]

Read OPL file in CSV format.

majis.opl.reader.read_opl_json(fname: str | Path, only: str | list | bool | None = 'MAJIS', validation: bool = True) list[EventWindow][source]

Read OPL file in JSON format.

Note

Re-use ITL JSON reader with OPL schema instead.

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.

OPL generic export module.

majis.opl.export.fmt_opl_csv(obs: EventWindow) list[str][source]

OPL CSV line formatter.

Warning

Currently the OPL CSV don’t have an explicit header. Here we assume that the header is as follow”

# key, start, end, obs_key, instrument

The initial key is composed of the following parameters:

<instrument>_<observation_type>_<type>

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

Save OPL events to a new OPL file.

Note

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

majis.opl.export.save_opl_json(fout: str | Path | None, *events: EventsList | EventsDict, overlap: bool = False) Path[source]

Export OPL file in JSON format.

Note

Re-use ITL JSON export with OPL schema instead.

OPL convert module.

majis.opl.convert.csv2json_opl(opl_csv: str | Path | None, overlap: bool = False) Path[source]

Export OPL from CSV to JSON format.

majis.opl.convert.json2csv_opl(opl_json: str | Path | None, overlap: bool = False, only: str | list | bool | None = 'MAJIS') Path[source]

Export OPL from JSON to CSV format.