From 1aa7f0edf5f023fbef49d4dc60a33d95e29185ee Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 15 Jan 2018 16:49:56 +0300 Subject: [PATCH] build fix --- .../plotfit/PlotFitResultAction.java | 6 +-- .../src/main/java/inr/numass/Numass.java | 4 +- .../src/main/kotlin/inr/numass/NumassIO.kt | 8 ++-- .../main/kotlin/inr/numass/NumassPlugin.kt | 38 +++++++++---------- .../src/main/kotlin/inr/numass/NumassUtils.kt | 8 ++-- .../inr/numass/actions/TransformDataAction.kt | 4 +- .../numass/models/sterile/NumassResolution.kt | 4 +- .../models/sterile/NumassTransmission.kt | 2 +- .../numass/tasks/NumassFitScanSummaryTask.kt | 2 +- .../kotlin/inr/numass/tasks/NumassTasks.kt | 14 +++---- 10 files changed, 42 insertions(+), 48 deletions(-) diff --git a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java index 022928ec..780f5956 100644 --- a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java +++ b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java @@ -32,7 +32,6 @@ import hep.dataforge.tables.Adapters; import hep.dataforge.tables.NavigableValuesSource; import hep.dataforge.tables.ValuesAdapter; -import java.util.function.Function; import java.util.stream.StreamSupport; /** @@ -63,13 +62,12 @@ public class PlotFitResultAction extends OneToOneAction { throw new RuntimeException("No adapter defined for data interpretation"); } - Function function = (x) -> model.getSpectrum().value(x, input.getParameters()); PlotFrame frame = PlotUtils.getPlotManager(context) .getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty())); - XYFunctionPlot fit = new XYFunctionPlot("fit"); - fit.setDensity(100, false); + XYFunctionPlot fit = new XYFunctionPlot("fit",(x) -> model.getSpectrum().value(x, input.getParameters())); + fit.setDensity(100); fit.setSmoothing(true); // ensuring all data points are calculated explicitly StreamSupport.stream(data.spliterator(), false) diff --git a/numass-main/src/main/java/inr/numass/Numass.java b/numass-main/src/main/java/inr/numass/Numass.java index 7ac882d1..b28ca7be 100644 --- a/numass-main/src/main/java/inr/numass/Numass.java +++ b/numass-main/src/main/java/inr/numass/Numass.java @@ -48,7 +48,7 @@ public class Numass { .ln() .text("\t") .content( - MarkupUtils.INSTANCE.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read")) + MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read")) ) .ln() .text("***Allowed actions***", "red") @@ -60,7 +60,7 @@ public class Numass { am.getAllActions() .map(name -> am.optAction(name).get()) .map(ActionDescriptor::build).forEach(descriptor -> - builder.text("\t").content(MarkupUtils.INSTANCE.markupDescriptor(descriptor)) + builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor)) ); builder.text("***End of actions list***", "red"); diff --git a/numass-main/src/main/kotlin/inr/numass/NumassIO.kt b/numass-main/src/main/kotlin/inr/numass/NumassIO.kt index f8ab9f05..1030ee3e 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassIO.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassIO.kt @@ -126,7 +126,7 @@ class NumassIO : BasicIOManager() { // String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete")); outputFile = dir.resolve(fileName) - return if (context.getBoolean("numass.consoleOutput", false)!!) { + return if (context.getBoolean("numass.consoleOutput", false)) { TeeOutputStream(Files.newOutputStream(outputFile), System.out) } else { Files.newOutputStream(outputFile) @@ -153,10 +153,8 @@ fun FitResult.display(context: Context, stage: String = "fit") { val func = { x: Double -> model.spectrum.value(x, parameters) } - val fit = XYFunctionPlot("fit") - fit.setDensity(100, false) - fit.setSmoothing(true) - fit.setFunction(func) + val fit = XYFunctionPlot("fit",func) + fit.density = 100 // ensuring all data points are calculated explicitly data.rows.map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) } diff --git a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt index 0f016777..38b8cb26 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt @@ -81,8 +81,8 @@ class NumassPlugin : BasicPlugin() { } math.registerBivariate("numass.resolutionTail") { meta -> - val alpha = meta.getDouble("tailAlpha", 0.0)!! - val beta = meta.getDouble("tailBeta", 0.0)!! + val alpha = meta.getDouble("tailAlpha", 0.0) + val beta = meta.getDouble("tailBeta", 0.0) BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 } } @@ -121,9 +121,9 @@ class NumassPlugin : BasicPlugin() { // }); manager.addModel("scatter") { context, meta -> - val A = meta.getDouble("resolution", 8.3e-5)!!//8.3e-5 - val from = meta.getDouble("from", 0.0)!! - val to = meta.getDouble("to", 0.0)!! + val A = meta.getDouble("resolution", 8.3e-5)//8.3e-5 + val from = meta.getDouble("from", 0.0) + val to = meta.getDouble("to", 0.0) val sp: ModularSpectrum sp = if (from == to) { @@ -138,27 +138,27 @@ class NumassPlugin : BasicPlugin() { } manager.addModel("scatter-empiric") { context, meta -> - val eGun = meta.getDouble("eGun", 19005.0)!! + val eGun = meta.getDouble("eGun", 19005.0) val interpolator = buildInterpolator(context, meta, eGun) val loss = EmpiricalLossSpectrum(interpolator, eGun + 5) val spectrum = NBkgSpectrum(loss) - val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!! + val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0) WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor } } manager.addModel("scatter-empiric-variable") { context, meta -> - val eGun = meta.getDouble("eGun", 19005.0)!! + val eGun = meta.getDouble("eGun", 19005.0) //builder transmisssion with given data, annotation and smoothing val interpolator = buildInterpolator(context, meta, eGun) val loss = VariableLossSpectrum.withData(interpolator, eGun + 5) - val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!! + val tritiumBackground = meta.getDouble("tritiumBkg", 0.0) val spectrum: NBkgSpectrum if (tritiumBackground == 0.0) { @@ -167,17 +167,17 @@ class NumassPlugin : BasicPlugin() { spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground) } - val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!! + val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0) WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor } } manager.addModel("scatter-analytic-variable") { context, meta -> - val eGun = meta.getDouble("eGun", 19005.0)!! + val eGun = meta.getDouble("eGun", 19005.0) val loss = VariableLossSpectrum.withGun(eGun + 5) - val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!! + val tritiumBackground = meta.getDouble("tritiumBkg", 0.0) val spectrum: NBkgSpectrum if (tritiumBackground == 0.0) { @@ -190,18 +190,18 @@ class NumassPlugin : BasicPlugin() { } manager.addModel("scatter-empiric-experimental") { context, meta -> - val eGun = meta.getDouble("eGun", 19005.0)!! + val eGun = meta.getDouble("eGun", 19005.0) //builder transmisssion with given data, annotation and smoothing val interpolator = buildInterpolator(context, meta, eGun) - val smoothing = meta.getDouble("lossSmoothing", 0.3)!! + val smoothing = meta.getDouble("lossSmoothing", 0.3) val loss = ExperimentalVariableLossSpectrum.withData(interpolator, eGun + 5, smoothing) val spectrum = NBkgSpectrum(loss) - val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!! + val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0) WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor } } @@ -216,7 +216,7 @@ class NumassPlugin : BasicPlugin() { manager.addModel("gun") { context, meta -> val gsp = GunSpectrum() - val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!! + val tritiumBackground = meta.getDouble("tritiumBkg", 0.0) val spectrum: NBkgSpectrum if (tritiumBackground == 0.0) { @@ -234,10 +234,10 @@ class NumassPlugin : BasicPlugin() { val transXName = an.getString("transXName", "Uset") val transYName = an.getString("transYName", "CR") - val stitchBorder = an.getDouble("stitchBorder", eGun - 7)!! - val nSmooth = an.getInt("nSmooth", 15)!! + val stitchBorder = an.getDouble("stitchBorder", eGun - 7) + val nSmooth = an.getInt("nSmooth", 15) - val w = an.getDouble("w", 0.8)!! + val w = an.getDouble("w", 0.8) if (an.hasValue("transFile")) { val transmissionFile = an.getString("transFile") diff --git a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt index 416bdd42..47a8a5a2 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt @@ -141,10 +141,10 @@ object NumassUtils { set.points.forEach { point -> val pointMeta = MetaBuilder("point") .putValue("voltage", point.voltage) - .putValue("index", point.getMeta().getInt("external_meta.point_index", -1)) - .putValue("run", point.getMeta().getString("external_meta.session", "")) - .putValue("group", point.getMeta().getString("external_meta.group", "")) - val pointName = "point_" + point.getMeta().getInt("external_meta.point_index", point.hashCode())!! + .putValue("index", point.meta.getInt("external_meta.point_index", -1)) + .putValue("run", point.meta.getString("external_meta.session", "")) + .putValue("group", point.meta.getString("external_meta.group", "")) + val pointName = "point_" + point.meta.getInt("external_meta.point_index", point.hashCode()) builder.putData(pointName, point, pointMeta) } set.hvData.ifPresent { hv -> builder.putData("hv", hv, Meta.empty()) } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt index 8ea8210c..bf2f9a62 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt @@ -85,8 +85,8 @@ class TransformDataAction : OneToOneAction() { .mapToDouble { cor -> cor.relativeErr(point) } .reduce { d1, d2 -> d1 * d1 + d2 * d2 }.orElse(0.0) ) - val originalCR = point.getDouble(COUNT_RATE_KEY)!! - val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY)!! + val originalCR = point.getDouble(COUNT_RATE_KEY) + val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY) cr.add(originalCR * correctionFactor) if (relativeCorrectionError == 0.0) { crErr.add(originalCRErr * correctionFactor) diff --git a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt index 30a89e04..e4056aec 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt @@ -40,8 +40,8 @@ class NumassResolution(context: Context, meta: Meta) : AbstractParametricBiFunct } meta.hasValue("tailAlpha") -> { //add polynomial function here - val alpha = meta.getDouble("tailAlpha")!! - val beta = meta.getDouble("tailBeta", 0.0)!! + val alpha = meta.getDouble("tailAlpha") + val beta = meta.getDouble("tailBeta", 0.0) BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 } } diff --git a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt index 85a96f5a..f2cddb0d 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt @@ -24,7 +24,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun private val trapFunc: BivariateFunction //private val lossCache = HashMap() - private val adjustX: Boolean = meta.getBoolean("adjustX", false)!! + private val adjustX: Boolean = meta.getBoolean("adjustX", false) init { if (meta.hasValue("trapping")) { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt index b86eb20c..733fa300 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt @@ -51,7 +51,7 @@ class NumassFitScanSummaryTask : AbstractTask() { input.forEach { key, fitRes -> val pars = fitRes.parameters - val u2Val = pars.getDouble("U2")!! / pars.getError("U2") + val u2Val = pars.getDouble("U2") / pars.getError("U2") val limit: Double if (Math.abs(u2Val) < 3) { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index d4aef9ae..94c803c1 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -106,7 +106,7 @@ val analyzeTask = task("analyze") { } pipe { set -> SmartAnalyzer().analyzeSet(set, meta).also { res -> - val outputMeta = meta.builder.putNode("data",set.meta) + val outputMeta = meta.builder.putNode("data", set.meta) context.io.out("numass.analyze", name).use { NumassUtils.write(it, outputMeta, res) } @@ -209,8 +209,8 @@ val filterTask = task("filter") { } pipe { data -> if (meta.hasValue("from") || meta.hasValue("to")) { - val uLo = meta.getDouble("from", 0.0)!! - val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY)!! + val uLo = meta.getDouble("from", 0.0) + val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY) this.log.report("Filtering finished") TableTransform.filter(data, NumassPoint.HV_KEY, uLo, uHi) } else if (meta.hasValue("condition")) { @@ -264,17 +264,15 @@ val plotFitTask = task("plotFit") { val frame = PlotUtils.getPlotManager(context) .getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty())) - val fit = XYFunctionPlot("fit").apply { - setFunction(function) - setDensity(100, false) - setSmoothing(true) + val fit = XYFunctionPlot("fit", function).apply { + density = 100 } frame.add(fit) // ensuring all data points are calculated explicitly StreamSupport.stream(data.spliterator(), false) - .map { dp -> Adapters.getXValue(adapter,dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) } + .map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) } frame.add(DataPlot.plot("data", adapter, data))