Search in sources :

Example 1 with NexusGroupData

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);
    }
}
Also used : NexusGroupData(gda.data.nexus.extractor.NexusGroupData)

Example 2 with NexusGroupData

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))));
    }
}
Also used : NexusTreeNode(gda.data.nexus.tree.NexusTreeNode) INexusTree(gda.data.nexus.tree.INexusTree) NexusGroupData(gda.data.nexus.extractor.NexusGroupData)

Example 3 with NexusGroupData

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);
    }
}
Also used : NXDetectorDataWithFilepathForSrs(gda.device.detector.NXDetectorDataWithFilepathForSrs) NexusTreeNode(gda.data.nexus.tree.NexusTreeNode) NexusGroupData(gda.data.nexus.extractor.NexusGroupData)

Example 4 with NexusGroupData

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;
}
Also used : RoiMetadata(gda.device.detector.nexusprocessor.roistats.RegionOfInterest.RoiMetadata) NXDetectorData(gda.device.detector.NXDetectorData) NexusGroupData(gda.data.nexus.extractor.NexusGroupData)

Example 5 with NexusGroupData

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;
}
Also used : NXDetectorData(gda.device.detector.NXDetectorData) NexusGroupData(gda.data.nexus.extractor.NexusGroupData)

Aggregations

NexusGroupData (gda.data.nexus.extractor.NexusGroupData)52 NexusTreeNode (gda.data.nexus.tree.NexusTreeNode)20 INexusTree (gda.data.nexus.tree.INexusTree)16 DeviceException (gda.device.DeviceException)9 NXDetectorData (gda.device.detector.NXDetectorData)9 Test (org.junit.Test)7 Dataset (org.eclipse.january.dataset.Dataset)6 Vector (java.util.Vector)5 GDANexusDetectorData (gda.device.detector.GDANexusDetectorData)4 NexusException (org.eclipse.dawnsci.nexus.NexusException)4 ILazyWriteableDataset (org.eclipse.january.dataset.ILazyWriteableDataset)4 PyString (org.python.core.PyString)4 NexusDetector (gda.device.detector.NexusDetector)3 File (java.io.File)3 URISyntaxException (java.net.URISyntaxException)3 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 IDataset (org.eclipse.january.dataset.IDataset)3 PyObject (org.python.core.PyObject)3 Detector (gda.device.Detector)2