A lot of minor fixes. Moving some code to kotlin
This commit is contained in:
parent
4b323fd145
commit
e61da4b5fd
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "1.2.0" apply false
|
||||
id "org.jetbrains.kotlin.jvm" version "1.2.10" apply false
|
||||
}
|
||||
|
||||
allprojects{
|
||||
@ -21,8 +21,8 @@ allprojects{
|
||||
}
|
||||
|
||||
dependencies{
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.0"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.10"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.10"
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,8 +59,8 @@ class SmartAnalyzer(processor: SignalProcessor? = null) : AbstractAnalyzer(proce
|
||||
return ValueMap(map)
|
||||
}
|
||||
|
||||
override fun getEvents(block: NumassBlock, config: Meta): Stream<NumassEvent> {
|
||||
return getAnalyzer(config).getEvents(block, config)
|
||||
override fun getEvents(block: NumassBlock, meta: Meta): Stream<NumassEvent> {
|
||||
return getAnalyzer(meta).getEvents(block, meta)
|
||||
}
|
||||
|
||||
override fun getTableFormat(config: Meta): TableFormat {
|
||||
|
@ -194,12 +194,12 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces
|
||||
* The filtered stream of events
|
||||
*
|
||||
* @param block
|
||||
* @param config
|
||||
* @param meta
|
||||
* @return
|
||||
*/
|
||||
override fun getEvents(block: NumassBlock, config: Meta): Stream<NumassEvent> {
|
||||
val t0 = getT0(block, config).toLong()
|
||||
return getEventsWithDelay(block, config).filter { pair -> pair.second >= t0 }.map { it.first }
|
||||
override fun getEvents(block: NumassBlock, meta: Meta): Stream<NumassEvent> {
|
||||
val t0 = getT0(block, meta).toLong()
|
||||
return getEventsWithDelay(block, meta).filter { pair -> pair.second >= t0 }.map { it.first }
|
||||
}
|
||||
|
||||
public override fun getTableFormat(config: Meta): TableFormat {
|
||||
|
@ -19,10 +19,10 @@ package inr.numass.scripts
|
||||
import hep.dataforge.fx.plots.PlotManager
|
||||
import hep.dataforge.kodex.buildContext
|
||||
import hep.dataforge.kodex.buildMeta
|
||||
import hep.dataforge.kodex.replaceColumn
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.plots.PlotPlugin
|
||||
import hep.dataforge.plots.data.DataPlot
|
||||
import hep.dataforge.tables.Adapters
|
||||
import inr.numass.NumassPlugin
|
||||
import inr.numass.data.NumassDataUtils
|
||||
import inr.numass.data.analyzers.NumassAnalyzer
|
||||
@ -65,37 +65,57 @@ fun main(args: Array<String>) {
|
||||
val meta = buildMeta {
|
||||
node("window"){
|
||||
"lo" to 300
|
||||
"up" to 1800
|
||||
"up" to 2600
|
||||
}
|
||||
}
|
||||
|
||||
with(NumassAnalyzer) {
|
||||
val events = getSpectrum(seconds, analyzer.getEvents(point).asSequence(),meta)
|
||||
.withBinning(binning)
|
||||
|
||||
val eventsNorming = events.getColumn(COUNT_RATE_KEY).stream().mapToDouble{it.doubleValue()}.sum()
|
||||
|
||||
println("The norming factor for unfiltered count rate is $eventsNorming")
|
||||
|
||||
val filtered = getSpectrum(
|
||||
seconds,
|
||||
analyzer.getEventsPairs(point, Meta.empty()).filter { it.second.timeOffset - it.first.timeOffset > t0 }.map { it.second },
|
||||
meta
|
||||
).withBinning(binning)
|
||||
|
||||
val filteredNorming = filtered.getColumn(COUNT_RATE_KEY).stream().mapToDouble{it.doubleValue()}.sum()
|
||||
|
||||
println("The norming factor for filtered count rate is $filteredNorming")
|
||||
|
||||
val defaultFiltered = getSpectrum(
|
||||
seconds,
|
||||
analyzer.getEvents(point, buildMeta {"t0" to t0}).asSequence(),
|
||||
meta
|
||||
).withBinning(binning)
|
||||
|
||||
val defaultFilteredNorming = filtered.getColumn(COUNT_RATE_KEY).stream().mapToDouble{it.doubleValue()}.sum()
|
||||
|
||||
println("The norming factor for default filtered count rate is $defaultFilteredNorming")
|
||||
|
||||
|
||||
plots.getPlotFrame("amps").apply {
|
||||
add(DataPlot.plot("events", ADAPTER, events))
|
||||
add(DataPlot.plot("filtered", ADAPTER, filtered))
|
||||
add(DataPlot.plot("events", ADAPTER, events.replaceColumn(COUNT_RATE_KEY){getDouble(COUNT_RATE_KEY)/eventsNorming}))
|
||||
add(DataPlot.plot("filtered", ADAPTER, filtered.replaceColumn(COUNT_RATE_KEY){getDouble(COUNT_RATE_KEY)/filteredNorming}))
|
||||
add(DataPlot.plot("defaultFiltered", ADAPTER, defaultFiltered.replaceColumn(COUNT_RATE_KEY){getDouble(COUNT_RATE_KEY)/defaultFilteredNorming}))
|
||||
}
|
||||
|
||||
plots.getPlotFrame("ratio").apply {
|
||||
|
||||
add(
|
||||
DataPlot.plot(
|
||||
"ratio",
|
||||
Adapters.DEFAULT_XY_ADAPTER,
|
||||
events.zip(filtered) { f, s ->
|
||||
Adapters.buildXYDataPoint(f.getDouble(CHANNEL_KEY), f.getDouble(COUNT_RATE_KEY) / s.getDouble(COUNT_RATE_KEY))
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
// plots.getPlotFrame("ratio").apply {
|
||||
//
|
||||
// add(
|
||||
// DataPlot.plot(
|
||||
// "ratio",
|
||||
// Adapters.DEFAULT_XY_ADAPTER,
|
||||
// events.zip(filtered) { f, s ->
|
||||
// Adapters.buildXYDataPoint(f.getDouble(CHANNEL_KEY), f.getDouble(COUNT_RATE_KEY) / s.getDouble(COUNT_RATE_KEY))
|
||||
// }
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user