From e5c98597e0aa108e5abecae108d41cef263c8350 Mon Sep 17 00:00:00 2001 From: sanbrock Date: Thu, 12 Dec 2024 19:47:20 +0100 Subject: [PATCH] add NXdata as an ActivityResult --- src/pynxtools/nomad/schema.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pynxtools/nomad/schema.py b/src/pynxtools/nomad/schema.py index 74f9a5440..783900163 100644 --- a/src/pynxtools/nomad/schema.py +++ b/src/pynxtools/nomad/schema.py @@ -36,6 +36,7 @@ from nomad.datamodel.data import EntryData, Schema from nomad.datamodel.metainfo import basesections from nomad.datamodel.metainfo.basesections import ( + ActivityResult, ActivityStep, BaseSection, Component, @@ -107,6 +108,7 @@ "NXidentifier": [EntityReference], "NXentry": [ActivityStep], "NXprocess": [ActivityStep], + "NXdata": [ActivityResult], # "object": BaseSection, } @@ -130,6 +132,8 @@ def normalize(self, archive, logger): ref = CompositeSystemReference(name=sec.name) ref.reference = sec self.samples.append(ref) + elif isinstance(sec, ActivityResult): + self.results.append(sec) if self.m_def.name == "Root": self.method = "Generic Experiment" else: @@ -926,7 +930,6 @@ def normalize_fabrication(self, archive, logger): __rename_nx_for_nomad("NXfabrication") ].section_cls super(current_cls, self).normalize(archive, logger) - self.lab_id = "Hello" def normalize_sample_component(self, archive, logger): @@ -936,6 +939,8 @@ def normalize_sample_component(self, archive, logger): ].section_cls if self.name__field: self.name = self.name__field + else: + self.name = self.__dict__["nx_name"] if self.mass__field: self.mass = self.mass__field # we may want to add normalisation for mass_fraction (calculating from components) @@ -947,6 +952,8 @@ def normalize_sample(self, archive, logger): current_cls = __section_definitions[__rename_nx_for_nomad("NXsample")].section_cls if self.name__field: self.name = self.name__field + else: + self.name = self.__dict__["nx_name"] # one could also copy local ids to identifier for search purposes super(current_cls, self).normalize(archive, logger) @@ -974,6 +981,14 @@ def normalize_process(self, archive, logger): super(current_cls, self).normalize(archive, logger) +def normalize_data(self, archive, logger): + """Normalizer for Data section.""" + current_cls = __section_definitions[__rename_nx_for_nomad("NXdata")].section_cls + self.name = self.__dict__["nx_name"] + # one could also copy local ids to identifier for search purposes + super(current_cls, self).normalize(archive, logger) + + def normalize_identifier(self, archive, logger): """Normalizer for Identifier section.""" @@ -1027,6 +1042,7 @@ def get_entry_reference(archive, f_name): __rename_nx_for_nomad("NXidentifier"): normalize_identifier, __rename_nx_for_nomad("NXentry"): normalize_entry, __rename_nx_for_nomad("NXprocess"): normalize_process, + __rename_nx_for_nomad("NXdata"): normalize_data, } # Handling nomad BaseSection and other inherited Section from BaseSection