Allow 2D coordinate or mask.#58
Conversation
| "properties": { | ||
| "neutron_type": {"$ref": "#/$defs/NeutronSourceType"}, | ||
| "wavelength_range": {"$ref": "#/$defs/ScippVariable"} | ||
| "wavelength_range": { |
There was a problem hiding this comment.
I didn't quite get why this one is needed...
| "title": "ScippVariable1D", | ||
| "type": "object" | ||
| }, | ||
| "ScippVariable2D": { |
There was a problem hiding this comment.
Not sure I followed: the 0D, 1D and 2D all seem to be identical?
In which place do we actually need the different types?
There was a problem hiding this comment.
At first I thought we would want to limit the 2D coordinate only for x, y dimension so I started splitting them into different Models so that 2D one can have literal type of dimensions but I wasn't sure if that's necessary so I removed it...
I guess we can just merge all three of them now. I'll update them.
|
I ended up making each 0-2D variable model definition more strict, e.g. number of items in the Then the weird 2D object values naturally won't pass the validation and the error messages will tell you why. |
| "maxItems": 2, | ||
| "minItems": 2, | ||
| "prefixItems": [{ "$ref": "#/$defs/ScippVariable0D" }, { "$ref": "#/$defs/ScippVariable0D" }], | ||
| "title": "Wavelength Range", | ||
| "type": "array" |
There was a problem hiding this comment.
Now the wavelength range has strict type of tuple[scalar, scalar]
| "neutron_type": {"$ref": "#/$defs/NeutronSourceType"}, | ||
| "wavelength_range": {"$ref": "#/$defs/ScippVariable"} | ||
| "wavelength_range": { | ||
| "anyOf": [{ "$ref": "#/$defs/ScippVariable0D" }, { "$ref": "#/$defs/ScippVariable1D" }, { "$ref": "#/$defs/ScippVariable2D" }], |
There was a problem hiding this comment.
Change to a tuple containing exactly two 0D variables?
| dims=('z',), shape=(1,), dtype='int', unit='m', values=[0] | ||
| ), | ||
| 'y': ScippVariable( | ||
| 'y': ScippVariable1D( |
There was a problem hiding this comment.
This is just a dummy metadata as an example in the documentation. I didn't include 2D coordinate since we don't want to encourage people to store 2D coordinates in the metadata.
There was a problem hiding this comment.
Sorry I had not seen it was creating some dummy data.
| raise ValueError( | ||
| "Only 1-dimensional or scalar variable is allowed for metadata. " | ||
| "The variable has more than 1 dimension." | ||
| "Only 2, 1-dimensional or scalar variable is allowed for metadata. " |
There was a problem hiding this comment.
| "Only 2, 1-dimensional or scalar variable is allowed for metadata. " | |
| "Only variables with at most 2 dimensions are allowed for metadata. " |
There was a problem hiding this comment.
I updated the error message...!
fixed #56
I updated the schema and fixed the IO helper according to the schema.
We didn't need to allow masks to be 2D but... just included the mask... masks are booleans so it shoudn't matter too much.