Slicer for numass
This commit is contained in:
parent
1881c3419e
commit
12114ffab3
@ -71,7 +71,8 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
fitTask,
|
fitTask,
|
||||||
plotFitTask,
|
plotFitTask,
|
||||||
histogramTask,
|
histogramTask,
|
||||||
fitScanTask
|
fitScanTask,
|
||||||
|
sliceTask
|
||||||
)
|
)
|
||||||
|
|
||||||
@Provides(Task.TASK_TARGET)
|
@Provides(Task.TASK_TARGET)
|
||||||
@ -109,7 +110,10 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
BivariateFunction { E: Double, U: Double ->
|
BivariateFunction { E: Double, U: Double ->
|
||||||
val D = E - U
|
val D = E - U
|
||||||
val factor = 7.33 - E / 1000.0 / 3.0
|
val factor = 7.33 - E / 1000.0 / 3.0
|
||||||
return@BivariateFunction 1.0 - (3.05346E-7 * D - 5.45738E-10 * Math.pow(D, 2.0) - 6.36105E-14 * Math.pow(D, 3.0)) * factor
|
return@BivariateFunction 1.0 - (3.05346E-7 * D - 5.45738E-10 * Math.pow(
|
||||||
|
D,
|
||||||
|
2.0
|
||||||
|
) - 6.36105E-14 * Math.pow(D, 3.0)) * factor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +271,15 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
} else if (an.hasMeta("transBuildAction")) {
|
} else if (an.hasMeta("transBuildAction")) {
|
||||||
val transBuild = an.getMeta("transBuildAction")
|
val transBuild = an.getMeta("transBuildAction")
|
||||||
try {
|
try {
|
||||||
return TransmissionInterpolator.fromAction(context, transBuild, transXName, transYName, nSmooth, w, stitchBorder)
|
return TransmissionInterpolator.fromAction(
|
||||||
|
context,
|
||||||
|
transBuild,
|
||||||
|
transXName,
|
||||||
|
transYName,
|
||||||
|
nSmooth,
|
||||||
|
w,
|
||||||
|
stitchBorder
|
||||||
|
)
|
||||||
} catch (ex: InterruptedException) {
|
} catch (ex: InterruptedException) {
|
||||||
throw RuntimeException("Transmission builder failed")
|
throw RuntimeException("Transmission builder failed")
|
||||||
}
|
}
|
||||||
@ -281,7 +293,11 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
return if (an.hasMeta(ValuesAdapter.ADAPTER_KEY)) {
|
return if (an.hasMeta(ValuesAdapter.ADAPTER_KEY)) {
|
||||||
Adapters.buildAdapter(an.getMeta(ValuesAdapter.ADAPTER_KEY))
|
Adapters.buildAdapter(an.getMeta(ValuesAdapter.ADAPTER_KEY))
|
||||||
} else {
|
} else {
|
||||||
Adapters.buildXYAdapter(NumassPoint.HV_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_ERROR_KEY)
|
Adapters.buildXYAdapter(
|
||||||
|
NumassPoint.HV_KEY,
|
||||||
|
NumassAnalyzer.COUNT_RATE_KEY,
|
||||||
|
NumassAnalyzer.COUNT_RATE_ERROR_KEY
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +319,13 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun displayChart(title: String, context: Context = Global, 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()
|
val frame = JFreeChartFrame()
|
||||||
frame.configure(meta)
|
frame.configure(meta)
|
||||||
frame.configureValue("title", title)
|
frame.configureValue("title", title)
|
||||||
|
@ -51,7 +51,7 @@ fun main(args: Array<String>) {
|
|||||||
hvs.forEach { hv ->
|
hvs.forEach { hv ->
|
||||||
val points = loader.points.filter {
|
val points = loader.points.filter {
|
||||||
it.voltage == hv
|
it.voltage == hv
|
||||||
}.map { it.channels[0]!! }.toList()
|
}.toList()
|
||||||
if (!points.isEmpty()) {
|
if (!points.isEmpty()) {
|
||||||
putStatic(
|
putStatic(
|
||||||
"point_${hv.toInt()}",
|
"point_${hv.toInt()}",
|
||||||
|
@ -35,6 +35,7 @@ import inr.numass.data.analyzers.NumassAnalyzer
|
|||||||
import inr.numass.data.analyzers.NumassAnalyzer.Companion.CHANNEL_KEY
|
import inr.numass.data.analyzers.NumassAnalyzer.Companion.CHANNEL_KEY
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer.Companion.COUNT_KEY
|
import inr.numass.data.analyzers.NumassAnalyzer.Companion.COUNT_KEY
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
import inr.numass.data.analyzers.SmartAnalyzer
|
||||||
|
import inr.numass.data.analyzers.countInWindow
|
||||||
import inr.numass.data.api.MetaBlock
|
import inr.numass.data.api.MetaBlock
|
||||||
import inr.numass.data.api.NumassPoint
|
import inr.numass.data.api.NumassPoint
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
@ -317,7 +318,7 @@ val histogramTask = task("histogram") {
|
|||||||
.filter { points == null || points.contains(it.voltage) }
|
.filter { points == null || points.contains(it.voltage) }
|
||||||
.groupBy { it.voltage }
|
.groupBy { it.voltage }
|
||||||
.mapValues {
|
.mapValues {
|
||||||
analyzer.getAmplitudeSpectrum(MetaBlock(it.value))
|
analyzer.getAmplitudeSpectrum(MetaBlock(it.value), meta.getMetaOrEmpty("analyzer"))
|
||||||
}
|
}
|
||||||
.forEach { u, spectrum ->
|
.forEach { u, spectrum ->
|
||||||
log.report("Aggregating data from U = $u")
|
log.report("Aggregating data from U = $u")
|
||||||
@ -383,6 +384,58 @@ val histogramTask = task("histogram") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sliceTask = task("slice") {
|
||||||
|
model { meta ->
|
||||||
|
dependsOn(selectTask, meta)
|
||||||
|
configure(meta.getMetaOrEmpty("slice"))
|
||||||
|
configure {
|
||||||
|
meta.useMeta("analyzer") { putNode(it) }
|
||||||
|
setValue("@target", meta.getString("@target", meta.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
join<NumassSet, Table> { data ->
|
||||||
|
val analyzer = SmartAnalyzer()
|
||||||
|
val slices = HashMap<String, IntRange>()
|
||||||
|
val formatBuilder = TableFormatBuilder()
|
||||||
|
formatBuilder.addColumn("set",ValueType.STRING)
|
||||||
|
formatBuilder.addColumn("time",ValueType.TIME)
|
||||||
|
meta.getMetaList("range").forEach {
|
||||||
|
val range = IntRange(it.getInt("from"), it.getInt("to"))
|
||||||
|
val name = it.getString("name", range.toString())
|
||||||
|
slices[name] = range
|
||||||
|
formatBuilder.addColumn(name, ValueType.NUMBER)
|
||||||
|
}
|
||||||
|
|
||||||
|
val table = buildTable(formatBuilder.build()) {
|
||||||
|
data.forEach { setName, set ->
|
||||||
|
val point = set.find {
|
||||||
|
it.index == meta.getInt("index", -1) ||
|
||||||
|
it.voltage == meta.getDouble("voltage", -1.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (point != null) {
|
||||||
|
val amplitudeSpectrum = analyzer.getAmplitudeSpectrum(point, meta.getMetaOrEmpty("analyzer"))
|
||||||
|
val map = HashMap<String, Any>()
|
||||||
|
map["set"] = setName
|
||||||
|
map["time"] = point.startTime
|
||||||
|
slices.mapValuesTo(map) { (_, range) ->
|
||||||
|
amplitudeSpectrum.countInWindow(
|
||||||
|
range.start.toShort(),
|
||||||
|
range.endInclusive.toShort()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
row(map)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// send raw table to the output
|
||||||
|
context.output.render(table, stage = "numass.table", name = name, meta = meta)
|
||||||
|
|
||||||
|
return@join table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val fitScanTask = task("fitscan") {
|
val fitScanTask = task("fitscan") {
|
||||||
model { meta ->
|
model { meta ->
|
||||||
dependsOn(filterTask, meta)
|
dependsOn(filterTask, meta)
|
||||||
|
Loading…
Reference in New Issue
Block a user