本文整理汇总了Java中org.eclipse.january.dataset.IDataset类的典型用法代码示例。如果您正苦于以下问题:Java IDataset类的具体用法?Java IDataset怎么用?Java IDataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataset类属于org.eclipse.january.dataset包,在下文中一共展示了IDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPartControl
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
if (system==null) {
parent.setLayout(new GridLayout(1, false));
final Label msg = new Label(parent, SWT.WRAP);
msg.setText("No plotting system found available.\nThere are probably no bundles providing plotting in the run configuration.\nThese may be obtained from dawn p2, for instance:\nhttp://opengda.org/DawnDiamond/2.0/updates/release/\n\nA static image is shown for our enjoyment.");
final Label img = new Label(parent, SWT.NONE);
img.setImage(XcenActivator.getImageDescriptor("icons/xstall.png").createImage());
return;
}
super.createPartControl(parent);
// TODO Hard coded an x-stall, should come from current data acquisition.
try {
final File loc = new File(BundleUtils.getBundleLocation(XcenActivator.PLUGIN_ID), "icons/xstall.png");
final IDataset image = service.getDataset(loc.getAbsolutePath(), new IMonitor.Stub());
system.createPlot2D(image, null, new NullProgressMonitor());
} catch (Exception ne) {
logger.error("Cannot load dataset!", ne);
}
}
示例2: calculateJuliaSet
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
/**
* Fill a Julia set around the origin for the value C = a + bi
*/
private IDataset calculateJuliaSet(final double a, final double b, int columns, int rows) {
final double xStart = -model.getMaxRealCoordinate();
final double xStop = model.getMaxRealCoordinate();
final double yStart = -model.getMaxImaginaryCoordinate();
final double yStop = model.getMaxImaginaryCoordinate();
final double yStep = (yStop - yStart) / (rows - 1);
double y;
IDataset juliaSet = DatasetFactory.zeros(rows,columns);
for (int yIndex = 0; yIndex < rows; yIndex++) {
y = yStart + yIndex * yStep;
IDataset line = calculateJuliaSetLine(a, b, y, xStart, xStop, columns);
for (int x = 0; x < line.getSize(); x++) {
juliaSet.set(line.getObject(x), yIndex, x);
}
}
return juliaSet;
}
示例3: writePosition
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Override
public void writePosition(IPosition position) throws Exception {
for (DummyMalcolmDatasetModel datasetModel : model.getDatasets()) {
// create the data to write into the dataset
int[] dataShape = getDataShape(datasetModel);
IDataset data = Random.rand(dataShape);
writeData(datasetModel.getName(), position, data);
}
// write the demand position for each malcolm controlled axis
for (String axisName : getModel().getAxesToMove()) {
writeDemandData(axisName, position);
}
// write unique key
final int uniqueKey = position.getStepIndex() + 1;
final IDataset newPositionData = DatasetFactory.createFromObject(uniqueKey);
writeData(DATASET_NAME_UNIQUE_KEYS, position, newPositionData);
nexusFile.flush();
}
示例4: write
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Override
public boolean write(IPosition loc) throws ScanningException {
try {
// Get the dataset we are slicing
ILoaderService lservice = ServiceHolder.getLoaderService();
IDataHolder holder = lservice.getData(model.getDataFile(), new IMonitor.Stub());
ILazyDataset data = holder.getLazyDataset("/entry/instrument/"+model.getDetectorName()+"/data");
int[] dshape = getDataShape(data);
IScanSlice rslice = IScanRankService.getScanRankService().createScanSlice(loc, dshape);
SliceND sliceData = new SliceND(data.getShape(), rslice.getStart(), rslice.getStop(), rslice.getStep());
IDataset slice = data.getSlice(sliceData);
return process(new SliceDeviceContext(loc, rslice, data, slice));
} catch (ScanningException se) {
throw se;
} catch (Exception other) {
throw new ScanningException(other);
}
}
示例5: process
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Override
boolean process(SliceDeviceContext context) throws ScanningException {
processed.setChunking(info.createChunk(getDataShape(context.getData())));
IJythonFunction jython = factory.createObject();
IDataset ret = jython.process(context.getSlice());
IScanSlice sslice = IScanRankService.getScanRankService().createScanSlice(context.getLocation(), ret.getShape());
SliceND slicenD = new SliceND(processed.getShape(), processed.getMaxShape(), sslice.getStart(), sslice.getStop(), sslice.getStep());
try {
processed.setSlice(null, ret, slicenD);
} catch (DatasetException e) {
throw new ScanningException(e);
}
return true;
}
示例6: createPlot
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
private void createPlot(AxisConfiguration conf) {
if (conf==null) return;
IDataset image = null;
if (conf.getMicroscopeImage()!=null && !"".equals(conf.getMicroscopeImage())) {
try {
image = ServiceHolder.getLoaderService().getDataset(conf.getMicroscopeImage(), null);
} catch (Exception ne) {
final File file = new File(conf.getMicroscopeImage());
ErrorDialog.openError(site.getShell(), "Problem Reading '"+file.getName()+"'",
"There was a problem reading '"+file.getName()+"'\n\n"
+ "Please contact our support representative.", new Status(IStatus.ERROR, Activator.PLUGIN_ID, ne.getMessage(), ne));
logger.error("Cannot read file!", ne);
}
}
if (image==null && conf.isRandomNoise()) {
image = Random.rand(4096, 3012);
}
if (image==null) {
system.getSelectedXAxis().setRange(conf.getFastAxisStart(), conf.getFastAxisEnd());
system.getSelectedYAxis().setRange(conf.getSlowAxisStart(), conf.getSlowAxisEnd());
return;
}
createTrace(conf, image);
}
示例7: createTrace
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
private void createTrace(AxisConfiguration conf, IDataset image) {
// Images are reversed
int fsize = image.getShape()[1];
int ssize = image.getShape()[0];
IDataset x = DatasetFactory.createRange(conf.getFastAxisStart(), conf.getFastAxisEnd(), (conf.getFastAxisEnd()-conf.getFastAxisStart())/fsize, Dataset.FLOAT);
x.setName(conf.getFastAxisName());
IDataset y = DatasetFactory.createRange(conf.getSlowAxisStart(), conf.getSlowAxisEnd(), (conf.getSlowAxisEnd()-conf.getSlowAxisStart())/ssize, Dataset.FLOAT);
y.setName(conf.getSlowAxisName());
IImageTrace it = system.getTrace("image")!=null
? (IImageTrace)system.getTrace("image")
: system.createImageTrace("image");
it.setData(image, Arrays.asList(new IDataset[]{x,y}), false);
double[] globalRange = new double[4];
globalRange[0] = conf.getFastAxisStart();
globalRange[1] = conf.getFastAxisEnd();
globalRange[2] = conf.getSlowAxisStart();
globalRange[3] = conf.getSlowAxisEnd();
it.setGlobalRange(globalRange);
system.addTrace(it);
job.schedule();
}
示例8: calculateJuliaSet
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
/**
* Fill a Julia set around the origin for the value C = a + bi
*/
private IDataset calculateJuliaSet(final double a, final double b, int columns, int rows) {
final double xStart = -model.getMaxx();
final double xStop = model.getMaxx();
final double yStart = -model.getMaxy();
final double yStop = model.getMaxy();
final double yStep = (yStop - yStart) / (rows - 1);
double y;
IDataset juliaSet = DatasetFactory.zeros(DoubleDataset.class, 1, 1, rows, columns);
for (int yIndex = 0; yIndex < rows; yIndex++) {
y = yStart + yIndex * yStep;
IDataset line = calculateJuliaSetLine(a, b, y, xStart, xStop, columns);
for (int x = 0; x < line.getSize(); x++) {
juliaSet.set(line.getObject(x), 0, 0, yIndex, x);
}
}
return juliaSet;
}
示例9: assertScanShape
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
private static void assertScanShape(NXcollection solsticeScanCollection, int... sizes) {
DataNode shapeDataNode = solsticeScanCollection.getDataNode(FIELD_NAME_SCAN_SHAPE);
assertNotNull(shapeDataNode);
IDataset shapeDataset;
try {
shapeDataset = shapeDataNode.getDataset().getSlice();
} catch (DatasetException e) {
throw new AssertionError("Could not get data from lazy dataset", e);
}
assertEquals(Integer.class, shapeDataset.getElementClass());
if (sizes.length == 0) {
// TODO remove this workaround when january updated
assertEquals(0, shapeDataset.getRank());
assertArrayEquals(new int[0], shapeDataset.getShape());
} else {
assertEquals(1, shapeDataset.getRank());
assertArrayEquals(new int[] { sizes.length }, shapeDataset.getShape());
for (int i = 0; i < sizes.length; i++) {
assertEquals(sizes[i], shapeDataset.getInt(i));
}
}
}
示例10: assertScanFinished
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
private static void assertScanFinished(NXentry entry, boolean finished) {
NXcollection scanPointsCollection = entry.getCollection(GROUP_NAME_SOLSTICE_SCAN);
assertNotNull(scanPointsCollection);
// check the scan finished boolean is set to true
DataNode dataNode = scanPointsCollection.getDataNode(FIELD_NAME_SCAN_FINISHED);
assertNotNull(dataNode);
IDataset dataset;
try {
dataset = dataNode.getDataset().getSlice();
} catch (DatasetException e) {
throw new AssertionError("Could not get data from lazy dataset", e);
}
assertEquals(Dataset.INT32, DTypeUtils.getDType(dataset)); // HDF5 doesn't support boolean datasets
assertEquals(1, dataset.getRank());
assertArrayEquals(new int[] {1}, dataset.getShape());
assertEquals(finished, dataset.getBoolean(0));
}
示例11: writeDataset
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
private void writeDataset(ILazyWriteableDataset datasetWriter, SliceND slice) throws EventException, InterruptedException {
try {
IScannable<?> scannable = scanDevService.getScannable(queueBean.getMonitor());
IDataset toWrite = DatasetFactory.createFromObject(scannable.getPosition());
datasetWriter.setSlice(new IMonitor.Stub(), toWrite, slice);
if (isTerminated()) throw new InterruptedException("Termination requested");
} catch (DatasetException dsEx) {
logger.error("Could not pass data from monitor into LazyDataset for writing");
broadcast(Status.FAILED, "Failed writing to LazyDataset: "+dsEx.getMessage());
throw new EventException("Failed writing to LazyDataset", dsEx);
} catch (ScanningException scEx) {
logger.error("Failed to get monitor with the name '"+queueBean.getMonitor()+"': "+scEx.getMessage());
broadcast(Status.FAILED, "Failed to get monitor with the name '"+queueBean.getMonitor()+"'");
throw new EventException("Failed to get monitor with the name '"+queueBean.getMonitor()+"'", scEx);
} catch (InterruptedException iEx) {
//We don't actually want to catch this here - it's handled in the calling method
throw iEx;
} catch (Exception ex) {
logger.error("Failed to read monitor with the name '"+queueBean.getMonitor()+"'");
broadcast(Status.FAILED, "Failed to read monitor with the name '"+queueBean.getMonitor()+"'");
throw new EventException("Failed to read monitor with the name '"+queueBean.getMonitor()+"'", ex);
}
}
示例12: testAxesMetadataReshapeEmpty
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Test
public void testAxesMetadataReshapeEmpty() throws Exception {
final int[] shape = new int[] { 1, 2, 3, 1 };
int r = shape.length;
ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
dataset.addMetadata(amd);
ILazyDataset v = dataset.getSliceView();
v.squeezeEnds();
assertEquals(2, v.getMetadata(AxesMetadata.class).get(0).getAxes().length);
IDataset d = v.getSlice(new Slice(1), null);
assertEquals(2, d.getMetadata(AxesMetadata.class).get(0).getAxes().length);
final int[] reshape = new int[] { 1, 1, 2, 3, 1 };
v.setShape(reshape);
assertEquals(5, v.getMetadata(AxesMetadata.class).get(0).getAxes().length);
d = v.getSlice((Slice) null, null, new Slice(1));
assertEquals(5, d.getMetadata(AxesMetadata.class).get(0).getAxes().length);
}
示例13: testSliceFromView
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
@Test
public void testSliceFromView() throws DatasetException {
final int[] shape = new int[] { 3, 10, 11};
final int[] ashape = new int[] {3};
ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
ILazyDataset ax = Random.lazyRand(Dataset.INT32, "Axis", ashape);
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, shape.length);
amd.setAxis(0, ax);
dataset.setMetadata(amd);
ILazyDataset view = dataset.getSliceView(new Slice(1,2),null,null);
IDataset slice = view.getSlice();
assertTrue(slice != null);
}
示例14: logicalAnd
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
/**element-by-element AND operator
* a & b logical_and(a,b)
*/
@Test
public void logicalAnd() {
// Equivalent tech
BooleanDataset bs = Comparisons.logicalAnd(a, b);
System.out.println("Result of a && b "+bs);
// Or more useful (?)
final IDataset booleans = DatasetFactory.zeros(BooleanDataset.class, 3, 3);
booleans.set(true, 0,0);
booleans.set(true, 1,1);
booleans.set(true, 1,2);
final IDataset and = Maths.multiply(a, booleans);
System.out.println("Keeping some values using a boolean mask "+and);
}
示例15: iterateImagesND
import org.eclipse.january.dataset.IDataset; //导入依赖的package包/类
/**
* Slice using basic Slice object
* @throws Exception
*/
@Test
public void iterateImagesND() throws DatasetException {
final ILazyDataset lz = Random.lazyRand(64, 64, 100, 100);
final PositionIterator it = new PositionIterator(new int[]{64, 64});
while(it.hasNext()) {
int[] pos = it.getPos();
Slice[] slice = new Slice[lz.getRank()];
for (int i = 0; i < pos.length; i++) {
slice[i] = new Slice(pos[i], pos[i]+1);
}
IDataset image = lz.getSlice(slice);
image.squeeze(); // This changes shape from 1,1,100,100 to 100,100
assertTrue(Arrays.equals(new int[]{100, 100}, image.getShape()));
}
}