minor fixes

This commit is contained in:
Alexander Nozik 2016-10-12 22:43:07 +03:00
parent c7422a7f70
commit ed1ed6b2b6
2 changed files with 40 additions and 29 deletions

View File

@ -22,7 +22,6 @@ import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.tables.*;
import java.io.OutputStream;
@ -63,31 +62,31 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString());
}
@Override
protected MetaBuilder outputMeta(DataNode<Table> input) {
String numassPath = input.dataStream().<String>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;
}
// @Override
// protected MetaBuilder outputMeta(DataNode<Table> 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 DataPoint mergeDataPoints(DataPoint dp1, DataPoint dp2) {
if (dp1 == null) {

View File

@ -18,6 +18,8 @@ import hep.dataforge.values.Value;
import hep.dataforge.workspace.AbstractTask;
import hep.dataforge.workspace.TaskModel;
import java.util.stream.Collectors;
/**
* @author Alexander Nozik
*/
@ -27,8 +29,18 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
@Override
protected DataNode<FitState> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
Meta config = model.meta();
String scanParameter = config.getString("scanPar", "msterile2");
Value scanValues = config.getValue("scanValues", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
String scanParameter = config.getString("scan.parameter", "msterile2");
Value scanValues;
if (config.hasValue("scan.masses")) {
scanValues = Value.of(config.getValue("scan.masses")
.listValue().stream()
.map(it -> Math.pow(it.doubleValue() * 1000, 2.0))
.collect(Collectors.toList())
);
} else {
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
}
Action<Table, FitState> action = new FitAction().withContext(model.getContext()).withParentProcess(callback.workName());
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);
@ -66,7 +78,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
@Override
protected TaskModel transformModel(TaskModel model) {
//Transmit meta as-is
MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("fit");
MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("fit").removeNode("scan");
if (model.meta().hasMeta("filter")) {
model.dependsOn("numass.filter", metaBuilder.build(), "prepare");
} else {