Multiple fixes in value representation
This commit is contained in:
parent
4194422352
commit
122c71c51d
@ -87,7 +87,7 @@ abstract class AbstractAnalyzer @JvmOverloads constructor(private val processor:
|
|||||||
val format = getTableFormat(config)
|
val format = getTableFormat(config)
|
||||||
|
|
||||||
return ListTable.Builder(format)
|
return ListTable.Builder(format)
|
||||||
.rows(set.points.map { point -> analyzePoint(point, config) })
|
.rows(set.points.map { point -> analyzeParent(point, config) })
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,8 @@ import hep.dataforge.tables.Adapters.*
|
|||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import hep.dataforge.values.ValueMap
|
import hep.dataforge.values.ValueMap
|
||||||
import hep.dataforge.values.Values
|
import hep.dataforge.values.Values
|
||||||
import inr.numass.data.api.NumassBlock
|
import inr.numass.data.api.*
|
||||||
import inr.numass.data.api.NumassEvent
|
|
||||||
import inr.numass.data.api.NumassPoint
|
|
||||||
import inr.numass.data.api.NumassPoint.Companion.HV_KEY
|
import inr.numass.data.api.NumassPoint.Companion.HV_KEY
|
||||||
import inr.numass.data.api.NumassSet
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
@ -55,9 +52,11 @@ interface NumassAnalyzer {
|
|||||||
* @param config
|
* @param config
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun analyzePoint(point: NumassPoint, config: Meta = Meta.empty()): Values {
|
fun analyzeParent(point: ParentBlock, config: Meta = Meta.empty()): Values {
|
||||||
val map = HashMap(analyze(point, config).asMap())
|
val map = HashMap(analyze(point, config).asMap())
|
||||||
map[HV_KEY] = Value.of(point.voltage)
|
if(point is NumassPoint) {
|
||||||
|
map[HV_KEY] = Value.of(point.voltage)
|
||||||
|
}
|
||||||
return ValueMap(map)
|
return ValueMap(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,8 @@ import hep.dataforge.values.Value
|
|||||||
import hep.dataforge.values.ValueMap
|
import hep.dataforge.values.ValueMap
|
||||||
import hep.dataforge.values.ValueType
|
import hep.dataforge.values.ValueType
|
||||||
import hep.dataforge.values.Values
|
import hep.dataforge.values.Values
|
||||||
import inr.numass.data.api.NumassBlock
|
import inr.numass.data.api.*
|
||||||
import inr.numass.data.api.NumassEvent
|
|
||||||
import inr.numass.data.api.NumassPoint
|
|
||||||
import inr.numass.data.api.NumassPoint.Companion.HV_KEY
|
import inr.numass.data.api.NumassPoint.Companion.HV_KEY
|
||||||
import inr.numass.data.api.SignalProcessor
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
import java.util.stream.Stream
|
import java.util.stream.Stream
|
||||||
@ -45,8 +42,8 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces
|
|||||||
|
|
||||||
override fun analyze(block: NumassBlock, config: Meta): Values {
|
override fun analyze(block: NumassBlock, config: Meta): Values {
|
||||||
//In case points inside points
|
//In case points inside points
|
||||||
if (block is NumassPoint) {
|
if (block is ParentBlock) {
|
||||||
return analyzePoint(block, config)
|
return analyzeParent(block, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +78,7 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun analyzePoint(point: NumassPoint, config: Meta): Values {
|
override fun analyzeParent(point: ParentBlock, config: Meta): Values {
|
||||||
//Average count rates, do not sum events
|
//Average count rates, do not sum events
|
||||||
val res = point.blocks.stream()
|
val res = point.blocks.stream()
|
||||||
.filter { it.events.findAny().isPresent }// filter for empty blocks
|
.filter { it.events.findAny().isPresent }// filter for empty blocks
|
||||||
@ -89,7 +86,9 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces
|
|||||||
.reduce(null) { v1, v2 -> this.combineBlockResults(v1, v2) }
|
.reduce(null) { v1, v2 -> this.combineBlockResults(v1, v2) }
|
||||||
|
|
||||||
val map = HashMap(res.asMap())
|
val map = HashMap(res.asMap())
|
||||||
map[HV_KEY] = Value.of(point.voltage)
|
if(point is NumassPoint) {
|
||||||
|
map[HV_KEY] = Value.of(point.voltage)
|
||||||
|
}
|
||||||
return ValueMap(map)
|
return ValueMap(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,17 @@ import java.time.Instant
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.stream.Stream
|
import java.util.stream.Stream
|
||||||
|
|
||||||
|
interface ParentBlock: NumassBlock{
|
||||||
|
val blocks: Collection<NumassBlock>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A block constructed from a set of other blocks. Internal blocks are not necessary subsequent. Blocks are automatically sorted.
|
* A block constructed from a set of other blocks. Internal blocks are not necessary subsequent. Blocks are automatically sorted.
|
||||||
* Created by darksnake on 16.07.2017.
|
* Created by darksnake on 16.07.2017.
|
||||||
*/
|
*/
|
||||||
class MetaBlock(blocks: Collection<NumassBlock>) : NumassBlock {
|
class MetaBlock(blocks: Collection<NumassBlock>) : ParentBlock {
|
||||||
|
|
||||||
private val blocks = TreeSet(Comparator.comparing<NumassBlock, Instant>{ it.startTime })
|
override val blocks = TreeSet(Comparator.comparing<NumassBlock, Instant>{ it.startTime })
|
||||||
|
|
||||||
init{
|
init{
|
||||||
this.blocks.addAll(blocks)
|
this.blocks.addAll(blocks)
|
||||||
|
@ -14,10 +14,10 @@ import java.util.stream.Stream
|
|||||||
/**
|
/**
|
||||||
* Created by darksnake on 06-Jul-17.
|
* Created by darksnake on 06-Jul-17.
|
||||||
*/
|
*/
|
||||||
interface NumassPoint : Metoid, NumassBlock, Provider {
|
interface NumassPoint : Metoid, ParentBlock, Provider {
|
||||||
|
|
||||||
|
|
||||||
val blocks: List<NumassBlock>
|
override val blocks: List<NumassBlock>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides block with given number (starting with 0)
|
* Provides block with given number (starting with 0)
|
||||||
|
@ -76,8 +76,8 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
"showErrors" to false
|
"showErrors" to false
|
||||||
"connectionType" to "step"
|
"connectionType" to "step"
|
||||||
}.apply {
|
}.apply {
|
||||||
configure(inputMeta.getMetaOrEmpty("histogram"))
|
configure(inputMeta.getMetaOrEmpty("histogram"))
|
||||||
}.fillData(histogram)
|
}.fillData(histogram)
|
||||||
|
|
||||||
histPlot.add(histogramPlot)
|
histPlot.add(histogramPlot)
|
||||||
}
|
}
|
||||||
@ -103,7 +103,9 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
} else {
|
} else {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
if(Thread.currentThread().isInterrupted){
|
||||||
|
throw InterruptedException()
|
||||||
|
}
|
||||||
statPlot.append(
|
statPlot.append(
|
||||||
Adapters.buildXYDataPoint(
|
Adapters.buildXYDataPoint(
|
||||||
t / 1000.0,
|
t / 1000.0,
|
||||||
|
@ -19,19 +19,20 @@ fun main(args: Array<String>) {
|
|||||||
dataDir = "D:\\Work\\Numass\\data\\2018_04"
|
dataDir = "D:\\Work\\Numass\\data\\2018_04"
|
||||||
}
|
}
|
||||||
|
|
||||||
val storage = NumassStorageFactory.buildLocal(context, "Fill_2", true, false);
|
val storage = NumassStorageFactory.buildLocal(context, "Fill_3", true, false);
|
||||||
|
|
||||||
val meta = buildMeta {
|
val meta = buildMeta {
|
||||||
"binNum" to 200
|
"binNum" to 200
|
||||||
|
"t0Step" to 100
|
||||||
node("window") {
|
node("window") {
|
||||||
"lo" to 0
|
"lo" to 500
|
||||||
"up" to 4000
|
"up" to 4000
|
||||||
}
|
}
|
||||||
"plot.showErrors" to false
|
//"plot.showErrors" to false
|
||||||
}
|
}
|
||||||
|
|
||||||
//def sets = ((2..14) + (22..31)).collect { "set_$it" }
|
//def sets = ((2..14) + (22..31)).collect { "set_$it" }
|
||||||
val sets = (2..14).map { "set_$it" }
|
val sets = (13..14).map { "set_$it" }
|
||||||
//def sets = (16..31).collect { "set_$it" }
|
//def sets = (16..31).collect { "set_$it" }
|
||||||
//def sets = (20..28).collect { "set_$it" }
|
//def sets = (20..28).collect { "set_$it" }
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ fun main(args: Array<String>) {
|
|||||||
storage.provide("loader::$set", NumassSet::class.java).orElse(null)
|
storage.provide("loader::$set", NumassSet::class.java).orElse(null)
|
||||||
}.filter { it != null }
|
}.filter { it != null }
|
||||||
|
|
||||||
val hvs = listOf(14000.0, 14200.0, 14600.0, 14800.0)//, 15000d, 15200d, 15400d, 15600d, 15800d]
|
val hvs = listOf(12000.0, 13000.0, 14000.0, 15000.0)//, 15000d, 15200d, 15400d, 15600d, 15800d]
|
||||||
|
|
||||||
val all = NumassDataUtils.join("sum", loaders)
|
val all = NumassDataUtils.join("sum", loaders)
|
||||||
|
|
||||||
@ -60,7 +61,9 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
val result = TimeAnalyzerAction().run(context, data, meta);
|
val result = TimeAnalyzerAction().run(context, data, meta);
|
||||||
|
|
||||||
result.computeAll();
|
result.nodeGoal().run()
|
||||||
|
|
||||||
readLine()
|
readLine()
|
||||||
|
println("Canceling task")
|
||||||
|
result.nodeGoal().cancel()
|
||||||
}
|
}
|
@ -87,7 +87,7 @@ val monitorTableTask = task("monitor") {
|
|||||||
data.values.stream().parallel()
|
data.values.stream().parallel()
|
||||||
.flatMap { it.points.stream() }
|
.flatMap { it.points.stream() }
|
||||||
.filter { it.voltage == monitorVoltage }
|
.filter { it.voltage == monitorVoltage }
|
||||||
.map { it -> analyzer.analyzePoint(it, analyzerMeta) }
|
.map { it -> analyzer.analyzeParent(it, analyzerMeta) }
|
||||||
).build()
|
).build()
|
||||||
|
|
||||||
if (meta.getBoolean("showPlot", true)) {
|
if (meta.getBoolean("showPlot", true)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user