Finished refactoring
This commit is contained in:
parent
87b70a02f7
commit
cca98f4fab
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.cryotemp;
|
package inr.numass.cryotemp;
|
||||||
|
|
||||||
import hep.dataforge.content.Named;
|
import hep.dataforge.names.Named;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.control.collectors.RegularPointCollector;
|
import hep.dataforge.control.collectors.RegularPointCollector;
|
||||||
import hep.dataforge.control.measurements.DataDevice;
|
import hep.dataforge.control.measurements.DataDevice;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.readvac.fx;
|
package inr.numass.readvac.fx;
|
||||||
|
|
||||||
import hep.dataforge.content.Named;
|
import hep.dataforge.names.Named;
|
||||||
import hep.dataforge.control.connections.DeviceViewController;
|
import hep.dataforge.control.connections.DeviceViewController;
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
|
@ -47,7 +47,7 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FitState execute(Logable log, Meta metaData, FitState input) {
|
protected FitState execute(Logable log, String name, Meta metaData, FitState input) {
|
||||||
|
|
||||||
PointSet data = input.getDataSet();
|
PointSet data = input.getDataSet();
|
||||||
if (!(input.getModel() instanceof XYModel)) {
|
if (!(input.getModel() instanceof XYModel)) {
|
||||||
@ -68,12 +68,11 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
|||||||
UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters());
|
UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters());
|
||||||
|
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin
|
||||||
.buildFrom(getContext()).buildPlotFrame(getName(), input.getName(),
|
.buildFrom(getContext()).buildPlotFrame(getName(), name,
|
||||||
metaData.getNode("plot", null));
|
metaData.getNode("plot", null));
|
||||||
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
|
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
|
||||||
|
|
||||||
// double[] x = new double[data.size()];
|
// double[] x = new double[data.size()];
|
||||||
|
|
||||||
// double[] y = new double[data.size()];
|
// double[] y = new double[data.size()];
|
||||||
// double xMin = Double.POSITIVE_INFINITY;
|
// double xMin = Double.POSITIVE_INFINITY;
|
||||||
//
|
//
|
||||||
@ -94,7 +93,6 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
|||||||
// xMax = x[i];
|
// xMax = x[i];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
frame.add(new PlottableFunction("fit", function, data, adapter));//FIXME replace by helper
|
frame.add(new PlottableFunction("fit", function, data, adapter));//FIXME replace by helper
|
||||||
|
|
||||||
frame.add(PlottableData.plot("data", adapter, data));
|
frame.add(PlottableData.plot("data", adapter, data));
|
||||||
|
@ -15,19 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass;
|
package inr.numass;
|
||||||
|
|
||||||
import hep.dataforge.actions.ActionResult;
|
import hep.dataforge.actions.RunManager;
|
||||||
import static hep.dataforge.actions.RunManager.executeXML;
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import static hep.dataforge.context.GlobalContext.out;
|
import static hep.dataforge.context.GlobalContext.out;
|
||||||
import hep.dataforge.data.DataManager;
|
import hep.dataforge.data.DataNode;
|
||||||
|
import hep.dataforge.data.FileDataFactory;
|
||||||
import hep.dataforge.datafitter.MINUITPlugin;
|
import hep.dataforge.datafitter.MINUITPlugin;
|
||||||
import hep.dataforge.io.IOManager;
|
import hep.dataforge.io.IOManager;
|
||||||
|
import hep.dataforge.io.MetaFileReader;
|
||||||
|
import hep.dataforge.meta.Meta;
|
||||||
import static inr.numass.NumassContext.printDescription;
|
import static inr.numass.NumassContext.printDescription;
|
||||||
import inr.numass.workbench.Workbench;
|
import inr.numass.workbench.Workbench;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import static java.util.Locale.setDefault;
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
@ -40,6 +41,7 @@ import org.apache.commons.cli.Options;
|
|||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -55,7 +57,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static ActionResult run(NumassContext context, String[] args) throws Exception {
|
public static DataNode run(NumassContext context, String[] args) throws Exception {
|
||||||
Logger logger = LoggerFactory.getLogger("numass-main");
|
Logger logger = LoggerFactory.getLogger("numass-main");
|
||||||
|
|
||||||
Options options = prepareOptions();
|
Options options = prepareOptions();
|
||||||
@ -67,15 +69,15 @@ public class Main {
|
|||||||
} catch (ParseException exp) {
|
} catch (ParseException exp) {
|
||||||
// oops, something went wrong
|
// oops, something went wrong
|
||||||
logger.error("Command line error. Reason: " + exp.getMessage());
|
logger.error("Command line error. Reason: " + exp.getMessage());
|
||||||
return ActionResult.empty();
|
return DataNode.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption("lc")) {
|
if (line.hasOption("lc")) {
|
||||||
printDescription(context, true);
|
printDescription(context, true);
|
||||||
return ActionResult.empty();
|
return DataNode.empty();
|
||||||
} else if (line.hasOption("l")) {
|
} else if (line.hasOption("l")) {
|
||||||
printDescription(context, false);
|
printDescription(context, false);
|
||||||
return ActionResult.empty();
|
return DataNode.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
String cfgPath;
|
String cfgPath;
|
||||||
@ -90,20 +92,22 @@ public class Main {
|
|||||||
cfgPath = line.getOptionValue("c");
|
cfgPath = line.getOptionValue("c");
|
||||||
if (cfgPath == null) {
|
if (cfgPath == null) {
|
||||||
logger.info("Configutation path not provided.");
|
logger.info("Configutation path not provided.");
|
||||||
return ActionResult.empty();
|
return DataNode.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
File config = context.io().getFile(cfgPath);
|
File configFile = context.io().getFile(cfgPath);
|
||||||
|
|
||||||
if (!config.exists()) {
|
if (!configFile.exists()) {
|
||||||
throw new FileNotFoundException("Configuration file not found");
|
throw new FileNotFoundException("Configuration file not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Meta config = MetaFileReader.read(configFile).build();
|
||||||
|
|
||||||
context.putValue(IOManager.ROOT_DIRECTORY_CONTEXT_KEY, config.getParentFile().toString());
|
context.putValue(IOManager.ROOT_DIRECTORY_CONTEXT_KEY, configFile.getParentFile().toString());
|
||||||
|
|
||||||
applyCLItoContext(line, context);
|
applyCLItoContext(line, context);
|
||||||
|
|
||||||
return executeXML(context, config);
|
return RunManager.executeAction(context, config);
|
||||||
} else {
|
} else {
|
||||||
Workbench.main(args);
|
Workbench.main(args);
|
||||||
return null;
|
return null;
|
||||||
@ -125,7 +129,7 @@ public class Main {
|
|||||||
dataDir = new File(workDir, dataPath);
|
dataDir = new File(workDir, dataPath);
|
||||||
}
|
}
|
||||||
if (dataDir.exists() && dataDir.isDirectory()) {
|
if (dataDir.exists() && dataDir.isDirectory()) {
|
||||||
context.putValue(DataManager.DATA_DIR, dataDir.getAbsolutePath());
|
context.putValue(FileDataFactory.DATA_DIR_KEY, dataDir.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundException("Data directory not found");
|
throw new FileNotFoundException("Data directory not found");
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass;
|
package inr.numass;
|
||||||
|
|
||||||
|
import hep.dataforge.data.FileData;
|
||||||
import hep.dataforge.io.BasicIOManager;
|
import hep.dataforge.io.BasicIOManager;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.names.Name;
|
import hep.dataforge.names.Name;
|
||||||
@ -29,6 +30,7 @@ import java.io.OutputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.output.TeeOutputStream;
|
import org.apache.commons.io.output.TeeOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +40,7 @@ import org.apache.commons.io.output.TeeOutputStream;
|
|||||||
public class NumassIO extends BasicIOManager {
|
public class NumassIO extends BasicIOManager {
|
||||||
|
|
||||||
public static final String NUMASS_OUTPUT_CONTEXT_KEY = "numass.outputDir";
|
public static final String NUMASS_OUTPUT_CONTEXT_KEY = "numass.outputDir";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream out(Name stage, Name name) {
|
public OutputStream out(Name stage, Name name) {
|
||||||
List<String> tokens = new ArrayList<>();
|
List<String> tokens = new ArrayList<>();
|
||||||
@ -96,7 +98,7 @@ public class NumassIO extends BasicIOManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawNMFile readAsDat(BinaryData source, Meta config) {
|
public static RawNMFile readAsDat(FileData source, Meta config) {
|
||||||
try {
|
try {
|
||||||
return new NumassDataReader(source, config).read();
|
return new NumassDataReader(source, config).read();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -104,17 +106,14 @@ public class NumassIO extends BasicIOManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawNMFile readAsPaw(BinaryData source) {
|
public static RawNMFile readAsPaw(FileData source) {
|
||||||
try {
|
return new NumassPawReader().readPaw(source.get(), source.fileName());
|
||||||
return new NumassPawReader().readPaw(source.getInputStream(), source.getName());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawNMFile getNumassData(FileData source, Meta config) {
|
public static RawNMFile getNumassData(FileData source, Meta config) {
|
||||||
RawNMFile dataFile;
|
RawNMFile dataFile;
|
||||||
switch (source.getExtension()) {
|
String extension = FilenameUtils.getExtension(source.fileName());
|
||||||
|
switch (extension) {
|
||||||
case "paw":
|
case "paw":
|
||||||
dataFile = readAsPaw(source);
|
dataFile = readAsPaw(source);
|
||||||
break;
|
break;
|
||||||
|
@ -30,13 +30,13 @@ public class AdjustErrorsAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, Meta meta, PointSet input) {
|
protected PointSet execute(Logable log, String name,Meta meta, PointSet 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ListPointSet(input.getName(), input.meta(), points, input.getDataFormat());
|
return new ListPointSet(points, input.getDataFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataPoint evalPoint(Meta meta, DataPoint dp) {
|
private DataPoint evalPoint(Meta meta, DataPoint dp) {
|
||||||
|
@ -33,20 +33,19 @@ import java.io.PrintWriter;
|
|||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "debunch", inputType = RawNMFile.class, outputType = RawNMFile.class)
|
@TypedActionDef(name = "debunch", inputType = RawNMFile.class, outputType = RawNMFile.class)
|
||||||
@ValueDef(name = "upperchanel", type = "NUMBER", def = "4095", info = "An upper chanel for debuncing")
|
@ValueDef(name = "upperchanel", type = "NUMBER", def = "4095", info = "An upper chanel for debuncing")
|
||||||
@ValueDef(name = "lowerchanel", type = "NUMBER", def = "0", info = "A lower chanel for debuncing")
|
@ValueDef(name = "lowerchanel", type = "NUMBER", def = "0", info = "A lower chanel for debuncing")
|
||||||
@ValueDef(name = "rejectprob", type = "NUMBER", def = "1e-5", info = "Rejection probability")
|
@ValueDef(name = "rejectprob", type = "NUMBER", def = "1e-5", info = "Rejection probability")
|
||||||
@ValueDef(name = "framelength", type = "NUMBER", def = "5", info = "Frame length in seconds")
|
@ValueDef(name = "framelength", type = "NUMBER", def = "5", info = "Frame length in seconds")
|
||||||
@ValueDef(name = "maxcr", type = "NUMBER", def = "100", info = "Maximum count rate for debunching")
|
@ValueDef(name = "maxcr", type = "NUMBER", def = "100", info = "Maximum count rate for debunching")
|
||||||
public class DebunchAction extends OneToOneAction<RawNMFile,RawNMFile> {
|
public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
|
||||||
|
|
||||||
|
|
||||||
public DebunchAction(Context context, Meta an) {
|
public DebunchAction(Context context, Meta an) {
|
||||||
super(context, an);
|
super(context, an);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RawNMFile execute(Logable log, Meta reader, RawNMFile source) throws ContentException {
|
protected RawNMFile execute(Logable log, String name, Meta reader, RawNMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
int upper = source.meta().getInt("upperchanel", this.meta().getInt("upperchanel", RawNMPoint.MAX_CHANEL));
|
int upper = source.meta().getInt("upperchanel", this.meta().getInt("upperchanel", RawNMPoint.MAX_CHANEL));
|
||||||
@ -72,7 +71,7 @@ public class DebunchAction extends OneToOneAction<RawNMFile,RawNMFile> {
|
|||||||
});
|
});
|
||||||
log.log("File {} completed", source.getName());
|
log.log("File {} completed", source.getName());
|
||||||
|
|
||||||
log.getLog().print(new PrintWriter(buildActionOutput(source)));
|
log.getLog().print(new PrintWriter(buildActionOutput(name)));
|
||||||
|
|
||||||
// res.configure(source.meta());
|
// res.configure(source.meta());
|
||||||
return res;
|
return res;
|
||||||
|
@ -33,13 +33,12 @@ import java.io.OutputStream;
|
|||||||
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
||||||
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
||||||
|
|
||||||
|
|
||||||
public FindBorderAction(Context context, Meta an) {
|
public FindBorderAction(Context context, Meta an) {
|
||||||
super(context, an);
|
super(context, an);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
int upperBorder = meta().getInt("upper", 4096);
|
int upperBorder = meta().getInt("upper", 4096);
|
||||||
@ -56,7 +55,7 @@ public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
|
|
||||||
BorderData bData = new BorderData(source, upperBorder, lowerBorder, referencePoint);
|
BorderData bData = new BorderData(source, upperBorder, lowerBorder, referencePoint);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(source);
|
OutputStream stream = buildActionOutput(name);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ package inr.numass.actions;
|
|||||||
|
|
||||||
import hep.dataforge.actions.ManyToOneAction;
|
import hep.dataforge.actions.ManyToOneAction;
|
||||||
import hep.dataforge.actions.GroupBuilder;
|
import hep.dataforge.actions.GroupBuilder;
|
||||||
import hep.dataforge.content.NamedGroup;
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
import hep.dataforge.points.ListPointSet;
|
import hep.dataforge.points.ListPointSet;
|
||||||
import hep.dataforge.points.MapPoint;
|
import hep.dataforge.points.MapPoint;
|
||||||
@ -27,12 +27,15 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import hep.dataforge.points.PointSet;
|
import hep.dataforge.points.PointSet;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,7 +43,6 @@ import hep.dataforge.points.PointSet;
|
|||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "merge", inputType = PointSet.class, outputType = PointSet.class, description = "Merge different numass data files into one.")
|
@TypedActionDef(name = "merge", inputType = PointSet.class, outputType = PointSet.class, description = "Merge different numass data files into one.")
|
||||||
@NodeDef(name = "grouping", info = "The defenition of grouping rule for this merge", target = "method::hep.dataforge.content.GroupBuilder.byAnnotation")
|
@NodeDef(name = "grouping", info = "The defenition of grouping rule for this merge", target = "method::hep.dataforge.content.GroupBuilder.byAnnotation")
|
||||||
//@Parameter(name = "groupBy", def = "mergeTag", info = "Defines the name of the value by which grouping is made. The value is supposed to be a String, but in practice could be any type which could be converted to String.")
|
|
||||||
public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
||||||
|
|
||||||
public static final String MERGE_NAME = "mergeName";
|
public static final String MERGE_NAME = "mergeName";
|
||||||
@ -51,80 +53,61 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<NamedGroup<PointSet>> buildGroups(Meta reader, List<PointSet> input) {
|
@SuppressWarnings("unchecked")
|
||||||
List<NamedGroup<PointSet>> groups;
|
protected List<DataNode<PointSet>> buildGroups(DataNode input) {
|
||||||
if (reader.hasValue("grouping.byValue")) {
|
Meta meta = inputMeta(input.meta());
|
||||||
groups = super.buildGroups(reader, input);
|
List<DataNode<PointSet>> groups;
|
||||||
|
if (meta.hasValue("grouping.byValue")) {
|
||||||
|
groups = super.buildGroups(input);
|
||||||
} else {
|
} else {
|
||||||
groups = GroupBuilder.byValue(MERGE_NAME, reader.getString(MERGE_NAME, "merge")).group(input);
|
groups = GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, "merge")).group(input);
|
||||||
}
|
}
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, Meta reader, NamedGroup<PointSet> input) {
|
protected PointSet execute(Logable log, DataNode<PointSet> input) {
|
||||||
return mergeOne(log, input.getName(), input.asList());
|
return mergeOne(log, input);
|
||||||
// List<DataSet> res = new ArrayList<>();
|
|
||||||
// for (NamedGroup<DataSet> buildGroups : groups) {
|
|
||||||
// res.add(mergeOne(log, buildGroups.getName(), buildGroups.asList()));
|
|
||||||
// }
|
|
||||||
// return new ContentList<>(input.getName(), PointSet.class, res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PointSet mergeOne(Logable log, String fileName, List<PointSet> files) {
|
private PointSet mergeOne(Logable log, DataNode<PointSet> input) {
|
||||||
PointSet[] data = new PointSet[files.size()];
|
List<PointSet> data = input.stream().<PointSet>map(item -> item.getValue().get()).collect(Collectors.toList());
|
||||||
String head = "Numass data merge\n";
|
PointSet res = mergeDataSets(input.getName(), data);
|
||||||
|
return res.sort("Uset", true);
|
||||||
|
}
|
||||||
|
|
||||||
String numassPath = "";
|
@Override
|
||||||
|
protected void afterGroup(Logable log, String groupName, Meta outputMeta, PointSet output) {
|
||||||
|
OutputStream stream = buildActionOutput(groupName);
|
||||||
|
ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* Проверяем являются ли пути одинаковыми у всех файлов
|
protected MetaBuilder outputMeta(DataNode<PointSet> input) {
|
||||||
* TODO не изящное решение
|
|
||||||
*/
|
String numassPath = input.stream().<String>map(item -> item.getValue().meta().getString("numass.path", null))
|
||||||
for (int i = 0; i < files.size(); i++) {
|
.reduce("", (String path, String newPath) -> {
|
||||||
data[i] = files.get(i);
|
if (path == null) {
|
||||||
head += "\t" + data[i].getName() + "\n";
|
return null;
|
||||||
if (numassPath != null) {
|
} else if (path.isEmpty()) {
|
||||||
String newPath = data[i].meta().getString("numass.path", null);
|
return newPath;
|
||||||
if (numassPath.isEmpty()) {
|
} else if (!path.equals(newPath)) {
|
||||||
numassPath = newPath;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (!numassPath.equals(newPath)) {
|
return newPath;
|
||||||
numassPath = null;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PointSet res = mergeDataSets(fileName, data);
|
|
||||||
|
|
||||||
|
MetaBuilder builder = super.outputMeta(input);
|
||||||
/*
|
/*
|
||||||
* Указываем путь только если он одинаковый для всех входных файлов
|
* Указываем путь только есл0и он одинаковый для всех входных файлов
|
||||||
*/
|
*/
|
||||||
if (numassPath != null) {
|
if (numassPath != null) {
|
||||||
res.setMeta(res.meta().getBuilder().putValue("numass.path", numassPath).build());
|
builder.putValue("numass.path", numassPath);
|
||||||
}
|
}
|
||||||
|
return builder;
|
||||||
res = res.sort("Uset", true);
|
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(res);
|
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, res, head);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Map<String, List<DataSet>> buildMergeGroups(String mergeBy, NamedGroup<DataSet> input) {
|
|
||||||
// Map<String, List<DataSet>> map = new HashMap<>();
|
|
||||||
// for (PointSet ds : input) {
|
|
||||||
// String tag = ds.meta().getString(mergeBy, meta().getString(mergeBy, "merge"));
|
|
||||||
// if (!map.containsKey(tag)) {
|
|
||||||
// map.put(tag, new ArrayList<>());
|
|
||||||
// }
|
|
||||||
// map.get(tag).add(ds);
|
|
||||||
// }
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
private DataPoint mergeDataPoints(DataPoint dp1, DataPoint dp2) {
|
private DataPoint mergeDataPoints(DataPoint dp1, DataPoint dp2) {
|
||||||
if (dp1 == null) {
|
if (dp1 == null) {
|
||||||
return dp2;
|
return dp2;
|
||||||
@ -167,7 +150,7 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PointSet mergeDataSets(String name, PointSet... ds) {
|
private PointSet mergeDataSets(String name, Collection<PointSet> ds) {
|
||||||
//Сливаем все точки в один набор данных
|
//Сливаем все точки в один набор данных
|
||||||
Map<Double, List<DataPoint>> points = new LinkedHashMap<>();
|
Map<Double, List<DataPoint>> points = new LinkedHashMap<>();
|
||||||
for (PointSet d : ds) {
|
for (PointSet d : ds) {
|
||||||
@ -185,15 +168,17 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
|
|
||||||
List<DataPoint> res = new ArrayList<>();
|
List<DataPoint> res = new ArrayList<>();
|
||||||
|
|
||||||
for (Map.Entry<Double, List<DataPoint>> entry : points.entrySet()) {
|
points.entrySet().stream().map((entry) -> {
|
||||||
DataPoint curPoint = null;
|
DataPoint curPoint = null;
|
||||||
for (DataPoint newPoint : entry.getValue()) {
|
for (DataPoint newPoint : entry.getValue()) {
|
||||||
curPoint = mergeDataPoints(curPoint, newPoint);
|
curPoint = mergeDataPoints(curPoint, newPoint);
|
||||||
}
|
}
|
||||||
|
return curPoint;
|
||||||
|
}).forEach((curPoint) -> {
|
||||||
res.add(curPoint);
|
res.add(curPoint);
|
||||||
}
|
});
|
||||||
|
|
||||||
return new ListPointSet(name, null, res);
|
return new ListPointSet(res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, Meta reader, PointSet sourceData) throws ContentException {
|
protected PointSet execute(Logable log, String name, Meta reader, PointSet sourceData) throws ContentException {
|
||||||
|
|
||||||
double monitor = reader.getDouble("monitorPoint", Double.NaN);
|
double monitor = reader.getDouble("monitorPoint", Double.NaN);
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
// } else {
|
// } else {
|
||||||
// format = DataFormat.of(parnames);
|
// format = DataFormat.of(parnames);
|
||||||
// }
|
// }
|
||||||
PointSet data = new ListPointSet(sourceData.getName(), sourceData.meta(), dataList);
|
PointSet data = new ListPointSet(dataList);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(data);
|
OutputStream stream = buildActionOutput(name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, head);
|
ColumnedDataWriter.writeDataSet(stream, data, head);
|
||||||
|
|
||||||
@ -141,15 +141,15 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterAction(ActionResult<PointSet> pack) throws ContentException {
|
protected void afterAction(String name, PointSet res) {
|
||||||
printMonitorData();
|
printMonitorData();
|
||||||
super.afterAction(pack);
|
super.afterAction(name, res); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMonitorData() {
|
private void printMonitorData() {
|
||||||
String monitorFileName = meta().getString("monitorFile", "monitor");
|
String monitorFileName = meta().getString("monitorFile", "monitor");
|
||||||
OutputStream stream = buildActionOutput(monitorFileName);
|
OutputStream stream = buildActionOutput(monitorFileName);
|
||||||
ListPointSet data = new ListPointSet("monitor", null, monitorPoints);
|
ListPointSet data = new ListPointSet(monitorPoints);
|
||||||
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ListPointSet execute(Logable log, Meta reader, NMFile dataFile) throws ContentException {
|
protected ListPointSet execute(Logable log, String name, Meta reader, NMFile dataFile) {
|
||||||
// log.logString("File %s started", dataFile.getName());
|
// log.logString("File %s started", dataFile.getName());
|
||||||
|
|
||||||
int upper = dataFile.meta().getInt("upperWindow", this.meta().getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1));
|
int upper = dataFile.meta().getInt("upperWindow", this.meta().getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1));
|
||||||
@ -112,9 +112,9 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
|
|||||||
}
|
}
|
||||||
head = head + "\n" + new XMLMetaWriter().writeString(meta(), null) + "\n";
|
head = head + "\n" + new XMLMetaWriter().writeString(meta(), null) + "\n";
|
||||||
|
|
||||||
ListPointSet data = new ListPointSet(dataFile.getName(), dataFile.meta(), dataList, format);
|
ListPointSet data = new ListPointSet(dataList, format);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(data);
|
OutputStream stream = buildActionOutput(name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, head);
|
ColumnedDataWriter.writeDataSet(stream, data, head);
|
||||||
// log.logString("File %s completed", dataFile.getName());
|
// log.logString("File %s completed", dataFile.getName());
|
||||||
|
@ -17,7 +17,7 @@ package inr.numass.actions;
|
|||||||
|
|
||||||
import hep.dataforge.actions.OneToOneAction;
|
import hep.dataforge.actions.OneToOneAction;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.points.FileData;
|
import hep.dataforge.data.FileData;
|
||||||
import hep.dataforge.description.NodeDef;
|
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;
|
||||||
@ -29,7 +29,7 @@ import inr.numass.data.NMFile;
|
|||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.data.RawNMFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "readData",
|
@TypedActionDef(name = "readData",
|
||||||
@ -46,20 +46,20 @@ public class ReadNumassDataAction extends OneToOneAction<FileData, NMFile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, Meta reader, FileData source) throws ContentException {
|
protected NMFile execute(Logable log, String name, Meta reader, FileData 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)) {
|
||||||
raw.generatePAW(buildActionOutput(source.getName() + ".paw"));
|
raw.generatePAW(buildActionOutput(name + ".paw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(meta().hasNode("debunch")){
|
if (meta().hasNode("debunch")) {
|
||||||
DebunchAction debunch = new DebunchAction(getContext(), meta().getNode("debunch"));
|
DebunchAction debunch = new DebunchAction(getContext(), meta().getNode("debunch"));
|
||||||
raw = debunch.execute(log, null, raw);
|
raw = debunch.execute(log, name, null, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMFile result = new NMFile(raw);
|
NMFile result = new NMFile(raw);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FitState execute(Logable log, Meta reader, FitState input) {
|
protected FitState execute(Logable log, String name, Meta reader, 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.");
|
||||||
@ -80,9 +80,9 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
UnivariateFunction scatterFunction;
|
UnivariateFunction scatterFunction;
|
||||||
boolean calculateRatio = false;
|
boolean calculateRatio = false;
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
||||||
.buildPlotFrame(getName(), input.getName()+".loss",
|
.buildPlotFrame(getName(), name + ".loss",
|
||||||
new MetaBuilder("plot")
|
new MetaBuilder("plot")
|
||||||
.setValue("plotTitle", "Differential scattering crossection for " + input.getName())
|
.setValue("plotTitle", "Differential scattering crossection for " + name)
|
||||||
);
|
);
|
||||||
switch (input.getModel().getName()) {
|
switch (input.getModel().getName()) {
|
||||||
case "scatter-variable":
|
case "scatter-variable":
|
||||||
@ -107,12 +107,12 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
threshold = reader.getDouble("ionThreshold", 17);
|
threshold = reader.getDouble("ionThreshold", 17);
|
||||||
ionRatio = calcultateIonRatio(pars, threshold);
|
ionRatio = calcultateIonRatio(pars, threshold);
|
||||||
log.log("The ionization ratio (using threshold {}) is {}", threshold, ionRatio);
|
log.log("The ionization ratio (using threshold {}) is {}", threshold, ionRatio);
|
||||||
ionRatioError = calultateIonRatioError(input, threshold);
|
ionRatioError = calultateIonRatioError(name, input, threshold);
|
||||||
log.log("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError);
|
log.log("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.getBoolean("printResult", false)) {
|
if (reader.getBoolean("printResult", false)) {
|
||||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(buildActionOutput(input), Charset.forName("UTF-8")));
|
PrintWriter writer = new PrintWriter(new OutputStreamWriter(buildActionOutput(name), Charset.forName("UTF-8")));
|
||||||
// writer.println("*** FIT PARAMETERS ***");
|
// writer.println("*** FIT PARAMETERS ***");
|
||||||
input.print(writer);
|
input.print(writer);
|
||||||
// for (Param param : pars.getSubSet(names).getParams()) {
|
// for (Param param : pars.getSubSet(names).getParams()) {
|
||||||
@ -150,7 +150,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
}
|
}
|
||||||
writer.printf("%s%n", "chi2");
|
writer.printf("%s%n", "chi2");
|
||||||
|
|
||||||
writer.printf("%s\t", input.getName());
|
writer.printf("%s\t", name);
|
||||||
|
|
||||||
for (Param param : pars.getSubSet(names).getParams()) {
|
for (Param param : pars.getSubSet(names).getParams()) {
|
||||||
writer.printf("%f\t%f\t", param.value(), param.getErr());
|
writer.printf("%f\t%f\t", param.value(), param.getErr());
|
||||||
@ -174,7 +174,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
|
|
||||||
ParamSet parameters = input.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
ParamSet parameters = input.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
||||||
NamedMatrix covariance = input.getCovariance();
|
NamedMatrix covariance = input.getCovariance();
|
||||||
PointSet spreadData = generateSpread(writer, input.getName(), parameters, covariance);
|
PointSet spreadData = generateSpread(writer, name, parameters, covariance);
|
||||||
ColumnedDataWriter.writeDataSet(System.out, spreadData, "", spreadData.getDataFormat().asArray());
|
ColumnedDataWriter.writeDataSet(System.out, spreadData, "", spreadData.getDataFormat().asArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,10 +208,10 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
return exProb / ionProb;
|
return exProb / ionProb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calultateIonRatioError(FitState state, double threshold) {
|
public double calultateIonRatioError(String dataNeme, FitState state, double threshold) {
|
||||||
ParamSet parameters = state.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
ParamSet parameters = state.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
||||||
NamedMatrix covariance = state.getCovariance();
|
NamedMatrix covariance = state.getCovariance();
|
||||||
return calultateIonRatioError(state.getName(), parameters, covariance, threshold);
|
return calultateIonRatioError(dataNeme, parameters, covariance, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("Unchecked")
|
@SuppressWarnings("Unchecked")
|
||||||
@ -225,14 +225,14 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
.filter(d -> !Double.isNaN(d))
|
.filter(d -> !Double.isNaN(d))
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
Histogram hist = new Histogram("ionRatio", 0.3, 0.5, 0.002);
|
Histogram hist = new Histogram(0.3, 0.5, 0.002);
|
||||||
hist.fill(res);
|
hist.fill(res);
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
||||||
.buildPlotFrame(getName(), name+".ionRatio",
|
.buildPlotFrame(getName(), name + ".ionRatio",
|
||||||
new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name)
|
new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name)
|
||||||
);
|
);
|
||||||
// XYPlotFrame frame = JFreeChartFrame.drawFrame("Ion ratio Distribution for " + name, null);
|
// XYPlotFrame frame = JFreeChartFrame.drawFrame("Ion ratio Distribution for " + name, null);
|
||||||
frame.add(PlottableData.plot(hist, new XYAdapter("binCenter", "count")));
|
frame.add(PlottableData.plot("ionRatio", hist, new XYAdapter("binCenter", "count")));
|
||||||
|
|
||||||
return new DescriptiveStatistics(res).getStandardDeviation();
|
return new DescriptiveStatistics(res).getStandardDeviation();
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] pointNames = {"e", "central", "lower", "upper", "dispersion"};
|
String[] pointNames = {"e", "central", "lower", "upper", "dispersion"};
|
||||||
ListPointSet res = new ListPointSet("spread", pointNames);
|
ListPointSet res = new ListPointSet(pointNames);
|
||||||
for (int i = 0; i < gridPoints; i++) {
|
for (int i = 0; i < gridPoints; i++) {
|
||||||
res.add(new MapPoint(pointNames, grid[i], central[i], lower[i], upper[i], dispersion[i]));
|
res.add(new MapPoint(pointNames, grid[i], central[i], lower[i], upper[i], dispersion[i]));
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
List<NMPoint> printPoints = new ArrayList<>();
|
List<NMPoint> printPoints = new ArrayList<>();
|
||||||
@ -73,9 +73,9 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (printPoints.size() > 0) {
|
if (printPoints.size() > 0) {
|
||||||
ESpectrum data = new ESpectrum(source.getName(), printPoints, chanelsPerBin, normalize);
|
ESpectrum data = new ESpectrum(printPoints, chanelsPerBin, normalize);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(data);
|
OutputStream stream = buildActionOutput(name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, source.getName());
|
ColumnedDataWriter.writeDataSet(stream, data, source.getName());
|
||||||
|
|
||||||
@ -156,13 +156,13 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JFreeChartFrame frame = FXPlotUtils.displayJFreeChart(head, null);
|
JFreeChartFrame frame = FXPlotUtils.displayJFreeChart(head, null);
|
||||||
|
|
||||||
frame.getYAxisConfig().putValue("title", axisName);
|
frame.getYAxisConfig().putValue("title", axisName);
|
||||||
|
|
||||||
JFreeChart chart = frame.getChart();
|
JFreeChart chart = frame.getChart();
|
||||||
|
|
||||||
chart.getXYPlot().setDataset(dataset);
|
chart.getXYPlot().setDataset(dataset);
|
||||||
|
|
||||||
chart.getXYPlot().setRenderer(new XYLineAndShapeRenderer(true, false));
|
chart.getXYPlot().setRenderer(new XYLineAndShapeRenderer(true, false));
|
||||||
|
|
||||||
chart.getLegend().setPosition(RectangleEdge.RIGHT);
|
chart.getLegend().setPosition(RectangleEdge.RIGHT);
|
||||||
|
@ -49,7 +49,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
||||||
boolean normalize;
|
boolean normalize;
|
||||||
Map<String, Pair<Integer, Integer>> slicingConfig;
|
Map<String, Pair<Integer, Integer>> slicingConfig;
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
|
|
||||||
SlicedData sData = new SlicedData(source, slicingConfig, normalize);
|
SlicedData sData = new SlicedData(source, slicingConfig, normalize);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(source);
|
OutputStream stream = buildActionOutput(name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, sData, null);
|
ColumnedDataWriter.writeDataSet(stream, sData, null);
|
||||||
|
|
||||||
log.log("File {} completed", source.getName());
|
log.log("File {} completed", source.getName());
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@ package inr.numass.actions;
|
|||||||
|
|
||||||
import hep.dataforge.actions.ManyToOneAction;
|
import hep.dataforge.actions.ManyToOneAction;
|
||||||
import hep.dataforge.actions.GroupBuilder;
|
import hep.dataforge.actions.GroupBuilder;
|
||||||
import hep.dataforge.content.NamedGroup;
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.data.Data;
|
||||||
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.points.Format;
|
import hep.dataforge.points.Format;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
import hep.dataforge.points.ListPointSet;
|
import hep.dataforge.points.ListPointSet;
|
||||||
@ -33,6 +34,8 @@ import java.io.OutputStream;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import hep.dataforge.points.PointSet;
|
import hep.dataforge.points.PointSet;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,26 +43,28 @@ import hep.dataforge.points.PointSet;
|
|||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "summary", inputType = FitState.class, outputType = PointSet.class, description = "Generate summary for fit results of different datasets.")
|
@TypedActionDef(name = "summary", inputType = FitState.class, outputType = PointSet.class, description = "Generate summary for fit results of different datasets.")
|
||||||
public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
||||||
|
|
||||||
public static final String SUMMARY_NAME = "sumName";
|
public static final String SUMMARY_NAME = "sumName";
|
||||||
|
|
||||||
public SummaryAction(Context context, Meta annotation) {
|
public SummaryAction(Context context, Meta annotation) {
|
||||||
super(context, annotation);
|
super(context, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<NamedGroup<FitState>> buildGroups(Meta reader, List<FitState> input) {
|
|
||||||
List<NamedGroup<FitState>> groups;
|
|
||||||
if (reader.hasNode("grouping")) {
|
|
||||||
groups = super.buildGroups(reader, input);
|
|
||||||
} else {
|
|
||||||
groups = GroupBuilder.byValue(SUMMARY_NAME, reader.getString(SUMMARY_NAME, "summary")).group(input);
|
|
||||||
}
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, Meta reader, NamedGroup<FitState> input){
|
@SuppressWarnings("unchecked")
|
||||||
|
protected List<DataNode<PointSet>> buildGroups(DataNode input) {
|
||||||
|
Meta meta = inputMeta(input.meta());
|
||||||
|
List<DataNode<PointSet>> groups;
|
||||||
|
if (meta.hasValue("grouping.byValue")) {
|
||||||
|
groups = super.buildGroups(input);
|
||||||
|
} else {
|
||||||
|
groups = GroupBuilder.byValue(SUMMARY_NAME, meta.getString(SUMMARY_NAME, "summary")).group(input);
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PointSet execute(Logable log, DataNode<FitState> input) {
|
||||||
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";
|
||||||
@ -69,32 +74,33 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
}
|
}
|
||||||
names[names.length - 1] = "chi2";
|
names[names.length - 1] = "chi2";
|
||||||
|
|
||||||
// boolean calculateWAV = meta().getBoolean("wav", true);
|
ListPointSet res = new ListPointSet(Format.forNames(8, names));
|
||||||
String fileName = reader.getString(SUMMARY_NAME, "summary");
|
|
||||||
|
|
||||||
ListPointSet res = new ListPointSet(fileName, Format.forNames(8, names));
|
|
||||||
|
|
||||||
double[] weights = new double[parNames.length];
|
double[] weights = new double[parNames.length];
|
||||||
Arrays.fill(weights, 0);
|
Arrays.fill(weights, 0);
|
||||||
double[] av = new double[parNames.length];
|
double[] av = new double[parNames.length];
|
||||||
Arrays.fill(av, 0);
|
Arrays.fill(av, 0);
|
||||||
|
|
||||||
for (FitState state : input) {
|
input.stream().forEach(new Consumer<Pair<String, Data<? extends FitState>>>() {
|
||||||
Value[] values = new Value[names.length];
|
@Override
|
||||||
values[0] = Value.of(state.getName());
|
public void accept(Pair<String, Data<? extends FitState>> item) {
|
||||||
for (int i = 0; i < parNames.length; i++) {
|
FitState state = item.getValue().get();
|
||||||
Value val = Value.of(state.getParameters().getValue(parNames[i]));
|
Value[] values = new Value[names.length];
|
||||||
values[2 * i + 1] = val;
|
values[0] = Value.of(item.getKey());
|
||||||
Value err = Value.of(state.getParameters().getError(parNames[i]));
|
for (int i = 0; i < parNames.length; i++) {
|
||||||
values[2 * i + 2] = err;
|
Value val = Value.of(state.getParameters().getValue(parNames[i]));
|
||||||
double weight = 1 / err.doubleValue() / err.doubleValue();
|
values[2 * i + 1] = val;
|
||||||
av[i] += val.doubleValue() * weight;
|
Value err = Value.of(state.getParameters().getError(parNames[i]));
|
||||||
weights[i] += weight;
|
values[2 * i + 2] = err;
|
||||||
|
double weight = 1 / err.doubleValue() / err.doubleValue();
|
||||||
|
av[i] += val.doubleValue() * weight;
|
||||||
|
weights[i] += weight;
|
||||||
|
}
|
||||||
|
values[values.length - 1] = Value.of(state.getChi2());
|
||||||
|
DataPoint point = new MapPoint(names, values);
|
||||||
|
res.add(point);
|
||||||
}
|
}
|
||||||
values[values.length - 1] = Value.of(state.getChi2());
|
});
|
||||||
DataPoint point = new MapPoint(names, values);
|
|
||||||
res.add(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
Value[] averageValues = new Value[names.length];
|
Value[] averageValues = new Value[names.length];
|
||||||
averageValues[0] = Value.of("average");
|
averageValues[0] = Value.of("average");
|
||||||
@ -107,11 +113,15 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
|
|
||||||
res.add(new MapPoint(names, averageValues));
|
res.add(new MapPoint(names, averageValues));
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(res);
|
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, res, fileName);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterGroup(Logable log, String groupName, Meta outputMeta, PointSet output) {
|
||||||
|
OutputStream stream = buildActionOutput(groupName);
|
||||||
|
ColumnedDataWriter.writeDataSet(stream, output, groupName);
|
||||||
|
|
||||||
|
super.afterGroup(log, groupName, outputMeta, output);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,19 +24,12 @@ import hep.dataforge.values.ValueFormat;
|
|||||||
import hep.dataforge.values.ValueFormatFactory;
|
import hep.dataforge.values.ValueFormatFactory;
|
||||||
import hep.dataforge.values.ValueType;
|
import hep.dataforge.values.ValueType;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import static java.lang.String.format;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import static java.lang.String.format;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -61,8 +54,8 @@ public class ESpectrum extends ListPointSet {
|
|||||||
|
|
||||||
int binning = 1;
|
int binning = 1;
|
||||||
|
|
||||||
public ESpectrum(String name, List<NMPoint> points, int binning, boolean normalize) {
|
public ESpectrum(List<NMPoint> points, int binning, boolean normalize) {
|
||||||
super(name, prepareFormat(points));
|
super(prepareFormat(points));
|
||||||
this.binning = binning;
|
this.binning = binning;
|
||||||
fill(points, normalize);
|
fill(points, normalize);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
import hep.dataforge.content.NamedMetaHolder;
|
import hep.dataforge.names.NamedMetaHolder;
|
||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
import hep.dataforge.content.Named;
|
import hep.dataforge.names.Named;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
import hep.dataforge.points.BinaryData;
|
import hep.dataforge.data.FileData;
|
||||||
import hep.dataforge.meta.MergeRule;
|
import hep.dataforge.meta.MergeRule;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -39,9 +39,9 @@ public class NumassDataReader {
|
|||||||
private Meta config;
|
private Meta config;
|
||||||
private double HVdev;
|
private double HVdev;
|
||||||
|
|
||||||
public NumassDataReader(BinaryData data, Meta config) throws IOException {
|
public NumassDataReader(FileData data, Meta config) throws IOException {
|
||||||
this(data.getInputStream(), data.meta()
|
this(data.get(), data.meta()
|
||||||
.getString("filename", data.getName()), MergeRule.replace(config, data.meta()));
|
.getString("filename", data.fileName()), MergeRule.replace(config, data.meta()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public NumassDataReader(String file, String fname, Meta config) throws FileNotFoundException {
|
public NumassDataReader(String file, String fname, Meta config) throws FileNotFoundException {
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
import hep.dataforge.content.Content;
|
import hep.dataforge.names.NamedMetaHolder;
|
||||||
import hep.dataforge.content.NamedMetaHolder;
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -27,7 +26,7 @@ import java.util.List;
|
|||||||
* Contains the whole data but requires a lot of memory
|
* Contains the whole data but requires a lot of memory
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class RawNMFile extends NamedMetaHolder implements Content {
|
public class RawNMFile extends NamedMetaHolder {
|
||||||
|
|
||||||
// public static String TYPE = ":data:numassdatafile";
|
// public static String TYPE = ":data:numassdatafile";
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import hep.dataforge.functions.ParametricFunction;
|
|||||||
import static hep.dataforge.maths.MatrixOperations.inverse;
|
import static hep.dataforge.maths.MatrixOperations.inverse;
|
||||||
import hep.dataforge.maths.NamedDoubleSet;
|
import hep.dataforge.maths.NamedDoubleSet;
|
||||||
import hep.dataforge.maths.NamedMatrix;
|
import hep.dataforge.maths.NamedMatrix;
|
||||||
|
import inr.numass.utils.TritiumUtils;
|
||||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||||
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
|
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
|
||||||
import org.apache.commons.math3.linear.RealMatrix;
|
import org.apache.commons.math3.linear.RealMatrix;
|
||||||
@ -39,7 +40,7 @@ public class SpectrumInformation {
|
|||||||
|
|
||||||
public NamedMatrix getExpetedCovariance(NamedDoubleSet set, ListPointSet data, String... parNames) {
|
public NamedMatrix getExpetedCovariance(NamedDoubleSet set, ListPointSet data, String... parNames) {
|
||||||
String[] names = parNames;
|
String[] names = parNames;
|
||||||
if(names.length==0) {
|
if (names.length == 0) {
|
||||||
names = source.namesAsArray();
|
names = source.namesAsArray();
|
||||||
}
|
}
|
||||||
NamedMatrix info = this.getInformationMatrix(set, data, names);
|
NamedMatrix info = this.getInformationMatrix(set, data, names);
|
||||||
@ -56,28 +57,28 @@ public class SpectrumInformation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public NamedMatrix getInformationMatrix(NamedDoubleSet set, ListPointSet data, String... parNames) {
|
public NamedMatrix getInformationMatrix(NamedDoubleSet set, ListPointSet data, String... parNames) {
|
||||||
SpectrumDataAdapter reader = new SpectrumDataAdapter(data.meta().getNode("aliases"));
|
SpectrumDataAdapter reader = TritiumUtils.adapter();
|
||||||
|
|
||||||
String[] names = parNames;
|
String[] names = parNames;
|
||||||
if(names.length==0) {
|
if (names.length == 0) {
|
||||||
names = source.namesAsArray();
|
names = source.namesAsArray();
|
||||||
}
|
}
|
||||||
assert source.names().contains(set.namesAsArray());
|
assert source.names().contains(set.namesAsArray());
|
||||||
assert source.names().contains(names);
|
assert source.names().contains(names);
|
||||||
RealMatrix res = new Array2DRowRealMatrix(names.length, names.length);
|
RealMatrix res = new Array2DRowRealMatrix(names.length, names.length);
|
||||||
|
|
||||||
for (DataPoint dp : data) {
|
for (DataPoint dp : data) {
|
||||||
/*PENDING Тут имеется глобальная неоптимальность связанная с тем,
|
/*PENDING Тут имеется глобальная неоптимальность связанная с тем,
|
||||||
* что при каждом вызове вычисляются две производные
|
* что при каждом вызове вычисляются две производные
|
||||||
* Нужно вычислять сразу всю матрицу для каждой точки, тогда количество
|
* Нужно вычислять сразу всю матрицу для каждой точки, тогда количество
|
||||||
* вызовов производных будет строго равно 1.
|
* вызовов производных будет строго равно 1.
|
||||||
*/
|
*/
|
||||||
res = res.add(getPointInfoMatrix(set, reader.getX(dp).doubleValue(), reader.getTime(dp), names).getMatrix());
|
res = res.add(getPointInfoMatrix(set, reader.getX(dp).doubleValue(), reader.getTime(dp), names).getMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NamedMatrix(res, names);
|
return new NamedMatrix(res, names);
|
||||||
}
|
}
|
||||||
|
|
||||||
// формула правильная!
|
// формула правильная!
|
||||||
public double getPoinSignificance(NamedDoubleSet set, String name1, String name2, double x) {
|
public double getPoinSignificance(NamedDoubleSet set, String name1, String name2, double x) {
|
||||||
return source.derivValue(name1, x, set) * source.derivValue(name2, x, set) / source.value(x, set);
|
return source.derivValue(name1, x, set) * source.derivValue(name2, x, set) / source.value(x, set);
|
||||||
@ -97,7 +98,7 @@ public class SpectrumInformation {
|
|||||||
|
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
for (int j = i; j < names.length; j++) {
|
for (int j = i; j < names.length; j++) {
|
||||||
double value = getPoinSignificance(set, names[i], names[j], x)*t;
|
double value = getPoinSignificance(set, names[i], names[j], x) * t;
|
||||||
res.setEntry(i, j, value);
|
res.setEntry(i, j, value);
|
||||||
if (i != j) {
|
if (i != j) {
|
||||||
res.setEntry(j, i, value);
|
res.setEntry(j, i, value);
|
||||||
@ -106,7 +107,7 @@ public class SpectrumInformation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
return new NamedMatrix(res, names);
|
return new NamedMatrix(res, names);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package inr.numass.models;
|
|||||||
import hep.dataforge.actions.ActionResult;
|
import hep.dataforge.actions.ActionResult;
|
||||||
import hep.dataforge.actions.RunManager;
|
import hep.dataforge.actions.RunManager;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
import hep.dataforge.io.ColumnedDataReader;
|
import hep.dataforge.io.ColumnedDataReader;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
@ -47,8 +48,8 @@ public class TransmissionInterpolator implements UnivariateFunction {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation, String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
|
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation, String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
|
||||||
ActionResult<PointSet> pack = RunManager.executeAction(context, actionAnnotation);
|
DataNode<PointSet> node = RunManager.executeAction(context, actionAnnotation);
|
||||||
PointSet data = pack.iterator().next().get();
|
PointSet data = node.iterator().next().get();
|
||||||
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
|
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,17 +18,10 @@ package inr.numass.utils;
|
|||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
import hep.dataforge.points.ListPointSet;
|
import hep.dataforge.points.ListPointSet;
|
||||||
import inr.numass.data.SpectrumDataAdapter;
|
import inr.numass.data.SpectrumDataAdapter;
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.exp;
|
import static java.lang.Math.exp;
|
||||||
import static java.lang.Math.sqrt;
|
import static java.lang.Math.sqrt;
|
||||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||||
import static java.lang.Math.abs;
|
import static java.lang.Math.abs;
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -68,7 +61,7 @@ public class TritiumUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ListPointSet correctForDeadTime(ListPointSet data, double dtime) {
|
public static ListPointSet correctForDeadTime(ListPointSet data, double dtime) {
|
||||||
SpectrumDataAdapter reader = new SpectrumDataAdapter(data.meta().getNode("aliases"));
|
SpectrumDataAdapter reader = adapter();
|
||||||
ListPointSet res = new ListPointSet(data.getDataFormat());
|
ListPointSet res = new ListPointSet(data.getDataFormat());
|
||||||
for (DataPoint dp : data) {
|
for (DataPoint dp : data) {
|
||||||
double corrFactor = 1 / (1 - dtime * reader.getCount(dp) /reader.getTime(dp));
|
double corrFactor = 1 / (1 - dtime * reader.getCount(dp) /reader.getTime(dp));
|
||||||
@ -86,7 +79,7 @@ public class TritiumUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ListPointSet setHVScale(ListPointSet data, double beta) {
|
public static ListPointSet setHVScale(ListPointSet data, double beta) {
|
||||||
SpectrumDataAdapter reader = new SpectrumDataAdapter(data.meta().getNode("aliases"));
|
SpectrumDataAdapter reader = adapter();
|
||||||
ListPointSet res = new ListPointSet(data.getDataFormat());
|
ListPointSet res = new ListPointSet(data.getDataFormat());
|
||||||
for (DataPoint dp : data) {
|
for (DataPoint dp : data) {
|
||||||
double corrFactor = 1 + beta;
|
double corrFactor = 1 + beta;
|
||||||
@ -95,6 +88,10 @@ public class TritiumUtils {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SpectrumDataAdapter adapter(){
|
||||||
|
return new SpectrumDataAdapter("Uset", "CR", "CRerr", "Time");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integral beta spectrum background with given amplitude (total count rate
|
* Integral beta spectrum background with given amplitude (total count rate
|
||||||
* from)
|
* from)
|
||||||
|
@ -14,7 +14,9 @@ import hep.dataforge.actions.ActionStateListener;
|
|||||||
import hep.dataforge.actions.RunManager;
|
import hep.dataforge.actions.RunManager;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.context.GlobalContext;
|
import hep.dataforge.context.GlobalContext;
|
||||||
import hep.dataforge.data.DataManager;
|
import hep.dataforge.data.DataFactory;
|
||||||
|
import hep.dataforge.data.DataNode;
|
||||||
|
import hep.dataforge.data.FileDataFactory;
|
||||||
import hep.dataforge.description.ActionDescriptor;
|
import hep.dataforge.description.ActionDescriptor;
|
||||||
import hep.dataforge.description.DescriptorUtils;
|
import hep.dataforge.description.DescriptorUtils;
|
||||||
import hep.dataforge.exceptions.NameNotFoundException;
|
import hep.dataforge.exceptions.NameNotFoundException;
|
||||||
@ -296,9 +298,9 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
public void runActions() {
|
public void runActions() {
|
||||||
clearAllStages();
|
clearAllStages();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
ActionResult data = new DataManager(getContext()).readFromConfig(getDataConfiguration());
|
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
|
||||||
Action action = RunManager.readAction(getContext(), getActionConfiguration());
|
Action action = RunManager.readAction(getContext(), getActionConfiguration());
|
||||||
action.addListener(this);
|
// action.addListener(this);
|
||||||
action.run(data);
|
action.run(data);
|
||||||
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
||||||
}, "actions").start();
|
}, "actions").start();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.workbench;
|
package inr.numass.workbench;
|
||||||
|
|
||||||
import hep.dataforge.content.Named;
|
import hep.dataforge.names.Named;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.workbench;
|
package inr.numass.workbench;
|
||||||
|
|
||||||
import hep.dataforge.content.Named;
|
import hep.dataforge.names.Named;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.plots.PlotFrame;
|
import hep.dataforge.plots.PlotFrame;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.prop.ar;
|
package inr.numass.prop.ar;
|
||||||
|
|
||||||
import hep.dataforge.content.NamedMetaHolder;
|
import hep.dataforge.names.NamedMetaHolder;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.prop.ar;
|
package inr.numass.prop.ar;
|
||||||
|
|
||||||
import hep.dataforge.content.NamedMetaHolder;
|
import hep.dataforge.names.NamedMetaHolder;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
import hep.dataforge.points.ListPointSet;
|
import hep.dataforge.points.ListPointSet;
|
||||||
import hep.dataforge.points.MapPoint;
|
import hep.dataforge.points.MapPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user