[no commit message]

This commit is contained in:
Alexander Nozik 2016-01-10 22:11:35 +03:00
parent 32cfbff1e2
commit 243f9f541c
10 changed files with 207 additions and 208 deletions

View File

@ -160,7 +160,7 @@ public class NumassPlugin extends BasicPlugin {
double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0);
Model res = new WeightedXYModel("scatter-variable", spectrum, getAdapter(an), (dp) -> weightReductionFactor); Model res = new WeightedXYModel("scatter-variable", spectrum, getAdapter(an), (dp) -> weightReductionFactor);
res.configure(an); res.setMeta(an);
return res; return res;
}); });
@ -196,7 +196,7 @@ public class NumassPlugin extends BasicPlugin {
double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0);
Model res = new WeightedXYModel("scatter-empiric-experimental", spectrum, getAdapter(an), (dp) -> weightReductionFactor); Model res = new WeightedXYModel("scatter-empiric-experimental", spectrum, getAdapter(an), (dp) -> weightReductionFactor);
res.configure(an); res.setMeta(an);
return res; return res;
}); });

View File

@ -102,7 +102,7 @@ public class MergeDataAction extends ManyToOneAction<DataSet, DataSet> {
* Указываем путь только если он одинаковый для всех входных файлов * Указываем путь только если он одинаковый для всех входных файлов
*/ */
if (numassPath != null) { if (numassPath != null) {
res.configure(res.meta().getBuilder().putValue("numass.path", numassPath).build()); res.setMeta(res.meta().getBuilder().putValue("numass.path", numassPath).build());
} }
res = res.sort("Uset", true); res = res.sort("Uset", true);

View File

@ -34,7 +34,6 @@ import inr.numass.data.NMPoint;
import inr.numass.data.RawNMPoint; import inr.numass.data.RawNMPoint;
import java.io.OutputStream; import java.io.OutputStream;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneOffset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.data; package inr.numass.data;
import hep.dataforge.content.AbstractContent; import hep.dataforge.content.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;
@ -33,7 +33,7 @@ import java.util.List;
*/ */
@ValueDef(name = "numass.path", info = "Path to this data file in numass repository.") @ValueDef(name = "numass.path", info = "Path to this data file in numass repository.")
@ValueDef(name = "numass.name", info = "The name of this data file.") @ValueDef(name = "numass.name", info = "The name of this data file.")
public class NMFile extends AbstractContent implements NumassData { public class NMFile extends NamedMetaHolder implements NumassData {
public static NMFile readStream(InputStream is, String fname, Meta config) throws IOException{ public static NMFile readStream(InputStream is, String fname, Meta config) throws IOException{
return new NMFile(new NumassDataReader(is, fname, config).read()); return new NMFile(new NumassDataReader(is, fname, config).read());

View File

@ -13,120 +13,121 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package inr.numass.data; package inr.numass.data;
import hep.dataforge.content.AbstractContent; import hep.dataforge.content.Content;
import java.io.BufferedOutputStream; import hep.dataforge.content.NamedMetaHolder;
import java.io.OutputStream; import java.io.BufferedOutputStream;
import java.io.PrintWriter; import java.io.OutputStream;
import java.util.ArrayList; import java.io.PrintWriter;
import java.util.List; import java.util.ArrayList;
import java.util.List;
/**
* Contains the whole data but requires a lot of memory /**
* @author Darksnake * Contains the whole data but requires a lot of memory
*/ * @author Darksnake
public class RawNMFile extends AbstractContent { */
public class RawNMFile extends NamedMetaHolder implements Content {
// public static String TYPE = ":data:numassdatafile";
// public static String TYPE = ":data:numassdatafile";
private final List<RawNMPoint> points;
private final List<RawNMPoint> points;
private String head;
private String head;
public void setHead(String head) {
this.head = head; public void setHead(String head) {
} this.head = head;
}
public String getHead() {
return head; public String getHead() {
} return head;
}
public RawNMFile(String fileName) {
super(fileName); public RawNMFile(String fileName) {
this.points = new ArrayList<>(); super(fileName);
} this.points = new ArrayList<>();
}
public void generatePAW(OutputStream stream) {
PrintWriter writer = new PrintWriter(new BufferedOutputStream(stream)); public void generatePAW(OutputStream stream) {
long counter = 0; PrintWriter writer = new PrintWriter(new BufferedOutputStream(stream));
for (RawNMPoint point : this.getData()) { long counter = 0;
double U = point.getUread(); for (RawNMPoint point : this.getData()) {
for (NMEvent event : point.getEvents()) { double U = point.getUread();
counter++; for (NMEvent event : point.getEvents()) {
writer.printf("%d\t%f\t%d\t%.1f\t%.2f%n", counter, event.getTime(), event.getChanel(), point.getLength(), U); counter++;
} writer.printf("%d\t%f\t%d\t%.1f\t%.2f%n", counter, event.getTime(), event.getChanel(), point.getLength(), U);
}
}
writer.flush(); }
} writer.flush();
}
/**
* merge of all point with given Uset /**
* @param U * merge of all point with given Uset
* @return * @param U
*/ * @return
public RawNMPoint getByUset(double U) { */
RawNMPoint res = null; public RawNMPoint getByUset(double U) {
RawNMPoint res = null;
for (RawNMPoint point : points) {
if (point.getUset() == U) { for (RawNMPoint point : points) {
if (res == null) { if (point.getUset() == U) {
res = point.clone(); if (res == null) {
} else { res = point.clone();
res = res.merge(point); } else {
} res = res.merge(point);
} }
} }
return res; }
} return res;
}
/**
* merge of all point with given Uread /**
* @param U * merge of all point with given Uread
* @return * @param U
*/ * @return
public RawNMPoint getByUread(double U) { */
RawNMPoint res = null; public RawNMPoint getByUread(double U) {
RawNMPoint res = null;
for (RawNMPoint point : points) {
if (point.getUread()== U) { for (RawNMPoint point : points) {
if (res == null) { if (point.getUread()== U) {
res = point.clone(); if (res == null) {
} else { res = point.clone();
res = res.merge(point); } else {
} res = res.merge(point);
} }
} }
return res; }
} return res;
}
/**
* @return the data /**
*/ * @return the data
public List<RawNMPoint> getData() { */
return points; public List<RawNMPoint> getData() {
} return points;
}
void putEvent(double U, short chanel, double time) {
for (RawNMPoint point : this.getData()) { void putEvent(double U, short chanel, double time) {
if (U == point.getUread()) { for (RawNMPoint point : this.getData()) {
point.putEvent(new NMEvent(chanel, time)); if (U == point.getUread()) {
return; point.putEvent(new NMEvent(chanel, time));
} return;
} }
RawNMPoint newpoint = new RawNMPoint(); }
newpoint.putEvent(new NMEvent(chanel, time)); RawNMPoint newpoint = new RawNMPoint();
this.putPoint(newpoint); newpoint.putEvent(new NMEvent(chanel, time));
} this.putPoint(newpoint);
}
public void putPoint(RawNMPoint point) {
points.add(point); public void putPoint(RawNMPoint point) {
} points.add(point);
}
public int size() {
return this.points.size(); public int size() {
} return this.points.size();
}
}
}

View File

@ -13,43 +13,43 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package inr.numass.prop.ar; package inr.numass.prop.ar;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.content.AbstractContent; import hep.dataforge.content.NamedMetaHolder;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* An episode of JNA measurements * An episode of JNA measurements
* *
* @author Darksnake * @author Darksnake
*/ */
public class JNAEpisode extends AbstractContent implements Iterable<JNASpectrum> { public class JNAEpisode extends NamedMetaHolder implements Iterable<JNASpectrum> {
private final List<JNASpectrum> spectra; private final List<JNASpectrum> spectra;
public JNAEpisode(String name, List<JNASpectrum> spectra) { public JNAEpisode(String name, List<JNASpectrum> spectra) {
super(name); super(name);
this.spectra = spectra; this.spectra = spectra;
} }
public JNAEpisode(String name, Meta annotation, List<JNASpectrum> spectra) { public JNAEpisode(String name, Meta annotation, List<JNASpectrum> spectra) {
super(name, annotation); super(name, annotation);
this.spectra = spectra; this.spectra = spectra;
} }
@Override @Override
public Iterator<JNASpectrum> iterator() { public Iterator<JNASpectrum> iterator() {
return spectra.iterator(); return spectra.iterator();
} }
public JNASpectrum get(int i) { public JNASpectrum get(int i) {
return spectra.get(i); return spectra.get(i);
} }
public int size() { public int size() {
return spectra.size(); return spectra.size();
} }
} }

View File

@ -17,7 +17,7 @@ package inr.numass.prop.ar;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.content.AbstractContent; import hep.dataforge.content.NamedMetaHolder;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.data.DataPoint; import hep.dataforge.data.DataPoint;
@ -37,7 +37,7 @@ import java.util.Map;
@NodeDef(name = "temperature", info = "The temperature measurements data for this spectrum.") @NodeDef(name = "temperature", info = "The temperature measurements data for this spectrum.")
@ValueDef(name = "relativeStartTime", type = "NUMBER", info = "Start time in days relative to some starting point.") @ValueDef(name = "relativeStartTime", type = "NUMBER", info = "Start time in days relative to some starting point.")
@ValueDef(name = "relativeStopTime", type = "NUMBER", info = "Stop time in days relative to some starting point.") @ValueDef(name = "relativeStopTime", type = "NUMBER", info = "Stop time in days relative to some starting point.")
public class JNASpectrum extends AbstractContent { public class JNASpectrum extends NamedMetaHolder {
public static String[] names = {"chanel", "count"}; public static String[] names = {"chanel", "count"};

View File

@ -21,7 +21,6 @@ import hep.dataforge.context.Context;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.log.Logable; import hep.dataforge.io.log.Logable;
import hep.dataforge.values.ValueType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;

View File

@ -13,44 +13,44 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package inr.numass.prop; package inr.numass.prop;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.data.DataSet; import hep.dataforge.data.DataSet;
import hep.dataforge.data.FileData; import hep.dataforge.data.FileData;
import hep.dataforge.datafitter.MINUITPlugin; import hep.dataforge.datafitter.MINUITPlugin;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import inr.numass.prop.ar.FitJNAData; import inr.numass.prop.ar.FitJNAData;
import inr.numass.prop.ar.JNAEpisode; import inr.numass.prop.ar.JNAEpisode;
import inr.numass.prop.ar.ReadJNADataAction; import inr.numass.prop.ar.ReadJNADataAction;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
/** /**
* *
* @author Darksnake * @author Darksnake
*/ */
public class TestFit { public class TestFit {
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws FileNotFoundException, InterruptedException { public static void main(String[] args) throws FileNotFoundException, InterruptedException {
GlobalContext.instance().loadPlugin(new MINUITPlugin()); GlobalContext.instance().loadPlugin(new MINUITPlugin());
File sourceDir = new File("c:\\Users\\Darksnake\\Dropbox\\jna_data"); File sourceDir = new File("c:\\Users\\Darksnake\\Dropbox\\jna_data");
FileData file = new FileData(new File(sourceDir, "ar37e2.dat")); FileData file = new FileData(new File(sourceDir, "ar37e2.dat"));
file.annotate(new MetaBuilder("meta") file.setMeta(new MetaBuilder("meta")
.putValue("timeFile", "tar37e2.dat") .putValue("timeFile", "tar37e2.dat")
.putValue("temperatureFile", "e2temp.txt") .putValue("temperatureFile", "e2temp.txt")
); );
JNAEpisode spectra = new ReadJNADataAction(GlobalContext.instance(), null).runOne(file); JNAEpisode spectra = new ReadJNADataAction(GlobalContext.instance(), null).runOne(file);
DataSet data = new FitJNAData(GlobalContext.instance(), null).runOne(spectra); DataSet data = new FitJNAData(GlobalContext.instance(), null).runOne(spectra);
ColumnedDataWriter.writeDataSet(System.out, data, "***RESULT***"); ColumnedDataWriter.writeDataSet(System.out, data, "***RESULT***");
} }
} }

View File

@ -45,7 +45,7 @@ public class TestReader {
// new MINUITModule().load(); // new MINUITModule().load();
FileData file = new FileData(new File("c:\\Users\\Darksnake\\Dropbox\\jna_data\\ar37e2.dat")); FileData file = new FileData(new File("c:\\Users\\Darksnake\\Dropbox\\jna_data\\ar37e2.dat"));
file.annotate(new MetaBuilder("meta") file.setMeta(new MetaBuilder("meta")
.putValue("timeFile", "c:\\Users\\Darksnake\\Dropbox\\jna_data\\tar37e2.dat") .putValue("timeFile", "c:\\Users\\Darksnake\\Dropbox\\jna_data\\tar37e2.dat")
.putValue("temperatureFile", "c:\\Users\\Darksnake\\Dropbox\\jna_data\\e2temp.txt") .putValue("temperatureFile", "c:\\Users\\Darksnake\\Dropbox\\jna_data\\e2temp.txt")
); );