Fix in logs and io. IOManager is now a genuine plugin

This commit is contained in:
Alexander Nozik 2016-11-18 15:43:09 +03:00
parent dd4c15f0a3
commit b62c5309e4
6 changed files with 20 additions and 29 deletions

View File

@ -15,6 +15,10 @@ println cli.usage
String cfgPath = cli.parse(args).c; String cfgPath = cli.parse(args).c;
println "Loading config file from $cfgPath" println "Loading config file from $cfgPath"
//println "Starting numass plugin in GLOBAL"
//Global.instance().pluginManager().loadPlugin("inr.numass:numass")
println "Starting Grind shell"
try { try {
new GrindShell().launch { new GrindShell().launch {
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder() GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder()
@ -25,5 +29,5 @@ try {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
Global.instance().close(); Global.terminate();
} }

View File

@ -21,7 +21,7 @@ import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.XMLMetaWriter; import hep.dataforge.io.XMLMetaWriter;
import hep.dataforge.io.reports.Reportable; import hep.dataforge.io.reports.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.tables.*; import hep.dataforge.tables.*;
@ -142,7 +142,7 @@ public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
* @param meta * @param meta
* @return * @return
*/ */
private double correction(Reportable log, NMPoint point, Laminate meta) { private double correction(Logable log, NMPoint point, Laminate meta) {
if (meta.hasValue("correction")) { if (meta.hasValue("correction")) {
// log.report("Using correction from formula: {}", meta.getString("correction")); // log.report("Using correction from formula: {}", meta.getString("correction"));
return evaluateExpression(point, meta.getString("correction")); return evaluateExpression(point, meta.getString("correction"));

View File

@ -6,17 +6,13 @@
package inr.numass.models.sterile; package inr.numass.models.sterile;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.stat.fit.ParamSet;
import hep.dataforge.stat.parametric.ParametricFunction;
import hep.dataforge.maths.MathPlugin; import hep.dataforge.maths.MathPlugin;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.stat.fit.ParamSet;
import hep.dataforge.stat.parametric.ParametricFunction;
import inr.numass.Numass; import inr.numass.Numass;
import inr.numass.models.BetaSpectrum; import inr.numass.models.*;
import inr.numass.models.ModularSpectrum;
import inr.numass.models.NBkgSpectrum;
import inr.numass.models.RangedNamedSetSpectrum;
import inr.numass.models.ResolutionFunction;
import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.BivariateFunction;
/** /**
@ -70,7 +66,7 @@ public class TestModels {
double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5 double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5
double from = meta.getDouble("from", 13900d); double from = meta.getDouble("from", 13900d);
double to = meta.getDouble("to", 18700d); double to = meta.getDouble("to", 18700d);
context.getReport().report("Setting up tritium model with real transmission function"); context.getLog().report("Setting up tritium model with real transmission function");
BivariateFunction resolutionTail; BivariateFunction resolutionTail;
if (meta.hasValue("resolution.tailAlpha")) { if (meta.hasValue("resolution.tailAlpha")) {
resolutionTail = ResolutionFunction.getAngledTail(meta.getDouble("resolution.tailAlpha"), meta.getDouble("resolution.tailBeta", 0)); resolutionTail = ResolutionFunction.getAngledTail(meta.getDouble("resolution.tailAlpha"), meta.getDouble("resolution.tailBeta", 0));
@ -81,7 +77,7 @@ public class TestModels {
RangedNamedSetSpectrum beta = new BetaSpectrum(); RangedNamedSetSpectrum beta = new BetaSpectrum();
ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to); ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to);
if (meta.getBoolean("caching", false)) { if (meta.getBoolean("caching", false)) {
context.getReport().report("Caching turned on"); context.getLog().report("Caching turned on");
sp.setCaching(true); sp.setCaching(true);
} }
//Adding trapping energy dependence //Adding trapping energy dependence

View File

@ -5,20 +5,21 @@
*/ */
package inr.numass.utils; package inr.numass.utils;
import hep.dataforge.io.reports.Reportable; import hep.dataforge.io.reports.Logable;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.tables.ListTable; import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import inr.numass.storage.NMPoint; import inr.numass.storage.NMPoint;
import inr.numass.storage.NumassData; import inr.numass.storage.NumassData;
import inr.numass.storage.RawNMPoint; import inr.numass.storage.RawNMPoint;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.math3.analysis.ParametricUnivariateFunction; import org.apache.commons.math3.analysis.ParametricUnivariateFunction;
import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.fitting.SimpleCurveFitter; import org.apache.commons.math3.fitting.SimpleCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoint; import org.apache.commons.math3.fitting.WeightedObservedPoint;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* A class to calculate underflow correction * A class to calculate underflow correction
* *
@ -26,7 +27,7 @@ import org.apache.commons.math3.fitting.WeightedObservedPoint;
*/ */
public class UnderflowCorrection { public class UnderflowCorrection {
public double get(Reportable log, Meta meta, NMPoint point) { public double get(Logable log, Meta meta, NMPoint point) {
if (point.getUset() >= meta.getDouble("underflow.threshold", 17000)) { if (point.getUset() >= meta.getDouble("underflow.threshold", 17000)) {
if (meta.hasValue("underflow.function")) { if (meta.hasValue("underflow.function")) {
return TritiumUtils.evaluateExpression(point, meta.getString("underflow.function")); return TritiumUtils.evaluateExpression(point, meta.getString("underflow.function"));

View File

@ -167,7 +167,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
// setting io manager // setting io manager
context.setIO(new WorkbenchIOManager(new NumassIO(), this)); context.setIO(new WorkbenchIOManager(new NumassIO(), this));
buildContextPane(); buildContextPane();
context.getReport().addReportListener(new FXReportListener(logPane)); context.getLog().addListener(new FXReportListener(logPane));
// display plots iside workbench // display plots iside workbench
PlotsPlugin.buildFrom(context).setPlotHolderDelegate(this); PlotsPlugin.buildFrom(context).setPlotHolderDelegate(this);

View File

@ -5,7 +5,7 @@
*/ */
package inr.numass.workbench; package inr.numass.workbench;
import hep.dataforge.context.Context; import hep.dataforge.io.BasicIOManager;
import hep.dataforge.io.IOManager; import hep.dataforge.io.IOManager;
import hep.dataforge.names.Name; import hep.dataforge.names.Name;
import org.apache.commons.io.output.TeeOutputStream; import org.apache.commons.io.output.TeeOutputStream;
@ -18,7 +18,7 @@ import java.io.OutputStream;
* An IOManager wrapper that redirects output to appropriate FX components * An IOManager wrapper that redirects output to appropriate FX components
* @author Alexander Nozik <altavir@gmail.com> * @author Alexander Nozik <altavir@gmail.com>
*/ */
public class WorkbenchIOManager implements IOManager { public class WorkbenchIOManager extends BasicIOManager {
private final IOManager manager; private final IOManager manager;
private final StagePaneHolder holder; private final StagePaneHolder holder;
@ -28,16 +28,6 @@ public class WorkbenchIOManager implements IOManager {
this.holder = holder; this.holder = holder;
} }
@Override
public Context getContext() {
return manager.getContext();
}
@Override
public void setContext(Context context) {
manager.setContext(context);
}
@Override @Override
public File getFile(String path) { public File getFile(String path) {
return manager.getFile(path); return manager.getFile(path);