A lot of minor fixes. Moving some code to kotlin

This commit is contained in:
Alexander Nozik 2017-12-17 13:43:37 +03:00
parent 467f0fadfc
commit 5e8db547eb
7 changed files with 52 additions and 27 deletions

View File

@ -23,6 +23,7 @@ allprojects{
dependencies{
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.10"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.10"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: '1.2.10'
}

View File

@ -169,9 +169,14 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces
* @return
*/
fun getEventsWithDelay(block: NumassBlock, config: Meta): Stream<Pair<NumassEvent, Long>> {
val inverted = config.getBoolean("inverted",false)
return super.getEvents(block, config).asSequence().zipWithNext { prev, next ->
val delay = Math.max(next.timeOffset - prev.timeOffset, 0)
if(inverted) {
Pair(next, delay)
} else{
Pair(prev, delay)
}
}.asStream()
}

View File

@ -0,0 +1,30 @@
/*
* Copyright 2017 Alexander Nozik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package inr.numass.scripts.temp
import hep.dataforge.context.Context
import hep.dataforge.context.Global
import hep.dataforge.fx.plots.PlotManager
import hep.dataforge.grind.GrindShell
import hep.dataforge.grind.helpers.PlotHelper
Context ctx = Global.instance()
ctx.getPluginManager().load(PlotManager)
new GrindShell(ctx).eval {
(plots as PlotHelper).plotFunction(0,1){Math.sin it}
}

View File

@ -13,7 +13,6 @@ import inr.numass.data.NumassDataUtils
import inr.numass.data.api.NumassPoint
import inr.numass.data.api.NumassSet
import inr.numass.data.api.SimpleNumassPoint
import inr.numass.data.storage.NumassStorage
import inr.numass.data.storage.NumassStorageFactory
/**
@ -26,12 +25,11 @@ ctx.getPluginManager().load(PlotManager)
ctx.getPluginManager().load(NumassPlugin)
new GrindShell(ctx).eval {
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
NumassStorage storage = NumassStorageFactory.buildLocal(rootDir);
def storage = NumassStorageFactory.buildLocal(ctx, "D:\\Work\\Numass\\data\\2017_05\\Fill_2", true, false);
Meta meta = Grind.buildMeta(binNum: 200) {
window(lo: 500, up: 1800)
Meta meta = Grind.buildMeta(binNum: 200, inverted: true) {
window(lo: 500, up: 3000)
plot(showErrors: false)
}
@ -44,7 +42,7 @@ new GrindShell(ctx).eval {
storage.provide("loader::$set", NumassSet.class).orElse(null)
}.findAll { it != null }
def hvs = [14000d, 14200d, 14600d, 14800d, 15000d, 15200d, 15400d, 15600d, 15800d, 16000d]
def hvs = [14000d]//[14000d, 14200d, 14600d, 14800d, 15000d, 15200d, 15400d, 15600d, 15800d]
def all = NumassDataUtils.join("sum", loaders)
@ -74,5 +72,5 @@ new GrindShell(ctx).eval {
result.computeAll();
storage.close()
// storage.close()
}

View File

@ -19,6 +19,7 @@ import hep.dataforge.actions.ActionManager
import hep.dataforge.context.BasicPlugin
import hep.dataforge.context.Context
import hep.dataforge.context.PluginDef
import hep.dataforge.fx.FXPlugin
import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.maths.MathPlugin
import hep.dataforge.meta.Meta
@ -280,6 +281,6 @@ class NumassPlugin : BasicPlugin() {
fun displayJFreeChart(title: String, width: Double = 800.0, height: Double = 600.0, meta: Meta = Meta.empty()): JFreeChartFrame {
val frame = JFreeChartFrame(meta)
frame.configureValue("title", title)
PlotContainer.display(frame, title, width, height)
FXPlugin().apply { startGlobal() }.display (PlotContainer(frame))
return frame
}

View File

@ -3,7 +3,6 @@ package inr.numass.actions
import hep.dataforge.actions.OneToOneAction
import hep.dataforge.context.Context
import hep.dataforge.description.*
import hep.dataforge.kodex.buildMeta
import hep.dataforge.kodex.configure
import hep.dataforge.maths.histogram.UnivariateHistogram
import hep.dataforge.meta.Laminate
@ -39,17 +38,13 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
val log = getLog(context, name);
val t0 = inputMeta.getDouble("t0", 30e3);
//val t0 = inputMeta.getDouble("t0", 30e3);
val loChannel = inputMeta.getInt("window.lo", 500);
val upChannel = inputMeta.getInt("window.up", 10000);
val pm = context.getFeature(PlotPlugin::class.java);
val trueCR = analyzer.analyze(input, buildMeta {
"t0" to t0
"window.lo" to loChannel
"window.up" to upChannel
}).getDouble("cr")
val trueCR = analyzer.analyze(input, inputMeta).getDouble("cr")
log.report("The expected count rate for 30 us delay is $trueCR")
@ -86,11 +81,10 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
"showSymbol" to false
"showErrors" to false
"connectionType" to "step"
node("@adapter") {
"y.value" to "count"
}
}.apply { configure(inputMeta.getMetaOrEmpty("histogram")) }
.fillData(histogram)
}.apply {
adapter = Adapters.buildXYAdapter("x", "count")
configure(inputMeta.getMetaOrEmpty("histogram"))
}.fillData(histogram)
histPlot.add(histogramPlot)
}
@ -108,11 +102,7 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
pm.getPlotFrame(getName(), "stat-method").add(statPlot)
(1..100).map { 1000 * it }.map { t ->
val result = analyzer.analyze(input, buildMeta {
"t0" to t
"window.lo" to loChannel
"window.up" to upChannel
})
val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t))
val norm = if (inputMeta.getBoolean("normalize", true)) {

View File

@ -42,7 +42,7 @@ class AmplitudeView(
"title" to "count rate"
"units" to "Hz"
}
"legend.show" to false
"legend.showComponent" to false
}
val binningProperty = SimpleObjectProperty<Int>(20)