Skip to content

Converter for MDIO dataset spec to Xarray Dataset and serialize it to Zarr #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9dd9fbc
schema_v1-dataset_builder-add_dimension
dmitriyrepin Jun 24, 2025
f88531e
Merge remote-tracking branch 'upstream/v1' into v1
dmitriyrepin Jun 26, 2025
1358f95
First take on add_dimension(), add_coordinate(), add_variable()
dmitriyrepin Jun 27, 2025
e5261cb
Finished add_dimension, add_coordinate, add_variable
dmitriyrepin Jun 28, 2025
95c01d8
Work on build
dmitriyrepin Jun 30, 2025
46f82f0
Generalize _to_dictionary()
dmitriyrepin Jul 1, 2025
0dc7cc8
build
dmitriyrepin Jul 1, 2025
79863ac
Dataset Build - pass one
dmitriyrepin Jul 2, 2025
ec480f1
Merge the latest TGSAI/mdio-python:v1 branch
dmitriyrepin Jul 2, 2025
fa81ea2
Merge branch 'v1' into v1
tasansal Jul 7, 2025
4b2b163
Revert .container changes
dmitriyrepin Jul 7, 2025
c532c3b
PR review: remove DEVELOPER_NOTES.md
dmitriyrepin Jul 7, 2025
08798cd
PR Review: add_coordinate() should accept only data_type: ScalarType
dmitriyrepin Jul 7, 2025
e8febe4
PR review: add_variable() data_type remove default
dmitriyrepin Jul 7, 2025
0a4be3f
RE review: do not add dimension variable
dmitriyrepin Jul 8, 2025
7b25d6b
PR Review: get api version from the package version
dmitriyrepin Jul 8, 2025
7ca3ed8
PR Review: remove add_dimension_coordinate
dmitriyrepin Jul 9, 2025
4d1ec9c
PR Review: add_coordinate() remove data_type default value
dmitriyrepin Jul 9, 2025
99fcf43
PR Review: improve unit tests by extracting common functionality in v…
dmitriyrepin Jul 9, 2025
0778fdd
Remove the Dockerfile changes. They are not supposed to be a part of …
dmitriyrepin Jul 9, 2025
7e74567
PR Review: run ruff
dmitriyrepin Jul 9, 2025
0aaa5f6
PR Review: fix pre-commit errors
dmitriyrepin Jul 10, 2025
1904dee
remove some noqa overrides
tasansal Jul 10, 2025
4c7c833
Writing XArray / Zarr
dmitriyrepin Jul 10, 2025
4b39ffa
gitignore
dmitriyrepin Jul 10, 2025
e772a4f
Merge remote-tracking branch 'upstream/v1' into v1
dmitriyrepin Jul 11, 2025
cea7308
to_zarr() fix compression
dmitriyrepin Jul 11, 2025
850135e
Fix precommit issues
dmitriyrepin Jul 11, 2025
82f1960
Use only make_campos_3d_acceptance_dataset
dmitriyrepin Jul 11, 2025
b5ee31e
PR Review: address the review comments
dmitriyrepin Jul 14, 2025
7b3ba70
Update _get_fill_value for StructuredType
dmitriyrepin Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ mdio1/*
pytest-of-*
tmp
debugging/*

test-data/*
16 changes: 16 additions & 0 deletions _dev/DEVELOPERS_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Wring empty XArray / Zarr to a local storage

src/mdio/schemas/v1/dataset_serializer.py

## Issues encountered

1. FIXED: Non-zero size of the serialized data files
2. FIXED: Not clear how to properly set `compressor`, `dimension_separator`, and `fill_value`
3. FIXED: For image_inline chunks[2] are somehow different?

4. `fill_value` for StructuredType is set to null, but "AAAAAAAAAAAAAAAA" is expected

## TO DO:

- Add more unit tests for internal functions
- Add a trest comparing expected and actual .zmetadata for the serialized dataset
195 changes: 195 additions & 0 deletions _dev/zmetadata.cpp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"metadata": {
".zattrs": {
"apiVersion": "1.0.0",
"attributes": {
"foo": "bar",
"textHeader": [
"C01 .......................... ",
"C02 .......................... ",
"C03 .......................... "
]
},
"createdOn": "2023-12-12T15:02:06.413469-06:00",
"name": "campos_3d"
},
".zgroup": {
"zarr_format": 2
},
"cdp-x/.zarray": {
"chunks": [256, 512],
"compressor": null,
"dimension_separator": "/",
"dtype": "<f4",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [256, 512],
"zarr_format": 2
},
"cdp-x/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline"],
"unitsV1": {
"length": "m"
}
},
"cdp-y/.zarray": {
"chunks": [256, 512],
"compressor": null,
"dimension_separator": "/",
"dtype": "<f4",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [256, 512],
"zarr_format": 2
},
"cdp-y/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline"],
"unitsV1": {
"length": "m"
}
},
"crossline/.zarray": {
"chunks": [512],
"compressor": null,
"dimension_separator": "/",
"dtype": "<u4",
"fill_value": null,
"filters": null,
"order": "C",
"shape": [512],
"zarr_format": 2
},
"crossline/.zattrs": {
"_ARRAY_DIMENSIONS": ["crossline"]
},
"depth/.zarray": {
"chunks": [384],
"compressor": null,
"dimension_separator": "/",
"dtype": "<u4",
"fill_value": null,
"filters": null,
"order": "C",
"shape": [384],
"zarr_format": 2
},
"depth/.zattrs": {
"_ARRAY_DIMENSIONS": ["depth"],
"unitsV1": {
"length": "m"
}
},
"image/.zarray": {
"chunks": [128, 128, 128],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "zstd",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": "/",
"dtype": "<f4",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [256, 512, 384],
"zarr_format": 2
},
"image/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline", "depth"],
"attributes": {
"fizz": "buzz"
},
"coordinates": "cdp-x cdp-y",
"statsV1": {
"count": 100,
"histogram": {
"binCenters": [1, 2],
"counts": [10, 15]
},
"max": 10.84,
"min": 5.61,
"sum": 1215.1,
"sumSquares": 125.12
}
},
"image_headers/.zarray": {
"chunks": [128, 128],
"compressor": null,
"dimension_separator": "/",
"dtype": [
["cdp-x", "<i4"],
["cdp-y", "<i4"],
["elevation", "<f2"],
["some_scalar", "<f2"]
],
"fill_value": "AAAAAAAAAAAAAAAA",
"filters": null,
"order": "C",
"shape": [256, 512],
"zarr_format": 2
},
"image_headers/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline"],
"coordinates": "cdp-x cdp-y"
},
"image_inline/.zarray": {
"chunks": [4, 512, 512],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "zstd",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": "/",
"dtype": "<f4",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [256, 512, 384],
"zarr_format": 2
},
"image_inline/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline", "depth"],
"coordinates": "cdp-x cdp-y",
"long_name": "inline optimized version of 3d_stack"
},
"inline/.zarray": {
"chunks": [256],
"compressor": null,
"dimension_separator": "/",
"dtype": "<u4",
"fill_value": null,
"filters": null,
"order": "C",
"shape": [256],
"zarr_format": 2
},
"inline/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline"]
},
"velocity/.zarray": {
"chunks": [128, 128, 128],
"compressor": null,
"dimension_separator": "/",
"dtype": "<f2",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [256, 512, 384],
"zarr_format": 2
},
"velocity/.zattrs": {
"_ARRAY_DIMENSIONS": ["inline", "crossline", "depth"],
"coordinates": "cdp-x cdp-y",
"unitsV1": {
"speed": "m/s"
}
}
},
"zarr_consolidated_format": 1
}
Loading
Loading