Remaking descriptors
This commit is contained in:
parent
464c53c465
commit
d8913bb984
@ -146,7 +146,7 @@ class PKT8Display : DeviceDisplayFX<PKT8Device>(), PKT8ValueListener {
|
||||
|
||||
private val plotFrame: PlotFrame by lazy {
|
||||
JFreeChartFrame(plotFrameMeta).apply {
|
||||
plots.descriptor = Descriptors.buildDescriptor(TimePlot::class.java)
|
||||
plots.descriptor = Descriptors.forElement(TimePlot::class.java)
|
||||
PlotUtils.setXAxis(this, "timestamp", "", "time")
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ new GrindShell(ctx).eval {
|
||||
|
||||
def beta = new NumassBeta();
|
||||
|
||||
def params = MetaMorph.morphNode(ParamSet,
|
||||
def params = MetaMorph.morph(ParamSet,
|
||||
Grind.buildMeta("params") {
|
||||
E0(value: 18575, err: 0.1)
|
||||
mnu2(value: 0, err: 0.01)
|
||||
|
@ -2,7 +2,6 @@ package inr.numass.scripts.temp
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.description.Descriptors
|
||||
import hep.dataforge.grind.Grind
|
||||
import hep.dataforge.grind.GrindShell
|
||||
import hep.dataforge.grind.helpers.PlotHelper
|
||||
@ -61,7 +60,7 @@ new GrindShell(ctx).eval {
|
||||
|
||||
PlotFrame frame = (plots as PlotHelper).getManager().getPlotFrame("test", "spectra")
|
||||
|
||||
frame.plots.setDescriptor(Descriptors.buildDescriptor(DataPlot))
|
||||
frame.plots.setType(DataPlot)
|
||||
frame.plots.configure(showErrors: false, showSymbol: false, showLine: true, connection: "step")
|
||||
|
||||
joined.points.filter { it.voltage in [14000d, 15000d, 16000d, 17000d, 18000d] }.forEach {
|
||||
|
@ -51,7 +51,7 @@ fun NumassBlock.plotAmplitudeSpectrum(plotName: String = "spectrum", frameName:
|
||||
"showLine" to true
|
||||
"showSymbol" to false
|
||||
"showErrors" to false
|
||||
}.setType(DataPlot::class)
|
||||
}.setType<DataPlot>()
|
||||
|
||||
val plot = DataPlot.plot(
|
||||
plotName,
|
||||
|
@ -60,7 +60,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
val frame = displayChart("differential").apply {
|
||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forObject(DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ fun main(args: Array<String>) {
|
||||
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
||||
|
||||
val frame = displayChart("integral[$hv]").apply {
|
||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forObject(DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ fun main(args: Array<String>) {
|
||||
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 = displayChart("integral").apply {
|
||||
this.plots.descriptor = Descriptors.buildDescriptor(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forObject(DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import hep.dataforge.stat.fit.ParamSet
|
||||
import inr.numass.NumassPlugin
|
||||
import inr.numass.models.NBkgSpectrum
|
||||
import inr.numass.models.sterile.SterileNeutrinoSpectrum
|
||||
import kotlin.math.sqrt
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@ -46,24 +47,36 @@ fun main(args: Array<String>) {
|
||||
//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("N", 8e5, 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())
|
||||
setParValue("msterile2", (1000 * 1000).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)
|
||||
}
|
||||
fun ParamSet.update(vararg override: Pair<String, Double>): ParamSet = this.copy().apply {
|
||||
override.forEach {
|
||||
setParValue(it.first, it.second)
|
||||
}
|
||||
}
|
||||
|
||||
fun plotSpectrum(name: String, vararg override: Pair<String, Double>): Plot {
|
||||
val x = (14000.0..18600.0).step(100.0).toList()
|
||||
val y = x.map { spectrum.value(it, pars) }
|
||||
val y = x.map { spectrum.value(it, params.update(*override)) }
|
||||
return DataPlot.plot(name, x.toDoubleArray(), y.toDoubleArray())
|
||||
}
|
||||
|
||||
fun plotResidual(name: String, vararg override: Pair<String, Double>): Plot {
|
||||
val x = (14000.0..18600.0).step(100.0).toList()
|
||||
val y = x.map {
|
||||
val base = spectrum.value(it, params)
|
||||
val mod = spectrum.value(it, params.update(*override))
|
||||
val err = sqrt(base/1e6)
|
||||
return@map (mod - base) / err
|
||||
}
|
||||
return DataPlot.plot(name, x.toDoubleArray(), y.toDoubleArray())
|
||||
}
|
||||
|
||||
@ -75,8 +88,22 @@ fun main(args: Array<String>) {
|
||||
"showSymbol" to false
|
||||
"showErrors" to false
|
||||
}
|
||||
add(plotSpectrum("base"))
|
||||
add(plotSpectrum("noTrap", "trap" to 0.0))
|
||||
plots.setType<DataPlot>()
|
||||
+plotSpectrum("base")
|
||||
+plotSpectrum("noTrap", "trap" to 0.0)
|
||||
}
|
||||
|
||||
context.plot("residuals") {
|
||||
plots.configure {
|
||||
"showLine" to true
|
||||
"showSymbol" to false
|
||||
"showErrors" to false
|
||||
}
|
||||
plots.setType<DataPlot>()
|
||||
+plotResidual("sterile_1","U2" to 1e-3)
|
||||
+plotResidual("sterile_3","msterile2" to (3000*3000).toDouble(),"U2" to 1e-3)
|
||||
+plotResidual("X","X" to 0.11)
|
||||
+plotResidual("trap", "trap" to 0.99)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user