Removed [PlotManager]
This commit is contained in:
parent
6277b551c0
commit
01d1fe5528
@ -18,12 +18,13 @@ package inr.numass.control.dante
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
import hep.dataforge.fx.plots.display
|
||||||
import hep.dataforge.kodex.KMetaBuilder
|
import hep.dataforge.kodex.KMetaBuilder
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.configure
|
import hep.dataforge.kodex.configure
|
||||||
import hep.dataforge.kodex.nullable
|
import hep.dataforge.kodex.nullable
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
|
import hep.dataforge.plots.jfreechart.chart
|
||||||
import hep.dataforge.tables.Adapters
|
import hep.dataforge.tables.Adapters
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer
|
import inr.numass.data.analyzers.NumassAnalyzer
|
||||||
import inr.numass.data.analyzers.SimpleAnalyzer
|
import inr.numass.data.analyzers.SimpleAnalyzer
|
||||||
@ -74,12 +75,12 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) {
|
fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) {
|
||||||
val meta = buildMeta("meta", metaAction)
|
val meta = buildMeta("meta", metaAction)
|
||||||
val plotManager = context.load(FXPlotManager::class)
|
|
||||||
val binning = meta.getInt("binning", 20)
|
val binning = meta.getInt("binning", 20)
|
||||||
val lo = meta.optNumber("window.lo").nullable?.toInt()
|
val lo = meta.optNumber("window.lo").nullable?.toInt()
|
||||||
val up = meta.optNumber("window.up").nullable?.toInt()
|
val up = meta.optNumber("window.up").nullable?.toInt()
|
||||||
val data = SimpleAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up)
|
val data = SimpleAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up)
|
||||||
plotManager.display(name = frameName) {
|
context.display(
|
||||||
|
chart {
|
||||||
val valueAxis = if (meta.getBoolean("normalize", false)) {
|
val valueAxis = if (meta.getBoolean("normalize", false)) {
|
||||||
NumassAnalyzer.COUNT_RATE_KEY
|
NumassAnalyzer.COUNT_RATE_KEY
|
||||||
} else {
|
} else {
|
||||||
@ -101,4 +102,6 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
|||||||
plot.configure(meta)
|
plot.configure(meta)
|
||||||
add(plot)
|
add(plot)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
@ -57,7 +57,7 @@ fun connectStorage(device: Device, config: Meta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun readResourceMeta(path: String): Meta {
|
fun readResourceMeta(path: String): Meta {
|
||||||
val resource = Global.output.optResource(path).nullable
|
val resource = Global.optResource(path).nullable
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
return XMLMetaReader().read(resource.stream)
|
return XMLMetaReader().read(resource.stream)
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,7 +2,6 @@ package inr.numass.scripts.models
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.grind.GrindShell
|
import hep.dataforge.grind.GrindShell
|
||||||
import hep.dataforge.grind.helpers.PlotHelper
|
import hep.dataforge.grind.helpers.PlotHelper
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
@ -24,7 +23,6 @@ import inr.numass.utils.DataModelUtils
|
|||||||
|
|
||||||
|
|
||||||
Context ctx = Global.instance()
|
Context ctx = Global.instance()
|
||||||
ctx.getPluginManager().load(FXPlotManager)
|
|
||||||
ctx.getPluginManager().load(NumassPlugin)
|
ctx.getPluginManager().load(NumassPlugin)
|
||||||
|
|
||||||
new GrindShell(ctx).eval {
|
new GrindShell(ctx).eval {
|
||||||
|
@ -3,7 +3,6 @@ package inr.numass.scripts.temp
|
|||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.description.Descriptors
|
import hep.dataforge.description.Descriptors
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.grind.Grind
|
import hep.dataforge.grind.Grind
|
||||||
import hep.dataforge.grind.GrindShell
|
import hep.dataforge.grind.GrindShell
|
||||||
import hep.dataforge.grind.helpers.PlotHelper
|
import hep.dataforge.grind.helpers.PlotHelper
|
||||||
@ -21,7 +20,6 @@ import inr.numass.data.storage.NumassStorage
|
|||||||
import inr.numass.data.storage.NumassStorageFactory
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
|
|
||||||
Context ctx = Global.instance()
|
Context ctx = Global.instance()
|
||||||
ctx.getPluginManager().load(FXPlotManager)
|
|
||||||
ctx.getPluginManager().load(NumassPlugin.class)
|
ctx.getPluginManager().load(NumassPlugin.class)
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,12 +18,10 @@ package inr.numass.scripts.temp
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.grind.GrindShell
|
import hep.dataforge.grind.GrindShell
|
||||||
import hep.dataforge.grind.helpers.PlotHelper
|
import hep.dataforge.grind.helpers.PlotHelper
|
||||||
|
|
||||||
Context ctx = Global.instance()
|
Context ctx = Global.instance()
|
||||||
ctx.getPluginManager().load(FXPlotManager)
|
|
||||||
|
|
||||||
new GrindShell(ctx).eval {
|
new GrindShell(ctx).eval {
|
||||||
(plots as PlotHelper).plotFunction(0,1){Math.sin it}
|
(plots as PlotHelper).plotFunction(0,1){Math.sin it}
|
||||||
|
@ -10,7 +10,6 @@ import hep.dataforge.cache.CachePlugin
|
|||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.data.DataNode
|
import hep.dataforge.data.DataNode
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.grind.GrindShell
|
import hep.dataforge.grind.GrindShell
|
||||||
import hep.dataforge.grind.helpers.PlotHelper
|
import hep.dataforge.grind.helpers.PlotHelper
|
||||||
import hep.dataforge.io.ColumnedDataWriter
|
import hep.dataforge.io.ColumnedDataWriter
|
||||||
@ -30,7 +29,6 @@ import static inr.numass.data.analyzers.NumassAnalyzer.CHANNEL_KEY
|
|||||||
import static inr.numass.data.analyzers.NumassAnalyzer.COUNT_RATE_KEY
|
import static inr.numass.data.analyzers.NumassAnalyzer.COUNT_RATE_KEY
|
||||||
|
|
||||||
Context ctx = Global.instance()
|
Context ctx = Global.instance()
|
||||||
ctx.getPluginManager().load(FXPlotManager)
|
|
||||||
ctx.getPluginManager().load(NumassPlugin)
|
ctx.getPluginManager().load(NumassPlugin)
|
||||||
ctx.getPluginManager().load(CachePlugin)
|
ctx.getPluginManager().load(CachePlugin)
|
||||||
|
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Alexander Nozik.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package hep.dataforge.plotfit;
|
|
||||||
|
|
||||||
import hep.dataforge.actions.OneToOneAction;
|
|
||||||
import hep.dataforge.context.Context;
|
|
||||||
import hep.dataforge.description.NodeDef;
|
|
||||||
import hep.dataforge.description.TypedActionDef;
|
|
||||||
import hep.dataforge.meta.Laminate;
|
|
||||||
import hep.dataforge.meta.Meta;
|
|
||||||
import hep.dataforge.plots.PlotFrame;
|
|
||||||
import hep.dataforge.plots.XYFunctionPlot;
|
|
||||||
import hep.dataforge.plots.data.DataPlot;
|
|
||||||
import hep.dataforge.plots.output.PlotOutputKt;
|
|
||||||
import hep.dataforge.stat.fit.FitResult;
|
|
||||||
import hep.dataforge.stat.fit.FitState;
|
|
||||||
import hep.dataforge.stat.models.XYModel;
|
|
||||||
import hep.dataforge.tables.Adapters;
|
|
||||||
import hep.dataforge.tables.NavigableValuesSource;
|
|
||||||
import hep.dataforge.tables.ValuesAdapter;
|
|
||||||
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author darksnake
|
|
||||||
*/
|
|
||||||
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class)
|
|
||||||
@NodeDef(key = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
|
|
||||||
public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FitResult execute(Context context, String name, FitResult input, Laminate metaData) {
|
|
||||||
|
|
||||||
FitState state = input.optState().orElseThrow(() -> new UnsupportedOperationException("Can't work with fit result not containing state, sorry! Will fix it later"));
|
|
||||||
|
|
||||||
NavigableValuesSource data = input.getData();
|
|
||||||
if (!(state.getModel() instanceof XYModel)) {
|
|
||||||
context.getHistory().getChronicle(name).reportError("The fit model should be instance of XYModel for this action. Action failed!");
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
XYModel model = (XYModel) state.getModel();
|
|
||||||
|
|
||||||
ValuesAdapter adapter;
|
|
||||||
if (metaData.hasMeta("adapter")) {
|
|
||||||
adapter = Adapters.buildAdapter(metaData.getMeta("adapter"));
|
|
||||||
} else if (state.getModel() instanceof XYModel) {
|
|
||||||
adapter = model.getAdapter();
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("No adapter defined for data interpretation");
|
|
||||||
}
|
|
||||||
|
|
||||||
PlotFrame frame = PlotOutputKt.getPlotFrame(context, getName(), name, metaData.getMeta("frame", Meta.empty()));
|
|
||||||
|
|
||||||
XYFunctionPlot fit = new XYFunctionPlot("fit", Meta.empty(), (Double x) -> model.getSpectrum().value(x, input.getParameters()));
|
|
||||||
fit.setDensity(100);
|
|
||||||
fit.setSmoothing(true);
|
|
||||||
// ensuring all data points are calculated explicitly
|
|
||||||
StreamSupport.stream(data.spliterator(), false)
|
|
||||||
.map(dp -> Adapters.getXValue(adapter, dp).getDouble()).sorted().forEach(fit::calculateIn);
|
|
||||||
|
|
||||||
frame.add(fit);
|
|
||||||
|
|
||||||
frame.add(DataPlot.Companion.plot("data", adapter, data));
|
|
||||||
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -129,7 +129,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
|
|||||||
// }
|
// }
|
||||||
Table res = ListTable.infer(dataList);
|
Table res = ListTable.infer(dataList);
|
||||||
|
|
||||||
context.getOutput().get(name, getName()).render(NumassUtils.INSTANCE.wrap(res, meta), Meta.empty());
|
context.getOutput().get(getName(), name).render(NumassUtils.INSTANCE.wrap(res, meta), Meta.empty());
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
|
|||||||
String monitorFileName = meta.getString("monitorFile", "monitor");
|
String monitorFileName = meta.getString("monitorFile", "monitor");
|
||||||
ListTable data = ListTable.infer(monitorPoints);
|
ListTable data = ListTable.infer(monitorPoints);
|
||||||
|
|
||||||
context.getOutput().get(monitorFileName, getName()).render(NumassUtils.INSTANCE.wrap(data, meta), Meta.empty());
|
context.getOutput().get(getName(), monitorFileName).render(NumassUtils.INSTANCE.wrap(data, meta), Meta.empty());
|
||||||
// ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames);
|
// ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class SubstractSpectrumAction extends OneToOneAction<Table, Table> {
|
|||||||
|
|
||||||
Table res = builder.build();
|
Table res = builder.build();
|
||||||
|
|
||||||
context.getOutput().get(name, getName()).render(NumassUtils.INSTANCE.wrap(res, inputMeta), Meta.empty());
|
context.getOutput().get(getName(), name).render(NumassUtils.INSTANCE.wrap(res, inputMeta), Meta.empty());
|
||||||
return res;
|
return res;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException("Could not read reference file", ex);
|
throw new RuntimeException("Could not read reference file", ex);
|
||||||
|
@ -295,9 +295,9 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun displayJFreeChart(title: String, width: Double = 800.0, height: Double = 600.0, meta: Meta = Meta.empty()): JFreeChartFrame {
|
fun displayChart(title: String, context: Context = Global, width: Double = 800.0, height: Double = 600.0, meta: Meta = Meta.empty()): JFreeChartFrame {
|
||||||
val frame = JFreeChartFrame(meta)
|
val frame = JFreeChartFrame(meta)
|
||||||
frame.configureValue("title", title)
|
frame.configureValue("title", title)
|
||||||
FXPlugin().apply { startGlobal() }.display(PlotContainer(frame), width, height)
|
context.pluginManager.load<FXPlugin>().display(PlotContainer(frame), width, height)
|
||||||
return frame
|
return frame
|
||||||
}
|
}
|
||||||
|
@ -207,8 +207,8 @@ fun pointExpression(expression: String, point: Values): Double {
|
|||||||
/**
|
/**
|
||||||
* Add set markers to time chart
|
* Add set markers to time chart
|
||||||
*/
|
*/
|
||||||
fun addSetMarkers(frame: JFreeChartFrame, sets: Collection<NumassSet>) {
|
fun JFreeChartFrame.addSetMarkers(sets: Collection<NumassSet>) {
|
||||||
val jfcPlot = frame.chart.xyPlot
|
val jfcPlot = chart.xyPlot
|
||||||
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
|
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
|
||||||
sets.stream().forEach {
|
sets.stream().forEach {
|
||||||
val start = it.startTime;
|
val start = it.startTime;
|
||||||
|
@ -60,7 +60,7 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
||||||
context.output.get(groupName, name).render(NumassUtils.wrap(output, outputMeta))
|
context.output[name, groupName].render(NumassUtils.wrap(output, outputMeta))
|
||||||
super.afterGroup(context, groupName, outputMeta, output)
|
super.afterGroup(context, groupName, outputMeta, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Alexander Nozik.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package inr.numass.actions
|
||||||
|
|
||||||
|
import hep.dataforge.actions.OneToOneAction
|
||||||
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.description.NodeDef
|
||||||
|
import hep.dataforge.description.TypedActionDef
|
||||||
|
import hep.dataforge.meta.Laminate
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.plots.XYFunctionPlot
|
||||||
|
import hep.dataforge.plots.data.DataPlot
|
||||||
|
import hep.dataforge.plots.output.plot
|
||||||
|
import hep.dataforge.stat.fit.FitResult
|
||||||
|
import hep.dataforge.stat.fit.FitState
|
||||||
|
import hep.dataforge.stat.models.XYModel
|
||||||
|
import hep.dataforge.tables.Adapters
|
||||||
|
import hep.dataforge.tables.ValuesAdapter
|
||||||
|
import java.util.stream.StreamSupport
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author darksnake
|
||||||
|
*/
|
||||||
|
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState::class, outputType = FitState::class)
|
||||||
|
@NodeDef(key = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
|
||||||
|
class PlotFitResultAction : OneToOneAction<FitResult, FitResult>() {
|
||||||
|
|
||||||
|
override fun execute(context: Context, name: String, input: FitResult, metaData: Laminate): FitResult {
|
||||||
|
|
||||||
|
val state = input.optState().orElseThrow { UnsupportedOperationException("Can't work with fit result not containing state, sorry! Will fix it later") }
|
||||||
|
|
||||||
|
val data = input.data
|
||||||
|
if (state.model !is XYModel) {
|
||||||
|
context.history.getChronicle(name).reportError("The fit model should be instance of XYModel for this action. Action failed!")
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
val model = state.model as XYModel
|
||||||
|
|
||||||
|
val adapter: ValuesAdapter
|
||||||
|
if (metaData.hasMeta("adapter")) {
|
||||||
|
adapter = Adapters.buildAdapter(metaData.getMeta("adapter"))
|
||||||
|
} else if (state.model is XYModel) {
|
||||||
|
adapter = model.adapter
|
||||||
|
} else {
|
||||||
|
throw RuntimeException("No adapter defined for data interpretation")
|
||||||
|
}
|
||||||
|
|
||||||
|
// val frame = PlotOutputKt.getPlotFrame(context, getName(), name, metaData.getMeta("frame", Meta.empty()))
|
||||||
|
|
||||||
|
|
||||||
|
val fit = XYFunctionPlot("fit", Meta.empty()) { x: Double -> model.spectrum.value(x, input.parameters) }
|
||||||
|
fit.density = 100
|
||||||
|
fit.smoothing = true
|
||||||
|
// ensuring all data points are calculated explicitly
|
||||||
|
StreamSupport.stream(data.spliterator(), false)
|
||||||
|
.map { dp -> Adapters.getXValue(adapter, dp).double }.sorted().forEach{ fit.calculateIn(it) }
|
||||||
|
|
||||||
|
context.plot(this.name, name, listOf(fit,DataPlot.plot("data", adapter, data)))
|
||||||
|
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -108,7 +108,7 @@ object SummaryAction : ManyToOneAction<FitState, Table>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
||||||
context.output.get(groupName, name).render(NumassUtils.wrap(output, outputMeta))
|
context.output[name, groupName].render(NumassUtils.wrap(output, outputMeta))
|
||||||
super.afterGroup(context, groupName, outputMeta, output)
|
super.afterGroup(context, groupName, outputMeta, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import hep.dataforge.maths.histogram.UnivariateHistogram
|
|||||||
import hep.dataforge.meta.Laminate
|
import hep.dataforge.meta.Laminate
|
||||||
import hep.dataforge.plots.XYFunctionPlot
|
import hep.dataforge.plots.XYFunctionPlot
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
import hep.dataforge.plots.output.getPlotFrame
|
import hep.dataforge.plots.output.plot
|
||||||
import hep.dataforge.tables.Adapters
|
import hep.dataforge.tables.Adapters
|
||||||
import hep.dataforge.tables.Table
|
import hep.dataforge.tables.Table
|
||||||
import hep.dataforge.values.ValueType
|
import hep.dataforge.values.ValueType
|
||||||
@ -60,16 +60,6 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
|
|
||||||
if (inputMeta.getBoolean("plotHist", true)) {
|
if (inputMeta.getBoolean("plotHist", true)) {
|
||||||
|
|
||||||
val histPlot = context.getPlotFrame(name, "histogram") {
|
|
||||||
node("xAxis") {
|
|
||||||
"title" to "delay"
|
|
||||||
"units" to "us"
|
|
||||||
}
|
|
||||||
node("yAxis") {
|
|
||||||
"type" to "log"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val histogramPlot = DataPlot(name, adapter = Adapters.buildXYAdapter("x", "count"))
|
val histogramPlot = DataPlot(name, adapter = Adapters.buildXYAdapter("x", "count"))
|
||||||
.configure {
|
.configure {
|
||||||
"showLine" to true
|
"showLine" to true
|
||||||
@ -80,13 +70,20 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
configure(inputMeta.getMetaOrEmpty("histogram"))
|
configure(inputMeta.getMetaOrEmpty("histogram"))
|
||||||
}.fillData(histogram)
|
}.fillData(histogram)
|
||||||
|
|
||||||
histPlot.add(histogramPlot)
|
|
||||||
|
|
||||||
histPlot.add(
|
val functionPlot = XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) {
|
||||||
XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) {
|
|
||||||
trueCR / 1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * binSize * Math.exp(-it * trueCR / 1e6)
|
trueCR / 1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * binSize * Math.exp(-it * trueCR / 1e6)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
context.plot("histogram", name, listOf(histogramPlot, functionPlot)) {
|
||||||
|
"xAxis" to {
|
||||||
|
"title" to "delay"
|
||||||
|
"units" to "us"
|
||||||
|
}
|
||||||
|
"yAxis" to {
|
||||||
|
"type" to "log"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputMeta.getBoolean("plotStat", true)) {
|
if (inputMeta.getBoolean("plotStat", true)) {
|
||||||
@ -99,7 +96,7 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
configure(inputMeta.getMetaOrEmpty("plot"))
|
configure(inputMeta.getMetaOrEmpty("plot"))
|
||||||
}
|
}
|
||||||
|
|
||||||
context.getPlotFrame(name, "stat-method") {
|
context.plot("stat-method", name, statPlot) {
|
||||||
"xAxis" to {
|
"xAxis" to {
|
||||||
"title" to "delay"
|
"title" to "delay"
|
||||||
"units" to "us"
|
"units" to "us"
|
||||||
@ -107,7 +104,7 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
"yAxis" to {
|
"yAxis" to {
|
||||||
"title" to "Relative count rate"
|
"title" to "Relative count rate"
|
||||||
}
|
}
|
||||||
}.add(statPlot)
|
}
|
||||||
|
|
||||||
(1..100).map { inputMeta.getDouble("t0Step", 1000.0) * it }.map { t ->
|
(1..100).map { inputMeta.getDouble("t0Step", 1000.0) * it }.map { t ->
|
||||||
val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t))
|
val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t))
|
||||||
|
@ -8,7 +8,7 @@ import hep.dataforge.kodex.configure
|
|||||||
import hep.dataforge.maths.histogram.UnivariateHistogram
|
import hep.dataforge.maths.histogram.UnivariateHistogram
|
||||||
import hep.dataforge.meta.Laminate
|
import hep.dataforge.meta.Laminate
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
import hep.dataforge.plots.output.getPlotFrame
|
import hep.dataforge.plots.output.plot
|
||||||
import hep.dataforge.tables.Adapters
|
import hep.dataforge.tables.Adapters
|
||||||
import hep.dataforge.tables.Table
|
import hep.dataforge.tables.Table
|
||||||
import hep.dataforge.values.ValueType
|
import hep.dataforge.values.ValueType
|
||||||
@ -69,16 +69,6 @@ class TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
|
|
||||||
if (inputMeta.getBoolean("plotHist", true)) {
|
if (inputMeta.getBoolean("plotHist", true)) {
|
||||||
|
|
||||||
val histPlot = context.getPlotFrame(name, "histogram"){
|
|
||||||
node("xAxis") {
|
|
||||||
"axisTitle" to "delay"
|
|
||||||
"axisUnits" to "us"
|
|
||||||
}
|
|
||||||
node("yAxis") {
|
|
||||||
"type" to "log"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val histogramPlot = DataPlot(name)
|
val histogramPlot = DataPlot(name)
|
||||||
.configure {
|
.configure {
|
||||||
"showLine" to true
|
"showLine" to true
|
||||||
@ -91,7 +81,16 @@ class TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
}.apply { configure(inputMeta.getMetaOrEmpty("histogram")) }
|
}.apply { configure(inputMeta.getMetaOrEmpty("histogram")) }
|
||||||
.fillData(histogram)
|
.fillData(histogram)
|
||||||
|
|
||||||
histPlot.add(histogramPlot)
|
|
||||||
|
context.plot("histogram", name, histogramPlot) {
|
||||||
|
"xAxis" to {
|
||||||
|
"axisTitle" to "delay"
|
||||||
|
"axisUnits" to "us"
|
||||||
|
}
|
||||||
|
"yAxis" to {
|
||||||
|
"type" to "log"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputMeta.getBoolean("plotStat", true)) {
|
if (inputMeta.getBoolean("plotStat", true)) {
|
||||||
@ -104,7 +103,7 @@ class TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
configure(inputMeta.getMetaOrEmpty("plot"))
|
configure(inputMeta.getMetaOrEmpty("plot"))
|
||||||
}
|
}
|
||||||
|
|
||||||
context.getPlotFrame(name, "stat-method").add(statPlot)
|
context.plot("stat-method", name, statPlot)
|
||||||
|
|
||||||
(1..100).map { 1000 * it }.map { t ->
|
(1..100).map { 1000 * it }.map { t ->
|
||||||
val result = analyzer.analyze(input, buildMeta {
|
val result = analyzer.analyze(input, buildMeta {
|
||||||
|
@ -103,7 +103,7 @@ class TransformDataAction : OneToOneAction<Table, Table>() {
|
|||||||
val res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).format, cr.stream()))
|
val res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).format, cr.stream()))
|
||||||
.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).format, crErr.stream()))
|
.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).format, crErr.stream()))
|
||||||
|
|
||||||
context.output.get(name, name).render(NumassUtils.wrap(res, meta))
|
context.output.get("", name).render(NumassUtils.wrap(res, meta))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,13 @@ package inr.numass.data
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
import hep.dataforge.fx.plots.display
|
||||||
import hep.dataforge.kodex.KMetaBuilder
|
import hep.dataforge.kodex.KMetaBuilder
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.configure
|
import hep.dataforge.kodex.configure
|
||||||
import hep.dataforge.kodex.nullable
|
import hep.dataforge.kodex.nullable
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
||||||
import hep.dataforge.tables.Adapters
|
import hep.dataforge.tables.Adapters
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer
|
import inr.numass.data.analyzers.NumassAnalyzer
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
import inr.numass.data.analyzers.SmartAnalyzer
|
||||||
@ -33,12 +34,12 @@ import inr.numass.data.api.NumassBlock
|
|||||||
|
|
||||||
fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) {
|
fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) {
|
||||||
val meta = buildMeta("meta", metaAction)
|
val meta = buildMeta("meta", metaAction)
|
||||||
val plotManager = context.load(FXPlotManager::class)
|
|
||||||
val binning = meta.getInt("binning", 20)
|
val binning = meta.getInt("binning", 20)
|
||||||
val lo = meta.optNumber("window.lo").nullable?.toInt()
|
val lo = meta.optNumber("window.lo").nullable?.toInt()
|
||||||
val up = meta.optNumber("window.up").nullable?.toInt()
|
val up = meta.optNumber("window.up").nullable?.toInt()
|
||||||
val data = SmartAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up)
|
val data = SmartAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up)
|
||||||
plotManager.display(name = frameName) {
|
context.display(
|
||||||
|
JFreeChartFrame().apply {
|
||||||
val valueAxis = if (meta.getBoolean("normalize", false)) {
|
val valueAxis = if (meta.getBoolean("normalize", false)) {
|
||||||
NumassAnalyzer.COUNT_RATE_KEY
|
NumassAnalyzer.COUNT_RATE_KEY
|
||||||
} else {
|
} else {
|
||||||
@ -60,4 +61,5 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
|||||||
plot.configure(meta)
|
plot.configure(meta)
|
||||||
add(plot)
|
add(plot)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package inr.numass.models.mc
|
package inr.numass.models.mc
|
||||||
|
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
import hep.dataforge.fx.plots.display
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.maths.chain.Chain
|
import hep.dataforge.maths.chain.Chain
|
||||||
import hep.dataforge.plots.XYFunctionPlot
|
import hep.dataforge.plots.XYFunctionPlot
|
||||||
|
import hep.dataforge.plots.jfreechart.chart
|
||||||
import hep.dataforge.stat.PolynomialDistribution
|
import hep.dataforge.stat.PolynomialDistribution
|
||||||
import hep.dataforge.stat.fit.ParamSet
|
import hep.dataforge.stat.fit.ParamSet
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
@ -17,7 +18,6 @@ fun sampleBeta(params: ParamSet): Chain<Double> {
|
|||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
NumassPlugin().startGlobal()
|
NumassPlugin().startGlobal()
|
||||||
val pm = FXPlotManager().apply { startGlobal() }
|
|
||||||
val meta = buildMeta("model") {
|
val meta = buildMeta("model") {
|
||||||
"fast" to true
|
"fast" to true
|
||||||
node("resolution") {
|
node("resolution") {
|
||||||
@ -47,9 +47,10 @@ fun main(args: Array<String>) {
|
|||||||
50 * distribution.density(18600.0 - it)
|
50 * distribution.density(18600.0 - it)
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.getPlotFrame("beta").apply {
|
Global.display(
|
||||||
|
chart {
|
||||||
add(spectrumPlot)
|
add(spectrumPlot)
|
||||||
add(distributionPlot)
|
add(distributionPlot)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import inr.numass.actions.TimeAnalyzerAction
|
import inr.numass.actions.TimeAnalyzerAction
|
||||||
import inr.numass.data.api.SimpleNumassPoint
|
import inr.numass.data.api.SimpleNumassPoint
|
||||||
@ -14,9 +13,6 @@ import kotlinx.coroutines.experimental.runBlocking
|
|||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
FXPlotManager().startGlobal()
|
|
||||||
|
|
||||||
val cr = 10.0
|
val cr = 10.0
|
||||||
val length = 1e12.toLong()
|
val length = 1e12.toLong()
|
||||||
val num = 60;
|
val num = 60;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.description.Descriptors
|
import hep.dataforge.description.Descriptors
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildContext
|
import hep.dataforge.kodex.buildContext
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.replaceColumn
|
import hep.dataforge.kodex.replaceColumn
|
||||||
@ -30,10 +29,11 @@ import inr.numass.data.analyzers.subtractAmplitudeSpectrum
|
|||||||
import inr.numass.data.analyzers.withBinning
|
import inr.numass.data.analyzers.withBinning
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
import inr.numass.data.storage.NumassStorageFactory
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
|
import inr.numass.displayChart
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) {
|
val context = buildContext("NUMASS", NumassPlugin::class.java) {
|
||||||
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
||||||
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
||||||
}
|
}
|
||||||
@ -59,14 +59,12 @@ fun main(args: Array<String>) {
|
|||||||
"window.up" to 1600
|
"window.up" to 1600
|
||||||
}
|
}
|
||||||
|
|
||||||
val plots = context.get(FXPlotManager::class.java)
|
val frame = displayChart("differential").apply {
|
||||||
|
|
||||||
val frame = plots.getPlotFrame("differential").apply {
|
|
||||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||||
this.plots.configureValue("showLine", true)
|
this.plots.configureValue("showLine", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val integralFrame = plots.getPlotFrame("integral")
|
val integralFrame = displayChart("integral")
|
||||||
|
|
||||||
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
||||||
val point1 = all.optPoint(hv).get()
|
val point1 = all.optPoint(hv).get()
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.description.Descriptors
|
import hep.dataforge.description.Descriptors
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildContext
|
import hep.dataforge.kodex.buildContext
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
@ -28,11 +27,12 @@ import inr.numass.data.analyzers.SmartAnalyzer
|
|||||||
import inr.numass.data.analyzers.withBinning
|
import inr.numass.data.analyzers.withBinning
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
import inr.numass.data.storage.NumassStorageFactory
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
|
import inr.numass.displayChart
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) {
|
val context = buildContext("NUMASS", NumassPlugin::class.java) {
|
||||||
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
||||||
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
||||||
}
|
}
|
||||||
@ -63,11 +63,9 @@ fun main(args: Array<String>) {
|
|||||||
val metaForChainInverted = metaForChain.builder.setValue("inverted", true)
|
val metaForChainInverted = metaForChain.builder.setValue("inverted", true)
|
||||||
|
|
||||||
|
|
||||||
val plots = context.get(FXPlotManager::class.java)
|
|
||||||
|
|
||||||
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
||||||
|
|
||||||
val frame = plots.getPlotFrame("integral[$hv]").apply {
|
val frame = displayChart("integral[$hv]").apply {
|
||||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||||
this.plots.configureValue("showLine", true)
|
this.plots.configureValue("showLine", true)
|
||||||
}
|
}
|
||||||
|
@ -17,22 +17,21 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.description.Descriptors
|
import hep.dataforge.description.Descriptors
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildContext
|
import hep.dataforge.kodex.buildContext
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer.Companion.AMPLITUDE_ADAPTER
|
import inr.numass.data.analyzers.NumassAnalyzer.Companion.AMPLITUDE_ADAPTER
|
||||||
|
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
import inr.numass.data.analyzers.SmartAnalyzer
|
||||||
import inr.numass.data.analyzers.withBinning
|
import inr.numass.data.analyzers.withBinning
|
||||||
import inr.numass.data.storage.ProtoNumassPoint
|
import inr.numass.data.storage.ProtoNumassPoint
|
||||||
|
import inr.numass.displayChart
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java)
|
val context = buildContext("NUMASS", NumassPlugin::class.java)
|
||||||
|
|
||||||
val analyzer = SmartAnalyzer()
|
val analyzer = SmartAnalyzer()
|
||||||
|
|
||||||
@ -45,12 +44,9 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
val metaForChainInverted = metaForChain.builder.setValue("inverted", true)
|
val metaForChainInverted = metaForChain.builder.setValue("inverted", true)
|
||||||
|
|
||||||
|
|
||||||
val plots = context.get(FXPlotManager::class.java)
|
|
||||||
|
|
||||||
val point = ProtoNumassPoint.readFile(Paths.get("D:\\Work\\Numass\\data\\2017_05_frames\\Fill_3_events\\set_33\\p36(30s)(HV1=17000).df"))
|
val point = ProtoNumassPoint.readFile(Paths.get("D:\\Work\\Numass\\data\\2017_05_frames\\Fill_3_events\\set_33\\p36(30s)(HV1=17000).df"))
|
||||||
|
|
||||||
val frame = plots.getPlotFrame("integral").apply {
|
val frame = displayChart("integral").apply {
|
||||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||||
this.plots.configureValue("showLine", true)
|
this.plots.configureValue("showLine", true)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package inr.numass.scripts.timeanalysis
|
package inr.numass.scripts.timeanalysis
|
||||||
|
|
||||||
import hep.dataforge.data.DataSet
|
import hep.dataforge.data.DataSet
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildContext
|
import hep.dataforge.kodex.buildContext
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
@ -14,7 +13,7 @@ import inr.numass.data.storage.NumassStorageFactory
|
|||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) {
|
val context = buildContext("NUMASS", NumassPlugin::class.java) {
|
||||||
rootDir = "D:\\Work\\Numass\\sterile2018_04"
|
rootDir = "D:\\Work\\Numass\\sterile2018_04"
|
||||||
dataDir = "D:\\Work\\Numass\\data\\2018_04"
|
dataDir = "D:\\Work\\Numass\\data\\2018_04"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package inr.numass.scripts.timeanalysis
|
package inr.numass.scripts.timeanalysis
|
||||||
|
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.coroutineContext
|
import hep.dataforge.kodex.coroutineContext
|
||||||
import hep.dataforge.kodex.generate
|
import hep.dataforge.kodex.generate
|
||||||
@ -19,7 +18,6 @@ import java.lang.Math.exp
|
|||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
FXPlotManager().startGlobal()
|
|
||||||
NumassPlugin().startGlobal()
|
NumassPlugin().startGlobal()
|
||||||
|
|
||||||
val cr = 30e3
|
val cr = 30e3
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package inr.numass.scripts.tristan
|
package inr.numass.scripts.tristan
|
||||||
|
|
||||||
import hep.dataforge.kodex.toList
|
|
||||||
import inr.numass.data.api.MetaBlock
|
import inr.numass.data.api.MetaBlock
|
||||||
import inr.numass.data.api.NumassBlock
|
import inr.numass.data.api.NumassBlock
|
||||||
import inr.numass.data.api.NumassPoint
|
import inr.numass.data.api.NumassPoint
|
||||||
@ -11,7 +10,7 @@ import java.io.File
|
|||||||
|
|
||||||
|
|
||||||
private fun NumassPoint.getChannels(): Map<Int, NumassBlock> {
|
private fun NumassPoint.getChannels(): Map<Int, NumassBlock> {
|
||||||
return blocks.toList().groupBy { it.channel ?: 0 }.mapValues { entry ->
|
return blocks.toList().groupBy { it.channel }.mapValues { entry ->
|
||||||
if (entry.value.size == 1) {
|
if (entry.value.size == 1) {
|
||||||
entry.value.first()
|
entry.value.first()
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,7 +68,7 @@ object NumassFitScanSummaryTask : AbstractTask<Table>() {
|
|||||||
pars.getValue("trap"))
|
pars.getValue("trap"))
|
||||||
}
|
}
|
||||||
val res = TableTransform.sort(builder.build(), "m", true)
|
val res = TableTransform.sort(builder.build(), "m", true)
|
||||||
context.output.get(nodeName, stage = name).render(NumassUtils.wrap(res, meta))
|
context.output[name, nodeName].render(NumassUtils.wrap(res, meta))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,21 +6,17 @@ import hep.dataforge.data.DataTree
|
|||||||
import hep.dataforge.data.DataUtils
|
import hep.dataforge.data.DataUtils
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.description.ValueDefs
|
import hep.dataforge.description.ValueDefs
|
||||||
import hep.dataforge.fx.plots.FXPlotManager
|
|
||||||
import hep.dataforge.fx.plots.plus
|
|
||||||
import hep.dataforge.io.output.Output.Companion.BINARY_MODE
|
|
||||||
import hep.dataforge.io.output.stream
|
import hep.dataforge.io.output.stream
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.configure
|
|
||||||
import hep.dataforge.kodex.task
|
import hep.dataforge.kodex.task
|
||||||
import hep.dataforge.kodex.useMeta
|
import hep.dataforge.kodex.useMeta
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.MetaUtils
|
import hep.dataforge.meta.MetaUtils
|
||||||
import hep.dataforge.plots.PlotFrame
|
|
||||||
import hep.dataforge.plots.PlotUtils
|
|
||||||
import hep.dataforge.plots.XYFunctionPlot
|
import hep.dataforge.plots.XYFunctionPlot
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
||||||
|
import hep.dataforge.plots.output.PlotOutput
|
||||||
|
import hep.dataforge.plots.output.plot
|
||||||
import hep.dataforge.stat.fit.FitHelper
|
import hep.dataforge.stat.fit.FitHelper
|
||||||
import hep.dataforge.stat.fit.FitResult
|
import hep.dataforge.stat.fit.FitResult
|
||||||
import hep.dataforge.stat.models.XYModel
|
import hep.dataforge.stat.models.XYModel
|
||||||
@ -62,7 +58,7 @@ val analyzeTask = task("analyze") {
|
|||||||
pipe<NumassSet, Table> { set ->
|
pipe<NumassSet, Table> { set ->
|
||||||
SmartAnalyzer().analyzeSet(set, meta).also { res ->
|
SmartAnalyzer().analyzeSet(set, meta).also { res ->
|
||||||
val outputMeta = meta.builder.putNode("data", set.meta)
|
val outputMeta = meta.builder.putNode("data", set.meta)
|
||||||
context.output.get(name, stage = "numass.analyze").render(NumassUtils.wrap(res, outputMeta))
|
context.output["numass.analyze", name].render(NumassUtils.wrap(res, outputMeta))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,27 +89,17 @@ val monitorTableTask = task("monitor") {
|
|||||||
).build()
|
).build()
|
||||||
|
|
||||||
if (meta.getBoolean("showPlot", true)) {
|
if (meta.getBoolean("showPlot", true)) {
|
||||||
context.provide("plots", FXPlotManager::class.java).ifPresent {
|
val plot = DataPlot.plot(name, Adapters.buildXYAdapter("timestamp", "cr", "crErr"), res)
|
||||||
it.display(stage = "monitor") {
|
context.plot("numass.monitor", name, plot) {
|
||||||
configure {
|
|
||||||
"xAxis.title" to "time"
|
"xAxis.title" to "time"
|
||||||
"xAxis.type" to "time"
|
"xAxis.type" to "time"
|
||||||
"yAxis.title" to "Count rate"
|
"yAxis.title" to "Count rate"
|
||||||
"yAxis.units" to "Hz"
|
"yAxis.units" to "Hz"
|
||||||
}
|
}
|
||||||
plots + DataPlot.plot(name, Adapters.buildXYAdapter("timestamp", "cr", "crErr"), res)
|
((context.output["numass.monitor", name] as? PlotOutput)?.frame as? JFreeChartFrame)?.addSetMarkers(data.values)
|
||||||
}.also { frame ->
|
|
||||||
if (frame is JFreeChartFrame) {
|
|
||||||
//add set markers
|
|
||||||
addSetMarkers(frame, data.values)
|
|
||||||
}
|
|
||||||
context.output.get(name, "numass.monitor", BINARY_MODE).render(PlotFrame.Wrapper().wrap(frame))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.output.get(name, stage = "numass.monitor").render(NumassUtils.wrap(res, meta))
|
context.output.get("numass.monitor", name).render(NumassUtils.wrap(res, meta))
|
||||||
|
|
||||||
return@join res;
|
return@join res;
|
||||||
}
|
}
|
||||||
@ -172,7 +158,7 @@ val subtractEmptyTask = task("dif") {
|
|||||||
|
|
||||||
res.goal.onComplete { r, _ ->
|
res.goal.onComplete { r, _ ->
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
context.output.get(input.name + "_subtract", stage = "numass.merge").render(NumassUtils.wrap(r, resMeta))
|
context.output.get("numass.merge", input.name + "_subtract").render(NumassUtils.wrap(r, resMeta))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +209,7 @@ val fitTask = task("fit") {
|
|||||||
configure(meta.getMeta("fit"))
|
configure(meta.getMeta("fit"))
|
||||||
}
|
}
|
||||||
pipe<Table, FitResult> { data ->
|
pipe<Table, FitResult> { data ->
|
||||||
context.output[name, "numass.fit"].stream.use { out ->
|
context.output["numass.fit", name].stream.use { out ->
|
||||||
val writer = PrintWriter(out)
|
val writer = PrintWriter(out)
|
||||||
writer.printf("%n*** META ***%n")
|
writer.printf("%n*** META ***%n")
|
||||||
writer.println(meta.toString())
|
writer.println(meta.toString())
|
||||||
@ -249,30 +235,25 @@ val plotFitTask = task("plotFit") {
|
|||||||
dependsOn(fitTask, meta)
|
dependsOn(fitTask, meta)
|
||||||
configure(meta.getMetaOrEmpty("plotFit"))
|
configure(meta.getMetaOrEmpty("plotFit"))
|
||||||
}
|
}
|
||||||
pipe<FitResult, PlotFrame> { input ->
|
pipe<FitResult, FitResult> { input ->
|
||||||
val fitModel = input.optModel(context).orElseThrow { IllegalStateException("Can't load model") } as XYModel
|
val fitModel = input.optModel(context).orElseThrow { IllegalStateException("Can't load model") } as XYModel
|
||||||
|
|
||||||
val data = input.data
|
val data = input.data
|
||||||
|
|
||||||
val adapter: ValuesAdapter = fitModel.adapter
|
val adapter: ValuesAdapter = fitModel.adapter
|
||||||
|
|
||||||
val function = { x: Double -> fitModel.spectrum.value(x, input.parameters) }
|
val function = { x: Double -> fitModel.spectrum.value(x, input.parameters) }
|
||||||
|
|
||||||
val frame = PlotUtils.getPlotManager(context)
|
|
||||||
.getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty()))
|
|
||||||
|
|
||||||
val fit = XYFunctionPlot("fit", function = function).apply {
|
val fit = XYFunctionPlot("fit", function = function).apply {
|
||||||
density = 100
|
density = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.add(fit)
|
|
||||||
|
|
||||||
// ensuring all data points are calculated explicitly
|
// ensuring all data points are calculated explicitly
|
||||||
StreamSupport.stream<Values>(data.spliterator(), false)
|
StreamSupport.stream<Values>(data.spliterator(), false)
|
||||||
.map { dp -> Adapters.getXValue(adapter, dp).double }.sorted().forEach { fit.calculateIn(it) }
|
.map { dp -> Adapters.getXValue(adapter, dp).double }.sorted().forEach { fit.calculateIn(it) }
|
||||||
|
|
||||||
frame.add(DataPlot.plot("data", adapter, data))
|
val dataPlot = DataPlot.plot("data", adapter, data)
|
||||||
|
|
||||||
return@pipe frame;
|
context.plot("numass.plotFit", name, listOf(fit, dataPlot))
|
||||||
|
|
||||||
|
return@pipe input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,6 @@ public class PlotScatter {
|
|||||||
+ "'ionW' = 11.33 ± 0.43\n"
|
+ "'ionW' = 11.33 ± 0.43\n"
|
||||||
+ "'exIonRatio' = 4.83 ± 0.36"
|
+ "'exIonRatio' = 4.83 ± 0.36"
|
||||||
);
|
);
|
||||||
LossCalculator.plotScatter(NumassPluginKt.displayJFreeChart("Loss function"), pars);
|
LossCalculator.plotScatter(NumassPluginKt.displayChart("Loss function"), pars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class TestNeLossParametrisation {
|
|||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
PlotFrame frame = NumassPluginKt.displayJFreeChart("Loss parametrisation test");
|
PlotFrame frame = NumassPluginKt.displayChart("Loss parametrisation test");
|
||||||
//JFreeChartFrame.drawFrame("Loss parametrisation test", null);
|
//JFreeChartFrame.drawFrame("Loss parametrisation test", null);
|
||||||
UnivariateFunction oldFunction = LossCalculator.getSingleScatterFunction();
|
UnivariateFunction oldFunction = LossCalculator.getSingleScatterFunction();
|
||||||
UnivariateFunction newFunction = getSingleScatterFunction(12.86, 16.78, 1.65, 12.38, 4.79);
|
UnivariateFunction newFunction = getSingleScatterFunction(12.86, 16.78, 1.65, 12.38, 4.79);
|
||||||
|
@ -28,7 +28,7 @@ import inr.numass.NumassPluginKt;
|
|||||||
public class TransmissionInterpolatorTest {
|
public class TransmissionInterpolatorTest {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JFreeChartFrame frame = NumassPluginKt.displayJFreeChart("TransmissionInterpolatorTest");
|
JFreeChartFrame frame = NumassPluginKt.displayChart("TransmissionInterpolatorTest");
|
||||||
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
|
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
|
||||||
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(Global.INSTANCE,
|
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(Global.INSTANCE,
|
||||||
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);
|
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);
|
||||||
|
Loading…
Reference in New Issue
Block a user