Metadata-Version: 2.4
Name: lima2mxh5master
Version: 0.0.4
Summary: Convert lima2 data to mx h5 master file
Author-email: ESRF <dau-pydev@esrf.fr>
License-Expression: MIT
Project-URL: Homepage, https://gitlab.esrf.fr/sb/lima2mxh5master/
Project-URL: Documentation, https://lima2mxh5master.readthedocs.io/
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: silx
Requires-Dist: pydantic
Requires-Dist: asteval
Requires-Dist: esrf-pathlib>=0.2
Requires-Dist: pint
Requires-Dist: sb-detectors<0.0.1a1,>=0.0.1a0
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: doc
Requires-Dist: sphinx>=4.5; extra == "doc"
Requires-Dist: sphinx-autodoc-typehints>=1.16; extra == "doc"
Requires-Dist: pydata-sphinx-theme; extra == "doc"
Dynamic: license-file

# lima2mxh5master

`lima2mxh5master` creates, updates, and inspects NeXus/HDF5 master files for
macromolecular crystallography workflows.

The project is currently in beta. Schema documents declare their specification
version and whether they create or update a file; bundled transformation profiles
also carry their own name and version.

## Installation

Python 3.10 or newer is required.

```bash
python -m pip install lima2mxh5master
```

For a development checkout:

```bash
python -m pip install -e .
```

## Create a file

```python
from lima2mxh5master.api import dump_dict_to_nx

create_schema = {
    "spec_version": 1,
    "operation": "create",
    "registry": {"source_dir": [], "classes": {}},
    "schema": {
        "entry": {
            "@NX_class": "NXentry",
            "title": "Example scan",
            "data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
        }
    },
}

dump_dict_to_nx(create_schema, "master.h5")
```

## Update a file

```python
from lima2mxh5master.api import update_h5_from_dict

update_schema = {
    "spec_version": 1,
    "operation": "update",
    "registry": {"source_dir": [], "classes": {}},
    "schema": {
        "entry": {
            ">=sampled": "${h5:self:/entry/data}[::10]",
        }
    },
}

update_h5_from_dict(
    update_schema,
    path_h5_base_file="master.h5",
    path_h5_output_file="sampled_master.h5",
)
```

`${h5:self:/entry/data}` explicitly reads the original base file;
`${h5:/entry/data}` is the equivalent shorthand. Schemas can also declare named
external inputs and reference them as `${h5:source_name:/entry/data}` in create
or update operations. Literal inputs use
`${h5:<../raw/data.h5>:/entry/data}`, and `vds.concatenate([...], axis=0)`
combines sliced HDF5 references into a virtual dataset without reading frame
data.

See the [full documentation](https://lima2mxh5master.readthedocs.io/en/latest/)
for schema syntax, in-place updates, deletions, HDF5 references, and bundled
profiles.
