Skip to content

Commit

Permalink
BROKEN: try indices and auxiliary_signals
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaelman committed Dec 20, 2024
1 parent 8549eaa commit 5228795
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
9 changes: 3 additions & 6 deletions src/nomad_parser_plugin_boss/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 17 additions & 13 deletions src/nomad_parser_plugin_boss/schema_packages/schema_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
)
)

Expand All @@ -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(
Expand All @@ -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__()

0 comments on commit 5228795

Please sign in to comment.