Using Maps/Dictionaries for attributes corresponding to `axisLabels`
- Dominant language
- C++
- Stars
- 161
- Forks
- 59
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 7
Description
Regarding the [openPMD-standard](https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#mesh-based-records) attributes corresponding to specific axes (e.g. `gridSpacing`, `globalGridOffset`) of a mesh should be ordered in the same way as the `axisLabels` in their array. Currently this is just a suggestion to implementors which totally makes sense.
Guaranteeing that `axisLabels` match axis specific attributes is possible by storing these attributes e.g. in a C++ `std::map`. That makes it impossible to mess up axis specific attributes and axis labels.
Currently the implementor has to make sure that the order is correct which does not guarantee the correct order such that the following implementation mistakes are possible
```C++
openPMD::Mesh mesh{};
std::vector axisLabels = {"x","y","z"};
mesh.setAxisLabels(axisLabels);
std::vector gridSpacing = {dx,dz,dy};
mesh.setGridSpacing(gridSpacing);
```
A safer way would be
```C++
openPMD::Mesh mesh{};
std::vector axisLabels = {"x","z","y"};
mesh.setAxisLabels(axisLabels);
std::map gridSpacing = {{"x",dx},{"y",dy},{"z",dz}};
mesh.setGridSpacing(gridSpacing);
```
In this implementation additional safeguards could be added within openPMD such that attributes can only be added for axes that are already stored in axisLabels.
Possible Problem:
I am not sure how well a python `dictionary` interacts with a C++ `std::map`. This might be an issue in the python API of openPMD.
Contributor guide
Assessment
This issue has not been assessed yet.