use of gda.data.nexus.extractor.NexusGroupData in project gda-core by openGDA.
the class NXDetectorDataStringAppender method appendTo.
@Override
public void appendTo(NXDetectorData data, String detectorName) {
for (int i = 0; i < elementNames.size(); i++) {
String name = elementNames.get(i);
String t = elementValues.get(i);
if (t.startsWith("nxfile://")) {
data.addExternalFileLink(detectorName, name, t, 0);
}
data.addData(detectorName, name, new NexusGroupData(t), null, null, null, false);
}
}
use of gda.data.nexus.extractor.NexusGroupData in project gda-core by openGDA.
the class NXDetectorDataTAppender method appendTo.
@Override
public void appendTo(NXDetectorData data, String detectorName) {
for (int i = 0; i < elementNames.size(); i++) {
String name = elementNames.get(i);
INexusTree valdata = null;
T t = elementValues.get(i);
if (t instanceof Double) {
data.setPlottableValue(name, (Double) t);
valdata = data.addData(detectorName, name, new NexusGroupData((Double) t), null, null, null, true);
} else if (t instanceof Integer) {
data.setPlottableValue(name, ((Integer) t).doubleValue());
valdata = data.addData(detectorName, name, new NexusGroupData((Integer) t), null, null, null, true);
}
if (valdata == null)
throw new RuntimeException("Only Double or Integer currently supported by NXDetectorDataTAppender");
valdata.addChildNode(new NexusTreeNode("local_name", NexusExtractor.AttrClassName, valdata, new NexusGroupData(String.format("%s.%s", detectorName, name))));
}
}
use of gda.data.nexus.extractor.NexusGroupData in project gda-core by openGDA.
the class NXDetectorDataFileAppenderForSrs method appendTo.
@Override
public void appendTo(NXDetectorData data, String detectorName) {
if (!(data instanceof NXDetectorDataWithFilepathForSrs)) {
logger.error("The read method which returns this object for {} must implement " + "NXFileWriterPlugin and return appendsFilepathStrings=true.", detectorName);
}
if (!StringUtils.hasLength(filename)) {
throw new IllegalArgumentException("filename is null or zero length");
}
NXDetectorDataWithFilepathForSrs dataForSrs = (NXDetectorDataWithFilepathForSrs) data;
NexusTreeNode fileNameNode = dataForSrs.addFileNames(detectorName, "image_data", new String[] { filename }, true, true);
fileNameNode.addChildNode(new NexusTreeNode("signal", NexusExtractor.AttrClassName, fileNameNode, new NexusGroupData(1)));
// add filename as an NXNote
dataForSrs.addFileName(detectorName, filename);
int indexOf = Arrays.asList(data.getExtraNames()).indexOf(filepathExtraName);
dataForSrs.setFilepathOutputFieldIndex(indexOf);
// this is needed as we have added an entry in extraNames
data.setPlottableValue(filepathExtraName, 0.);
if (xPixelSize != null) {
data.addData(detectorName, "x_pixel_size", new NexusGroupData(xPixelSize), xPixelSizeUnit);
}
if (yPixelSize != null) {
data.addData(detectorName, "y_pixel_size", new NexusGroupData(yPixelSize), yPixelSizeUnit);
}
}
use of gda.data.nexus.extractor.NexusGroupData in project gda-core by openGDA.
the class RoiStatsProcessor method process.
@Override
public GDANexusDetectorData process(String detectorName, String dataName, Dataset dataset) throws Exception {
NXDetectorData result = new NXDetectorData();
for (RegionOfInterest roi : roiList) {
Set<RoiMetadata> rois = roi.getRoiMetadata();
NXDetectorData roiData = new NXDetectorData(rois.stream().map(RoiMetadata::getName).toArray(String[]::new), rois.stream().map(RoiMetadata::getFormat).toArray(String[]::new), detectorName);
for (RoiMetadata roiMeta : rois) {
// in addData the null args are: units, signalVal and interpretation
roiData.addData(detectorName, roiMeta.getName(), new NexusGroupData(roiMeta.getData()), null, null, null, true);
roiData.setPlottableValue(roiMeta.getName(), roiMeta.getData());
}
roiData.mergeIn(statsProcessor.process(detectorName, roi.getNamePrefix(), dataset.getSliceView(roi.getSlice())));
result.mergeIn(roiData);
}
return result;
}
use of gda.data.nexus.extractor.NexusGroupData in project gda-core by openGDA.
the class ExampleDataSetProcessor method process.
@Override
public GDANexusDetectorData process(final String detName, String dataName, Dataset dataset) throws Exception {
val = val + 1.;
NXDetectorData res = new NXDetectorData();
res.addData(detName, new NexusGroupData(val), null, 1);
return res;
}
Aggregations