majis-ops


Namemajis-ops JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryJuice/MAJIS operations toolbox
upload_time2024-06-19 21:41:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords esa ias juice majis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            MAJIS Operations Toolbox
========================

<img src="https://majis-ops.readthedocs.io/en/latest/_images/logo-square.svg" align="right" hspace="50" vspace="50" height="200" alt="Majis operations toolbox logo">

[![Pipeline Status](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/badges/main/pipeline.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/pipelines/main/latest)
[![Test coverage](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/badges/main/coverage.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/pipelines/main/latest)
[![Documentation Status](https://readthedocs.org/projects/majis-ops/badge/?version=latest)](https://app.readthedocs.org/projects/majis-ops/builds/?version=latest)
[![Latest release](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/-/badges/release.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/-/releases)


This toolbox aims to collect MAJIS Operations scripts in a common python package.

The full documentation of the package can be found in [majis-ops.readthedocs.io](https://majis-ops.readthedocs.io)

🚀 Installation
---------------
```bash
python -m pip install majis-ops
```

🛰️ Basic examples
-----------------
### 🐍 As python package
- Read a ITL file:
```python
from majis.itl import read_itl

# Load absolute time ITL as EventsDict object
itl_abs = read_itl('absolute_time.itl')

# Load relative time ITL as EventsList object
itl_rel = read_itl('relative_time.itl', refs='events.evf', flat=True)
```
__Note:__ Relative datetime can be provided either with a EVF file or inline with one or multiple strings: `DATETIME  REF_NAME (COUNT = N)`

- Export one (or multiple) ITL blocks:
```python
from majis.itl import save_itl, save_csv, save_xlsm

# Export as absolute ITL
save_itl('output.itl', itl_abs, itl_rel, …)

# Export as relative ITL
save_itl('output.itl', itl_abs, itl_rel, …, ref='DATETIME  REF_NAME (COUNT = N)')

# Export as CSV
save_csv('output.csv', itl_abs, itl_rel, …)

# Export as XLSM timeline w.r.t. C/A reference (based on default template)
save_xlsm('output.xlsm', itl_abs, ca_ref='DATETIME  REF_CA (COUNT = N)')

# Append to an existing XLSM timeline
save_xlsm(None, itl_abs, timeline='timeline.xlsm')
```
__Notes:__
- When multiple ITL are provided, they will be concatenate and ordered by date.
- Absolute and relative ITL are compatible.
- Export can be either absolute or relative to a reference.
- Observation block must not overlap.

- Manipulate MAJIS timeline (`.xlsm` file):
```python
>>> from majis import Timeline

>>> timeline = Timeline(timeline='timeline.xlsm')

# Get template version
>>> template.version
<Version('2.0')>

# Get template changelog
>>> template.log
'>>>    2.0 | 2024-06-04 | Vincent Carlier'
'Empty template with 500 lines pre-filled with formulas and data validation format'
'...'
'>>>    1.0 | 2022-11-08 | François Poulet'
'creation'

# Get science changelog
>>> template.science
''  # Empty by default

# Get the number of observations
>>> len(timeline)
10

# Get the list of observations
>>> timeline['OBS_NAME']
['OBS_001', ...]

# Get an observation details
>>> timeline[1]
{'OBS_NAME': 'OBS_001', 'start_angle': 1.5, ...}

# Get an observation property
>>> timeline['start_angle', 1]
1.5

# Append new observations from ITL file
>>> timeline.append('absolute_time.itl')

# Edit a single field
>>> timeline['start_angle', 1] = -1.5
>>> timeline['start_angle', 1]
-1.5

# Save to the same XLSM timeline
>>> timeline.save()

# Create a new timeline from the default template and a relative ITL file
>>> timeline = Timeline('relative_time.itl', refs='events.evf')

# Compute all relative time w.r.t. to a C/A reference
>>> timeline.ca_ref = '2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)'
>>> timeline['First CU_frame start wrt C/A', 1]
'-001.18:35:25'

# Export the timeline to a new file
>>> timeline.save('new_timeline.xlsm')
```

### 👾 As command line interface
```bash
$ majis-itl --help

usage: majis-itl [-h] [-o output.[itl|csv|xlsm]] [-f]
                 [-t "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)"]
                 [-r "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)"]
                 [--timeline timeline.xlsm] [--header "# my-custom-header"]
                 [--overlap] [--csv] [--csv-sep separator]
                 [input.itl ...]

MAJIS ITL toolbox

positional arguments:
  input.itl             Input ITL filename(s). If multiple files are provided
                        they will be concatenated.

options:
  -h, --help            show this help message and exit
  -o output.[itl|csv|xlsm], --output output.[itl|csv|xlsm]
                        Output filename, it could be either ITL, CSV or XLSM.
                        If none provided, the results will be displayed (only
                        for ITL and CSV).
  -f, --force           Overwrite the output file if already exists.
  -t "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)", --time-ref "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)"
                        Input events time reference(s). If multiple values are
                        required use an `events.evf` file.
  -r "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)", --relative-to "YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)"
                        Reference time to be used for relative time output.
  --timeline timeline.xlsm
                        Original timeline to append. If no explicit `--output`
                        is provided new observations will be append in this
                        file.
  --header "# my-custom-header"
                        ITL custom file header.
  --overlap             Allow blocks overlap.
  --csv                 Display the ITL as CSV.
  --csv-sep separator   CSV separator (default: ";")
```

_Examples:_
- Convert a single ITL with relative time as an absolute CSV ITL file:
```bash
majis-itl relative_time.itl --time-ref "2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)" --output output.csv
```

- Concatenate two ITL with absolute and relative times as an relative ITL file:
```bash
majis-itl absolute_time.itl relative_time.itl --ref-time events.evf --relative-to "2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)" --output output.itl
```

__Note:__ If no `--output` flag is present, the output is display in the console.

- Create a new MAJIS timeline (`.xlsm`) from a ITL the default template.
```bash
majis-itl absolute_time.itl --output output.xlsm
```

- Edit an existing MAJIS timeline to compute relative time w.r.t. C/A reference.
```bash
majis-itl --timeline timeline.xlsm --relative-to "2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)"
```

__Note:__ If no `--output` flag is present, the output will be save in the original template.


👐 Contribution
---------------
If you want to contribute to this project, you need to install [`hatch`](https://hatch.pypa.io/latest/install/) on your system, then clone the depot and install de default env:
```bash
git clone https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox.git
cd majis-ops-toolbox

# Install dev dependencies
hatch env create

# Setup pre-commit hook
hatch -e linter run pre-commit install
```

To lint and format the source code:

```bash
hatch -e linter run check
hatch -e linter run format
```

To test the module:
```bash
hatch -e tests run tests
```

To build the docs:
```bash
hatch -e docs run build
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "majis-ops",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Beno\u00eet Seignovert <benoit.seignovert@univ-nantes.fr>",
    "keywords": "esa, ias, juice, majis",
    "author": null,
    "author_email": "Beno\u00eet Seignovert <benoit.seignovert@univ-nantes.fr>, Axelle Gottafray <quentin.gottafray@ias.u-psud.fr>",
    "download_url": "https://files.pythonhosted.org/packages/03/d4/c0762114a8381fcfa20ef1b3ad8b48a7ebff2adb0edf2421f7a0e597331e/majis_ops-1.0.0.tar.gz",
    "platform": null,
    "description": "MAJIS Operations Toolbox\n========================\n\n<img src=\"https://majis-ops.readthedocs.io/en/latest/_images/logo-square.svg\" align=\"right\" hspace=\"50\" vspace=\"50\" height=\"200\" alt=\"Majis operations toolbox logo\">\n\n[![Pipeline Status](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/badges/main/pipeline.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/pipelines/main/latest)\n[![Test coverage](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/badges/main/coverage.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/pipelines/main/latest)\n[![Documentation Status](https://readthedocs.org/projects/majis-ops/badge/?version=latest)](https://app.readthedocs.org/projects/majis-ops/builds/?version=latest)\n[![Latest release](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/-/badges/release.svg)](https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/-/releases)\n\n\nThis toolbox aims to collect MAJIS Operations scripts in a common python package.\n\nThe full documentation of the package can be found in [majis-ops.readthedocs.io](https://majis-ops.readthedocs.io)\n\n\ud83d\ude80 Installation\n---------------\n```bash\npython -m pip install majis-ops\n```\n\n\ud83d\udef0\ufe0f Basic examples\n-----------------\n### \ud83d\udc0d As python package\n- Read a ITL file:\n```python\nfrom majis.itl import read_itl\n\n# Load absolute time ITL as EventsDict object\nitl_abs = read_itl('absolute_time.itl')\n\n# Load relative time ITL as EventsList object\nitl_rel = read_itl('relative_time.itl', refs='events.evf', flat=True)\n```\n__Note:__ Relative datetime can be provided either with a EVF file or inline with one or multiple strings: `DATETIME  REF_NAME (COUNT = N)`\n\n- Export one (or multiple) ITL blocks:\n```python\nfrom majis.itl import save_itl, save_csv, save_xlsm\n\n# Export as absolute ITL\nsave_itl('output.itl', itl_abs, itl_rel, \u2026)\n\n# Export as relative ITL\nsave_itl('output.itl', itl_abs, itl_rel, \u2026, ref='DATETIME  REF_NAME (COUNT = N)')\n\n# Export as CSV\nsave_csv('output.csv', itl_abs, itl_rel, \u2026)\n\n# Export as XLSM timeline w.r.t. C/A reference (based on default template)\nsave_xlsm('output.xlsm', itl_abs, ca_ref='DATETIME  REF_CA (COUNT = N)')\n\n# Append to an existing XLSM timeline\nsave_xlsm(None, itl_abs, timeline='timeline.xlsm')\n```\n__Notes:__\n- When multiple ITL are provided, they will be concatenate and ordered by date.\n- Absolute and relative ITL are compatible.\n- Export can be either absolute or relative to a reference.\n- Observation block must not overlap.\n\n- Manipulate MAJIS timeline (`.xlsm` file):\n```python\n>>> from majis import Timeline\n\n>>> timeline = Timeline(timeline='timeline.xlsm')\n\n# Get template version\n>>> template.version\n<Version('2.0')>\n\n# Get template changelog\n>>> template.log\n'>>>    2.0 | 2024-06-04 | Vincent Carlier'\n'Empty template with 500 lines pre-filled with formulas and data validation format'\n'...'\n'>>>    1.0 | 2022-11-08 | Fran\u00e7ois Poulet'\n'creation'\n\n# Get science changelog\n>>> template.science\n''  # Empty by default\n\n# Get the number of observations\n>>> len(timeline)\n10\n\n# Get the list of observations\n>>> timeline['OBS_NAME']\n['OBS_001', ...]\n\n# Get an observation details\n>>> timeline[1]\n{'OBS_NAME': 'OBS_001', 'start_angle': 1.5, ...}\n\n# Get an observation property\n>>> timeline['start_angle', 1]\n1.5\n\n# Append new observations from ITL file\n>>> timeline.append('absolute_time.itl')\n\n# Edit a single field\n>>> timeline['start_angle', 1] = -1.5\n>>> timeline['start_angle', 1]\n-1.5\n\n# Save to the same XLSM timeline\n>>> timeline.save()\n\n# Create a new timeline from the default template and a relative ITL file\n>>> timeline = Timeline('relative_time.itl', refs='events.evf')\n\n# Compute all relative time w.r.t. to a C/A reference\n>>> timeline.ca_ref = '2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)'\n>>> timeline['First CU_frame start wrt C/A', 1]\n'-001.18:35:25'\n\n# Export the timeline to a new file\n>>> timeline.save('new_timeline.xlsm')\n```\n\n### \ud83d\udc7e As command line interface\n```bash\n$ majis-itl --help\n\nusage: majis-itl [-h] [-o output.[itl|csv|xlsm]] [-f]\n                 [-t \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\"]\n                 [-r \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\"]\n                 [--timeline timeline.xlsm] [--header \"# my-custom-header\"]\n                 [--overlap] [--csv] [--csv-sep separator]\n                 [input.itl ...]\n\nMAJIS ITL toolbox\n\npositional arguments:\n  input.itl             Input ITL filename(s). If multiple files are provided\n                        they will be concatenated.\n\noptions:\n  -h, --help            show this help message and exit\n  -o output.[itl|csv|xlsm], --output output.[itl|csv|xlsm]\n                        Output filename, it could be either ITL, CSV or XLSM.\n                        If none provided, the results will be displayed (only\n                        for ITL and CSV).\n  -f, --force           Overwrite the output file if already exists.\n  -t \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\", --time-ref \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\"\n                        Input events time reference(s). If multiple values are\n                        required use an `events.evf` file.\n  -r \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\", --relative-to \"YYYY-MM-DDTHH:MM:SS REF_NAME (COUNT = N)\"\n                        Reference time to be used for relative time output.\n  --timeline timeline.xlsm\n                        Original timeline to append. If no explicit `--output`\n                        is provided new observations will be append in this\n                        file.\n  --header \"# my-custom-header\"\n                        ITL custom file header.\n  --overlap             Allow blocks overlap.\n  --csv                 Display the ITL as CSV.\n  --csv-sep separator   CSV separator (default: \";\")\n```\n\n_Examples:_\n- Convert a single ITL with relative time as an absolute CSV ITL file:\n```bash\nmajis-itl relative_time.itl --time-ref \"2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)\" --output output.csv\n```\n\n- Concatenate two ITL with absolute and relative times as an relative ITL file:\n```bash\nmajis-itl absolute_time.itl relative_time.itl --ref-time events.evf --relative-to \"2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)\" --output output.itl\n```\n\n__Note:__ If no `--output` flag is present, the output is display in the console.\n\n- Create a new MAJIS timeline (`.xlsm`) from a ITL the default template.\n```bash\nmajis-itl absolute_time.itl --output output.xlsm\n```\n\n- Edit an existing MAJIS timeline to compute relative time w.r.t. C/A reference.\n```bash\nmajis-itl --timeline timeline.xlsm --relative-to \"2032-09-24T21:33:36 PERIJOVE_12PJ (COUNT = 1)\"\n```\n\n__Note:__ If no `--output` flag is present, the output will be save in the original template.\n\n\n\ud83d\udc50 Contribution\n---------------\nIf you want to contribute to this project, you need to install [`hatch`](https://hatch.pypa.io/latest/install/) on your system, then clone the depot and install de default env:\n```bash\ngit clone https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox.git\ncd majis-ops-toolbox\n\n# Install dev dependencies\nhatch env create\n\n# Setup pre-commit hook\nhatch -e linter run pre-commit install\n```\n\nTo lint and format the source code:\n\n```bash\nhatch -e linter run check\nhatch -e linter run format\n```\n\nTo test the module:\n```bash\nhatch -e tests run tests\n```\n\nTo build the docs:\n```bash\nhatch -e docs run build\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Juice/MAJIS operations toolbox",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://majis-ops.readthedocs.io/en/latest/",
        "Issues": "https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox/-/issues",
        "Source": "https://git.ias.u-psud.fr/majis_sgs/operations/majis-ops-toolbox"
    },
    "split_keywords": [
        "esa",
        " ias",
        " juice",
        " majis"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "70add4a33a685a78e9888ee3569eeffcb4ebcfc477c3a552ef18c9d6e947710d",
                "md5": "b067d0a151d1e7c723f0e74cf50258fc",
                "sha256": "204d25ab35ff5a8668486bad0f215af5c4cdaddc639bcd9a884d5d459474692c"
            },
            "downloads": -1,
            "filename": "majis_ops-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b067d0a151d1e7c723f0e74cf50258fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 125802,
            "upload_time": "2024-06-19T21:41:31",
            "upload_time_iso_8601": "2024-06-19T21:41:31.722295Z",
            "url": "https://files.pythonhosted.org/packages/70/ad/d4a33a685a78e9888ee3569eeffcb4ebcfc477c3a552ef18c9d6e947710d/majis_ops-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "03d4c0762114a8381fcfa20ef1b3ad8b48a7ebff2adb0edf2421f7a0e597331e",
                "md5": "3fcf641e8486f6a7cacf0c2c39664d26",
                "sha256": "131cebc4f1a217dbb20cde0fa431b5217532e2ce33f34de7817053a4188f8b79"
            },
            "downloads": -1,
            "filename": "majis_ops-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3fcf641e8486f6a7cacf0c2c39664d26",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 397143,
            "upload_time": "2024-06-19T21:41:35",
            "upload_time_iso_8601": "2024-06-19T21:41:35.254902Z",
            "url": "https://files.pythonhosted.org/packages/03/d4/c0762114a8381fcfa20ef1b3ad8b48a7ebff2adb0edf2421f7a0e597331e/majis_ops-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-19 21:41:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "majis-ops"
}
        
Elapsed time: 0.33084s