Skip to content

Commit

Permalink
Extend schema to allow units of "1" and "1/s" or "R" column
Browse files Browse the repository at this point in the history
  • Loading branch information
aglavic committed Jun 20, 2022
1 parent 478eff0 commit 5c36156
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 64 deletions.
200 changes: 137 additions & 63 deletions orsopy/fileio/schema/refl_header.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,47 +168,54 @@
"probe"
]
},
"Sample": {
"title": "Sample",
"Value": {
"title": "Value",
"type": "object",
"properties": {
"name": {
"magnitude": {
"type": [
"string",
"number",
"null"
]
},
"category": {
"unit": {
"description": "SI unit string",
"type": [
"string",
"null"
]
},
"composition": {
"comment": {
"type": [
"string",
"null"
]
},
"description": {
}
},
"required": [
"magnitude"
]
},
"ValueRange": {
"title": "ValueRange",
"type": "object",
"properties": {
"min": {
"type": [
"string",
"number",
"null"
]
},
"environment": {
"items": {
"type": "string"
},
"max": {
"type": [
"array",
"number",
"null"
]
},
"sample_parameters": {
"description": "Using keys for parameters and Value* objects for values.",
"unit": {
"description": "SI unit string",
"type": [
"object",
"string",
"null"
]
},
Expand All @@ -220,14 +227,27 @@
}
},
"required": [
"name"
"min",
"max"
]
},
"Value": {
"title": "Value",
"ValueVector": {
"title": "ValueVector",
"type": "object",
"properties": {
"magnitude": {
"x": {
"type": [
"number",
"null"
]
},
"y": {
"type": [
"number",
"null"
]
},
"z": {
"type": [
"number",
"null"
Expand All @@ -248,23 +268,45 @@
}
},
"required": [
"magnitude"
"x",
"y",
"z"
]
},
"ValueRange": {
"title": "ValueRange",
"ComplexValue": {
"title": "ComplexValue",
"type": "object",
"properties": {
"min": {
"type": [
"number",
"null"
"real": {
"anyOf": [
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "null"
}
]
},
"max": {
"type": [
"number",
"null"
"imag": {
"anyOf": [
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "null"
}
]
},
"unit": {
Expand All @@ -282,55 +324,69 @@
}
},
"required": [
"min",
"max"
"real"
]
},
"Polarization": {
"title": "Polarization",
"description": "The first symbol indicates the magnetisation direction of the incident\nbeam. An optional second symbol indicates the direction of the scattered\nbeam, if a spin analyser is present.",
"enum": [
"unpolarized",
"po",
"mo",
"op",
"om",
"mm",
"mp",
"pm",
"pp"
],
"type": "string"
},
"ValueVector": {
"title": "ValueVector",
"Sample": {
"title": "Sample",
"type": "object",
"properties": {
"x": {
"name": {
"type": [
"number",
"string",
"null"
]
},
"y": {
"category": {
"type": [
"number",
"string",
"null"
]
},
"z": {
"composition": {
"type": [
"number",
"string",
"null"
]
},
"unit": {
"description": "SI unit string",
"description": {
"type": [
"string",
"null"
]
},
"environment": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"sample_parameters": {
"description": "Using keys for parameters and Value* objects for values.",
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/Value"
},
{
"$ref": "#/definitions/ValueRange"
},
{
"$ref": "#/definitions/ValueVector"
},
{
"$ref": "#/definitions/ComplexValue"
}
]
},
"type": [
"object",
"null"
]
},
"comment": {
"type": [
"string",
Expand All @@ -339,11 +395,25 @@
}
},
"required": [
"x",
"y",
"z"
"name"
]
},
"Polarization": {
"title": "Polarization",
"description": "The first symbol indicates the magnetisation direction of the incident\nbeam. An optional second symbol indicates the direction of the scattered\nbeam, if a spin analyser is present.",
"enum": [
"unpolarized",
"po",
"mo",
"op",
"om",
"mm",
"mp",
"pm",
"pp"
],
"type": "string"
},
"InstrumentSettings": {
"title": "InstrumentSettings",
"type": "object",
Expand Down Expand Up @@ -760,6 +830,8 @@
"enum": [
"1/angstrom",
"1/nm",
"1",
"1/s",
null
]
},
Expand Down Expand Up @@ -802,6 +874,8 @@
"enum": [
"1/angstrom",
"1/nm",
"1",
"1/s",
null
]
},
Expand Down
39 changes: 39 additions & 0 deletions orsopy/fileio/schema/refl_header.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ definitions:
- name
title: Column
type: object
ComplexValue:
properties:
comment:
type:
- string
- 'null'
imag:
anyOf:
- type: number
- items:
type: number
type: array
- type: 'null'
real:
anyOf:
- type: number
- items:
type: number
type: array
- type: 'null'
unit:
description: SI unit string
type:
- string
- 'null'
required:
- real
title: ComplexValue
type: object
DataSource:
properties:
comment:
Expand Down Expand Up @@ -289,6 +318,8 @@ definitions:
enum:
- 1/angstrom
- 1/nm
- '1'
- 1/s
- null
required:
- name
Expand All @@ -312,6 +343,8 @@ definitions:
enum:
- 1/angstrom
- 1/nm
- '1'
- 1/s
- null
required:
- name
Expand Down Expand Up @@ -394,6 +427,12 @@ definitions:
- string
- 'null'
sample_parameters:
additionalProperties:
anyOf:
- $ref: '#/definitions/Value'
- $ref: '#/definitions/ValueRange'
- $ref: '#/definitions/ValueVector'
- $ref: '#/definitions/ComplexValue'
description: Using keys for parameters and Value* objects for values.
type:
- object
Expand Down
2 changes: 1 addition & 1 deletion tools/header_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def schema_extra(schema: Dict[str, Any]) -> None:
"type": "object",
"properties": {
"name": {"enum": ["<cname>"]},
"unit": {"enum": ["1/angstrom", "1/nm", None]},
"unit": {"enum": ["1/angstrom", "1/nm", "1", "1/s", None]},
"dimension": {"dimension": "dimension of column", "anyOf": [{"type": "string"}, {"type": "null"}]},
"comment": {"anyOf": [{"type": "string"}, {"type": "null"}]},
},
Expand Down

0 comments on commit 5c36156

Please sign in to comment.