Open domna opened 4 months ago
I just tried it, it is actually already supported. You can write
choice:
pass_energy(NX_FLOAT):
unit: NX_ENERGY
drift_energy(NX_FLOAT):
unit: NX_ENERGY
which is translated through nyaml as
<field name="choice">
<field name="pass_energy" type="NX_FLOAT" units="NX_ENERGY"/>
<field name="drift_energy" type="NX_FLOAT" units="NX_ENERGY"/>
</field>
The backwards conversion does also work.
So this is just a documentation issue.
Yes, but it is picking up a different syntax. It should be a tag choice
, i.e.,
<choice ...>
...
</choie>
Ah right. Anyway, according to the manual, choice
is only for groups, so it should not actually work for choosing between different fields of a base class, right? And it should also have a fixed name like pixel_shape
in the example in the manual, so just choosing between two different names is also not supported.
Ah right. Anyway, according to the manual,
choice
is only for groups, so it should not actually work for choosing between different fields of a base class, right? And it should also have a fixed name likepixel_shape
in the example in the manual, so just choosing between two different names is also not supported.
Yes, I actually remembered this incorrectly. I updated my original comment on the drift_energy. However, I think it's also helpful to have the choice element for fields, so I opened an issue for it: https://github.com/nexusformat/definitions/issues/1357
Anyways, I think we should still add the support in nyaml and pynxtools.
In NXDL one can use a choice element to select out of two elements. We should also support this in this conversion tool.
Here is a link to the manual: https://manual.nexusformat.org/defs_intro.html#choice