From f8539364d99b34ebc5125f76a3045e4772f38f24 Mon Sep 17 00:00:00 2001 From: darksnake Date: Wed, 23 Aug 2017 16:58:47 +0300 Subject: [PATCH] Grind shell fixes --- .../numass/scripts/underflow/Underflow.groovy | 6 +-- .../inr/numass/actions/MergeDataAction.java | 37 ------------------- .../java/inr/numass/tasks/NumassFitTask.java | 6 +-- .../inr/numass/tasks/NumassPrepareTask.java | 22 ++++++++--- .../numass/tasks/NumassTableFilterTask.java | 8 ++-- .../java/inr/numass/utils/NumassUtils.java | 1 + 6 files changed, 27 insertions(+), 53 deletions(-) diff --git a/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy b/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy index 8cdec347..e5b73e1e 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy @@ -35,9 +35,9 @@ ctx.pluginManager().load(CachePlugin.class) Meta meta = buildMeta { data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}") - generate(t0: 3e4, sort: true) - subtract(reference: 18600) - fit(xlow: 450, xHigh: 700, upper: 3100, binning: 20) + generate(t0: 3e4) + subtract(reference: 18500) + fit(xlow: 500, xHigh: 700, upper: 3100, binning: 20) } diff --git a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java index e82a3f64..1936baeb 100644 --- a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java @@ -65,32 +65,6 @@ public class MergeDataAction extends ManyToOneAction { output(context, groupName, stream -> NumassUtils.writeSomething(stream, outputMeta, output)); } -// @Override -// protected MetaBuilder outputMeta(DataNode input) { -// -// String numassPath = input.dataStream().map(data -> data.meta().getString("numass.path", "")) -// .reduce("", (String path, String newPath) -> { -// if (path.isEmpty()) { -// return null; -// } else if (path.isEmpty()) { -// return newPath; -// } else if (!path.equals(newPath)) { -// return null; -// } else { -// return newPath; -// } -// }); -// -// MetaBuilder builder = super.outputMeta(input); -// /* -// * Указываем путь только есл0и он одинаковый для всех входных файлов -// */ -// if (numassPath != null) { -// builder.putValue("numass.path", numassPath); -// } -// return builder; -// } - private Values mergeDataPoints(Values dp1, Values dp2) { if (dp1 == null) { return dp2; @@ -100,16 +74,11 @@ public class MergeDataAction extends ManyToOneAction { } double voltage = dp1.getValue(NumassPoint.HV_KEY).doubleValue(); - //усредняем измеренное напряжение -// double Uread = (dp1.getValue(parnames[1]).doubleValue() + dp2.getValue(parnames[1]).doubleValue()) / 2; - double t1 = dp1.getValue(NumassPoint.LENGTH_KEY).doubleValue(); double t2 = dp2.getValue(NumassPoint.LENGTH_KEY).doubleValue(); double time = t1 + t2; long total = dp1.getValue(NumassAnalyzer.COUNT_KEY).intValue() + dp2.getValue(NumassAnalyzer.COUNT_KEY).intValue(); -// long wind = dp1.getValue(parnames[4]).intValue() + dp2.getValue(parnames[4]).intValue(); -// double corr = dp1.getValue(parnames[5]).doubleValue() + dp2.getValue(parnames[5]).doubleValue(); double cr1 = dp1.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue(); double cr2 = dp2.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue(); @@ -124,12 +93,6 @@ public class MergeDataAction extends ManyToOneAction { ValueMap.Builder map = ValueMap.of(parnames, voltage, time, total, cr, crErr).builder(); -// if (dp1.getNames().contains("relCR") && dp2.getNames().contains("relCR")) { -// double relCR = (dp1.getDouble("relCR") + dp2.getDouble("relCR")) / 2; -// map.putValue("relCR", relCR); -// map.putValue("relCRerr", crErr * relCR / cr); -// } - return map.build(); } diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java index a2b8fc5d..4b7b366d 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java @@ -44,7 +44,7 @@ public class NumassFitTask extends SingleActionTask { @Override public void validate(TaskModel model) { - if (!model.meta().hasMeta("fit")) { + if (model.meta().isEmpty()) { throw new RuntimeException("Fit element not found in model"); } } @@ -52,7 +52,7 @@ public class NumassFitTask extends SingleActionTask { @Override protected Action getAction(TaskModel model) { Action action = new FitAction(); - if (model.meta().getBoolean("fit.plot", false)) { + if (model.meta().getBoolean("plot", false)) { return ActionUtils.compose(action, new PlotFitResultAction()); } else { return action; @@ -61,7 +61,7 @@ public class NumassFitTask extends SingleActionTask { @Override protected Meta transformMeta(TaskModel model) { - return model.meta().getMeta("fit"); + return model.meta(); } diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java index bc111613..07c33f04 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java @@ -13,6 +13,7 @@ import hep.dataforge.data.DataNode; import hep.dataforge.data.DataTree; import hep.dataforge.description.NodeDef; import hep.dataforge.meta.Meta; +import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.Template; import hep.dataforge.tables.Table; import hep.dataforge.workspace.tasks.AbstractTask; @@ -85,6 +86,15 @@ public class NumassPrepareTask extends AbstractTask
{ @Override protected void updateModel(TaskModel.Builder model, Meta meta) { + model.configure( + new MetaBuilder() + .putNode(meta.getMetaOrEmpty("data")) + .putNode(meta.getMetaOrEmpty("prepare")) + .putNode(meta.getMetaOrEmpty("monitor")) + .putNode(meta.getMetaOrEmpty("merge")) + + ); + if (meta.hasValue("data.from")) { model.data(meta.getString("data.from.*")); } else { @@ -164,12 +174,12 @@ public class NumassPrepareTask extends AbstractTask
{ return action.run(context, data, meta); } - @Override - public void validate(TaskModel model) { - if (!model.meta().hasMeta("data")) { - - } - } +// @Override +// public void validate(TaskModel model) { +// if (!model.meta().hasMeta("data")) { +// +// } +// } @Override public String getName() { diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java index 3c9abdef..a99620a5 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java @@ -53,13 +53,13 @@ public class NumassTableFilterTask extends SingleActionTask { private class FilterTableAction extends OneToOneAction { @Override protected Table execute(Context context, String name, Table input, Laminate inputMeta) { - if (inputMeta.hasValue("filter.from") || inputMeta.hasValue("filter.to")) { - double uLo = inputMeta.getDouble("filter.from", 0); - double uHi = inputMeta.getDouble("filter.to", Double.POSITIVE_INFINITY); + if (inputMeta.hasValue("from") || inputMeta.hasValue("to")) { + double uLo = inputMeta.getDouble("from", 0); + double uHi = inputMeta.getDouble("to", Double.POSITIVE_INFINITY); getLogger(inputMeta).debug("Filtering finished"); return TableTransform.filter(input, "Uset", uLo, uHi); } else if (inputMeta.hasValue("filter.condition")) { - Predicate predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("filter.condition"), unbox(dp)); + Predicate predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("condition"), unbox(dp)); return TableTransform.filter(input, predicate); } else { throw new RuntimeException("No filtering condition specified"); diff --git a/numass-main/src/main/java/inr/numass/utils/NumassUtils.java b/numass-main/src/main/java/inr/numass/utils/NumassUtils.java index 8cf7cc60..5e310ce1 100644 --- a/numass-main/src/main/java/inr/numass/utils/NumassUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/NumassUtils.java @@ -106,6 +106,7 @@ public class NumassUtils { .setData(dataWriter) .build() ); + stream.flush(); } catch (IOException e) { throw new RuntimeException(e); }