From 01d1fe5528ddf68a21a733f10a026175f15b97ec Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 21 May 2018 21:21:12 +0300 Subject: [PATCH] Removed [PlotManager] --- .../inr/numass/control/dante/DanteTest.kt | 49 +++++------ .../inr/numass/control/NumassControlUtils.kt | 2 +- .../numass/scripts/models/TristanModel.groovy | 2 - .../numass/scripts/temp/JoinSpectra.groovy | 2 - .../inr/numass/scripts/temp/TestFXExit.groovy | 2 - .../numass/scripts/underflow/Underflow.groovy | 2 - .../plotfit/PlotFitResultAction.java | 81 ------------------- .../numass/actions/MonitorCorrectAction.java | 4 +- .../actions/SubstractSpectrumAction.java | 4 +- .../main/kotlin/inr/numass/NumassPlugin.kt | 4 +- .../src/main/kotlin/inr/numass/NumassUtils.kt | 4 +- .../inr/numass/actions/MergeDataAction.kt | 2 +- .../inr/numass/actions/PlotFitResultAction.kt | 76 +++++++++++++++++ .../inr/numass/actions/SummaryAction.kt | 2 +- .../inr/numass/actions/TimeAnalyzerAction.kt | 35 ++++---- .../inr/numass/actions/TimeSpectrumAction.kt | 25 +++--- .../inr/numass/actions/TransformDataAction.kt | 4 +- .../kotlin/inr/numass/data/Visualization.kt | 48 +++++------ .../inr/numass/models/mc/BetaSampler.kt | 17 ++-- .../main/kotlin/inr/numass/scripts/Bunches.kt | 4 - .../numass/scripts/DifferentialSpectrum.kt | 10 +-- .../inr/numass/scripts/InversedChain.kt | 8 +- .../inr/numass/scripts/InversedChainProto.kt | 10 +-- .../scripts/timeanalysis/AnalyzePoint.kt | 3 +- .../scripts/timeanalysis/TestAnalyzer.kt | 2 - .../inr/numass/scripts/tristan/ViewPoint.kt | 3 +- .../numass/tasks/NumassFitScanSummaryTask.kt | 2 +- .../kotlin/inr/numass/tasks/NumassTasks.kt | 55 +++++-------- .../java/inr/numass/models/PlotScatter.java | 2 +- .../models/TestNeLossParametrisation.java | 2 +- .../models/TransmissionInterpolatorTest.java | 2 +- 31 files changed, 211 insertions(+), 257 deletions(-) delete mode 100644 numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java create mode 100644 numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt diff --git a/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteTest.kt b/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteTest.kt index bb5592ca..80e00cbf 100644 --- a/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteTest.kt +++ b/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteTest.kt @@ -18,12 +18,13 @@ package inr.numass.control.dante import hep.dataforge.context.Context 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.buildMeta import hep.dataforge.kodex.configure import hep.dataforge.kodex.nullable import hep.dataforge.plots.data.DataPlot +import hep.dataforge.plots.jfreechart.chart import hep.dataforge.tables.Adapters import inr.numass.data.analyzers.NumassAnalyzer import inr.numass.data.analyzers.SimpleAnalyzer @@ -74,31 +75,33 @@ fun main(args: Array) { fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) { val meta = buildMeta("meta", metaAction) - val plotManager = context.load(FXPlotManager::class) val binning = meta.getInt("binning", 20) val lo = meta.optNumber("window.lo").nullable?.toInt() val up = meta.optNumber("window.up").nullable?.toInt() val data = SimpleAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up) - plotManager.display(name = frameName) { - val valueAxis = if (meta.getBoolean("normalize", false)) { - NumassAnalyzer.COUNT_RATE_KEY - } else { - NumassAnalyzer.COUNT_KEY - } - plots.configure { - "connectionType" to "step" - "thickness" to 2 - "showLine" to true - "showSymbol" to false - "showErrors" to false - }.setType(DataPlot::class) + context.display( + chart { + val valueAxis = if (meta.getBoolean("normalize", false)) { + NumassAnalyzer.COUNT_RATE_KEY + } else { + NumassAnalyzer.COUNT_KEY + } + plots.configure { + "connectionType" to "step" + "thickness" to 2 + "showLine" to true + "showSymbol" to false + "showErrors" to false + }.setType(DataPlot::class) + + val plot = DataPlot.plot( + plotName, + Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis), + data + ) + plot.configure(meta) + add(plot) + } + ) - val plot = DataPlot.plot( - plotName, - Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis), - data - ) - plot.configure(meta) - add(plot) - } } \ No newline at end of file diff --git a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt index fcef9df5..080dba53 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt @@ -57,7 +57,7 @@ fun connectStorage(device: Device, config: Meta) { } fun readResourceMeta(path: String): Meta { - val resource = Global.output.optResource(path).nullable + val resource = Global.optResource(path).nullable if (resource != null) { return XMLMetaReader().read(resource.stream) } else { diff --git a/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy b/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy index af21810a..c66f1ea9 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/models/TristanModel.groovy @@ -2,7 +2,6 @@ package inr.numass.scripts.models import hep.dataforge.context.Context import hep.dataforge.context.Global -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.grind.GrindShell import hep.dataforge.grind.helpers.PlotHelper import hep.dataforge.meta.Meta @@ -24,7 +23,6 @@ import inr.numass.utils.DataModelUtils Context ctx = Global.instance() -ctx.getPluginManager().load(FXPlotManager) ctx.getPluginManager().load(NumassPlugin) new GrindShell(ctx).eval { diff --git a/numass-main/src/main/groovy/inr/numass/scripts/temp/JoinSpectra.groovy b/numass-main/src/main/groovy/inr/numass/scripts/temp/JoinSpectra.groovy index 503514f5..579173d6 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/temp/JoinSpectra.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/temp/JoinSpectra.groovy @@ -3,7 +3,6 @@ package inr.numass.scripts.temp import hep.dataforge.context.Context import hep.dataforge.context.Global import hep.dataforge.description.Descriptors -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.grind.Grind import hep.dataforge.grind.GrindShell import hep.dataforge.grind.helpers.PlotHelper @@ -21,7 +20,6 @@ import inr.numass.data.storage.NumassStorage import inr.numass.data.storage.NumassStorageFactory Context ctx = Global.instance() -ctx.getPluginManager().load(FXPlotManager) ctx.getPluginManager().load(NumassPlugin.class) diff --git a/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy b/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy index 607c0237..6ef98c8d 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy @@ -18,12 +18,10 @@ package inr.numass.scripts.temp import hep.dataforge.context.Context import hep.dataforge.context.Global -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.grind.GrindShell import hep.dataforge.grind.helpers.PlotHelper Context ctx = Global.instance() -ctx.getPluginManager().load(FXPlotManager) new GrindShell(ctx).eval { (plots as PlotHelper).plotFunction(0,1){Math.sin it} diff --git a/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy b/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy index 8a474c9a..2c76b02a 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/underflow/Underflow.groovy @@ -10,7 +10,6 @@ import hep.dataforge.cache.CachePlugin import hep.dataforge.context.Context import hep.dataforge.context.Global import hep.dataforge.data.DataNode -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.grind.GrindShell import hep.dataforge.grind.helpers.PlotHelper 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 Context ctx = Global.instance() -ctx.getPluginManager().load(FXPlotManager) ctx.getPluginManager().load(NumassPlugin) ctx.getPluginManager().load(CachePlugin) diff --git a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java deleted file mode 100644 index 581a4fc2..00000000 --- a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java +++ /dev/null @@ -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 { - - @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; - } - -} diff --git a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java index 2bb75fef..32378124 100644 --- a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java @@ -129,7 +129,7 @@ public class MonitorCorrectAction extends OneToOneAction { // } 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; } @@ -194,7 +194,7 @@ public class MonitorCorrectAction extends OneToOneAction { String monitorFileName = meta.getString("monitorFile", "monitor"); 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); } } diff --git a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java index 380858df..8ee8fac5 100644 --- a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java @@ -30,7 +30,7 @@ public class SubstractSpectrumAction extends OneToOneAction { @Override protected Table execute(Context context, String name, Table input, Laminate inputMeta) { try { - String referencePath = inputMeta. getString("file", "empty.dat"); + String referencePath = inputMeta.getString("file", "empty.dat"); Path referenceFile = context.getRootDir().resolve(referencePath); Table referenceTable = new ColumnedDataReader(referenceFile).toTable(); ListTable.Builder builder = new ListTable.Builder(input.getFormat()); @@ -49,7 +49,7 @@ public class SubstractSpectrumAction extends OneToOneAction { 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; } catch (IOException ex) { throw new RuntimeException("Could not read reference file", ex); diff --git a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt index 837939b0..8bca4b37 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt @@ -295,9 +295,9 @@ class NumassPlugin : BasicPlugin() { * @return */ @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) frame.configureValue("title", title) - FXPlugin().apply { startGlobal() }.display(PlotContainer(frame), width, height) + context.pluginManager.load().display(PlotContainer(frame), width, height) return frame } diff --git a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt index ae44231d..b744f07a 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt @@ -207,8 +207,8 @@ fun pointExpression(expression: String, point: Values): Double { /** * Add set markers to time chart */ -fun addSetMarkers(frame: JFreeChartFrame, sets: Collection) { - val jfcPlot = frame.chart.xyPlot +fun JFreeChartFrame.addSetMarkers(sets: Collection) { + val jfcPlot = chart.xyPlot val paint = Color(0.0f, 0.0f, 1.0f, 0.1f) sets.stream().forEach { val start = it.startTime; diff --git a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt index 71740d86..71090f8d 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt @@ -60,7 +60,7 @@ class MergeDataAction : ManyToOneAction() { } 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) } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt new file mode 100644 index 00000000..fc7c0897 --- /dev/null +++ b/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt @@ -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() { + + 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 + } + +} diff --git a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt index 2e6c26c2..a23800e9 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt @@ -108,7 +108,7 @@ object SummaryAction : ManyToOneAction() { } 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) } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt index 023f21c4..c6a7c28b 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -8,7 +8,7 @@ import hep.dataforge.maths.histogram.UnivariateHistogram import hep.dataforge.meta.Laminate import hep.dataforge.plots.XYFunctionPlot 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.Table import hep.dataforge.values.ValueType @@ -60,16 +60,6 @@ class TimeAnalyzerAction : OneToOneAction() { 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")) .configure { "showLine" to true @@ -80,13 +70,20 @@ class TimeAnalyzerAction : OneToOneAction() { configure(inputMeta.getMetaOrEmpty("histogram")) }.fillData(histogram) - histPlot.add(histogramPlot) - histPlot.add( - XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) { - trueCR / 1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * binSize * Math.exp(-it * trueCR / 1e6) - } - ) + val functionPlot = XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) { + 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)) { @@ -99,7 +96,7 @@ class TimeAnalyzerAction : OneToOneAction() { configure(inputMeta.getMetaOrEmpty("plot")) } - context.getPlotFrame(name, "stat-method") { + context.plot("stat-method", name, statPlot) { "xAxis" to { "title" to "delay" "units" to "us" @@ -107,7 +104,7 @@ class TimeAnalyzerAction : OneToOneAction() { "yAxis" to { "title" to "Relative count rate" } - }.add(statPlot) + } (1..100).map { inputMeta.getDouble("t0Step", 1000.0) * it }.map { t -> val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t)) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt index 246b17b5..f2fc0d05 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt @@ -8,7 +8,7 @@ import hep.dataforge.kodex.configure import hep.dataforge.maths.histogram.UnivariateHistogram import hep.dataforge.meta.Laminate 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.Table import hep.dataforge.values.ValueType @@ -69,16 +69,6 @@ class TimeSpectrumAction : OneToOneAction() { 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) .configure { "showLine" to true @@ -91,7 +81,16 @@ class TimeSpectrumAction : OneToOneAction() { }.apply { configure(inputMeta.getMetaOrEmpty("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)) { @@ -104,7 +103,7 @@ class TimeSpectrumAction : OneToOneAction() { configure(inputMeta.getMetaOrEmpty("plot")) } - context.getPlotFrame(name, "stat-method").add(statPlot) + context.plot("stat-method", name, statPlot) (1..100).map { 1000 * it }.map { t -> val result = analyzer.analyze(input, buildMeta { diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt index e8c1d679..69be71db 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt @@ -103,7 +103,7 @@ class TransformDataAction : OneToOneAction() { 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())) - context.output.get(name, name).render(NumassUtils.wrap(res, meta)) + context.output.get("", name).render(NumassUtils.wrap(res, meta)) return res } @@ -116,7 +116,7 @@ class TransformDataAction : OneToOneAction() { val expr = corrMeta.getString("value") val errExpr = corrMeta.getString("err", "") return object : Correction { - override val name=corrMeta.getString("name", corrMeta.name) + override val name = corrMeta.getString("name", corrMeta.name) override fun corr(point: Values): Double { return pointExpression(expr, point) diff --git a/numass-main/src/main/kotlin/inr/numass/data/Visualization.kt b/numass-main/src/main/kotlin/inr/numass/data/Visualization.kt index f6d356d3..7ff62124 100644 --- a/numass-main/src/main/kotlin/inr/numass/data/Visualization.kt +++ b/numass-main/src/main/kotlin/inr/numass/data/Visualization.kt @@ -18,12 +18,13 @@ package inr.numass.data import hep.dataforge.context.Context 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.buildMeta import hep.dataforge.kodex.configure import hep.dataforge.kodex.nullable import hep.dataforge.plots.data.DataPlot +import hep.dataforge.plots.jfreechart.JFreeChartFrame import hep.dataforge.tables.Adapters import inr.numass.data.analyzers.NumassAnalyzer import inr.numass.data.analyzers.SmartAnalyzer @@ -33,31 +34,32 @@ import inr.numass.data.api.NumassBlock fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName: String = "", context: Context = Global, metaAction: KMetaBuilder.() -> Unit = {}) { val meta = buildMeta("meta", metaAction) - val plotManager = context.load(FXPlotManager::class) val binning = meta.getInt("binning", 20) val lo = meta.optNumber("window.lo").nullable?.toInt() val up = meta.optNumber("window.up").nullable?.toInt() val data = SmartAnalyzer().getAmplitudeSpectrum(this, meta.getMetaOrEmpty("spectrum")).withBinning(binning, lo, up) - plotManager.display(name = frameName) { - val valueAxis = if (meta.getBoolean("normalize", false)) { - NumassAnalyzer.COUNT_RATE_KEY - } else { - NumassAnalyzer.COUNT_KEY - } - plots.configure { - "connectionType" to "step" - "thickness" to 2 - "showLine" to true - "showSymbol" to false - "showErrors" to false - }.setType(DataPlot::class) + context.display( + JFreeChartFrame().apply { + val valueAxis = if (meta.getBoolean("normalize", false)) { + NumassAnalyzer.COUNT_RATE_KEY + } else { + NumassAnalyzer.COUNT_KEY + } + plots.configure { + "connectionType" to "step" + "thickness" to 2 + "showLine" to true + "showSymbol" to false + "showErrors" to false + }.setType(DataPlot::class) - val plot = DataPlot.plot( - plotName, - Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis), - data - ) - plot.configure(meta) - add(plot) - } + val plot = DataPlot.plot( + plotName, + Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis), + data + ) + plot.configure(meta) + add(plot) + } + ) } \ No newline at end of file diff --git a/numass-main/src/main/kotlin/inr/numass/models/mc/BetaSampler.kt b/numass-main/src/main/kotlin/inr/numass/models/mc/BetaSampler.kt index 466a48af..5c7c8bd4 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/mc/BetaSampler.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/mc/BetaSampler.kt @@ -1,10 +1,11 @@ package inr.numass.models.mc 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.maths.chain.Chain import hep.dataforge.plots.XYFunctionPlot +import hep.dataforge.plots.jfreechart.chart import hep.dataforge.stat.PolynomialDistribution import hep.dataforge.stat.fit.ParamSet import inr.numass.NumassPlugin @@ -17,7 +18,6 @@ fun sampleBeta(params: ParamSet): Chain { fun main(args: Array) { NumassPlugin().startGlobal() - val pm = FXPlotManager().apply { startGlobal() } val meta = buildMeta("model") { "fast" to true node("resolution") { @@ -44,12 +44,13 @@ fun main(args: Array) { val distribution = PolynomialDistribution(0.0, 5000.0, 3.0); val distributionPlot = XYFunctionPlot.plot("distribution", 14000.0, 18500.0, 500) { - 50*distribution.density(18600.0 - it) - } - - pm.getPlotFrame("beta").apply { - add(spectrumPlot) - add(distributionPlot) + 50 * distribution.density(18600.0 - it) } + Global.display( + chart { + add(spectrumPlot) + add(distributionPlot) + } + ) } \ No newline at end of file diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/Bunches.kt b/numass-main/src/main/kotlin/inr/numass/scripts/Bunches.kt index 2731159e..c8bcb414 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/Bunches.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/Bunches.kt @@ -1,6 +1,5 @@ package inr.numass.scripts -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildMeta import inr.numass.actions.TimeAnalyzerAction import inr.numass.data.api.SimpleNumassPoint @@ -14,9 +13,6 @@ import kotlinx.coroutines.experimental.runBlocking import java.time.Instant fun main(args: Array) { - - FXPlotManager().startGlobal() - val cr = 10.0 val length = 1e12.toLong() val num = 60; diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/DifferentialSpectrum.kt b/numass-main/src/main/kotlin/inr/numass/scripts/DifferentialSpectrum.kt index e7296e24..24df6019 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/DifferentialSpectrum.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/DifferentialSpectrum.kt @@ -17,7 +17,6 @@ package inr.numass.scripts import hep.dataforge.description.Descriptors -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildContext import hep.dataforge.kodex.buildMeta 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.api.NumassSet import inr.numass.data.storage.NumassStorageFactory +import inr.numass.displayChart fun main(args: Array) { - val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) { + val context = buildContext("NUMASS", NumassPlugin::class.java) { rootDir = "D:\\Work\\Numass\\sterile\\2017_11" dataDir = "D:\\Work\\Numass\\data\\2017_11" } @@ -59,14 +59,12 @@ fun main(args: Array) { "window.up" to 1600 } - val plots = context.get(FXPlotManager::class.java) - - val frame = plots.getPlotFrame("differential").apply { + val frame = displayChart("differential").apply { this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class) 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)) { val point1 = all.optPoint(hv).get() diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/InversedChain.kt b/numass-main/src/main/kotlin/inr/numass/scripts/InversedChain.kt index 3767e055..9096347a 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/InversedChain.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/InversedChain.kt @@ -17,7 +17,6 @@ package inr.numass.scripts import hep.dataforge.description.Descriptors -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildContext import hep.dataforge.kodex.buildMeta 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.api.NumassSet import inr.numass.data.storage.NumassStorageFactory +import inr.numass.displayChart fun main(args: Array) { - val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) { + val context = buildContext("NUMASS", NumassPlugin::class.java) { rootDir = "D:\\Work\\Numass\\sterile\\2017_11" dataDir = "D:\\Work\\Numass\\data\\2017_11" } @@ -63,11 +63,9 @@ fun main(args: Array) { 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)) { - val frame = plots.getPlotFrame("integral[$hv]").apply { + val frame = displayChart("integral[$hv]").apply { this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class) this.plots.configureValue("showLine", true) } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/InversedChainProto.kt b/numass-main/src/main/kotlin/inr/numass/scripts/InversedChainProto.kt index dbaa3f19..a99f6b97 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/InversedChainProto.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/InversedChainProto.kt @@ -17,22 +17,21 @@ package inr.numass.scripts import hep.dataforge.description.Descriptors -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildContext import hep.dataforge.kodex.buildMeta import hep.dataforge.plots.data.DataPlot import inr.numass.NumassPlugin import inr.numass.data.analyzers.NumassAnalyzer.Companion.AMPLITUDE_ADAPTER - import inr.numass.data.analyzers.SmartAnalyzer import inr.numass.data.analyzers.withBinning import inr.numass.data.storage.ProtoNumassPoint +import inr.numass.displayChart import java.nio.file.Paths fun main(args: Array) { - val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) + val context = buildContext("NUMASS", NumassPlugin::class.java) val analyzer = SmartAnalyzer() @@ -45,12 +44,9 @@ fun main(args: Array) { 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 frame = plots.getPlotFrame("integral").apply { + val frame = displayChart("integral").apply { this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class) this.plots.configureValue("showLine", true) } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt index a1070175..cde28184 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt @@ -1,7 +1,6 @@ package inr.numass.scripts.timeanalysis import hep.dataforge.data.DataSet -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildContext import hep.dataforge.kodex.buildMeta import inr.numass.NumassPlugin @@ -14,7 +13,7 @@ import inr.numass.data.storage.NumassStorageFactory fun main(args: Array) { - val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) { + val context = buildContext("NUMASS", NumassPlugin::class.java) { rootDir = "D:\\Work\\Numass\\sterile2018_04" dataDir = "D:\\Work\\Numass\\data\\2018_04" } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/TestAnalyzer.kt b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/TestAnalyzer.kt index 3ccf3717..b0c1bf8f 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/TestAnalyzer.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/TestAnalyzer.kt @@ -1,7 +1,6 @@ package inr.numass.scripts.timeanalysis import hep.dataforge.context.Global -import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.kodex.buildMeta import hep.dataforge.kodex.coroutineContext import hep.dataforge.kodex.generate @@ -19,7 +18,6 @@ import java.lang.Math.exp import java.time.Instant fun main(args: Array) { - FXPlotManager().startGlobal() NumassPlugin().startGlobal() val cr = 30e3 diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ViewPoint.kt b/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ViewPoint.kt index 11f76f81..24ac0255 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ViewPoint.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ViewPoint.kt @@ -1,6 +1,5 @@ package inr.numass.scripts.tristan -import hep.dataforge.kodex.toList import inr.numass.data.api.MetaBlock import inr.numass.data.api.NumassBlock import inr.numass.data.api.NumassPoint @@ -11,7 +10,7 @@ import java.io.File private fun NumassPoint.getChannels(): Map { - return blocks.toList().groupBy { it.channel ?: 0 }.mapValues { entry -> + return blocks.toList().groupBy { it.channel }.mapValues { entry -> if (entry.value.size == 1) { entry.value.first() } else { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt index 98e8d881..66fcfb40 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt @@ -68,7 +68,7 @@ object NumassFitScanSummaryTask : AbstractTask() { pars.getValue("trap")) } 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 } diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index e1a2dbd5..384f1ebd 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -6,21 +6,17 @@ import hep.dataforge.data.DataTree import hep.dataforge.data.DataUtils import hep.dataforge.description.ValueDef 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.kodex.buildMeta -import hep.dataforge.kodex.configure import hep.dataforge.kodex.task import hep.dataforge.kodex.useMeta import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaUtils -import hep.dataforge.plots.PlotFrame -import hep.dataforge.plots.PlotUtils import hep.dataforge.plots.XYFunctionPlot import hep.dataforge.plots.data.DataPlot 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.FitResult import hep.dataforge.stat.models.XYModel @@ -62,7 +58,7 @@ val analyzeTask = task("analyze") { pipe { set -> SmartAnalyzer().analyzeSet(set, meta).also { res -> 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() if (meta.getBoolean("showPlot", true)) { - context.provide("plots", FXPlotManager::class.java).ifPresent { - it.display(stage = "monitor") { - configure { - "xAxis.title" to "time" - "xAxis.type" to "time" - "yAxis.title" to "Count rate" - "yAxis.units" to "Hz" - } - plots + DataPlot.plot(name, Adapters.buildXYAdapter("timestamp", "cr", "crErr"), res) - }.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)) - - } + val plot = DataPlot.plot(name, Adapters.buildXYAdapter("timestamp", "cr", "crErr"), res) + context.plot("numass.monitor", name, plot) { + "xAxis.title" to "time" + "xAxis.type" to "time" + "yAxis.title" to "Count rate" + "yAxis.units" to "Hz" } + ((context.output["numass.monitor", name] as? PlotOutput)?.frame as? JFreeChartFrame)?.addSetMarkers(data.values) } - 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; } @@ -172,7 +158,7 @@ val subtractEmptyTask = task("dif") { res.goal.onComplete { r, _ -> 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")) } pipe { data -> - context.output[name, "numass.fit"].stream.use { out -> + context.output["numass.fit", name].stream.use { out -> val writer = PrintWriter(out) writer.printf("%n*** META ***%n") writer.println(meta.toString()) @@ -249,30 +235,25 @@ val plotFitTask = task("plotFit") { dependsOn(fitTask, meta) configure(meta.getMetaOrEmpty("plotFit")) } - pipe { input -> + pipe { input -> val fitModel = input.optModel(context).orElseThrow { IllegalStateException("Can't load model") } as XYModel val data = input.data - val adapter: ValuesAdapter = fitModel.adapter - 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 { density = 100 } - frame.add(fit) - // ensuring all data points are calculated explicitly StreamSupport.stream(data.spliterator(), false) .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; } } diff --git a/numass-main/src/test/java/inr/numass/models/PlotScatter.java b/numass-main/src/test/java/inr/numass/models/PlotScatter.java index 131c1b7b..6d42421d 100644 --- a/numass-main/src/test/java/inr/numass/models/PlotScatter.java +++ b/numass-main/src/test/java/inr/numass/models/PlotScatter.java @@ -36,6 +36,6 @@ public class PlotScatter { + "'ionW' = 11.33 ± 0.43\n" + "'exIonRatio' = 4.83 ± 0.36" ); - LossCalculator.plotScatter(NumassPluginKt.displayJFreeChart("Loss function"), pars); + LossCalculator.plotScatter(NumassPluginKt.displayChart("Loss function"), pars); } } diff --git a/numass-main/src/test/java/inr/numass/models/TestNeLossParametrisation.java b/numass-main/src/test/java/inr/numass/models/TestNeLossParametrisation.java index c539c5ba..ef0624a4 100644 --- a/numass-main/src/test/java/inr/numass/models/TestNeLossParametrisation.java +++ b/numass-main/src/test/java/inr/numass/models/TestNeLossParametrisation.java @@ -32,7 +32,7 @@ public class TestNeLossParametrisation { * @param args the command line arguments */ 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); UnivariateFunction oldFunction = LossCalculator.getSingleScatterFunction(); UnivariateFunction newFunction = getSingleScatterFunction(12.86, 16.78, 1.65, 12.38, 4.79); diff --git a/numass-main/src/test/java/inr/numass/models/TransmissionInterpolatorTest.java b/numass-main/src/test/java/inr/numass/models/TransmissionInterpolatorTest.java index 5fe0ef3c..50688e2a 100644 --- a/numass-main/src/test/java/inr/numass/models/TransmissionInterpolatorTest.java +++ b/numass-main/src/test/java/inr/numass/models/TransmissionInterpolatorTest.java @@ -28,7 +28,7 @@ import inr.numass.NumassPluginKt; public class TransmissionInterpolatorTest { public static void main(String[] args) { - JFreeChartFrame frame = NumassPluginKt.displayJFreeChart("TransmissionInterpolatorTest"); + JFreeChartFrame frame = NumassPluginKt.displayChart("TransmissionInterpolatorTest"); //JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null); TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(Global.INSTANCE, "d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);