From 60e8a52128843414a345f0dc7199f097407a2bde Mon Sep 17 00:00:00 2001 From: Sarthak Kapoor Date: Thu, 5 Sep 2024 18:53:20 +0200 Subject: [PATCH] Populate results without references --- src/nomad_measurements/xrd/schema.py | 46 +++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/nomad_measurements/xrd/schema.py b/src/nomad_measurements/xrd/schema.py index 5f3a7bad..fd34ecea 100644 --- a/src/nomad_measurements/xrd/schema.py +++ b/src/nomad_measurements/xrd/schema.py @@ -985,31 +985,29 @@ def write_xrd_data( source_dict: dict = metadata_dict.get('source', {}) scan_type = metadata_dict.get('scan_type', None) - if scan_type == 'line': - result = XRDResult1D( - intensity=xrd_dict.get('intensity', None), - two_theta=xrd_dict.get('2Theta', None), - omega=xrd_dict.get('Omega', None), - chi=xrd_dict.get('Chi', None), - phi=xrd_dict.get('Phi', None), - scan_axis=metadata_dict.get('scan_axis', None), - integration_time=xrd_dict.get('countTime', None), - ) - result.normalize(archive, logger) - - elif scan_type == 'rsm': - result = XRDResultRSM( - intensity=xrd_dict.get('intensity', None), - two_theta=xrd_dict.get('2Theta', None), - omega=xrd_dict.get('Omega', None), - chi=xrd_dict.get('Chi', None), - phi=xrd_dict.get('Phi', None), - scan_axis=metadata_dict.get('scan_axis', None), - integration_time=xrd_dict.get('countTime', None), - ) - result.normalize(archive, logger) - else: + if scan_type not in ['line', 'rsm']: raise NotImplementedError(f'Scan type `{scan_type}` is not supported.') + if self.state_use_nexus_file: + # Create a new result section + if self.results: + self.results = [] + if scan_type == 'line': + result = XRDResult1D_HDF5() + elif scan_type == 'rsm': + result = XRDResultRSM_HDF5() + result.scan_axis = metadata_dict.get('scan_axis', None) + result.integration_time = xrd_dict.get('countTime', None) + if not self.state_use_nexus_file: + if scan_type == 'line': + result = XRDResult1D() + elif scan_type == 'rsm': + result = XRDResultRSM() + result.intensity = xrd_dict.get('intensity', None) + result.two_theta = xrd_dict.get('2Theta', None) + result.omega = xrd_dict.get('Omega', None) + result.chi = xrd_dict.get('Chi', None) + result.phi = xrd_dict.get('Phi', None) + result.normalize(archive, logger) source = XRayTubeSource( xray_tube_material=source_dict.get('anode_material', None),