Minor fixes in plots
This commit is contained in:
parent
a11f8d99d0
commit
34eb8fc559
@ -38,28 +38,28 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
|||||||
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)
|
||||||
context.display(
|
context.display {
|
||||||
JFreeChartFrame().apply {
|
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 {
|
||||||
NumassAnalyzer.COUNT_KEY
|
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)
|
|
||||||
}
|
}
|
||||||
)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -47,10 +47,10 @@ fun main(args: Array<String>) {
|
|||||||
50 * distribution.density(18600.0 - it)
|
50 * distribution.density(18600.0 - it)
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.display(
|
Global.display {
|
||||||
chart {
|
chart {
|
||||||
add(spectrumPlot)
|
add(spectrumPlot)
|
||||||
add(distributionPlot)
|
add(distributionPlot)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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.scripts.models
|
||||||
|
|
||||||
|
import hep.dataforge.context.Global
|
||||||
|
import hep.dataforge.fx.plots.display
|
||||||
|
import hep.dataforge.kodex.configure
|
||||||
|
import hep.dataforge.kodex.step
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.plots.Plot
|
||||||
|
import hep.dataforge.plots.data.DataPlot
|
||||||
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
||||||
|
import hep.dataforge.plots.jfreechart.JFreeChartPlugin
|
||||||
|
import hep.dataforge.stat.fit.ParamSet
|
||||||
|
import inr.numass.NumassPlugin
|
||||||
|
import inr.numass.models.NBkgSpectrum
|
||||||
|
import inr.numass.models.sterile.SterileNeutrinoSpectrum
|
||||||
|
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
JFreeChartPlugin().startGlobal()
|
||||||
|
NumassPlugin().startGlobal()
|
||||||
|
|
||||||
|
val sp = SterileNeutrinoSpectrum(Global, Meta.empty())
|
||||||
|
//beta.setCaching(false);
|
||||||
|
|
||||||
|
val spectrum = NBkgSpectrum(sp)
|
||||||
|
//val model = XYModel(Meta.empty(), SpectrumAdapter(Meta.empty()), spectrum)
|
||||||
|
|
||||||
|
val params = ParamSet().apply {
|
||||||
|
setPar("N", 2e6 / 100, 6.0, 0.0, Double.POSITIVE_INFINITY)
|
||||||
|
setPar("bkg", 2.0, 0.03)
|
||||||
|
setPar("E0", 18575.0, 1.0)
|
||||||
|
setPar("mnu2", 0.0, 1.0)
|
||||||
|
setParValue("msterile2", (8000 * 8000).toDouble())
|
||||||
|
setPar("U2", 0.0, 1e-3)
|
||||||
|
setPar("X", 0.1, 0.01)
|
||||||
|
setPar("trap", 1.0, 0.01)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun plotSpectrum(name: String, vararg override: Pair<String, Double>): Plot {
|
||||||
|
val pars = params.copy().apply {
|
||||||
|
override.forEach {
|
||||||
|
setParValue(it.first,it.second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val x = (14000.0..18600.0).step(100.0).toList()
|
||||||
|
val y = x.map { spectrum.value(it, pars) }
|
||||||
|
return DataPlot.plot(name, x.toDoubleArray(), y.toDoubleArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
Global.display {
|
||||||
|
JFreeChartFrame().apply {
|
||||||
|
plots.configure {
|
||||||
|
"showLine" to true
|
||||||
|
"showSymbol" to false
|
||||||
|
"showErrors" to false
|
||||||
|
}
|
||||||
|
add(plotSpectrum("base"))
|
||||||
|
add(plotSpectrum("noTrap", "trap" to 0.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user