Provider revising
This commit is contained in:
commit
2fb2a6ca4a
@ -36,6 +36,15 @@ task repl(dependsOn: classes, type: JavaExec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task grindTask(dependsOn: classes, type: JavaExec){
|
||||||
|
group "numass"
|
||||||
|
main 'inr.numass.RunTask'
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
description "Run a task in a numass workspace"
|
||||||
|
standardInput = System.in
|
||||||
|
standardOutput = System.out
|
||||||
|
}
|
||||||
|
|
||||||
task simulate(dependsOn: classes, type: JavaExec) {
|
task simulate(dependsOn: classes, type: JavaExec) {
|
||||||
group "numass"
|
group "numass"
|
||||||
main 'inr.numass.scripts.Simulate'
|
main 'inr.numass.scripts.Simulate'
|
||||||
|
@ -22,7 +22,7 @@ println "Starting Grind shell"
|
|||||||
|
|
||||||
if (cfgPath) {
|
if (cfgPath) {
|
||||||
try {
|
try {
|
||||||
GrindTerminal.dumb().launch {
|
GrindTerminal.system().launch {
|
||||||
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder(it.shell.context).read(new File(cfgPath)).startup {
|
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder(it.shell.context).read(new File(cfgPath)).startup {
|
||||||
it.loadTask(NumassPrepareTask)
|
it.loadTask(NumassPrepareTask)
|
||||||
it.loadTask(NumassTableFilterTask)
|
it.loadTask(NumassTableFilterTask)
|
||||||
|
23
numass-main/src/main/groovy/inr/numass/RunTask.groovy
Normal file
23
numass-main/src/main/groovy/inr/numass/RunTask.groovy
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package inr.numass
|
||||||
|
|
||||||
|
import hep.dataforge.grind.GrindWorkspaceBuilder
|
||||||
|
import inr.numass.tasks.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by darksnake on 18-Apr-17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
cfgPath = "D:\\Work\\Numass\\sterile2016_10\\workspace.groovy"
|
||||||
|
|
||||||
|
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder().read(new File(cfgPath)).startup {
|
||||||
|
it.loadTask(NumassPrepareTask)
|
||||||
|
it.loadTask(NumassTableFilterTask)
|
||||||
|
it.loadTask(NumassFitScanTask)
|
||||||
|
it.loadTask(NumassSubstractEmptySourceTask)
|
||||||
|
it.loadTask(NumassFitScanSummaryTask)
|
||||||
|
it.loadTask(NumassFitTask)
|
||||||
|
it.loadTask(NumassFitSummaryTask)
|
||||||
|
}
|
||||||
|
|
||||||
|
numass.scansum "fill_1"
|
@ -27,6 +27,7 @@ import hep.dataforge.plots.PlotFrame;
|
|||||||
import hep.dataforge.plots.PlotUtils;
|
import hep.dataforge.plots.PlotUtils;
|
||||||
import hep.dataforge.plots.data.PlottableData;
|
import hep.dataforge.plots.data.PlottableData;
|
||||||
import hep.dataforge.plots.data.PlottableXYFunction;
|
import hep.dataforge.plots.data.PlottableXYFunction;
|
||||||
|
import hep.dataforge.stat.fit.FitResult;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitState;
|
||||||
import hep.dataforge.stat.models.XYModel;
|
import hep.dataforge.stat.models.XYModel;
|
||||||
import hep.dataforge.tables.NavigablePointSource;
|
import hep.dataforge.tables.NavigablePointSource;
|
||||||
@ -41,10 +42,10 @@ import java.util.stream.StreamSupport;
|
|||||||
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class)
|
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class)
|
||||||
@NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
|
@NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
|
||||||
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.")
|
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.")
|
||||||
public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FitState execute(Context context, String name, FitState input, Laminate metaData) {
|
protected FitResult execute(Context context, String name, FitResult input, Laminate metaData) {
|
||||||
|
|
||||||
NavigablePointSource data = input.getDataSet();
|
NavigablePointSource data = input.getDataSet();
|
||||||
if (!(input.getModel() instanceof XYModel)) {
|
if (!(input.getModel() instanceof XYModel)) {
|
||||||
|
@ -31,9 +31,11 @@ import hep.dataforge.meta.Meta;
|
|||||||
public class Numass {
|
public class Numass {
|
||||||
|
|
||||||
public static Context buildContext(Context parent, Meta meta) {
|
public static Context buildContext(Context parent, Meta meta) {
|
||||||
Context numassContext = Global.getContext("numass").withParent(parent).withProperties(meta);
|
return Context.builder("NUMASS")
|
||||||
numassContext.pluginManager().load("inr.numass:numass");
|
.parent(parent)
|
||||||
return numassContext;
|
.properties(meta)
|
||||||
|
.plugin(NumassPlugin.class)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Context buildContext() {
|
public static Context buildContext() {
|
||||||
|
@ -72,7 +72,7 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
public void attach(Context context) {
|
public void attach(Context context) {
|
||||||
// StorageManager.buildFrom(context);
|
// StorageManager.buildFrom(context);
|
||||||
super.attach(context);
|
super.attach(context);
|
||||||
context.setIO(new NumassIO());
|
context.pluginManager().load(new NumassIO());
|
||||||
FitManager fm = context.getFeature(FitManager.class);
|
FitManager fm = context.getFeature(FitManager.class);
|
||||||
loadModels(fm.getModelManager());
|
loadModels(fm.getModelManager());
|
||||||
loadMath(MathPlugin.buildFrom(context));
|
loadMath(MathPlugin.buildFrom(context));
|
||||||
|
@ -58,7 +58,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
|
|||||||
|
|
||||||
TreeMap<Instant, DataPoint> index = getMonitorIndex(monitor, sourceData);
|
TreeMap<Instant, DataPoint> index = getMonitorIndex(monitor, sourceData);
|
||||||
if (index.isEmpty()) {
|
if (index.isEmpty()) {
|
||||||
getReport(context, name).reportError("No monitor points found");
|
context.getLog(name).reportError("No monitor points found");
|
||||||
return sourceData;
|
return sourceData;
|
||||||
}
|
}
|
||||||
double norm = 0;
|
double norm = 0;
|
||||||
|
@ -80,7 +80,7 @@ public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
|
|||||||
corrections.add(new DeadTimeCorrection(meta.getString("deadTime")));
|
corrections.add(new DeadTimeCorrection(meta.getString("deadTime")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.hasNode("correction")) {
|
if (meta.optMeta("correction").isPresent()) {
|
||||||
corrections.addAll(meta.getMetaList("correction").stream()
|
corrections.addAll(meta.getMetaList("correction").stream()
|
||||||
.map((Function<Meta, Correction>) this::makeCorrection)
|
.map((Function<Meta, Correction>) this::makeCorrection)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
@ -11,6 +11,7 @@ import hep.dataforge.data.DataTree;
|
|||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.stat.fit.FitAction;
|
import hep.dataforge.stat.fit.FitAction;
|
||||||
|
import hep.dataforge.stat.fit.FitResult;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitState;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
@ -40,7 +41,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
} else {
|
} else {
|
||||||
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
|
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
|
||||||
}
|
}
|
||||||
Action<Table, FitState> action = new FitAction();
|
Action<Table, FitResult> action = new FitAction();
|
||||||
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
|
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
|
||||||
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);
|
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
.filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val));
|
.filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val));
|
||||||
}
|
}
|
||||||
// Data<Table> newData = new Data<Table>(data.getGoal(),data.type(),overrideMeta);
|
// Data<Table> newData = new Data<Table>(data.getGoal(),data.type(),overrideMeta);
|
||||||
DataNode<FitState> node = action.run(model.getContext(), DataNode.of("fit_" + i, table, Meta.empty()), overrideMeta);
|
DataNode<FitResult> node = action.run(model.getContext(), DataNode.of("fit_" + i, table, Meta.empty()), overrideMeta);
|
||||||
resultBuilder.putData(table.getName() + ".fit_" + i, node.getData());
|
resultBuilder.putData(table.getName() + ".fit_" + i, node.getData());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.plotfit.PlotFitResultAction;
|
import hep.dataforge.plotfit.PlotFitResultAction;
|
||||||
import hep.dataforge.stat.fit.FitAction;
|
import hep.dataforge.stat.fit.FitAction;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitResult;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.workspace.SingleActionTask;
|
import hep.dataforge.workspace.SingleActionTask;
|
||||||
import hep.dataforge.workspace.TaskModel;
|
import hep.dataforge.workspace.TaskModel;
|
||||||
@ -31,7 +31,7 @@ import hep.dataforge.workspace.TaskModel;
|
|||||||
/**
|
/**
|
||||||
* Created by darksnake on 16-Sep-16.
|
* Created by darksnake on 16-Sep-16.
|
||||||
*/
|
*/
|
||||||
public class NumassFitTask extends SingleActionTask<Table, FitState> {
|
public class NumassFitTask extends SingleActionTask<Table, FitResult> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -51,8 +51,8 @@ public class NumassFitTask extends SingleActionTask<Table, FitState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Action<Table, FitState> getAction(TaskModel model) {
|
protected Action<Table, FitResult> getAction(TaskModel model) {
|
||||||
Action<Table, FitState> action = new FitAction();
|
Action<Table, FitResult> action = new FitAction();
|
||||||
if (model.meta().getBoolean("fit.plot", false)) {
|
if (model.meta().getBoolean("fit.plot", false)) {
|
||||||
return ActionUtils.compose(action, new PlotFitResultAction());
|
return ActionUtils.compose(action, new PlotFitResultAction());
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,6 +29,7 @@ import hep.dataforge.tables.MapPoint;
|
|||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.workspace.AbstractTask;
|
import hep.dataforge.workspace.AbstractTask;
|
||||||
import hep.dataforge.workspace.TaskModel;
|
import hep.dataforge.workspace.TaskModel;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -77,7 +78,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
|
|||||||
|
|
||||||
|
|
||||||
private Data<? extends Table> subtractBackground(Data<? extends Table> mergeData, Data<? extends Table> emptyData) {
|
private Data<? extends Table> subtractBackground(Data<? extends Table> mergeData, Data<? extends Table> emptyData) {
|
||||||
return DataUtils.combine(Table.class, mergeData, emptyData, mergeData.meta(), (BiFunction<Table, Table, Table>) this::subtractBackground);
|
return DataUtils.combine(mergeData, emptyData, Table.class, mergeData.meta(), (BiFunction<Table, Table, Table>) this::subtractBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Table subtractBackground(Table merge, Table empty) {
|
private Table subtractBackground(Table merge, Table empty) {
|
||||||
@ -90,7 +91,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
|
|||||||
pointBuilder.putValue("CR", Math.max(0, point.getDouble("CR") - referencePoint.get().getDouble("CR")));
|
pointBuilder.putValue("CR", Math.max(0, point.getDouble("CR") - referencePoint.get().getDouble("CR")));
|
||||||
pointBuilder.putValue("CRerr", Math.sqrt(Math.pow(point.getDouble("CRerr"), 2d) + Math.pow(referencePoint.get().getDouble("CRerr"), 2d)));
|
pointBuilder.putValue("CRerr", Math.sqrt(Math.pow(point.getDouble("CRerr"), 2d) + Math.pow(referencePoint.get().getDouble("CRerr"), 2d)));
|
||||||
} else {
|
} else {
|
||||||
getLogger().warn("No reference point found for Uset = {}", point.getDouble("Uset"));
|
LoggerFactory.getLogger(getClass()).warn("No reference point found for Uset = {}", point.getDouble("Uset"));
|
||||||
}
|
}
|
||||||
builder.row(pointBuilder.build());
|
builder.row(pointBuilder.build());
|
||||||
});
|
});
|
||||||
|
@ -50,6 +50,7 @@ class NumassLoaderView : View() {
|
|||||||
lateinit var main: MainView
|
lateinit var main: MainView
|
||||||
|
|
||||||
var data: NumassData? = null
|
var data: NumassData? = null
|
||||||
|
val spectrumData = PlottableData("spectrum")
|
||||||
|
|
||||||
private val detectorPlotPane: AnchorPane by fxid();
|
private val detectorPlotPane: AnchorPane by fxid();
|
||||||
private val tabPane: TabPane by fxid();
|
private val tabPane: TabPane by fxid();
|
||||||
@ -175,13 +176,11 @@ class NumassLoaderView : View() {
|
|||||||
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
||||||
val t = hvData.get()
|
val t = hvData.get()
|
||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
// hvPlot.plot.clear()
|
|
||||||
val set = PlottableGroup<TimePlottable>()
|
val set = PlottableGroup<TimePlottable>()
|
||||||
for (dp in t) {
|
for (dp in t) {
|
||||||
val block = dp.getString("block", "default")
|
val block = dp.getString("block", "default")
|
||||||
if (!set.has(block)) {
|
if (!set.has(block)) {
|
||||||
|
set.add(TimePlottable(block))
|
||||||
set.add(hvPlot.plot.opt(block).orElseGet{TimePlottable(block)} as TimePlottable)
|
|
||||||
}
|
}
|
||||||
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
||||||
}
|
}
|
||||||
@ -217,8 +216,7 @@ class NumassLoaderView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSpectrumPane(points: List<NumassPoint>) {
|
private fun setupSpectrumPane(points: List<NumassPoint>) {
|
||||||
val spectrumData = spectrumPlot.plot.opt("spectrum").orElseGet{PlottableData("spectrum")} as PlottableData
|
spectrumPlot.plot.add(spectrumData)
|
||||||
spectrumPlot.plot.add(spectrumData) //does nothing if it is the same plottable
|
|
||||||
|
|
||||||
val lowChannel = channelSlider.lowValue.toInt()
|
val lowChannel = channelSlider.lowValue.toInt()
|
||||||
val highChannel = channelSlider.highValue.toInt()
|
val highChannel = channelSlider.highValue.toInt()
|
||||||
|
Loading…
Reference in New Issue
Block a user