[no commit message]

This commit is contained in:
Alexander Nozik 2016-04-30 16:13:50 +03:00
parent ac8340006d
commit 36fd859c8e
20 changed files with 101 additions and 63 deletions

View File

@ -24,7 +24,6 @@ import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotsPlugin;
@ -34,22 +33,23 @@ import hep.dataforge.plots.data.PlottableFunction;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
import hep.dataforge.tables.PointSource; import hep.dataforge.tables.PointSource;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
* @author darksnake * @author darksnake
*/ */
@TypedActionDef(name = "plotFit", description = "Plot fit result", inputType = FitState.class, outputType = FitState.class) @TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class)
@NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.") @NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.") @ValueDef(name = "plotTitle", def = "", info = "The title of the plot.")
public class PlotFitResultAction extends OneToOneAction<FitState, FitState> { public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
@Override @Override
protected FitState execute(Context context,Logable log, String name, Laminate metaData, FitState input) { protected FitState execute(Context context,Reportable log, String name, Laminate metaData, FitState input) {
PointSource data = input.getDataSet(); PointSource data = input.getDataSet();
if (!(input.getModel() instanceof XYModel)) { if (!(input.getModel() instanceof XYModel)) {
log.logError("The fit model should be instance of XYModel for this action. Action failed!"); log.reportError("The fit model should be instance of XYModel for this action. Action failed!");
return input; return input;
} }
XYModel model = (XYModel) input.getModel(); XYModel model = (XYModel) input.getModel();

View File

@ -43,6 +43,18 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *

View File

@ -11,13 +11,13 @@ import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.ListTable; import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.MapPoint;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import hep.dataforge.tables.PointSource; import hep.dataforge.tables.PointSource;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* Adjust errors for all numass points in the dataset * Adjust errors for all numass points in the dataset
@ -28,7 +28,7 @@ import hep.dataforge.tables.Table;
public class AdjustErrorsAction extends OneToOneAction<Table, Table> { public class AdjustErrorsAction extends OneToOneAction<Table, Table> {
@Override @Override
protected Table execute(Context context, Logable log, String name, Laminate meta, Table input) { protected Table execute(Context context, Reportable log, String name, Laminate meta, Table input) {
List<DataPoint> points = new ArrayList<>(); List<DataPoint> points = new ArrayList<>();
for (DataPoint dp : input) { for (DataPoint dp : input) {
points.add(evalPoint(meta, dp)); points.add(evalPoint(meta, dp));

View File

@ -20,13 +20,13 @@ import hep.dataforge.context.Context;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import inr.numass.data.RawNMFile; import inr.numass.data.RawNMFile;
import inr.numass.data.RawNMPoint; import inr.numass.data.RawNMPoint;
import inr.numass.debunch.DebunchReport; import inr.numass.debunch.DebunchReport;
import inr.numass.debunch.FrameAnalizer; import inr.numass.debunch.FrameAnalizer;
import java.io.PrintWriter; import java.io.PrintWriter;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -41,8 +41,8 @@ import java.io.PrintWriter;
public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> { public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
@Override @Override
protected RawNMFile execute(Context context, Logable log, String name, Laminate meta, RawNMFile source) throws ContentException { protected RawNMFile execute(Context context, Reportable log, String name, Laminate meta, RawNMFile source) throws ContentException {
log.log("File {} started", source.getName()); log.report("File {} started", source.getName());
int upper = meta.getInt("upperchanel", RawNMPoint.MAX_CHANEL); int upper = meta.getInt("upperchanel", RawNMPoint.MAX_CHANEL);
int lower = meta.getInt("lowerchanel", 0); int lower = meta.getInt("lowerchanel", 0);
@ -57,7 +57,7 @@ public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
if (cr < maxCR) { if (cr < maxCR) {
DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point); DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
log.log("Debunching file '{}', point '{}': {} percent events {} percent time in bunches", log.report("Debunching file '{}', point '{}': {} percent events {} percent time in bunches",
source.getName(), point.getUset(), report.eventsFiltred() * 100, report.timeFiltred() * 100); source.getName(), point.getUset(), report.eventsFiltred() * 100, report.timeFiltred() * 100);
point = report.getPoint(); point = report.getPoint();
} }
@ -65,9 +65,9 @@ public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
}).forEach((point) -> { }).forEach((point) -> {
res.putPoint(point); res.putPoint(point);
}); });
log.log("File {} completed", source.getName()); log.report("File {} completed", source.getName());
log.getLog().print(new PrintWriter(buildActionOutput(context, name))); log.getReport().print(new PrintWriter(buildActionOutput(context, name)));
// res.configure(source.meta()); // res.configure(source.meta());
return res; return res;

View File

@ -20,12 +20,12 @@ import hep.dataforge.context.Context;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import inr.numass.data.NMFile; import inr.numass.data.NMFile;
import inr.numass.data.NMPoint; import inr.numass.data.NMPoint;
import java.io.OutputStream; import java.io.OutputStream;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -35,8 +35,8 @@ import java.io.OutputStream;
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> { public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
@Override @Override
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException { protected NMFile execute(Context context, Reportable log, String name, Laminate meta, NMFile source) throws ContentException {
log.log("File {} started", source.getName()); log.report("File {} started", source.getName());
int upperBorder = meta.getInt("upper", 4096); int upperBorder = meta.getInt("upper", 4096);
int lowerBorder = meta.getInt("lower", 0); int lowerBorder = meta.getInt("lower", 0);
@ -46,7 +46,7 @@ public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
if (substractReference > 0) { if (substractReference > 0) {
referencePoint = source.getByUset(substractReference); referencePoint = source.getByUset(substractReference);
if (referencePoint == null) { if (referencePoint == null) {
log.log("Reference point {} not found", substractReference); log.report("Reference point {} not found", substractReference);
} }
} }
@ -56,7 +56,7 @@ public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
ColumnedDataWriter.writeDataSet(stream, bData, String.format("%s : lower = %d upper = %d", source.getName(), lowerBorder, upperBorder)); ColumnedDataWriter.writeDataSet(stream, bData, String.format("%s : lower = %d upper = %d", source.getName(), lowerBorder, upperBorder));
log.log("File {} completed", source.getName()); log.report("File {} completed", source.getName());
return source; return source;
} }

View File

@ -22,7 +22,6 @@ import hep.dataforge.data.DataNode;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
@ -36,12 +35,13 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
* @author Darksnake * @author Darksnake
*/ */
@TypedActionDef(name = "merge", inputType = Table.class, outputType = Table.class, description = "Merge different numass data files into one.") @TypedActionDef(name = "merge", inputType = Table.class, outputType = Table.class, info = "Merge different numass data files into one.")
@NodeDef(name = "grouping", info = "The defenition of grouping rule for this merge", target = "method::hep.dataforge.actions.GroupBuilder.byAnnotation") @NodeDef(name = "grouping", info = "The defenition of grouping rule for this merge", target = "method::hep.dataforge.actions.GroupBuilder.byAnnotation")
public class MergeDataAction extends ManyToOneAction<Table, Table> { public class MergeDataAction extends ManyToOneAction<Table, Table> {
@ -62,13 +62,13 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
} }
@Override @Override
protected Table execute(Context context, Logable log, String nodeName, Map<String, Table> data, Meta meta) { protected Table execute(Context context, Reportable log, String nodeName, Map<String, Table> data, Meta meta) {
Table res = mergeDataSets(nodeName, data.values()); Table res = mergeDataSets(nodeName, data.values());
return new ListTable(res.getFormat(),res.sort("Uset", true)); return new ListTable(res.getFormat(),res.sort("Uset", true));
} }
@Override @Override
protected void afterGroup(Context context, Logable log, String groupName, Meta outputMeta, Table output) { protected void afterGroup(Context context, Reportable log, String groupName, Meta outputMeta, Table output) {
OutputStream stream = buildActionOutput(context, groupName); OutputStream stream = buildActionOutput(context, groupName);
ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString()); ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString());
} }
@ -76,7 +76,7 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
@Override @Override
protected MetaBuilder outputMeta(DataNode<Table> input) { protected MetaBuilder outputMeta(DataNode<Table> input) {
String numassPath = input.stream().<String>map(item -> item.getValue().meta().getString("numass.path", null)) String numassPath = input.dataStream().<String>map(item -> item.getValue().meta().getString("numass.path", null))
.reduce("", (String path, String newPath) -> { .reduce("", (String path, String newPath) -> {
if (path == null) { if (path == null) {
return null; return null;

View File

@ -24,7 +24,6 @@ import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; 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.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
@ -38,6 +37,7 @@ import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import hep.dataforge.tables.PointSource; import hep.dataforge.tables.PointSource;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -55,13 +55,13 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
//FIXME remove from state //FIXME remove from state
@Override @Override
protected Table execute(Context context, Logable log, String name, Laminate meta, Table sourceData) throws ContentException { protected Table execute(Context context, Reportable log, String name, Laminate meta, Table sourceData) throws ContentException {
double monitor = meta.getDouble("monitorPoint", Double.NaN); double monitor = meta.getDouble("monitorPoint", Double.NaN);
TreeMap<LocalDateTime, DataPoint> index = getMonitorIndex(monitor, sourceData); TreeMap<LocalDateTime, DataPoint> index = getMonitorIndex(monitor, sourceData);
if (index.isEmpty()) { if (index.isEmpty()) {
log.logError("No monitor points found"); log.reportError("No monitor points found");
return sourceData; return sourceData;
} }
double norm = 0; double norm = 0;

View File

@ -26,7 +26,6 @@ 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.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import inr.numass.data.NMFile; import inr.numass.data.NMFile;
@ -37,6 +36,7 @@ import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -59,7 +59,7 @@ public class PrepareDataAction extends OneToOneAction<NMFile, Table> {
} }
@Override @Override
protected ListTable execute(Context context, Logable log, String name, Laminate meta, NMFile dataFile) { protected ListTable execute(Context context, Reportable log, String name, Laminate meta, NMFile dataFile) {
// log.logString("File %s started", dataFile.getName()); // log.logString("File %s started", dataFile.getName());
int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1); int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);

View File

@ -22,19 +22,19 @@ import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import static inr.numass.NumassIO.getNumassData; import static inr.numass.NumassIO.getNumassData;
import inr.numass.data.NMFile; import inr.numass.data.NMFile;
import inr.numass.data.RawNMFile; import inr.numass.data.RawNMFile;
import java.io.File; import java.io.File;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
* @author Darksnake * @author Darksnake
*/ */
@TypedActionDef(name = "readData", @TypedActionDef(name = "readData",
inputType = Binary.class, outputType = NMFile.class, description = "Read binary numass data file") inputType = Binary.class, outputType = NMFile.class, info = "Read binary numass data file")
@ValueDef(name = "fileName", info = "The name of the file. By default equals file name.") @ValueDef(name = "fileName", info = "The name of the file. By default equals file name.")
@ValueDef(name = "HVdev", info = "Divider for HV measurements. Should be set to 1.0 for numass data 2014", @ValueDef(name = "HVdev", info = "Divider for HV measurements. Should be set to 1.0 for numass data 2014",
def = "2.468555393226049", type = "NUMBER") def = "2.468555393226049", type = "NUMBER")
@ -43,7 +43,7 @@ import java.io.File;
public class ReadNumassDataAction extends OneToOneAction<Binary, NMFile> { public class ReadNumassDataAction extends OneToOneAction<Binary, NMFile> {
@Override @Override
protected NMFile execute(Context context, Logable log, String name, Laminate meta, Binary source) throws ContentException { protected NMFile execute(Context context, Reportable log, String name, Laminate meta, Binary source) throws ContentException {
// log.logString("File '%s' started", source.getName()); // log.logString("File '%s' started", source.getName());
RawNMFile raw = getNumassData(source, meta); RawNMFile raw = getNumassData(source, meta);
if (meta.getBoolean("paw", false)) { if (meta.getBoolean("paw", false)) {

View File

@ -28,7 +28,6 @@ import hep.dataforge.datafitter.models.Histogram;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.PrintFunction; import hep.dataforge.io.PrintFunction;
import hep.dataforge.io.log.Logable;
import hep.dataforge.maths.GridCalculator; import hep.dataforge.maths.GridCalculator;
import hep.dataforge.maths.NamedDoubleSet; import hep.dataforge.maths.NamedDoubleSet;
import hep.dataforge.maths.NamedMatrix; import hep.dataforge.maths.NamedMatrix;
@ -54,19 +53,20 @@ import org.apache.commons.math3.stat.StatUtils;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
* @author darksnake * @author darksnake
*/ */
@TypedActionDef(name = "showLoss", inputType = FitState.class, outputType = FitState.class, @TypedActionDef(name = "showLoss", inputType = FitState.class, outputType = FitState.class,
description = "Show loss spectrum for fit with loss model. Calculate excitation to ionisation ratio.") info = "Show loss spectrum for fit with loss model. Calculate excitation to ionisation ratio.")
public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> { public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
private static final String[] names = {"X", "exPos", "ionPos", "exW", "ionW", "exIonRatio"}; private static final String[] names = {"X", "exPos", "ionPos", "exW", "ionW", "exIonRatio"};
@Override @Override
protected FitState execute(Context context, Logable log, String name, Laminate meta, FitState input) { protected FitState execute(Context context, Reportable log, String name, Laminate meta, FitState input) {
ParamSet pars = input.getParameters(); ParamSet pars = input.getParameters();
if (!pars.names().contains(names)) { if (!pars.names().contains(names)) {
LoggerFactory.getLogger(getClass()).error("Wrong input FitState. Must be loss spectrum fit."); LoggerFactory.getLogger(getClass()).error("Wrong input FitState. Must be loss spectrum fit.");
@ -102,9 +102,9 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
if (calculateRatio) { if (calculateRatio) {
threshold = meta.getDouble("ionThreshold", 17); threshold = meta.getDouble("ionThreshold", 17);
ionRatio = calcultateIonRatio(pars, threshold); ionRatio = calcultateIonRatio(pars, threshold);
log.log("The ionization ratio (using threshold {}) is {}", threshold, ionRatio); log.report("The ionization ratio (using threshold {}) is {}", threshold, ionRatio);
ionRatioError = calultateIonRatioError(context, name, input, threshold); ionRatioError = calultateIonRatioError(context, name, input, threshold);
log.log("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError); log.report("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError);
} }
if (meta.getBoolean("printResult", false)) { if (meta.getBoolean("printResult", false)) {

View File

@ -20,7 +20,6 @@ import hep.dataforge.context.Context;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.plots.fx.FXPlotUtils; import hep.dataforge.plots.fx.FXPlotUtils;
@ -38,6 +37,7 @@ import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection; import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleEdge;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -47,8 +47,8 @@ import org.jfree.ui.RectangleEdge;
public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> { public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
@Override @Override
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException { protected NMFile execute(Context context, Reportable log, String name, Laminate meta, NMFile source) throws ContentException {
log.log("File {} started", source.getName()); log.report("File {} started", source.getName());
List<NMPoint> printPoints = new ArrayList<>(); List<NMPoint> printPoints = new ArrayList<>();
List<NMPoint> showPoints = new ArrayList<>(); List<NMPoint> showPoints = new ArrayList<>();
@ -78,7 +78,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
} }
log.log("File {} completed", source.getName()); log.report("File {} completed", source.getName());
return source; return source;
} }

View File

@ -20,7 +20,6 @@ import hep.dataforge.context.Context;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import inr.numass.data.NMFile; import inr.numass.data.NMFile;
@ -30,6 +29,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.math3.util.Pair; import org.apache.commons.math3.util.Pair;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
@ -46,7 +46,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
} }
@Override @Override
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException { protected NMFile execute(Context context, Reportable log, String name, Laminate meta, NMFile source) throws ContentException {
boolean normalize; boolean normalize;
Map<String, Pair<Integer, Integer>> slicingConfig; Map<String, Pair<Integer, Integer>> slicingConfig;
@ -66,7 +66,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
if (slicingConfig == null) { if (slicingConfig == null) {
throw new RuntimeException("Slice configuration not defined"); throw new RuntimeException("Slice configuration not defined");
} }
log.log("File {} started", source.getName()); log.report("File {} started", source.getName());
SlicedData sData = new SlicedData(source, slicingConfig, normalize); SlicedData sData = new SlicedData(source, slicingConfig, normalize);
@ -74,7 +74,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
ColumnedDataWriter.writeDataSet(stream, sData, null); ColumnedDataWriter.writeDataSet(stream, sData, null);
log.log("File {} completed", source.getName()); log.report("File {} completed", source.getName());
return source; return source;
} }

View File

@ -26,7 +26,6 @@ import hep.dataforge.tables.MapPoint;
import hep.dataforge.datafitter.FitState; import hep.dataforge.datafitter.FitState;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
import java.io.OutputStream; import java.io.OutputStream;
@ -34,12 +33,13 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.io.reports.Reportable;
/** /**
* *
* @author Darksnake * @author Darksnake
*/ */
@TypedActionDef(name = "summary", inputType = FitState.class, outputType = Table.class, description = "Generate summary for fit results of different datasets.") @TypedActionDef(name = "summary", inputType = FitState.class, outputType = Table.class, info = "Generate summary for fit results of different datasets.")
public class SummaryAction extends ManyToOneAction<FitState, Table> { public class SummaryAction extends ManyToOneAction<FitState, Table> {
public static final String SUMMARY_NAME = "sumName"; public static final String SUMMARY_NAME = "sumName";
@ -58,7 +58,7 @@ public class SummaryAction extends ManyToOneAction<FitState, Table> {
} }
@Override @Override
protected Table execute(Context context, Logable log, String nodeName, Map<String, FitState> input, Meta meta) { protected Table execute(Context context, Reportable log, String nodeName, Map<String, FitState> input, Meta meta) {
String[] parNames = meta.getStringArray("parnames"); String[] parNames = meta.getStringArray("parnames");
String[] names = new String[2 * parNames.length + 2]; String[] names = new String[2 * parNames.length + 2];
names[0] = "file"; names[0] = "file";
@ -108,7 +108,7 @@ public class SummaryAction extends ManyToOneAction<FitState, Table> {
} }
@Override @Override
protected void afterGroup(Context context, Logable log, String groupName, Meta outputMeta, Table output) { protected void afterGroup(Context context, Reportable log, String groupName, Meta outputMeta, Table output) {
OutputStream stream = buildActionOutput(context, groupName); OutputStream stream = buildActionOutput(context, groupName);
ColumnedDataWriter.writeDataSet(stream, output, groupName); ColumnedDataWriter.writeDataSet(stream, output, groupName);

View File

@ -31,6 +31,14 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *

View File

@ -83,7 +83,6 @@ public class NumassServer extends AbstractNetworkListener {
int port = meta().getInt("ratpack.port", 8336); int port = meta().getInt("ratpack.port", 8336);
ratpack = RatpackServer.start((RatpackServerSpec server) -> server ratpack = RatpackServer.start((RatpackServerSpec server) -> server
.serverConfig((ServerConfigBuilder config) -> config .serverConfig((ServerConfigBuilder config) -> config
// .baseDir(Paths.get(getClass().getClassLoader().getResource("ratpack").toURI()))
.baseDir(BaseDir.find()) .baseDir(BaseDir.find())
.address(InetAddress.getLocalHost()) .address(InetAddress.getLocalHost())
.port(port)) .port(port))
@ -97,8 +96,8 @@ public class NumassServer extends AbstractNetworkListener {
private void startRun(Meta annotation) throws StorageException { private void startRun(Meta annotation) throws StorageException {
String path = annotation.getString("path", DEFAULT_RUN_PATH); String path = annotation.getString("path", DEFAULT_RUN_PATH);
Meta meta = annotation.getNode("meta", null); //Meta meta = annotation.getNode("meta", null);
run = new NumassRun(path, new NumassStorage(root, path, meta), getResponseFactory()); run = new NumassRun(path, NumassStorage.buildNumassStorage(root, path, false, true), getResponseFactory());
getRootState().setValue("numass.current.run", path); getRootState().setValue("numass.current.run", path);
} }
@ -142,7 +141,7 @@ public class NumassServer extends AbstractNetworkListener {
*/ */
private void updateRun() throws StorageException { private void updateRun() throws StorageException {
String currentRun = getRootState().getString("numass.current.run", DEFAULT_RUN_PATH); String currentRun = getRootState().getString("numass.current.run", DEFAULT_RUN_PATH);
this.run = new NumassRun(currentRun, new NumassStorage(root, currentRun, null), getResponseFactory()); this.run = new NumassRun(currentRun, NumassStorage.buildNumassStorage(root, currentRun, false, true), getResponseFactory());
} }
/** /**

View File

@ -8,6 +8,7 @@ package inr.numass.server;
import freemarker.template.Template; import freemarker.template.Template;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.storage.api.ObjectLoader; import hep.dataforge.storage.api.ObjectLoader;
import hep.dataforge.storage.api.PointLoader;
import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.servlet.StorageRatpackHandler; import hep.dataforge.storage.servlet.StorageRatpackHandler;
import hep.dataforge.storage.servlet.Utils; import hep.dataforge.storage.servlet.Utils;
@ -67,6 +68,21 @@ public class NumassStorageHandler extends StorageRatpackHandler {
} }
} }
@Override
protected String pointLoaderPlotOptions(PointLoader loader) {
if (loader.getName().contains("msp") || loader.getName().contains("vac")) {
return " legend: { \n"
+ " position: 'bottom' \n"
+ " },\n"
+ " title: '" + loader.getName() + "',\n"
+ " vAxis:{\n"
+ " logScale: true\n"
+ " }";
} else {
return super.pointLoaderPlotOptions(loader);
}
}
private String render(NumassNote note) { private String render(NumassNote note) {
return String.format("<strong id=\"%s\">%s</strong> %s", note.ref(), formatter.format(note.time()), note.content()); return String.format("<strong id=\"%s\">%s</strong> %s", note.ref(), formatter.format(note.time()), note.content());
} }

View File

@ -9,10 +9,10 @@
<title>Numass storage</title> <title>Numass storage</title>
</head> </head>
<style> <style>
.shifted { .shifted {
margin: 20px; margin: 20px;
} }
</style> </style>
<body> <body>
<div class="container"> <div class="container">

View File

@ -85,6 +85,14 @@ public class NumassStorage extends FileStorage {
} }
} }
public static NumassStorage buildNumassStorage(FileStorage parent, String path, boolean readOnly, boolean monitor) throws StorageException {
Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", readOnly)
.setValue("monitor", monitor);
return new NumassStorage(parent, path, meta);
}
public static NumassStorage buildNumassRoot(String uri, boolean readOnly, boolean monitor) throws StorageException { public static NumassStorage buildNumassRoot(String uri, boolean readOnly, boolean monitor) throws StorageException {
try { try {
Meta meta = new MetaBuilder("storage") Meta meta = new MetaBuilder("storage")
@ -97,7 +105,7 @@ public class NumassStorage extends FileStorage {
} }
} }
public NumassStorage(FileStorage parent, String path, Meta config) throws StorageException { protected NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
super(parent, path, config); super(parent, path, config);
super.refresh(); super.refresh();
//TODO read meta from numass_group_meta to .numass element //TODO read meta from numass_group_meta to .numass element
@ -228,7 +236,7 @@ public class NumassStorage extends FileStorage {
} }
public static EventBuilder builder(String source, String fileName, int fileSize) { public static EventBuilder builder(String source, String fileName, int fileSize) {
return new EventBuilder("numass.storage.pushData") return EventBuilder.make("numass.storage.pushData")
.setSource(source) .setSource(source)
.setMetaValue(FILE_NAME_KEY, fileName) .setMetaValue(FILE_NAME_KEY, fileName)
.setMetaValue(FILE_SIZE_KEY, fileSize); .setMetaValue(FILE_SIZE_KEY, fileSize);

View File

@ -21,7 +21,6 @@ package inr.numass.viewer;
* and open the template in the editor. * and open the template in the editor.
*/ */
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.DFProcess;
import hep.dataforge.context.ProcessManager; import hep.dataforge.context.ProcessManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
@ -36,9 +35,6 @@ import hep.dataforge.storage.api.Storage;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;

View File

@ -125,9 +125,8 @@ public class NumassLoaderTreeBuilder {
callback.updateProgress(-1, 1); callback.updateProgress(-1, 1);
callback.updateProgress(0, storage.loaders().size()); callback.updateProgress(0, storage.loaders().size());
for (Loader loader : storage.loaders().values()) { for (Loader loader : storage.loaders().values()) {
callback.updateMessage("Building numass data loader " + loader.getName());
if (loader instanceof NumassData) { if (loader instanceof NumassData) {
callback.updateMessage("Building numass data loader " + loader.getName());
NumassData numassLoader = (NumassData) loader; NumassData numassLoader = (NumassData) loader;
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader)); TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader));