Skip to content

Commit

Permalink
add NXdata as an ActivityResult
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbrock committed Dec 12, 2024
1 parent 61f4f2c commit e5c9859
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/pynxtools/nomad/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -107,6 +108,7 @@
"NXidentifier": [EntityReference],
"NXentry": [ActivityStep],
"NXprocess": [ActivityStep],
"NXdata": [ActivityResult],
# "object": BaseSection,
}

Expand All @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e5c9859

Please sign in to comment.