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 { Meta meta = buildMeta {
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}") data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")
generate(t0: 3e4, sort: true) generate(t0: 3e4)
subtract(reference: 18600) subtract(reference: 18500)
fit(xlow: 450, xHigh: 700, upper: 3100, binning: 20) 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)); 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) { private Values mergeDataPoints(Values dp1, Values dp2) {
if (dp1 == null) { if (dp1 == null) {
return dp2; return dp2;
@ -100,16 +74,11 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
} }
double voltage = dp1.getValue(NumassPoint.HV_KEY).doubleValue(); 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 t1 = dp1.getValue(NumassPoint.LENGTH_KEY).doubleValue();
double t2 = dp2.getValue(NumassPoint.LENGTH_KEY).doubleValue(); double t2 = dp2.getValue(NumassPoint.LENGTH_KEY).doubleValue();
double time = t1 + t2; double time = t1 + t2;
long total = dp1.getValue(NumassAnalyzer.COUNT_KEY).intValue() + dp2.getValue(NumassAnalyzer.COUNT_KEY).intValue(); 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 cr1 = dp1.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue();
double cr2 = dp2.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(); 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(); return map.build();
} }

View File

@ -44,7 +44,7 @@ public class NumassFitTask extends SingleActionTask<Table, FitResult> {
@Override @Override
public void validate(TaskModel model) { public void validate(TaskModel model) {
if (!model.meta().hasMeta("fit")) { if (model.meta().isEmpty()) {
throw new RuntimeException("Fit element not found in model"); throw new RuntimeException("Fit element not found in model");
} }
} }
@ -52,7 +52,7 @@ public class NumassFitTask extends SingleActionTask<Table, FitResult> {
@Override @Override
protected Action<Table, FitResult> getAction(TaskModel model) { protected Action<Table, FitResult> getAction(TaskModel model) {
Action<Table, FitResult> action = new FitAction(); 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()); return ActionUtils.compose(action, new PlotFitResultAction());
} else { } else {
return action; return action;
@ -61,7 +61,7 @@ public class NumassFitTask extends SingleActionTask<Table, FitResult> {
@Override @Override
protected Meta transformMeta(TaskModel model) { 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.data.DataTree;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.meta.Template; import hep.dataforge.meta.Template;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.workspace.tasks.AbstractTask; import hep.dataforge.workspace.tasks.AbstractTask;
@ -85,6 +86,15 @@ public class NumassPrepareTask extends AbstractTask<Table> {
@Override @Override
protected void updateModel(TaskModel.Builder model, Meta meta) { 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")) { if (meta.hasValue("data.from")) {
model.data(meta.getString("data.from.*")); model.data(meta.getString("data.from.*"));
} else { } else {
@ -164,12 +174,12 @@ public class NumassPrepareTask extends AbstractTask<Table> {
return action.run(context, data, meta); return action.run(context, data, meta);
} }
@Override // @Override
public void validate(TaskModel model) { // public void validate(TaskModel model) {
if (!model.meta().hasMeta("data")) { // if (!model.meta().hasMeta("data")) {
//
} // }
} // }
@Override @Override
public String getName() { public String getName() {

View File

@ -53,13 +53,13 @@ public class NumassTableFilterTask extends SingleActionTask<Table, Table> {
private class FilterTableAction extends OneToOneAction<Table, Table> { private class FilterTableAction extends OneToOneAction<Table, Table> {
@Override @Override
protected Table execute(Context context, String name, Table input, Laminate inputMeta) { protected Table execute(Context context, String name, Table input, Laminate inputMeta) {
if (inputMeta.hasValue("filter.from") || inputMeta.hasValue("filter.to")) { if (inputMeta.hasValue("from") || inputMeta.hasValue("to")) {
double uLo = inputMeta.getDouble("filter.from", 0); double uLo = inputMeta.getDouble("from", 0);
double uHi = inputMeta.getDouble("filter.to", Double.POSITIVE_INFINITY); double uHi = inputMeta.getDouble("to", Double.POSITIVE_INFINITY);
getLogger(inputMeta).debug("Filtering finished"); getLogger(inputMeta).debug("Filtering finished");
return TableTransform.filter(input, "Uset", uLo, uHi); return TableTransform.filter(input, "Uset", uLo, uHi);
} else if (inputMeta.hasValue("filter.condition")) { } 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); return TableTransform.filter(input, predicate);
} else { } else {
throw new RuntimeException("No filtering condition specified"); throw new RuntimeException("No filtering condition specified");

View File

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