A lot of minor fixes in numass

This commit is contained in:
Alexander Nozik 2019-02-08 20:58:08 +03:00
parent 12114ffab3
commit b25c1dd0eb
6 changed files with 49 additions and 24 deletions

View File

@ -35,11 +35,11 @@ class NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
override fun fill(builder: DataNodeEditor<NumassSet>, context: Context, meta: Meta) {
runBlocking {
val storage = NumassDirectory.read(context,meta.getString("path")) as Storage
val storage = NumassDirectory.read(context, meta.getString("path")) as Storage
storage.sequence().forEach { pair ->
val value = pair.second
if (value is NumassSet) {
builder.putStatic(pair.first.unescaped, value)
builder.putStatic(pair.first.unescaped, value, value.meta)
}
}
}

View File

@ -45,12 +45,11 @@ object MergeDataAction : ManyToOneAction<Table, Table>("numass.merge", Table::cl
override fun buildGroups(context: Context, input: DataNode<Table>, actionMeta: Meta): List<DataNode<Table>> {
val meta = inputMeta(context, input.meta, actionMeta)
val groups: List<DataNode<Table>> = if (meta.hasValue("grouping.byValue")) {
return if (meta.hasValue("grouping.byValue")) {
super.buildGroups(context, input, actionMeta)
} else {
GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, input.name)).group(input)
}
return groups
}
override fun execute(context: Context, nodeName: String, data: Map<String, Table>, meta: Laminate): Table {

View File

@ -23,7 +23,7 @@ fun main(args: Array<String>) {
}
//val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
val storage = NumassDirectory.read(context, "Fill_3_events") ?: error("Storage not found")
val storage = NumassDirectory.read(context, "Fill_3") ?: error("Storage not found")
val analyzer = SmartAnalyzer()
@ -34,7 +34,7 @@ fun main(args: Array<String>) {
// "window.up" to 1600
}
val set = storage.provide("set_58", NumassSet::class.java).nullable ?: error("Set does not exist")
val set = storage.provide("set_4", NumassSet::class.java).nullable ?: error("Set does not exist")
val frame = displayChart("slices").apply {
plots.setType<DataPlot>()

View File

@ -36,7 +36,7 @@ import inr.numass.data.storage.NumassDirectory
import inr.numass.displayChart
import inr.numass.subthreshold.Threshold
fun main(args: Array<String>) {
fun main() {
val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) {
rootDir = "D:\\Work\\Numass\\sterile\\2017_05_frames"
dataDir = "D:\\Work\\Numass\\data\\2017_05_frames"
@ -54,7 +54,7 @@ fun main(args: Array<String>) {
"xLow" to 1000
"xHigh" to 1300
"upper" to 6000
"binning" to 20
"binning" to 32
//"reference" to 18600
}

View File

@ -35,19 +35,24 @@ import inr.numass.subthreshold.Threshold
fun main(args: Array<String>) {
val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) {
rootDir = "D:\\Work\\Numass\\sterile\\2017_05"
dataDir = "D:\\Work\\Numass\\data\\2017_05"
rootDir = "D:\\Work\\Numass\\sterile\\2017_05_frames"
dataDir = "D:\\Work\\Numass\\data\\2017_05_frames"
output = FXOutputManager() + DirectoryOutput()
}
val storage = NumassDirectory.read(context, "Fill_2") as? FileStorage ?: error("Storage not found")
val storage = NumassDirectory.read(context, "Fill_3") as? FileStorage ?: error("Storage not found")
val meta = buildMeta {
"delta" to -200
"delta" to -300
"method" to "pow"
"t0" to 15e3
"window.lo" to 400
"window.up" to 1600
// "window.lo" to 400
// "window.up" to 1600
"xLow" to 1000
"xHigh" to 1300
"upper" to 6000
"binning" to 32
//"reference" to 18600
}
val frame = displayChart("correction").apply {

View File

@ -1,10 +1,7 @@
package inr.numass.tasks
import hep.dataforge.configure
import hep.dataforge.data.CustomDataFilter
import hep.dataforge.data.DataSet
import hep.dataforge.data.DataTree
import hep.dataforge.data.DataUtils
import hep.dataforge.data.*
import hep.dataforge.io.output.stream
import hep.dataforge.io.render
import hep.dataforge.meta.Meta
@ -22,6 +19,7 @@ import hep.dataforge.stat.fit.FitResult
import hep.dataforge.stat.models.XYModel
import hep.dataforge.tables.*
import hep.dataforge.useMeta
import hep.dataforge.useValue
import hep.dataforge.values.ValueType
import hep.dataforge.values.Values
import hep.dataforge.values.asValue
@ -50,10 +48,17 @@ import java.util.stream.StreamSupport
import kotlin.collections.HashMap
import kotlin.collections.set
private val filterForward = DataFilter.byMetaValue("iteration_info.reverse") {
!(it?.boolean ?: false)
}
private val filterReverse = DataFilter.byMetaValue("iteration_info.reverse") {
it?.boolean ?: false
}
val selectTask = task("select") {
descriptor {
info = "Select data from initial data pool"
value("forward", types = listOf(ValueType.BOOLEAN), info = "Select only forward or only backward sets")
}
model { meta ->
data("*")
@ -61,9 +66,18 @@ val selectTask = task("select") {
}
transform<NumassSet> { data ->
logger.info("Starting selection from data node with size ${data.size}")
CustomDataFilter(meta).filter(data.checked(NumassSet::class.java)).also {
logger.info("Selected ${it.size} elements")
var res = data.checked(NumassSet::class.java).filter(CustomDataFilter(meta))
meta.useValue("forward") {
res = if (it.boolean) {
res.filter(filterForward)
} else {
res.filter(filterReverse)
}
}
logger.info("Selected ${res.size} elements")
res
}
}
@ -362,7 +376,15 @@ val histogramTask = task("histogram") {
}.sumByStep(NumassAnalyzer.CHANNEL_KEY, meta.getDouble("binning", 16.0)) //apply binning
// send raw table to the output
context.output.render(table, stage = "numass.histogram", name = name, meta = meta)
context.output.render(table, stage = "numass.histogram", name = name) {
update(meta)
data.toSortedMap().forEach { name, set ->
putNode("data", buildMeta {
"name" to name
set.meta.useMeta("iteration_info"){"iteration" to it}
})
}
}
if (meta.getBoolean("plot", false)) {
context.plotFrame("$name.plot", stage = "numass.histogram") {
@ -379,7 +401,6 @@ val histogramTask = task("histogram") {
}
}
return@join table
}
}
@ -397,8 +418,8 @@ val sliceTask = task("slice") {
val analyzer = SmartAnalyzer()
val slices = HashMap<String, IntRange>()
val formatBuilder = TableFormatBuilder()
formatBuilder.addColumn("set",ValueType.STRING)
formatBuilder.addColumn("time",ValueType.TIME)
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())