Fixed grid in JFreeChart
This commit is contained in:
parent
b02c14eb34
commit
2a83072d30
@ -19,12 +19,11 @@ package inr.numass.control.dante
|
||||
import hep.dataforge.configure
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.fx.plots.displayPlot
|
||||
import hep.dataforge.meta.KMetaBuilder
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.nullable
|
||||
import hep.dataforge.plots.data.DataPlot
|
||||
import hep.dataforge.plots.jfreechart.chart
|
||||
import hep.dataforge.plots.output.plot
|
||||
import hep.dataforge.tables.Adapters
|
||||
import inr.numass.data.analyzers.NumassAnalyzer
|
||||
import inr.numass.data.analyzers.SimpleAnalyzer
|
||||
@ -79,29 +78,27 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
||||
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)
|
||||
context.displayPlot {
|
||||
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>()
|
||||
|
||||
val plot = DataPlot.plot(
|
||||
plotName,
|
||||
data,
|
||||
Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis)
|
||||
)
|
||||
plot.configure(meta)
|
||||
add(plot)
|
||||
context.plot(plotName) {
|
||||
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>()
|
||||
|
||||
val plot = DataPlot.plot(
|
||||
plotName,
|
||||
data,
|
||||
Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis)
|
||||
)
|
||||
plot.configure(meta)
|
||||
+plot
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package inr.numass.control
|
||||
|
||||
import hep.dataforge.configure
|
||||
import hep.dataforge.fx.plots.PlotContainer
|
||||
import hep.dataforge.meta.KMetaBuilder
|
||||
import hep.dataforge.plots.PlotFrame
|
||||
@ -137,10 +138,8 @@ fun EventTarget.switch(text: String = "", op: (ToggleSwitch.() -> Unit) = {}): T
|
||||
/**
|
||||
* Add frame
|
||||
*/
|
||||
fun BorderPane.plot(plottable: Plottable, metaTransform: (KMetaBuilder.() -> Unit)? = null): PlotFrame {
|
||||
val meta = KMetaBuilder("plotFrame");
|
||||
metaTransform?.invoke(meta)
|
||||
val frame = JFreeChartFrame(meta)
|
||||
fun BorderPane.plot(plottable: Plottable, metaTransform: (KMetaBuilder.() -> Unit) = {}): PlotFrame {
|
||||
val frame = JFreeChartFrame().configure(metaTransform)
|
||||
frame.add(plottable)
|
||||
center = PlotContainer(frame).root
|
||||
return frame;
|
||||
|
@ -68,7 +68,7 @@ object PlotFitResultAction : OneToOneAction<FitResult, FitResult>() {
|
||||
StreamSupport.stream(data.spliterator(), false)
|
||||
.map { dp -> Adapters.getXValue(adapter, dp).double }.sorted().forEach{ fit.calculateIn(it) }
|
||||
|
||||
context.plot(listOf(fit,DataPlot.plot("data", data, adapter)), this.name, name)
|
||||
context.plot(listOf(fit,DataPlot.plot("data", data, adapter)), name, this.name)
|
||||
|
||||
return input
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ object TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
||||
cr / 1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * binSize * Math.exp(-it * cr / 1e6)
|
||||
}
|
||||
|
||||
context.plot(listOf(histogramPlot, functionPlot), stage = this.name, name = "histogram") {
|
||||
context.plot(listOf(histogramPlot, functionPlot), name = "histogram", stage = this.name) {
|
||||
"xAxis" to {
|
||||
"title" to "delay"
|
||||
"units" to "us"
|
||||
@ -105,7 +105,7 @@ object TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
||||
"title" to "${name}_${input.voltage}"
|
||||
}
|
||||
|
||||
context.plot(statPlot, stage = this.name, name = "count rate") {
|
||||
context.plot(statPlot, name = "count rate", stage = this.name) {
|
||||
"xAxis" to {
|
||||
"title" to "delay"
|
||||
"units" to "us"
|
||||
@ -115,7 +115,7 @@ object TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
||||
}
|
||||
}
|
||||
|
||||
context.plot(errorPlot, stage = this.name, name = "error"){
|
||||
context.plot(errorPlot, name = "error", stage = this.name){
|
||||
"xAxis" to {
|
||||
"title" to "delay"
|
||||
"units" to "us"
|
||||
|
@ -82,7 +82,7 @@ object TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
|
||||
.fillData(histogram)
|
||||
|
||||
|
||||
context.plot(histogramPlot, "histogram", name) {
|
||||
context.plot(histogramPlot, name, "histogram") {
|
||||
"xAxis" to {
|
||||
"title" to "delay"
|
||||
"units" to "us"
|
||||
@ -103,7 +103,7 @@ object TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
|
||||
configure(inputMeta.getMetaOrEmpty("plot"))
|
||||
}
|
||||
|
||||
context.plot(statPlot, "stat-method", name)
|
||||
context.plot(statPlot, name, "stat-method")
|
||||
|
||||
(1..100).map { 1000 * it }.map { t ->
|
||||
val result = analyzer.analyze(input, buildMeta {
|
||||
|
@ -16,15 +16,13 @@
|
||||
|
||||
package inr.numass.data
|
||||
|
||||
import hep.dataforge.configure
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.fx.plots.displayPlot
|
||||
import hep.dataforge.meta.KMetaBuilder
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.nullable
|
||||
import hep.dataforge.plots.data.DataPlot
|
||||
import hep.dataforge.plots.jfreechart.chart
|
||||
import hep.dataforge.plots.output.plot
|
||||
import hep.dataforge.tables.Adapters
|
||||
import inr.numass.data.analyzers.NumassAnalyzer
|
||||
import inr.numass.data.analyzers.SmartAnalyzer
|
||||
@ -38,28 +36,26 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
||||
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)
|
||||
context.displayPlot {
|
||||
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>()
|
||||
|
||||
val plot = DataPlot.plot(
|
||||
plotName,
|
||||
data,
|
||||
Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis)
|
||||
)
|
||||
plot.configure(meta)
|
||||
add(plot)
|
||||
context.plot(plotName) {
|
||||
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>()
|
||||
|
||||
val plot = DataPlot.plot(
|
||||
plotName,
|
||||
data,
|
||||
Adapters.buildXYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis)
|
||||
)
|
||||
plot.configure(meta)
|
||||
add(plot)
|
||||
}
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
package inr.numass.models.mc
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.fx.plots.displayPlot
|
||||
import hep.dataforge.maths.chain.Chain
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.plots.data.XYFunctionPlot
|
||||
import hep.dataforge.plots.jfreechart.chart
|
||||
import hep.dataforge.plots.output.plot
|
||||
import hep.dataforge.stat.PolynomialDistribution
|
||||
import hep.dataforge.stat.fit.ParamSet
|
||||
import inr.numass.NumassPlugin
|
||||
@ -47,10 +46,8 @@ fun main(args: Array<String>) {
|
||||
50 * distribution.density(18600.0 - it)
|
||||
}
|
||||
|
||||
Global.displayPlot {
|
||||
chart {
|
||||
add(spectrumPlot)
|
||||
add(distributionPlot)
|
||||
}
|
||||
Global.plot("beta") {
|
||||
add(spectrumPlot)
|
||||
add(distributionPlot)
|
||||
}
|
||||
}
|
@ -30,7 +30,10 @@ fun main(args: Array<String>) {
|
||||
|
||||
val point = (1..num).map {
|
||||
Global.generate {
|
||||
NumassGenerator.generateEvents(cr).withDeadTime { (dt * 1000).toLong() }.generateBlock(start.plusNanos(it * length), length)
|
||||
NumassGenerator
|
||||
.generateEvents(cr)
|
||||
.withDeadTime { (dt * 1000).toLong() }
|
||||
.generateBlock(start.plusNanos(it * length), length)
|
||||
}
|
||||
}.join(Global.coroutineContext) { blocks ->
|
||||
SimpleNumassPoint(blocks, 12000.0)
|
||||
@ -44,8 +47,10 @@ fun main(args: Array<String>) {
|
||||
"mean" to TimeAnalyzer.AveragingMethod.ARITHMETIC
|
||||
}
|
||||
"binNum" to 200
|
||||
"t0.max" to 1e4
|
||||
"t0.max" to 5e4
|
||||
}
|
||||
|
||||
TimeAnalyzerAction.simpleRun(point, meta);
|
||||
|
||||
readLine()
|
||||
}
|
@ -49,12 +49,15 @@ fun main(args: Array<String>) {
|
||||
.generateEvents(cr)
|
||||
|
||||
val bunches = NumassGenerator
|
||||
.generateBunches(10.0, 0.001, 5.0)
|
||||
.generateBunches(3.0, 0.001, 5.0)
|
||||
|
||||
val discharges = NumassGenerator
|
||||
.generateBunches(50.0,0.001,0.1)
|
||||
|
||||
NumassGenerator.mergeEventChains(events, bunches, discharges).withDeadTime { (dt * 1000).toLong() }.generateBlock(start.plusNanos(it * length), length)
|
||||
NumassGenerator
|
||||
.mergeEventChains(events, bunches, discharges)
|
||||
.withDeadTime { (dt * 1000).toLong() }
|
||||
.generateBlock(start.plusNanos(it * length), length)
|
||||
}
|
||||
}.join(Global.coroutineContext) { blocks ->
|
||||
SimpleNumassPoint(blocks, 18000.0)
|
||||
|
@ -107,7 +107,7 @@ val monitorTableTask = task("monitor") {
|
||||
|
||||
if (meta.getBoolean("showPlot", true)) {
|
||||
val plot = DataPlot.plot(name, res, Adapters.buildXYAdapter("timestamp", "cr", "crErr"))
|
||||
context.plot(plot, "numass.monitor", name) {
|
||||
context.plot(plot, name, "numass.monitor") {
|
||||
"xAxis.title" to "time"
|
||||
"xAxis.type" to "time"
|
||||
"yAxis.title" to "Count rate"
|
||||
@ -268,7 +268,7 @@ val plotFitTask = task("plotFit") {
|
||||
|
||||
val dataPlot = DataPlot.plot("data", data, adapter)
|
||||
|
||||
context.plot(listOf(fit, dataPlot), "numass.plotFit", name)
|
||||
context.plot(listOf(fit, dataPlot), name, "numass.plotFit")
|
||||
|
||||
return@pipe input;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user