Skip to content
Snippets Groups Projects
Commit f3a993ee authored by Anjali Aggarwal's avatar Anjali Aggarwal
Browse files

xas update

parent 64f55226
No related branches found
No related tags found
1 merge request!13Resolve "Todo: Define XAS technique"
Pipeline #126820 failed
import yaml
import argparse
import json
from linkml_runtime.utils.schemaview import SchemaView
# from linkml.generators.jsonschemagen import
from linkml.generators.jsonschemagen import JsonSchemaGenerator
def convert_linkml_to_jsonschema(yaml_schema_path, json_schema_output):
# Load the schema using SchemaView
schema_view = SchemaView(yaml_schema_path)
# Generate JSON schema
json_schema = JsonSchemaGenerator(schema_view.schema).serialize()
# Save JSON schema to file
with open(json_schema_output, 'w') as file:
file.write(json_schema)
def main():
# Initialize the parser
parser = argparse.ArgumentParser(description="Gen json schema")
# Add the file argument
parser.add_argument('-i', '--input', type=str, default='schema.yaml', help='The path to the LinkML YAML schema file to be read (default: schema.yaml).')
parser.add_argument('-o', '--output', type=str, default='schema.json', help='The path to save the JSON schema output (default: schema.json).')
# Parse the arguments
args = parser.parse_args()
# Read and print the file content
schema_view = convert_linkml_to_jsonschema(args.input,args.output)
print(schema_view.schema)
# json_schema = JsonSchemaGenerator(schema_view.schema).serialize()
# with open("file.json", "w") as outfile:
# json.dump(json_schema, outfile)
if __name__ == "__main__":
main()
\ No newline at end of file
{
"$defs": {
"MetaObject": {
"additionalProperties": true,
"description": "",
"title": "MetaObject",
"type": [
"null",
"boolean",
"object",
"number",
"string"
]
},
"Pizza": {
"additionalProperties": false,
"description": "",
"properties": {
"Base": {
"$ref": "#/$defs/PizzaBase"
},
"CountryOfOrigin": {
"type": "string"
},
"Spiciness": {
"$ref": "#/$defs/SpicinessLevel"
},
"Topping": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"title": "Pizza",
"type": "object"
},
"PizzaBase": {
"description": "",
"enum": [
"DeepPanBase",
"ThinAndCrispyBase",
"WholeWheatBase",
"StuffedCrustBase"
],
"title": "PizzaBase",
"type": "string"
},
"PizzaScientificMetadata": {
"additionalProperties": false,
"description": "The metadata associated with Pizza",
"properties": {
"Base": {
"$ref": "#/$defs/PizzaBase"
},
"CountryOfOrigin": {
"type": "string"
},
"CustomParams": {
"type": "string"
},
"Spiciness": {
"$ref": "#/$defs/SpicinessLevel"
},
"Topping": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"title": "PizzaScientificMetadata",
"type": "object"
},
"Pizzadataset": {
"additionalProperties": false,
"description": "The metadata associated with P65",
"properties": {
"accessGroups": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"contactEmail": {
"description": "Email of the contact person for this dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"creationLocation": {
"description": "Unique location identifier where data was taken, usually in the form /Site-name/facility-name/instrumentOrBeamline-name. This field is required if the dataset is a Raw dataset."
},
"creationTime": {
"description": "Time when dataset became fully available on disk, i.e. all containing files have been written. Format according to chapter 5.6 internet date/time format in RFC 3339. Local times without timezone/offset info are automatically transformed to UTC using the timezone of the API server."
},
"dataFormat": {
"description": "Defines the format of the data files in this dataset, e.g Nexus Version x.y."
},
"dataQualityMetrics": {
"description": "Data Quality Metrics is a number given by the user to rate the dataset.",
"type": "number"
},
"datasetName": {
"description": "A name for the dataset, given by the creator to carry some semantic meaning. Useful for display purposes e.g. instead of displaying the pid. Will be autofilled if missing using info from sourceFolder."
},
"description": {
"description": "Free text explanation of contents of dataset."
},
"instrumentId": {
"description": "ID of the instrument where the data was created."
},
"isPublished": {
"description": "The ID of the proposal to which the dataset belongs."
},
"keywords": {
"items": {},
"type": "array"
},
"license": {
"description": "Name of the license under which the data can be used."
},
"orcidOfOwner": {
"description": "ORCID of the owner or custodian. The string may contain a list of ORCIDs, which should then be separated by semicolons."
},
"owner": {
"description": "Owner or custodian of the dataset, usually first name + last name. The string may contain a list of persons, which should then be seperated by semicolons."
},
"ownerEmail": {
"description": "Email of the owner or custodian of the dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"ownerGroup": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"principalInvestigator": {
"description": "First name and last name of principal investigator(s). If multiple PIs are present, use a semicolon separated list. This field is required if the dataset is a Raw dataset."
},
"proposalId": {
"description": "The ID of the proposal to which the dataset belongs."
},
"scientificMetadata": {
"$ref": "#/$defs/PizzaScientificMetadata"
},
"size": {
"description": "Total size of all source files contained in source folder on disk when unpacked.",
"type": "number"
},
"sourceFolder": {
"description": "Absolute file path on file server containing the files of this dataset, e.g. /some/path/to/sourcefolder. In case of a single file dataset, e.g. HDF5 data, it contains the path up to, but excluding the filename. Trailing slashes are removed."
},
"type": {
"$ref": "#/$defs/TypeOptions",
"description": "Characterize type of dataset, either 'raw' or 'derived'. Autofilled when choosing the proper inherited models."
}
},
"required": [
"scientificMetadata",
"owner",
"type",
"principalInvestigator"
],
"title": "Pizzadataset",
"type": "object"
},
"ScientificMetadataCommons": {
"additionalProperties": false,
"description": "some optional common properties",
"properties": {
"CustomParams": {
"type": "string"
}
},
"title": "ScientificMetadataCommons",
"type": "object"
},
"SpicinessLevel": {
"description": "",
"enum": [
"Hot",
"Medium",
"Mild",
"None"
],
"title": "SpicinessLevel",
"type": "string"
},
"TypeOptions": {
"description": "",
"enum": [
"raw",
"derived"
],
"title": "TypeOptions",
"type": "string"
}
},
"$id": "https://desy.de/linkml/opendata/pizza2",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalProperties": true,
"description": "The metadata associated with P65",
"metamodel_version": "1.7.0",
"properties": {
"accessGroups": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"contactEmail": {
"description": "Email of the contact person for this dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"creationLocation": {
"description": "Unique location identifier where data was taken, usually in the form /Site-name/facility-name/instrumentOrBeamline-name. This field is required if the dataset is a Raw dataset."
},
"creationTime": {
"description": "Time when dataset became fully available on disk, i.e. all containing files have been written. Format according to chapter 5.6 internet date/time format in RFC 3339. Local times without timezone/offset info are automatically transformed to UTC using the timezone of the API server."
},
"dataFormat": {
"description": "Defines the format of the data files in this dataset, e.g Nexus Version x.y."
},
"dataQualityMetrics": {
"description": "Data Quality Metrics is a number given by the user to rate the dataset.",
"type": "number"
},
"datasetName": {
"description": "A name for the dataset, given by the creator to carry some semantic meaning. Useful for display purposes e.g. instead of displaying the pid. Will be autofilled if missing using info from sourceFolder."
},
"description": {
"description": "Free text explanation of contents of dataset."
},
"instrumentId": {
"description": "ID of the instrument where the data was created."
},
"isPublished": {
"description": "The ID of the proposal to which the dataset belongs."
},
"keywords": {
"items": {},
"type": "array"
},
"license": {
"description": "Name of the license under which the data can be used."
},
"orcidOfOwner": {
"description": "ORCID of the owner or custodian. The string may contain a list of ORCIDs, which should then be separated by semicolons."
},
"owner": {
"description": "Owner or custodian of the dataset, usually first name + last name. The string may contain a list of persons, which should then be seperated by semicolons."
},
"ownerEmail": {
"description": "Email of the owner or custodian of the dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"ownerGroup": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"principalInvestigator": {
"description": "First name and last name of principal investigator(s). If multiple PIs are present, use a semicolon separated list. This field is required if the dataset is a Raw dataset."
},
"proposalId": {
"description": "The ID of the proposal to which the dataset belongs."
},
"scientificMetadata": {
"$ref": "#/$defs/PizzaScientificMetadata"
},
"size": {
"description": "Total size of all source files contained in source folder on disk when unpacked.",
"type": "number"
},
"sourceFolder": {
"description": "Absolute file path on file server containing the files of this dataset, e.g. /some/path/to/sourcefolder. In case of a single file dataset, e.g. HDF5 data, it contains the path up to, but excluding the filename. Trailing slashes are removed."
},
"type": {
"$ref": "#/$defs/TypeOptions",
"description": "Characterize type of dataset, either 'raw' or 'derived'. Autofilled when choosing the proper inherited models."
}
},
"required": [
"scientificMetadata",
"owner",
"type",
"principalInvestigator"
],
"title": "pizza2",
"type": "object",
"version": null
}
\ No newline at end of file
{
"$defs": {
"MetaObject": {
"additionalProperties": true,
"description": "",
"title": "MetaObject",
"type": [
"null",
"boolean",
"object",
"number",
"string"
]
},
"Pizza": {
"additionalProperties": false,
"description": "",
"properties": {
"Base": {
"$ref": "#/$defs/PizzaBase"
},
"CountryOfOrigin": {
"type": "string"
},
"Spiciness": {
"$ref": "#/$defs/SpicinessLevel"
},
"Topping": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"title": "Pizza",
"type": "object"
},
"PizzaBase": {
"description": "",
"enum": [
"DeepPanBase",
"ThinAndCrispyBase",
"WholeWheatBase",
"StuffedCrustBase"
],
"title": "PizzaBase",
"type": "string"
},
"PizzaScientificMetadata": {
"additionalProperties": false,
"description": "The metadata associated with Pizza",
"properties": {
"Base": {
"$ref": "#/$defs/PizzaBase"
},
"CountryOfOrigin": {
"type": "string"
},
"CustomParams": {
"type": "string"
},
"Spiciness": {
"$ref": "#/$defs/SpicinessLevel"
},
"Topping": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"title": "PizzaScientificMetadata",
"type": "object"
},
"Pizzadataset": {
"additionalProperties": false,
"description": "The metadata associated with P65",
"properties": {
"accessGroups": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"contactEmail": {
"description": "Email of the contact person for this dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"creationLocation": {
"description": "Unique location identifier where data was taken, usually in the form /Site-name/facility-name/instrumentOrBeamline-name. This field is required if the dataset is a Raw dataset."
},
"creationTime": {
"description": "Time when dataset became fully available on disk, i.e. all containing files have been written. Format according to chapter 5.6 internet date/time format in RFC 3339. Local times without timezone/offset info are automatically transformed to UTC using the timezone of the API server."
},
"dataFormat": {
"description": "Defines the format of the data files in this dataset, e.g Nexus Version x.y."
},
"dataQualityMetrics": {
"description": "Data Quality Metrics is a number given by the user to rate the dataset.",
"type": "number"
},
"datasetName": {
"description": "A name for the dataset, given by the creator to carry some semantic meaning. Useful for display purposes e.g. instead of displaying the pid. Will be autofilled if missing using info from sourceFolder."
},
"description": {
"description": "Free text explanation of contents of dataset."
},
"instrumentId": {
"description": "ID of the instrument where the data was created."
},
"isPublished": {
"description": "The ID of the proposal to which the dataset belongs."
},
"keywords": {
"items": {},
"type": "array"
},
"license": {
"description": "Name of the license under which the data can be used."
},
"orcidOfOwner": {
"description": "ORCID of the owner or custodian. The string may contain a list of ORCIDs, which should then be separated by semicolons."
},
"owner": {
"description": "Owner or custodian of the dataset, usually first name + last name. The string may contain a list of persons, which should then be seperated by semicolons."
},
"ownerEmail": {
"description": "Email of the owner or custodian of the dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"ownerGroup": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"principalInvestigator": {
"description": "First name and last name of principal investigator(s). If multiple PIs are present, use a semicolon separated list. This field is required if the dataset is a Raw dataset."
},
"proposalId": {
"description": "The ID of the proposal to which the dataset belongs."
},
"scientificMetadata": {
"$ref": "#/$defs/PizzaScientificMetadata"
},
"size": {
"description": "Total size of all source files contained in source folder on disk when unpacked.",
"type": "number"
},
"sourceFolder": {
"description": "Absolute file path on file server containing the files of this dataset, e.g. /some/path/to/sourcefolder. In case of a single file dataset, e.g. HDF5 data, it contains the path up to, but excluding the filename. Trailing slashes are removed."
},
"type": {
"$ref": "#/$defs/TypeOptions",
"description": "Characterize type of dataset, either 'raw' or 'derived'. Autofilled when choosing the proper inherited models."
}
},
"required": [
"scientificMetadata",
"owner",
"type",
"principalInvestigator"
],
"title": "Pizzadataset",
"type": "object"
},
"ScientificMetadataCommons": {
"additionalProperties": false,
"description": "some optional common properties",
"properties": {
"CustomParams": {
"type": "string"
}
},
"title": "ScientificMetadataCommons",
"type": "object"
},
"SpicinessLevel": {
"description": "",
"enum": [
"Hot",
"Medium",
"Mild",
"None"
],
"title": "SpicinessLevel",
"type": "string"
},
"TypeOptions": {
"description": "",
"enum": [
"raw",
"derived"
],
"title": "TypeOptions",
"type": "string"
}
},
"$id": "https://desy.de/linkml/opendata/pizza2",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalProperties": true,
"description": "The metadata associated with P65",
"metamodel_version": "1.7.0",
"properties": {
"accessGroups": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"contactEmail": {
"description": "Email of the contact person for this dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"creationLocation": {
"description": "Unique location identifier where data was taken, usually in the form /Site-name/facility-name/instrumentOrBeamline-name. This field is required if the dataset is a Raw dataset."
},
"creationTime": {
"description": "Time when dataset became fully available on disk, i.e. all containing files have been written. Format according to chapter 5.6 internet date/time format in RFC 3339. Local times without timezone/offset info are automatically transformed to UTC using the timezone of the API server."
},
"dataFormat": {
"description": "Defines the format of the data files in this dataset, e.g Nexus Version x.y."
},
"dataQualityMetrics": {
"description": "Data Quality Metrics is a number given by the user to rate the dataset.",
"type": "number"
},
"datasetName": {
"description": "A name for the dataset, given by the creator to carry some semantic meaning. Useful for display purposes e.g. instead of displaying the pid. Will be autofilled if missing using info from sourceFolder."
},
"description": {
"description": "Free text explanation of contents of dataset."
},
"instrumentId": {
"description": "ID of the instrument where the data was created."
},
"isPublished": {
"description": "The ID of the proposal to which the dataset belongs."
},
"keywords": {
"items": {},
"type": "array"
},
"license": {
"description": "Name of the license under which the data can be used."
},
"orcidOfOwner": {
"description": "ORCID of the owner or custodian. The string may contain a list of ORCIDs, which should then be separated by semicolons."
},
"owner": {
"description": "Owner or custodian of the dataset, usually first name + last name. The string may contain a list of persons, which should then be seperated by semicolons."
},
"ownerEmail": {
"description": "Email of the owner or custodian of the dataset. The string may contain a list of emails, which should then be seperated by semicolons."
},
"ownerGroup": {
"description": "Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151"
},
"principalInvestigator": {
"description": "First name and last name of principal investigator(s). If multiple PIs are present, use a semicolon separated list. This field is required if the dataset is a Raw dataset."
},
"proposalId": {
"description": "The ID of the proposal to which the dataset belongs."
},
"scientificMetadata": {
"$ref": "#/$defs/PizzaScientificMetadata"
},
"size": {
"description": "Total size of all source files contained in source folder on disk when unpacked.",
"type": "number"
},
"sourceFolder": {
"description": "Absolute file path on file server containing the files of this dataset, e.g. /some/path/to/sourcefolder. In case of a single file dataset, e.g. HDF5 data, it contains the path up to, but excluding the filename. Trailing slashes are removed."
},
"type": {
"$ref": "#/$defs/TypeOptions",
"description": "Characterize type of dataset, either 'raw' or 'derived'. Autofilled when choosing the proper inherited models."
}
},
"required": [
"scientificMetadata",
"owner",
"type",
"principalInvestigator"
],
"title": "pizza2",
"type": "object",
"version": null
}
\ No newline at end of file
id: https://example.org/xas-catalysis
name: XAS Catalysis
description: Schema for X-ray Absorption Spectroscopy (XAS) technique in catalysis experiments at the DESY P64 beamline
prefixes:
schema: http://schema.org/
linkml: https://w3id.org/linkml/
default_range: string
imports:
- linkml:types
default_prefix: xas_catalysis
types:
float:
base: float
datetime:
base: datetime
classes:
CatalysisExperiment:
description: Information about the catalysis experiment using XAS at the DESY P64 beamline
attributes:
experimentID:
description: Unique identifier for the experiment
required: true
sample:
description: Information about the sample used in the experiment
range: Sample
instrument:
description: Information about the instrument used for the experiment
range: Instrument
technique:
description: Information about the XAS technique used
range: Technique
dataProcessing:
description: Information about data processing methods used
range: DataProcessing
metadata:
description: Additional metadata related to the experiment
range: MetaObject
startTime:
description: Start time of the experiment
range: datetime
endTime:
description: End time of the experiment
range: datetime
Sample:
description: Information about the sample used in the XAS catalysis experiment
attributes:
sampleID:
description: Unique identifier for the sample
required: true
material:
description: Material of the sample
preparationMethod:
description: Method used to prepare the sample
catalyst:
description: Catalyst used in the experiment
reactionConditions:
description: Reaction conditions (e.g., temperature, pressure)
description:
description: Detailed description of the sample
Instrument:
description: Information about the instrument used for the XAS catalysis experiment
attributes:
instrumentID:
description: Unique identifier for the instrument
required: true
name:
description: Name of the instrument
facility:
description: Facility where the instrument is located
default: DESY
beamline:
description: Beamline used for the experiment
default: P64
energyRange:
description: Energy range used in the experiment
range: EnergyRange
DataProcessing:
description: Information about data processing methods used in the XAS catalysis experiment
attributes:
software:
description: Software used for data processing
version:
description: Version of the software
method:
description: Method or algorithm used for data processing
MetaObject:
description: Generic metadata object
class_uri: linkml:Any
EnergyRange:
description: Energy range used in the XAS experiment
attributes:
minEnergy:
description: Minimum energy in electron volts (eV)
range: float
required: true
maxEnergy:
description: Maximum energy in electron volts (eV)
range: float
required: true
Technique:
description: Information about the XAS technique used in the catalysis experiment
attributes:
techniqueType:
description: Type of XAS technique (e.g., EXAFS, XANES)
range: TechniqueTypeEnum
required: true
edge:
description: Absorption edge (e.g., K-edge, L-edge)
range: EdgeEnum
detector:
description: Type of detector used
range: DetectorEnum
monochromator:
description: Type of monochromator used
range: MonochromatorEnum
enums:
TechniqueTypeEnum:
permissible_values:
EXAFS:
description: Extended X-ray Absorption Fine Structure
XANES:
description: X-ray Absorption Near Edge Structure
EdgeEnum:
permissible_values:
K-edge:
description: K absorption edge
L-edge:
description: L absorption edge
M-edge:
description: M absorption edge
DetectorEnum:
permissible_values:
Fluorescence:
description: Fluorescence detector
Transmission:
description: Transmission detector
ElectronYield:
description: Electron yield detector
MonochromatorEnum:
permissible_values:
Si111:
description: Silicon (111) monochromator
Si311:
description: Silicon (311) monochromator
Ge111:
description: Germanium (111) monochromator
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment