Minor fixes

This commit is contained in:
Alexander Nozik 2018-06-21 16:28:44 +03:00
parent 1b3e48c94f
commit 66fc5f0f3c
10 changed files with 21 additions and 31 deletions

View File

@ -113,14 +113,9 @@ class NumassDataLoader(
TODO()
}
override fun respond(message: Envelope): Envelope {
throw TODO("Not supported yet.")
}
override val startTime: Instant
get() = meta.optValue("start_time").map<Instant> { it.time }.orElseGet { super.startTime }
override val isOpen: Boolean
get() = true

View File

@ -195,10 +195,10 @@ fun getFSS(context: Context, meta: Meta): FSS? {
fun pointExpression(expression: String, point: Values): Double {
val exprParams = HashMap<String, Any>()
//Adding all point values to expression parameters
point.names.forEach { name -> exprParams.put(name, point.getValue(name).value) }
point.names.forEach { name -> exprParams[name] = point.getValue(name).value }
//Adding aliases for commonly used parameters
exprParams.put("T", point.getDouble("length"))
exprParams.put("U", point.getDouble("voltage"))
exprParams["T"] = point.getDouble("length")
exprParams["U"] = point.getDouble("voltage")
return ExpressionUtils.function(expression, exprParams)
}
@ -252,7 +252,7 @@ fun Values.unbox(): Map<String, Any?> {
val res = HashMap<String, Any?>()
for (field in this.names) {
val value = this.getValue(field)
res.put(field, value.value)
res[field] = value.value
}
return res
}

View File

@ -22,7 +22,7 @@ import inr.numass.data.api.NumassSet
ValueDef(key = "window.lo", type = arrayOf(NUMBER, STRING), def = "0", info = "Lower bound for window"),
ValueDef(key = "window.up", type = arrayOf(NUMBER, STRING), def = "10000", info = "Upper bound for window")
)
class AnalyzeDataAction : OneToOneAction<NumassSet, Table>() {
object AnalyzeDataAction : OneToOneAction<NumassSet, Table>() {
override fun execute(context: Context, name: String, input: NumassSet, inputMeta: Laminate): Table {
//TODO add processor here
val analyzer = NumassAnalyzer.DEFAULT_ANALYZER

View File

@ -39,7 +39,7 @@ import java.util.*
*/
@TypedActionDef(name = "numass.merge", inputType = Table::class, outputType = Table::class, info = "Merge different numass data files into one.")
@NodeDef(key = "grouping", info = "The definition of grouping rule for this merge", from = "method::hep.dataforge.actions.GroupBuilder.byMeta")
class MergeDataAction : ManyToOneAction<Table, Table>() {
object MergeDataAction : ManyToOneAction<Table, Table>() {
private val parnames = arrayOf(NumassPoint.HV_KEY, NumassPoint.LENGTH_KEY, NumassAnalyzer.COUNT_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_ERROR_KEY)
@ -123,8 +123,6 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
}
companion object {
const val MERGE_NAME = "mergeName"
}
const val MERGE_NAME = "mergeName"
}

View File

@ -36,7 +36,7 @@ import java.util.stream.StreamSupport
*/
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState::class, outputType = FitState::class)
@NodeDef(key = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
class PlotFitResultAction : OneToOneAction<FitResult, FitResult>() {
object PlotFitResultAction : OneToOneAction<FitResult, FitResult>() {
override fun execute(context: Context, name: String, input: FitResult, metaData: Laminate): FitResult {

View File

@ -34,7 +34,7 @@ import kotlin.streams.asStream
NodeDef(key = "plot", info = "Configuration for stat plots")
)
@TypedActionDef(name = "timeSpectrum", inputType = NumassPoint::class, outputType = Table::class)
class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
object TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
private val analyzer = TimeAnalyzer();
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {

View File

@ -33,7 +33,7 @@ import kotlin.streams.asStream
NodeDef(key = "plot", info = "Configuration for stat plots")
)
@TypedActionDef(name = "numass.timeSpectrum", inputType = NumassPoint::class, outputType = Table::class)
class TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
object TimeSpectrumAction : OneToOneAction<NumassPoint, Table>() {
private val analyzer = TimeAnalyzer();
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {

View File

@ -35,7 +35,7 @@ import java.util.*
ValueDef(key = "utransform", info = "Expression for voltage transformation. Uses U as input")
)
@NodeDef(key = "correction", multiple = true, from = "method::inr.numass.actions.TransformDataAction.makeCorrection")
class TransformDataAction : OneToOneAction<Table, Table>() {
object TransformDataAction : OneToOneAction<Table, Table>() {
override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table {
@ -103,7 +103,7 @@ class TransformDataAction : OneToOneAction<Table, Table>() {
val res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).format, cr.stream()))
.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).format, crErr.stream()))
context.output.get("", name).render(NumassUtils.wrap(res, meta))
context.output["", name].render(NumassUtils.wrap(res, meta))
return res
}

View File

@ -76,7 +76,7 @@ class SterileNeutrinoSpectrum @JvmOverloads constructor(
/**
* Direct Gauss-Legandre integration
* Direct Gauss-Legendre integration
*
* @param u
* @param sourceFunction
@ -98,9 +98,7 @@ class SterileNeutrinoSpectrum @JvmOverloads constructor(
val fsSource: (Double) -> Double = fss?.let { fss ->
{ eIn: Double ->
(0 until fss.size()).sumByDouble { fss.getP(it) * sourceFunction.value(fss.getE(it), eIn, set) }
}
{ eIn: Double -> (0 until fss.size()).sumByDouble { fss.getP(it) * sourceFunction.value(fss.getE(it), eIn, set) } }
} ?: { eIn: Double -> sourceFunction.value(0.0, eIn, set) }

View File

@ -25,7 +25,7 @@ import hep.dataforge.values.ValueType
import hep.dataforge.values.Values
import inr.numass.NumassUtils
import inr.numass.actions.MergeDataAction
import inr.numass.actions.MergeDataAction.Companion.MERGE_NAME
import inr.numass.actions.MergeDataAction.MERGE_NAME
import inr.numass.actions.TransformDataAction
import inr.numass.addSetMarkers
import inr.numass.data.analyzers.SmartAnalyzer
@ -44,7 +44,7 @@ val selectTask = task("select") {
}
transform<NumassSet> { data ->
logger.info("Starting selection from data node with size ${data.size}")
CustomDataFilter(meta).filter<NumassSet>(data.checked(NumassSet::class.java)).also {
CustomDataFilter(meta).filter(data.checked(NumassSet::class.java)).also {
logger.info("Selected ${it.size} elements")
}
}
@ -99,7 +99,7 @@ val monitorTableTask = task("monitor") {
((context.output["numass.monitor", name] as? PlotOutput)?.frame as? JFreeChartFrame)?.addSetMarkers(data.values)
}
context.output.get("numass.monitor", name).render(NumassUtils.wrap(res, meta))
context.output["numass.monitor", name].render(NumassUtils.wrap(res, meta))
return@join res;
}
@ -110,7 +110,7 @@ val mergeTask = task("merge") {
dependsOn(analyzeTask, meta)
configure(meta.getMetaOrEmpty("merge"))
}
action<Table, Table>(MergeDataAction())
action<Table, Table>(MergeDataAction)
}
val mergeEmptyTask = task("empty") {
@ -147,7 +147,7 @@ val subtractEmptyTask = task("dif") {
val empty = data.getCheckedNode("empty", Table::class.java).data
?: throw RuntimeException("No empty data found")
rootNode.visit(Table::class.java, { input ->
rootNode.visit(Table::class.java) { input ->
val resMeta = buildMeta {
putNode("data", input.meta)
putNode("empty", empty.meta)
@ -163,7 +163,7 @@ val subtractEmptyTask = task("dif") {
}
builder.putData(input.name, res)
})
}
builder.build()
}
}
@ -179,9 +179,8 @@ val transformTask = task("transform") {
} else {
dependsOn(analyzeTask, meta);
}
configure(MetaUtils.optEither(meta, "transform", "prepare").orElse(Meta.empty()))
}
action<Table, Table>(TransformDataAction())
action<Table, Table>(TransformDataAction)
}
val filterTask = task("filter") {