Multiple plot fixes.

This commit is contained in:
darksnake 2017-08-01 14:42:16 +03:00
parent 115cf378e4
commit 56d2988eaf
2 changed files with 32 additions and 23 deletions

View File

@ -14,7 +14,6 @@ import hep.dataforge.data.DataSet
import hep.dataforge.grind.GrindShell import hep.dataforge.grind.GrindShell
import hep.dataforge.grind.actions.GrindPipe import hep.dataforge.grind.actions.GrindPipe
import hep.dataforge.grind.helpers.PlotHelper import hep.dataforge.grind.helpers.PlotHelper
import hep.dataforge.io.ColumnedDataWriter
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.plots.data.PlottableData import hep.dataforge.plots.data.PlottableData
import hep.dataforge.plots.data.PlottableGroup import hep.dataforge.plots.data.PlottableGroup
@ -32,6 +31,7 @@ import inr.numass.data.api.NumassSet
import inr.numass.data.api.SimpleNumassPoint import inr.numass.data.api.SimpleNumassPoint
import inr.numass.data.storage.NumassStorage import inr.numass.data.storage.NumassStorage
import inr.numass.data.storage.NumassStorageFactory import inr.numass.data.storage.NumassStorageFactory
import javafx.application.Platform
import java.util.stream.Collectors import java.util.stream.Collectors
@ -46,7 +46,7 @@ ctx.pluginManager().load(CachePlugin.class)
Meta meta = buildMeta { Meta meta = buildMeta {
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}") data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")
generate(t0: 3e4, sort: false) generate(t0: 3e4, sort: true)
subtract(reference: 18600) subtract(reference: 18600)
fit(xlow: 450, xHigh: 700, upper: 3100, binning: 20) fit(xlow: 450, xHigh: 700, upper: 3100, binning: 20)
} }
@ -91,21 +91,25 @@ new GrindShell(ctx).eval {
} }
DataNode<Table> spectra = generate.run(context, data, meta.getMeta("generate")); DataNode<Table> spectra = generate.run(context, data, meta.getMeta("generate"));
spectra = context.getFeature(CachePlugin).cacheNode("underflow", meta, spectra) Meta id = buildMeta {
put meta.getMeta("data")
put meta.getMeta("generate")
}
spectra = context.getFeature(CachePlugin).cacheNode("underflow", id, spectra)
//subtracting reference point //subtracting reference point
Map<Double, Table> spectraMap Map<Double, Table> spectraMap
if (meta.hasValue("subtract.reference")) { if (meta.hasValue("subtract.reference")) {
String referenceVoltage = meta["subtract.reference"].stringValue() String referenceVoltage = meta["subtract.reference"]
println "subtracting reference point ${referenceVoltage}" println "subtracting reference point ${referenceVoltage}"
def referencePoint = spectra.compute(referenceVoltage) def referencePoint = spectra.compute(referenceVoltage)
spectraMap = spectra spectraMap = spectra
.findAll { it.name != referenceVoltage } .findAll { it.name != referenceVoltage }
.collectEntries { .collectEntries {
[(it.meta["voltage"].doubleValue()): NumassDataUtils.subtractSpectrum(it.get(), referencePoint)] [(it.meta["voltage"]): NumassDataUtils.subtractSpectrum(it.get(), referencePoint)]
} }
} else { } else {
spectraMap = spectra.collectEntries { return [(it.meta["voltage"].doubleValue()): it.get()] } spectraMap = spectra.collectEntries { return [(it.meta["voltage"]): it.get()] }
} }
//Showing selected points //Showing selected points
@ -131,22 +135,27 @@ new GrindShell(ctx).eval {
showPoints(spectraMap.findAll { it.key in [16200d, 16400d, 16800d, 17000d, 17200d, 17700d] }) showPoints(spectraMap.findAll { it.key in [16200d, 16400d, 16800d, 17000d, 17200d, 17700d] })
Table correctionTable = TableTransform.filter( [550, 600, 650, 750].each { xHigh ->
UnderflowFitter.fitAllPoints( println "Caclculate correctuion for upper linearity bound: ${xHigh}"
spectraMap, Table correctionTable = TableTransform.filter(
meta["fit.xlow"].intValue(), UnderflowFitter.fitAllPoints(
meta["fit.xHigh"].intValue(), spectraMap,
meta["fit.upper"].intValue(), meta["fit.xlow"] as int,
meta["fit.binning"].intValue() xHigh,
), meta["fit.upper"] as int,
"correction", meta["fit.binning"] as int
0, ),
2 "correction",
) 0,
2
)
ColumnedDataWriter.writeTable(System.out, correctionTable, "underflow parameters") // ColumnedDataWriter.writeTable(System.out, correctionTable, "underflow parameters")
(plots as PlotHelper).plot(correctionTable, name: "correction", frame: "Correction") { Platform.runLater {
adapter("x.value": "U", "y.value": "correction") (plots as PlotHelper).plot(correctionTable, name: "upper_${xHigh}", frame: "Correction") {
adapter("x.value": "U", "y.value": "correction")
}
}
} }
} }

View File

@ -68,7 +68,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters()); Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
PlotFrame frame = PlotUtils.getPlotManager(context) PlotFrame frame = PlotUtils.getPlotManager(context)
.buildPlotFrame(getName(), name, metaData.getMeta("plot", Meta.empty())); .getPlotFrame(getName(), name, metaData.getMeta("plot", Meta.empty()));
PlottableXYFunction fit = new PlottableXYFunction("fit"); PlottableXYFunction fit = new PlottableXYFunction("fit");
fit.setDensity(100, false); fit.setDensity(100, false);