From 52287956d137f474923fd93431d8df7c54b0d09e Mon Sep 17 00:00:00 2001 From: ndaelman Date: Fri, 20 Dec 2024 20:28:27 +0100 Subject: [PATCH] BROKEN: try indices and auxiliary_signals --- .../parsers/parser.py | 9 ++---- .../schema_packages/schema_package.py | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/nomad_parser_plugin_boss/parsers/parser.py b/src/nomad_parser_plugin_boss/parsers/parser.py index 0e649f7..17348f9 100644 --- a/src/nomad_parser_plugin_boss/parsers/parser.py +++ b/src/nomad_parser_plugin_boss/parsers/parser.py @@ -139,14 +139,11 @@ def compute_parameters(rank: int): # Save slices slice_path = f'parameter_slices/{parameter_counter}' section = archive.data.m_setdefault(slice_path) + main_data = archive.data.parameter_slices[0].m_annotations if parameter_counter == 0: - archive.data.parameter_slices[0].m_annotations['h5web'] = ( - H5WebAnnotation(auxiliary_signals=[]) - ) + main_data['h5web'] = H5WebAnnotation(auxiliary_signals=[]) else: - archive.data.parameter_slices[0].m_annotations[ - 'h5web' - ].auxiliary_signals.append('../' + slice_path) + main_data['h5web'].auxiliary_signals.append('/data/' + slice_path) section.fitted_values = np.array(mu_all_slices) section.fitted_stddevs = np.sqrt(var_all_slices) diff --git a/src/nomad_parser_plugin_boss/schema_packages/schema_package.py b/src/nomad_parser_plugin_boss/schema_packages/schema_package.py index 0b0e607..b70592f 100644 --- a/src/nomad_parser_plugin_boss/schema_packages/schema_package.py +++ b/src/nomad_parser_plugin_boss/schema_packages/schema_package.py @@ -30,7 +30,7 @@ class ParameterSpaceSlice(Schema): m_def = Section( a_h5web=H5WebAnnotation( signal='./fitted_values', - axes=['blank', 'parameter_2_values', 'parameter_1_values'], + axes=['parameter_1_values', 'parameter_2_values'], ) ) @@ -43,18 +43,13 @@ class ParameterSpaceSlice(Schema): fitted_stddevs = Quantity(type=HDF5Dataset, unit='eV') parameter_1_values = Quantity( - type=HDF5Dataset, a_h5web=H5WebAnnotation(long_name='') + type=HDF5Dataset, a_h5web=H5WebAnnotation(long_name='', indices=1) ) parameter_2_values = Quantity( - type=HDF5Dataset, a_h5web=H5WebAnnotation(long_name='') + type=HDF5Dataset, a_h5web=H5WebAnnotation(long_name='', indices=2) ) - blank = Quantity(type=HDF5Dataset, a_h5web=H5WebAnnotation()) - - def normalize(self, archive, logger): - self.blank = np.array([]) - class PotentialEnergySurfaceFit(Schema): m_def = Section( @@ -71,16 +66,25 @@ class PotentialEnergySurfaceFit(Schema): parameter_slices = SubSection(sub_section=ParameterSpaceSlice.m_def, repeats=True) - def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger'): if isinstance(self.parameter_names, list): if len(self.parameter_names) == (n_slices := len(self.parameter_slices)): - for slice_indices, parameter_slice in zip(generate_slices(n_slices), self.parameter_slices): + for slice_indices, parameter_slice in zip( + generate_slices(n_slices), self.parameter_slices + ): main_rank, upper_rank = slice_indices - parameter_slice.parameter_1_values.m_annotations['h5web'].long_name = self.parameter_names[main_rank] - parameter_slice.parameter_2_values.m_annotations['h5web'].long_name = self.parameter_names[upper_rank] + parameter_slice.parameter_1_values.m_annotations[ + 'h5web' + ].long_name = self.parameter_names[main_rank] + parameter_slice.parameter_2_values.m_annotations[ + 'h5web' + ].long_name = self.parameter_names[upper_rank] else: - logger.warning('Length mismatch between parameter names and slices. Not updating annotations.', n_names=len(self.parameter_names), n_slices=n_slices) + logger.warning( + 'Length mismatch between parameter names and slices. Not updating annotations.', + n_names=len(self.parameter_names), + n_slices=n_slices, + ) m_package.__init_metainfo__()