Skip to content
Snippets Groups Projects
Commit 3cc4d96d authored by Simon Wittl's avatar Simon Wittl
Browse files

Merge branch 'uv' into 'main'

Uv

See merge request roboct/definitions/json_schemas!7
parents 5ec451b3 4c37ef23
No related branches found
No related tags found
No related merge requests found
......@@ -35,9 +35,9 @@ This schema defines the properties for projection data in THD JSON format.
| `detector_vertical_vector` | array | Vertical orientation vector of the detector | 3 numbers | No |
| `detector_center_orientation_quat` | array | Quaternion representing the detector's center orientation | 4 numbers | Yes |
| `pixel_pitch_width_mm` | number | Pixel pitch in millimeters (width) | Minimum 0.001 | Yes |
| `pixel_pitch_heigth_mm` | number | Pixel pitch in millimeters (heigth) | Minimum 0.001 | Yes |
| `pixel_pitch_height_mm` | number | Pixel pitch in millimeters (height) | Minimum 0.001 | Yes |
| `image_width_px` | integer | Width of the image in pixels | Minimum 1 | Yes |
| `image_heigth_px` | integer | Height of the image in pixels | Minimum 1 | Yes |
| `image_height_px` | integer | Height of the image in pixels | Minimum 1 | Yes |
| `projection_matrix_cera` | array | Projection matrix for CERA, representing transformations | 3 arrays of 4 numbers | No |
......@@ -68,3 +68,54 @@ def main():
projection_validator = get_projection_validator()
projection_validator.folder(FOLDER)
```
## Contribute
- For changes please make a pull request.
- Update the version and date number of the schema.
- Add a new datatyp:
- add a moulde to `src`\ `thd_json`\ `new_data_type`
- add a validation function to the `__init__.py` of the `new_data_typ`. Example of [`projection`.\__init\__.py"](./src/thd_json/projection/__init__.py):
```python:../src/thd_json/projection/__init__.py
from thd_json import Validator
from pathlib import Path
import argparse
def get_projection_validator(json_suffix: str = '*.json') -> Validator:
return Validator(Path(__file__).parent / Path('projection.json'), json_suffix)
def projection_cli():
parser = argparse.ArgumentParser(description='JSON THD Projection Validator CLI with uv.')
parser.add_argument('folder', help='Folder to check.', type=str)
parser.add_argument('suffix', help='Projection suffix.', default='*.json', type=Path, nargs='?')
args = parser.parse_args()
suffix = str(args.suffix)
if not suffix.startswith('*'):
raise ValueError(f'The suffix must always start with: "*". \nIt is: {suffix}')
validator = get_projection_validator(
suffix)
folder = Path(args.folder)
if not folder.exists():
raise FileNotFoundError(f'Folder: {folder} does not exist')
validator.folder(Path(args.folder))
if __name__ == "__main__":
projection_cli()
```
- add the CLI script to the `pyproject.toml`
```toml
[project.scripts]
projection_validator = "thd_json.projection:projection_cli"
...
new_data_typ_validator = "thd_json.new_data_typ:new_data_typ_cli"
```
......@@ -66,7 +66,7 @@
},
"pixel_pitch_height_mm": {
"type": "number",
"description": "Pixel pitch in heigth dimension measured in millimeters.",
"description": "Pixel pitch in height dimension measured in millimeters.",
"minimum": 0.001
},
"image_width_px": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment