diff --git a/changes.md b/changes.md index a712a8db1..a25f18e8f 100644 --- a/changes.md +++ b/changes.md @@ -11,6 +11,7 @@ Unit tests and system test added for link creation cases. ([#607](https://github.com/ess-dmsc/kafka-to-nexus/pull/607)) - Fixed a bug where the file-writer will not abandon an alternative command topic if it fails to start a file-writing job. +- The f142 value statistics written to file is now done so according to the NeXus format. ## Version 4.0.0: Many, many changes diff --git a/src/WriterModule/f142/f142_Writer.cpp b/src/WriterModule/f142/f142_Writer.cpp index f38b7b375..6211fcb15 100644 --- a/src/WriterModule/f142/f142_Writer.cpp +++ b/src/WriterModule/f142/f142_Writer.cpp @@ -371,17 +371,18 @@ void f142_Writer::write(FlatbufferMessage const &Message) { void f142_Writer::register_meta_data(hdf5::node::Group const &HDFGroup, const MetaData::TrackerPtr &Tracker) { - auto UsedAttributeWriter = - MetaData::getPathOffsetAttributeWriter("value"); + if (MetaData.getValue()) { - MetaDataMin = MetaData::Value(HDFGroup, "min", UsedAttributeWriter); + MetaDataMin = MetaData::Value(HDFGroup, "minimum_value", + MetaData::basicDatasetWriter); Tracker->registerMetaData(MetaDataMin); - MetaDataMax = MetaData::Value(HDFGroup, "max", UsedAttributeWriter); + MetaDataMax = MetaData::Value(HDFGroup, "maximum_value", + MetaData::basicDatasetWriter); Tracker->registerMetaData(MetaDataMax); - MetaDataMean = - MetaData::Value(HDFGroup, "mean", UsedAttributeWriter); + MetaDataMean = MetaData::Value( + HDFGroup, "average_value", MetaData::basicDatasetWriter); Tracker->registerMetaData(MetaDataMean); } } diff --git a/src/WriterModule/f142/f142_Writer.h b/src/WriterModule/f142/f142_Writer.h index 3a0668d97..d380ad635 100644 --- a/src/WriterModule/f142/f142_Writer.h +++ b/src/WriterModule/f142/f142_Writer.h @@ -43,8 +43,8 @@ class f142_Writer : public WriterModule::Base { void write(FlatbufferMessage const &Message) override; f142_Writer() - : WriterModule::Base(false, "NXlog"), MetaDataMin("", "min"), - MetaDataMax("", "max"), MetaDataMean("", "mean") {} + : WriterModule::Base(false, "NXlog"), MetaDataMin("", "minimum_value"), + MetaDataMax("", "maximum_value"), MetaDataMean("", "average_value") {} ~f142_Writer() override = default; enum class Type { diff --git a/system-tests/test_f142_meta_data.py b/system-tests/test_f142_meta_data.py index a67417e34..c4e70388c 100644 --- a/system-tests/test_f142_meta_data.py +++ b/system-tests/test_f142_meta_data.py @@ -95,12 +95,12 @@ def test_f142_meta_data(writer_channel, worker_pool, kafka_address): # file writer should recognise there is no data in that topic and close the corresponding streamer without problem. file_path = f"output-files/{file_name}" with OpenNexusFile(file_path) as file: - assert file["entry/meta_data_1/value"].attrs["min"] == Min - assert file["entry/meta_data_1/value"].attrs["max"] == Max - assert file["entry/meta_data_1/value"].attrs["mean"] == Mean + assert file["entry/meta_data_1/minimum_value"][0] == Min + assert file["entry/meta_data_1/maximum_value"][0] == Max + assert file["entry/meta_data_1/average_value"][0] == Mean FullArr = np.concatenate([Array1, Array2, Array3]) - assert file["entry/meta_data_2/value"].attrs["min"] == FullArr.min() - assert file["entry/meta_data_2/value"].attrs["max"] == FullArr.max() - assert file["entry/meta_data_2/value"].attrs["mean"] == FullArr.mean() + assert file["entry/meta_data_2/minimum_value"][0] == FullArr.min() + assert file["entry/meta_data_2/maximum_value"][0] == FullArr.max() + assert file["entry/meta_data_2/average_value"][0] == FullArr.mean()