From ad96c7a78b577a165e9c3e98eb9b0588f9e74f23 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 28 Nov 2017 18:31:50 +0300 Subject: [PATCH] Fixed adapters --- .../src/main/java/inr/numass/data/SpectrumAdapter.java | 3 +-- .../groovy/inr/numass/scripts/models/TristanModel.groovy | 2 +- .../src/main/java/inr/numass/data/SpectrumGenerator.java | 4 ++-- .../src/main/java/inr/numass/utils/OldDataReader.java | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/numass-core/src/main/java/inr/numass/data/SpectrumAdapter.java b/numass-core/src/main/java/inr/numass/data/SpectrumAdapter.java index 22b8674f..7c45b4ab 100644 --- a/numass-core/src/main/java/inr/numass/data/SpectrumAdapter.java +++ b/numass-core/src/main/java/inr/numass/data/SpectrumAdapter.java @@ -17,7 +17,6 @@ package inr.numass.data; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.tables.Adapters; import hep.dataforge.tables.BasicAdapter; import hep.dataforge.tables.ValueMap; import hep.dataforge.tables.ValuesAdapter; @@ -108,6 +107,6 @@ public class SpectrumAdapter extends BasicAdapter { @Override public Stream listComponents() { - return Stream.concat(super.listComponents(), Stream.of(Adapters.Y_VALUE_KEY, Adapters.Y_ERROR_KEY)).distinct(); + return Stream.concat(super.listComponents(), Stream.of(X_VALUE_KEY, Y_VALUE_KEY, POINT_LENGTH_NAME)).distinct(); } } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy b/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy index ae64efe9..47c7c176 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy @@ -67,7 +67,7 @@ new GrindShell(ctx).eval { ph.plot(data: (2000..19500).step(50).collectEntries { [it, model.value(it, params)] }, name: "spectrum-mod") .configure(showLine: true, showSymbol: false, showErrors: false, thickness: 2, connectionType: "spline", color: "green") - ph.plot(data: data, adapter: new SpectrumAdapter()) + ph.plot(data: data, adapter: new SpectrumAdapter(Meta.empty())) .configure(color: "blue") FitState state = new FitState(data, model, params); diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java b/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java index 6aaa2d22..004bd8d6 100644 --- a/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java +++ b/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java @@ -67,7 +67,7 @@ public class SpectrumGenerator implements Generator { @Override public Table generateData(Iterable config) { - ListTable.Builder res = new ListTable.Builder(Adapters.getXYFormat(adapter)); + ListTable.Builder res = new ListTable.Builder(Adapters.getFormat(adapter)); for (Values aConfig : config) { res.row(this.generateDataPoint(aConfig)); } @@ -82,7 +82,7 @@ public class SpectrumGenerator implements Generator { * @return */ public Table generateExactData(Iterable config) { - ListTable.Builder res = new ListTable.Builder(Adapters.getXYFormat(adapter)); + ListTable.Builder res = new ListTable.Builder(Adapters.getFormat(adapter)); for (Values aConfig : config) { res.row(this.generateExactDataPoint(aConfig)); } diff --git a/numass-main/src/main/java/inr/numass/utils/OldDataReader.java b/numass-main/src/main/java/inr/numass/utils/OldDataReader.java index 60db021f..1a0616d9 100644 --- a/numass-main/src/main/java/inr/numass/utils/OldDataReader.java +++ b/numass-main/src/main/java/inr/numass/utils/OldDataReader.java @@ -61,7 +61,7 @@ public class OldDataReader { public static Table readData(String path, double Elow) { SpectrumAdapter factory = new SpectrumAdapter(Meta.empty()); - ListTable.Builder res = new ListTable.Builder(Adapters.getXYFormat(factory)); + ListTable.Builder res = new ListTable.Builder(Adapters.getFormat(factory)); Path file = Global.instance().getIo().getFile(path); double x; int count; @@ -113,7 +113,7 @@ public class OldDataReader { public static Table readDataAsGun(String path, double Elow) { SpectrumAdapter factory = new SpectrumAdapter(Meta.empty()); - ListTable.Builder res = new ListTable.Builder(Adapters.getXYFormat(factory)); + ListTable.Builder res = new ListTable.Builder(Adapters.getFormat(factory)); Path file = Global.instance().getIo().getFile(path); double x; long count; @@ -146,7 +146,7 @@ public class OldDataReader { public static Table readSpectrumData(String path) { SpectrumAdapter factory = new SpectrumAdapter(Meta.empty()); - ListTable.Builder res = new ListTable.Builder(Adapters.getXYFormat(factory)); + ListTable.Builder res = new ListTable.Builder(Adapters.getFormat(factory)); Path file = Global.instance().getIo().getFile(path); double x; double count;