Skip to content

Commit

Permalink
Merge pull request #613 from ess-dmsc/ECDC-2691_f142_meta_data_fix
Browse files Browse the repository at this point in the history
Fix f142 meta data.
  • Loading branch information
SkyToGround authored Nov 23, 2021
2 parents d67fde4 + dedc470 commit 44e0883
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/WriterModule/f142/f142_Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>("value");

if (MetaData.getValue()) {
MetaDataMin = MetaData::Value<double>(HDFGroup, "min", UsedAttributeWriter);
MetaDataMin = MetaData::Value<double>(HDFGroup, "minimum_value",
MetaData::basicDatasetWriter<double>);
Tracker->registerMetaData(MetaDataMin);

MetaDataMax = MetaData::Value<double>(HDFGroup, "max", UsedAttributeWriter);
MetaDataMax = MetaData::Value<double>(HDFGroup, "maximum_value",
MetaData::basicDatasetWriter<double>);
Tracker->registerMetaData(MetaDataMax);

MetaDataMean =
MetaData::Value<double>(HDFGroup, "mean", UsedAttributeWriter);
MetaDataMean = MetaData::Value<double>(
HDFGroup, "average_value", MetaData::basicDatasetWriter<double>);
Tracker->registerMetaData(MetaDataMean);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/WriterModule/f142/f142_Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions system-tests/test_f142_meta_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 44e0883

Please sign in to comment.