Fit sytem partially redone
This commit is contained in:
parent
5eb59a9f98
commit
d5a04116e1
@ -76,7 +76,7 @@ allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
|
|||||||
SpectrumGenerator generator = new SpectrumGenerator(model, allPars);
|
SpectrumGenerator generator = new SpectrumGenerator(model, allPars);
|
||||||
|
|
||||||
// ColumnedDataFile file = new ColumnedDataFile("d:\\PlayGround\\RUN36.cfg");
|
// ColumnedDataFile file = new ColumnedDataFile("d:\\PlayGround\\RUN36.cfg");
|
||||||
// ListTable config = file.getDataSet("time","X");
|
// ListTable config = file.getPoints("time","X");
|
||||||
double Elow = 14000d;
|
double Elow = 14000d;
|
||||||
double Eup = 18600d;
|
double Eup = 18600d;
|
||||||
int numpoints = (int) ((Eup - Elow) / 50);
|
int numpoints = (int) ((Eup - Elow) / 50);
|
||||||
|
@ -47,17 +47,19 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
|
|||||||
@Override
|
@Override
|
||||||
protected FitResult execute(Context context, String name, FitResult input, Laminate metaData) {
|
protected FitResult execute(Context context, String name, FitResult input, Laminate metaData) {
|
||||||
|
|
||||||
NavigablePointSource data = input.getDataSet();
|
FitState state = input.getState().orElseThrow(()->new UnsupportedOperationException("Can't work with fit result not containing state, sorry! Will fix it later"));
|
||||||
if (!(input.getModel() instanceof XYModel)) {
|
|
||||||
|
NavigablePointSource data = input.getData();
|
||||||
|
if (!(state.getModel() instanceof XYModel)) {
|
||||||
context.getLog(name).reportError("The fit model should be instance of XYModel for this action. Action failed!");
|
context.getLog(name).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) state.getModel();
|
||||||
|
|
||||||
XYAdapter adapter;
|
XYAdapter adapter;
|
||||||
if (metaData.hasMeta("adapter")) {
|
if (metaData.hasMeta("adapter")) {
|
||||||
adapter = new XYAdapter(metaData.getMeta("adapter"));
|
adapter = new XYAdapter(metaData.getMeta("adapter"));
|
||||||
} else if (input.getModel() instanceof XYModel) {
|
} else if (state.getModel() instanceof XYModel) {
|
||||||
adapter = model.getAdapter();
|
adapter = model.getAdapter();
|
||||||
} else {
|
} else {
|
||||||
throw new ContentException("No adapter defined for data interpretation");
|
throw new ContentException("No adapter defined for data interpretation");
|
||||||
@ -73,7 +75,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
|
|||||||
fit.setSmoothing(true);
|
fit.setSmoothing(true);
|
||||||
// ensuring all data points are calculated explicitly
|
// ensuring all data points are calculated explicitly
|
||||||
StreamSupport.stream(data.spliterator(), false)
|
StreamSupport.stream(data.spliterator(), false)
|
||||||
.map(dp -> adapter.getX(dp).doubleValue()).sorted().forEach(d -> fit.calculateIn(d));
|
.map(dp -> adapter.getX(dp).doubleValue()).sorted().forEach(fit::calculateIn);
|
||||||
|
|
||||||
frame.add(fit);
|
frame.add(fit);
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.stat.fit.FitAction;
|
import hep.dataforge.stat.fit.FitAction;
|
||||||
import hep.dataforge.stat.fit.FitResult;
|
import hep.dataforge.stat.fit.FitResult;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import hep.dataforge.workspace.AbstractTask;
|
import hep.dataforge.workspace.AbstractTask;
|
||||||
@ -23,11 +22,11 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* @author Alexander Nozik
|
* @author Alexander Nozik
|
||||||
*/
|
*/
|
||||||
public class NumassFitScanTask extends AbstractTask<FitState> {
|
public class NumassFitScanTask extends AbstractTask<FitResult> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataNode<FitState> run(TaskModel model, DataNode<?> data) {
|
protected DataNode<FitResult> run(TaskModel model, DataNode<?> data) {
|
||||||
Meta config = model.meta();
|
Meta config = model.meta();
|
||||||
String scanParameter = config.getString("scan.parameter", "msterile2");
|
String scanParameter = config.getString("scan.parameter", "msterile2");
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
|
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
|
||||||
}
|
}
|
||||||
Action<Table, FitResult> action = new FitAction();
|
Action<Table, FitResult> action = new FitAction();
|
||||||
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
|
DataTree.Builder<FitResult> resultBuilder = DataTree.builder(FitResult.class);
|
||||||
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);
|
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);
|
||||||
|
|
||||||
if (config.hasMeta("merge")) {
|
if (config.hasMeta("merge")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user