Skip to content

Commit

Permalink
Lock the state for using nexus file and corresponding references
Browse files Browse the repository at this point in the history
  • Loading branch information
ka-sarthak committed Sep 5, 2024
1 parent fafa271 commit f72d393
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/nomad_measurements/xrd/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,15 +937,19 @@ class ELNXRayDiffraction(XRayDiffraction, EntryData, PlotSection):
diffraction_method_name.m_annotations['eln'] = ELNAnnotation(
component=ELNComponentEnum.EnumEditQuantity,
)
generate_nexus_file = Quantity(
use_nexus_file = Quantity(
type=bool,
description='Whether or not to generate a NeXus output file (if possible).',
default=True,
description="""
Whether or not to generate a NeXus output file and use it to store array data.
Once set to True, it cannot be set back to False.
""",
default=False,
a_eln=ELNAnnotation(
component=ELNComponentEnum.BoolEditQuantity,
label='Generate NeXus file',
),
)
state_use_nexus_file = False

def get_read_write_functions(self) -> tuple[Callable, Callable]:
"""
Expand Down Expand Up @@ -1045,6 +1049,12 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger'):
normalized.
logger (BoundLogger): A structlog logger.
"""
# lock the decision of using nexus file references once it is set True
if self.state_use_nexus_file:
self.use_nexus_file = True
if self.use_nexus_file:
self.state_use_nexus_file = True

if self.data_file is not None:
read_function, write_function = self.get_read_write_functions()
if read_function is None or write_function is None:
Expand Down

0 comments on commit f72d393

Please sign in to comment.