From 8368b2f35940f8a2871a47821c3ed0c8d8e22a43 Mon Sep 17 00:00:00 2001 From: Felix Dietrich <felix.dietrich@tum.de> Date: Sat, 26 Feb 2022 18:34:29 +0100 Subject: [PATCH] Add tabulartree metaschema for tabular CSV data with user defined metaschema. --- nomad/datamodel/datamodel.py | 3 ++ nomad/datamodel/metainfo/tabulartree.py | 57 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 nomad/datamodel/metainfo/tabulartree.py diff --git a/nomad/datamodel/datamodel.py b/nomad/datamodel/datamodel.py index 3250cd0499..2f99944cd3 100644 --- a/nomad/datamodel/datamodel.py +++ b/nomad/datamodel/datamodel.py @@ -39,6 +39,7 @@ from .metainfo.simulation.run import Run # noqa from .metainfo.workflow import Workflow # noqa from .metainfo.measurements import Measurement # noqa from .metainfo.catalysis import ExperimentCatalysis # noqa +from nomad.datamodel.metainfo.tabulartree import TabularTree # noqa class AuthLevel(int, Enum): @@ -696,5 +697,7 @@ class EntryArchive(metainfo.MSection): experiment_catalysis = metainfo.SubSection(sub_section=ExperimentCatalysis, repeats=False) + tabular_tree = metainfo.SubSection(sub_section=TabularTree, repeats=False) + m_package.__init_metainfo__() diff --git a/nomad/datamodel/metainfo/tabulartree.py b/nomad/datamodel/metainfo/tabulartree.py new file mode 100644 index 0000000000..49675061ae --- /dev/null +++ b/nomad/datamodel/metainfo/tabulartree.py @@ -0,0 +1,57 @@ +# +# Copyright The NOMAD Authors. +# +# This file is part of NOMAD. See https://nomad-lab.eu for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import typing + +from nomad.metainfo import ( + MSection, Package, Quantity, SubSection) + + +m_package = Package(name='tabulartree') + + +class TabularTreeNodeInfo(MSection): + value = Quantity(type=typing.Any) + description = Quantity(type=str) + unit = Quantity(type=str) + + +class TabularTreeLevel3(MSection): + name = Quantity(type=str, default='<node name?>') + info = SubSection(sub_section=TabularTreeNodeInfo) + + +class TabularTreeLevel2(MSection): + name = Quantity(type=str, default='<node name?>') + info = SubSection(sub_section=TabularTreeNodeInfo) + nodes = SubSection(sub_section=TabularTreeLevel3, repeats=True) + + +class TabularTreeLevel1(MSection): + name = Quantity(type=str, default='<node name?>') + info = SubSection(sub_section=TabularTreeNodeInfo) + nodes = SubSection(sub_section=TabularTreeLevel2, repeats=True) + + +class TabularTree(MSection): + name = Quantity(type=str, default='<node name?>') + info = SubSection(sub_section=TabularTreeNodeInfo) + nodes = SubSection(sub_section=TabularTreeLevel1, repeats=True) + + +m_package.__init_metainfo__() -- GitLab