Table reducer test

This commit is contained in:
Alexander Nozik 2018-07-23 18:20:51 +03:00
parent b90050cf20
commit 6c5dc8fbb5
2 changed files with 10 additions and 16 deletions

View File

@ -23,6 +23,7 @@ import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta;
import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.Table;
import hep.dataforge.tables.Tables;
import hep.dataforge.values.ValueFactory;
import hep.dataforge.values.ValueMap;
import hep.dataforge.values.Values;
@ -129,7 +130,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
// } else {
// format = DataFormat.of(parnames);
// }
Table res = ListTable.infer(dataList);
Table res = Tables.infer(dataList);
context.getOutput().get(getName(), name, TEXT_TYPE).render(NumassUtils.INSTANCE.wrap(res, meta), Meta.empty());
@ -194,7 +195,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
private void printMonitorData(Context context, Meta meta) {
if (!monitorPoints.isEmpty()) {
String monitorFileName = meta.getString("monitorFile", "monitor");
ListTable data = ListTable.infer(monitorPoints);
ListTable data = Tables.infer(monitorPoints);
context.getOutput().get(getName(), monitorFileName, TEXT_TYPE).render(NumassUtils.INSTANCE.wrap(data, meta), Meta.empty());
// ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames);

View File

@ -210,7 +210,7 @@ val filterTask = task("filter") {
this.log.report("Filtering finished")
Tables.filter(data, NumassPoint.HV_KEY, uLo, uHi)
} else if (meta.hasValue("condition")) {
Tables.filter(data, Predicate{ ExpressionUtils.condition(meta.getString("condition"), it.unbox()) })
Tables.filter(data, Predicate { ExpressionUtils.condition(meta.getString("condition"), it.unbox()) })
} else {
throw RuntimeException("No filtering condition specified")
}
@ -285,7 +285,7 @@ val histogramTask = task("histogram") {
configure(meta.getMetaOrEmpty("histogram"))
configure {
meta.useMeta("analyzer") { putNode(it) }
setValue("@target", meta.getString("@target",meta.name))
setValue("@target", meta.getString("@target", meta.name))
}
}
join<NumassSet, Table> { data ->
@ -328,17 +328,10 @@ val histogramTask = task("histogram") {
}
row(values)
}
}
//apply binning
val processedTable: Table = if(meta.hasValue("binning")){
table.sumByStep(NumassAnalyzer.CHANNEL_KEY, meta.getDouble("binning"))
} else{
table
}
}.sumByStep(NumassAnalyzer.CHANNEL_KEY, meta.getDouble("binning", 20.0)) //apply binning
// send raw table to the output
context.output.render(processedTable, stage = "numass.histogram", name = name, meta = meta)
context.output.render(table, stage = "numass.histogram", name = name, meta = meta)
if (meta.getBoolean("plot", false)) {
context.plot("$name.plot", stage = "numass.histogram") {
@ -349,13 +342,13 @@ val histogramTask = task("histogram") {
"showLine" to true
"connectionType" to "step"
}
processedTable.format.names.filter { it != "channel" }.forEach {
+DataPlot.plot(it, processedTable, adapter = Adapters.buildXYAdapter("channel", it))
table.format.names.filter { it != "channel" }.forEach {
+DataPlot.plot(it, table, adapter = Adapters.buildXYAdapter("channel", it))
}
}
}
return@join processedTable
return@join table
}
}