Separated Input and Output management. Input moved to context

This commit is contained in:
Alexander Nozik 2018-05-17 20:52:36 +03:00
parent 11f130d8f5
commit a489d33548
2 changed files with 17 additions and 22 deletions

View File

@ -88,7 +88,7 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
histPlot.add(
XYFunctionPlot.plot(name + "_theory", 0.0, binSize * binNum) {
trueCR/1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * Math.exp( - it * trueCR / 1e6)
trueCR/1e6 * initialEstimate.getInt(NumassAnalyzer.COUNT_KEY) * binSize * Math.exp( - it * trueCR / 1e6)
}
)
}

View File

@ -1,16 +1,17 @@
package inr.numass.scripts.timeanalysis
import hep.dataforge.context.Global
import hep.dataforge.fx.plots.FXPlotManager
import hep.dataforge.kodex.buildMeta
import hep.dataforge.kodex.coroutineContext
import hep.dataforge.kodex.generate
import hep.dataforge.kodex.join
import hep.dataforge.maths.chain.MarkovChain
import inr.numass.NumassPlugin
import inr.numass.actions.TimeAnalyzerAction
import inr.numass.data.api.OrphanNumassEvent
import inr.numass.data.api.SimpleNumassPoint
import inr.numass.data.generateBlock
import kotlinx.coroutines.experimental.channels.produce
import kotlinx.coroutines.experimental.channels.toList
import kotlinx.coroutines.experimental.runBlocking
import org.apache.commons.math3.random.JDKRandomGenerator
import org.apache.commons.math3.random.RandomGenerator
import java.time.Instant
@ -21,7 +22,7 @@ fun main(args: Array<String>) {
val cr = 30e3
val length = 30e9.toLong()
val num = 4
val num = 2
val dt = 6.5
val rnd = JDKRandomGenerator()
@ -37,25 +38,19 @@ fun main(args: Array<String>) {
val start = Instant.now()
//TODO make parallel
val blockChannel = produce {
(1..num).forEach {
send(
val point = (1..num).map {
Global.generate {
MarkovChain(OrphanNumassEvent(1000, 0)) { event ->
//val deltaT = rnd.nextDeltaTime(cr * exp(- event.timeOffset / 1e11))
val deltaT = rnd.nextDeltaTime(cr)
OrphanNumassEvent(1000, event.timeOffset + deltaT)
}.generateBlock(start.plusNanos(it * length), length)
)
}
}
}.join(Global.coroutineContext) {blocks->
SimpleNumassPoint(blocks, 12000.0)
}.get()
val blocks = runBlocking {
blockChannel.toList()
}
val point = SimpleNumassPoint(blocks, 12000.0)
val meta = buildMeta {
"t0" to 3000