Grind shell fixes

This commit is contained in:
darksnake 2017-08-23 16:58:47 +03:00
parent d9fb708dde
commit f8539364d9
6 changed files with 27 additions and 53 deletions

View File

@ -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)
}

View File

@ -65,32 +65,6 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
output(context, groupName, stream -> NumassUtils.writeSomething(stream, outputMeta, output));
}
// @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 Values mergeDataPoints(Values dp1, Values dp2) {
if (dp1 == null) {
return dp2;
@ -100,16 +74,11 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
}
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<Table, Table> {
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();
}

View File

@ -44,7 +44,7 @@ public class NumassFitTask extends SingleActionTask<Table, FitResult> {
@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<Table, FitResult> {
@Override
protected Action<Table, FitResult> getAction(TaskModel model) {
Action<Table, FitResult> 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<Table, FitResult> {
@Override
protected Meta transformMeta(TaskModel model) {
return model.meta().getMeta("fit");
return model.meta();
}

View File

@ -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<Table> {
@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<Table> {
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() {

View File

@ -53,13 +53,13 @@ public class NumassTableFilterTask extends SingleActionTask<Table, Table> {
private class FilterTableAction extends OneToOneAction<Table, Table> {
@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<Values> predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("filter.condition"), unbox(dp));
Predicate<Values> predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("condition"), unbox(dp));
return TableTransform.filter(input, predicate);
} else {
throw new RuntimeException("No filtering condition specified");

View File

@ -106,6 +106,7 @@ public class NumassUtils {
.setData(dataWriter)
.build()
);
stream.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}