Metadata-Version: 2.5
Name: ptr-editor
Version: 1.0.0a1
Summary: Utilities to edit PTR files.
Project-URL: documentation, https://juice-soc-public.io.esa.int/python/ptr-editor/main/
Project-URL: homepage, https://gitlab.esa.int/juice-soc-public/python/ptr-editor
Project-URL: repository, https://github.com/luca-penasa/ptr-editor
Author-email: Luca Penasa <luca.penasa@inaf.it>, Benoît Seignovert <benoit.seignovert@univ-nantes.fr>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: <4.0,>=3.11
Requires-Dist: attrs>=24
Requires-Dist: jsonschema>=4.0.0
Requires-Dist: loguru<0.8,>=0.7.2
Requires-Dist: lxml>=6.0.2
Requires-Dist: numpy<2.5
Requires-Dist: pandas<4,>=2.2.3
Requires-Dist: pint>=0.24.4
Requires-Dist: planetary-coverage>=1.2.0
Requires-Dist: platformdirs>=4.4.0
Requires-Dist: ptwrapper>=2.7.0
Requires-Dist: pydantic<3,>=2.11
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: quick-spice-manager>=0.2.5
Requires-Dist: requests-cache>=1.2.1
Requires-Dist: spiceypy>=5
Provides-Extra: all
Requires-Dist: anywidget>=0.9; extra == 'all'
Requires-Dist: astropy>=7.1.1; extra == 'all'
Requires-Dist: matplotlib>=3.7; extra == 'all'
Requires-Dist: openpyxl>=3.1.5; extra == 'all'
Requires-Dist: plotly>=5; extra == 'all'
Requires-Dist: rich>=13.0.0; extra == 'all'
Requires-Dist: typer>=0.20.0; extra == 'all'
Provides-Extra: cli
Requires-Dist: rich>=13.0.0; extra == 'cli'
Requires-Dist: typer>=0.20.0; extra == 'cli'
Provides-Extra: excel
Requires-Dist: openpyxl>=3.1.5; extra == 'excel'
Provides-Extra: generators
Requires-Dist: astropy>=7.1.1; extra == 'generators'
Provides-Extra: plot
Requires-Dist: matplotlib>=3.7; extra == 'plot'
Requires-Dist: plotly>=5; extra == 'plot'
Provides-Extra: viewer
Requires-Dist: anywidget>=0.9; extra == 'viewer'
Description-Content-Type: text/markdown

# Ptr Editor

[![PyPI](https://img.shields.io/pypi/v/ptr-editor?style=flat-square)](https://pypi.python.org/pypi/ptr-editor/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ptr-editor?style=flat-square)](https://pypi.python.org/pypi/ptr-editor/)
[![PyPI - License](https://img.shields.io/pypi/l/ptr-editor?style=flat-square)](https://pypi.python.org/pypi/ptr-editor/)
[![Coookiecutter - Wolt](https://img.shields.io/badge/cookiecutter-Wolt-00c2e8?style=flat-square&logo=cookiecutter&logoColor=D4AA00&link=https://github.com/woltapp/wolt-python-package-cookiecutter)](https://github.com/woltapp/wolt-python-package-cookiecutter)


---

**Documentation**: [https://juice-soc-public.io.esa.int/python/ptr-editor/main/](https://juice-soc-public.io.esa.int/python/ptr-editor/main/)

**Source Code**: [https://gitlab.esa.int/juice-soc-public/python/ptr-editor](https://gitlab.esa.int/juice-soc-public/python/ptr-editor)

**PyPI**: [https://pypi.org/project/ptr-editor/](https://pypi.org/project/ptr-editor/)

---



## Installation

### Basic Installation

```sh
pip install ptr-editor
```

### Optional Features

#### CLI Module

To use the command-line interface (optional), install with CLI dependencies:

```sh
pip install "ptr-editor[cli]"
```

Then you can use commands like:
```sh
ptr-editor validate path/to/file.ptx
```


## Configuration

### Logging

ptr-editor shows its warnings, and those of quick-spice-manager (which downloads the SPICE
kernels: an unreachable server, a fallback to cached kernels, a failed download), without
any setup: as HTML in Jupyter, on stderr elsewhere. Your own loguru handlers are kept.

```python
import ptr_editor

ptr_editor.set_logger_level("ERROR")                       # errors only
ptr_editor.set_logger_level("INFO", "quick_spice_manager")  # the kernels' progress too
```

You can also set ptr-editor's level with a `.env` file:

1. Copy the example environment file:
   ```sh
   cp .env.example .env
   ```

2. Edit `.env` and set your desired log level:
   ```
   PTR_EDITOR_LOG_LEVEL=INFO
   ```

Valid log levels are: `TRACE`, `DEBUG`, `INFO`, `SUCCESS`, `WARNING`, `ERROR`, `CRITICAL`

Alternatively, you can set the environment variable directly:
```sh
export PTR_EDITOR_LOG_LEVEL=DEBUG
```

Or in Python before importing ptr_editor:
```python
import os
os.environ["PTR_EDITOR_LOG_LEVEL"] = "DEBUG"
import ptr_editor
```

## Development

* Clone this repository
* Requirements:
  * [uv](https://docs.astral.sh/uv/)
  * Python 3.11+
* Create a virtual environment and install the dependencies, by:

```sh
cd ptr-editor
uv sync --all-groups
```

## Running

The package is mainly intended to be used as a library within jupyter notebooks or python scripts.

To quickly start a jupyter notebook with the package installed, you can use:

```sh
uv run jupyter lab tutorial
```

note: for this to work you need to have installed the package with uv as above.


### Testing

```sh
uv run pytest
```

### Documentation

The user manual is the Jupyter Book in [`tutorial/`](tutorial/): a quick start, a guide by task, examples, a cheat sheet and the API
reference (built from the docstrings). The GitLab CI publishes it on every push to `main` at
<https://juice-soc-public.io.esa.int/python/ptr-editor/main/>. To build it locally:

```bash
just docs          # multi-page HTML  ->  tutorial/_build/html/index.html
just docs-single   # one HTML page    ->  tutorial/_build/singlehtml/index.html
just docs-pdf      # PDF              ->  tutorial/_build/pdf/ptr-editor.pdf
just docs-downloads  # the site as published, with the manual to download (one
                     # self-contained HTML page and the PDF, named with the version)
                     # in tutorial/_build/html/downloads/, linked from the front page
```

Every build executes the notebooks first. The PDF and the downloads print the single page
with headless Chromium: run `uv run --group docs playwright install chromium` once, and keep
the network on (the figures load plotly.js from its CDN; in the downloadable page they are
images, and the page opens offline).

The notebooks are also tests: `uv run pytest tutorial` runs the ones listed in `tutorial/_toc.yml`.

Developer notes (AGM internals, reverse-engineering method, testing strategy) are in
[`docs/dev/`](docs/dev/). They are not published.

### Releasing

#### Manual release

Releases are done with the command, e.g. incrementing patch:

```bash
uv run just bump patch
# also push, of course:
git push origin main --tags
```

this will update the changelog, commit it, and make a corresponding tag.

as the CI is not yet configured for publish on pypi it can be done by hand:

```bash
uv build
uv publish --build path/to/wheel
```
#### Automatic release - to be fixed


Trigger the [Draft release workflow](https://github.com/luca-penasa/ptr-editor/actions/workflows/draft_release.yml)
(press _Run workflow_). This will update the changelog & version and create a GitHub release which is in _Draft_ state.

Find the draft release from the
[GitHub releases](https://github.com/luca-penasa/ptr-editor/releases) and publish it. When
 a release is published, it'll trigger [release](https://github.com/luca-penasa/ptr-editor/blob/master/.github/workflows/release.yml) workflow which creates PyPI
 release and deploys updated documentation.

### Updating with copier

To update the skeleton of the project using copier:
```sh
uvx copier update --defaults
```

### Pre-commit

Pre-commit hooks run all the auto-formatting (`ruff format`), linters (e.g. `ruff` and `mypy`), and other quality
 checks to make sure the changeset is in good shape before a commit/push happens.

You can install the hooks with (runs for each commit):

```sh
pre-commit install
```

Or if you want them to run only for each push:

```sh
pre-commit install -t pre-push
```

Or if you want e.g. want to run all checks manually for all files:

```sh
pre-commit run --all-files
```

## How this project is developed

ptr-editor is developed with the help of AI coding assistants (large language models). They are
used to write and refactor code, tests and documentation, under the direction of the developers,
who review every change. What keeps it correct is the test suite, not the tool: it covers the
public API, runs every docstring example and tutorial notebook, and checks the attitude behaviour
against the AGM itself (OSVE). If something looks wrong, please report it.

---

This project was generated using [a fork](https://github.com/luca-penasa/wolt-python-package-cookiecutter) of the [wolt-python-package-cookiecutter](https://github.com/woltapp/wolt-python-package-cookiecutter) template.
