本文整理汇总了Java中org.eclipse.january.dataset.DatasetFactory类的典型用法代码示例。如果您正苦于以下问题:Java DatasetFactory类的具体用法?Java DatasetFactory怎么用?Java DatasetFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatasetFactory类属于org.eclipse.january.dataset包,在下文中一共展示了DatasetFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: calculateJuliaSet
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的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;
}
开发者ID:eclipse,项目名称:scanning,代码行数:21,代码来源:MandelbrotDetector.java
示例2: write
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
private Number write(Number demand, Number actual, IPosition loc) throws Exception {
if (lzValue==null) return actual;
if (actual!=null) {
// write actual position
final Dataset newActualPositionData = DatasetFactory.createFromObject(actual);
IScanSlice rslice = IScanRankService.getScanRankService().createScanSlice(loc);
SliceND sliceND = new SliceND(lzValue.getShape(), lzValue.getMaxShape(), rslice.getStart(), rslice.getStop(), rslice.getStep());
if (isWritingOn()) lzValue.setSlice(null, newActualPositionData, sliceND);
}
if (lzSet==null) return actual;
if (demand!=null) {
int index = loc.getIndex(getName());
if (index<0) {
throw new Exception("Incorrect data index for scan for value of '"+getName()+"'. The index is "+index);
}
final int[] startPos = new int[] { index };
final int[] stopPos = new int[] { index + 1 };
// write demand position
final Dataset newDemandPositionData = DatasetFactory.createFromObject(demand);
if (isWritingOn()) lzSet.setSlice(null, newDemandPositionData, startPos, stopPos, null);
}
return actual;
}
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:MockNeXusScannable.java
示例3: getNexusProvider
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Override
public NexusObjectProvider<NXpositioner> getNexusProvider(NexusScanInfo info) throws NexusException {
final NXpositioner positioner = NexusNodeFactory.createNXpositioner();
positioner.setNameScalar(getName());
if (info.getScanRole(getName()) == ScanRole.MONITOR_PER_SCAN) {
try {
// note: assume this scannable is a monitor, so no set value dataset created
positioner.setValue(DatasetFactory.createFromObject(getPosition()));
} catch (Exception e) {
throw new NexusException("Could not get value for scannable " + getName(), e);
}
} else {
lzValue = positioner.initializeLazyDataset(NXpositioner.NX_VALUE, info.getRank(), String.class);
lzValue.setChunking(info.createChunk(false, 8));
lzValue.setWritingAsync(true);
}
registerAttributes(positioner, this);
return new NexusObjectWrapper<>(getName(), positioner, NXpositioner.NX_VALUE);
}
开发者ID:eclipse,项目名称:scanning,代码行数:23,代码来源:MockStringNexusScannable.java
示例4: writePosition
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的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();
}
开发者ID:eclipse,项目名称:scanning,代码行数:21,代码来源:DummyMalcolmDevice.java
示例5: writePosition
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
/**
* Write the given position to the NexusFile.
* The unique key of the position is added to the <code>uniqueKeys</code> dataset,
* and the position as a string, as returned by {@link IPosition#toString()},
* is added to the <code>points</code>
* @param position
* @throws Exception
*/
private Object writePosition(IPosition position) {
if (!malcolmScan) {
IScanSlice rslice = IScanRankService.getScanRankService().createScanSlice(position);
SliceND sliceND = new SliceND(uniqueKeysDataset.getShape(), uniqueKeysDataset.getMaxShape(), rslice.getStart(), rslice.getStop(), rslice.getStep());
final int uniqueKey = position.getStepIndex() + 1;
final Dataset newActualPosition = DatasetFactory.createFromObject(uniqueKey);
try {
uniqueKeysDataset.setSlice(null, newActualPosition, sliceND);
} catch (DatasetException e) {
logger.error("Could not write unique key");
}
return newActualPosition;
}
return null;
}
开发者ID:eclipse,项目名称:scanning,代码行数:24,代码来源:SolsticeScanMonitor.java
示例6: process
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Override
public boolean process(SliceDeviceContext context) throws ScanningException {
averaged.setChunking(info.createChunk(getDataShape(context.getData())));
double mean = (Double)context.getSlice().squeeze().mean();
IScanSlice sslice = IScanRankService.getScanRankService().createScanSlice(context.getLocation());
SliceND slicenD = new SliceND(averaged.getShape(), averaged.getMaxShape(), sslice.getStart(), sslice.getStop(), sslice.getStep());
try {
averaged.setSlice(null, DatasetFactory.createFromObject(mean), slicenD);
} catch (DatasetException e) {
throw new ScanningException(e);
}
return true;
}
开发者ID:eclipse,项目名称:scanning,代码行数:18,代码来源:AveragingSlicingDevice.java
示例7: createTrace
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的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();
}
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:PlottingController.java
示例8: calculateJuliaSet
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的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;
}
开发者ID:eclipse,项目名称:scanning,代码行数:21,代码来源:MockWritingMandelbrotDetector.java
示例9: writeDataset
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的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);
}
}
开发者ID:eclipse,项目名称:scanning,代码行数:26,代码来源:MonitorAtomProcess.java
示例10: testSum
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testSum() throws Exception {
Dataset a = DatasetFactory.createRange(100);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 0), 1e-9, 1e-15);
a.setShape(10, 10);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, 1), 1e-9, 1e-15);
a.setShape(4, 5, 5);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(2), LazyMaths.sum(a, 2), 1e-9, 1e-15);
a.setShape(4, 5, 1, 5);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(2), LazyMaths.sum(a, 2), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(3), LazyMaths.sum(a, 3), 1e-9, 1e-15);
}
开发者ID:eclipse,项目名称:january,代码行数:22,代码来源:LazyMathsTest.java
示例11: testSumIgnoreAxes
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testSumIgnoreAxes() throws Exception {
Dataset a = DatasetFactory.createRange(100);
a.setShape(10, 10);
// force the use of the varargs sum method by using 1-element arrays
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, new int[]{1}), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, new int[]{0}), 1e-9, 1e-15);
a.setShape(4, 5, 5);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 1, 2), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, 0, 2), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(2), LazyMaths.sum(a, 0, 1), 1e-9, 1e-15);
a.setShape(4, 5, 1, 5);
TestUtils.assertDatasetEquals(a.sum(0), LazyMaths.sum(a, 1, 2, 3), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1), LazyMaths.sum(a, 0, 2, 3), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(2), LazyMaths.sum(a, 0, 1, 3), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(3), LazyMaths.sum(a, 0, 1, 2), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(0).sum(0), LazyMaths.sum(a, false, 0, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1).sum(0), LazyMaths.sum(a, false, 1, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(1).sum(0), LazyMaths.sum(a, false, 0, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.sum(3).sum(2).sum(0), LazyMaths.sum(a, false, 0, 3, 2), 1e-9, 1e-15);
}
开发者ID:eclipse,项目名称:january,代码行数:26,代码来源:LazyMathsTest.java
示例12: testProduct
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testProduct() throws Exception {
Dataset a = DatasetFactory.createRange(100);
a.iadd(1.);
a.idivide(100.);
TestUtils.assertDatasetEquals(a.product(0), LazyMaths.product(a, 0), 1e-9, 1e-15);
a.setShape(10, 10);
TestUtils.assertDatasetEquals(a.product(0), LazyMaths.product(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(1), LazyMaths.product(a, 1), 1e-9, 1e-15);
a.setShape(4, 5, 5);
TestUtils.assertDatasetEquals(a.product(0), LazyMaths.product(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(1), LazyMaths.product(a, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(2), LazyMaths.product(a, 2), 1e-9, 1e-15);
a.setShape(4, 5, 1, 5);
TestUtils.assertDatasetEquals(a.product(0), LazyMaths.product(a, 0), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(1), LazyMaths.product(a, 1), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(2), LazyMaths.product(a, 2), 1e-9, 1e-15);
TestUtils.assertDatasetEquals(a.product(3), LazyMaths.product(a, 3), 1e-9, 1e-15);
}
开发者ID:eclipse,项目名称:january,代码行数:24,代码来源:LazyMathsTest.java
示例13: testPosition
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testPosition() {
double[] da = { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
DoubleDataset a = new DoubleDataset(da);
assertEquals(6,a.maxPos()[0]);
assertEquals(0,a.minPos()[0]);
Dataset b = DatasetFactory.zeros(IntegerDataset.class, 100, 200);
b.set(100, new int[]{50,100});
b.set(-100, new int[]{51,101});
assertEquals(50,b.maxPos()[0]);
assertEquals(100,b.maxPos()[1]);
assertEquals(51,b.minPos()[0]);
assertEquals(101,b.minPos()[1]);
}
开发者ID:eclipse,项目名称:january,代码行数:20,代码来源:IntegerDatasetTest.java
示例14: indexIterator
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
/**
* Index Iterator
*/
@Test
public void indexIterator() {
Dataset ta = DatasetFactory.createRange(DoubleDataset.class, 0, 1024, 1).reshape(16, 8, 1024 / (16 * 8));
IndexIterator iter = ta.getIterator();
for (int i = 0; iter.hasNext(); i++) {
assertEquals(i, ta.getElementDoubleAbs(iter.index), 1e-5*i);
}
iter.reset();
for (int i = 0; iter.hasNext(); i++) {
assertEquals(i, ta.getElementDoubleAbs(iter.index), 1e-5*i);
}
}
开发者ID:eclipse,项目名称:january,代码行数:19,代码来源:IterationExamples.java
示例15: checkInterpolate3
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
private void checkInterpolate3(Dataset a, double x) {
int s = a.getShapeRef()[0];
Dataset dv = Maths.interpolate(DatasetFactory.createRange(IntegerDataset.class, s), a, DatasetFactory.createFromObject(x), 0, 0);
double v = dv.getElementDoubleAbs(0);
if (x <= -1 || x >= s) {
Assert.assertEquals(0, v, 1e-15);
return;
}
int i = (int) Math.floor(x);
double f1 = 0;
double f2 = 0;
double t = x - i;
if (x < 0 || x > s - 1) {
} else if (x == s - 1) {
f1 = a.getDouble(i);
} else {
f1 = a.getDouble(i);
f2 = a.getDouble(i + 1);
}
Assert.assertEquals((1 - t) * f1 + t * f2, v, 1e-15);
}
开发者ID:eclipse,项目名称:january,代码行数:23,代码来源:MathsTest.java
示例16: testArctan2Integer
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testArctan2Integer() {
Dataset a = DatasetFactory.createFromObject(new int[] { 4, 2, 6 });
Dataset b = DatasetFactory.createFromObject(new int[] { 1, 2, 3 });
int size = a.getSize();
int[] c = new int[size];
for (int i = 0; i < size; i++) {
double atan2 = Math.atan2(a.getDouble(i), b.getDouble(i));
c[i] = (int) atan2;
}
Dataset expectedResult = DatasetFactory.createFromObject(c);
Dataset actualResult = Maths.arctan2(a, b);
TestUtils.assertDatasetEquals(expectedResult, actualResult, true, ABSERRD, ABSERRD);
}
开发者ID:eclipse,项目名称:january,代码行数:17,代码来源:MathsTest.java
示例17: testHypotenusInteger
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testHypotenusInteger() {
Dataset a = DatasetFactory.createFromObject(new int[] { 4, 2, 6 });
Dataset b = DatasetFactory.createFromObject(new int[] { 1, 2, 3 });
int size = a.getSize();
int[] c = new int[size];
for (int i = 0; i < size; i++) {
double hypot = Math.hypot(a.getDouble(i), b.getDouble(i));
c[i] = (int) hypot;
}
Dataset expectedResult = DatasetFactory.createFromObject(c);
Dataset actualResult = Maths.hypot(a, b);
TestUtils.assertDatasetEquals(expectedResult, actualResult, true, ABSERRD, ABSERRD);
}
开发者ID:eclipse,项目名称:january,代码行数:17,代码来源:MathsTest.java
示例18: testAbsComplexInput
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testAbsComplexInput() {
double[] ds = new double[] { -0, 1, 2, -3, 4, 5 };
Dataset a = DatasetFactory.createFromObject(ComplexDoubleDataset.class, ds);
Dataset o = DatasetFactory.createFromObject(ComplexDoubleDataset.class, new double[] { 0, 4, 0, 0, 0, 0 });
int size = ds.length;
double[] c = new double[size];
for (int i = 0; i < size; i = i + 2) {
double val = Math.hypot(ds[i], ds[i + 1]);
c[i] = val; // real part
c[i + 1] = 0; // imaginary part
}
Dataset expectedResult = DatasetFactory.createFromObject(ComplexDoubleDataset.class, c);
Dataset actualResult = Maths.abs(a, o);
TestUtils.assertDatasetEquals(expectedResult, actualResult, true, ABSERRD, ABSERRD);
}
开发者ID:eclipse,项目名称:january,代码行数:19,代码来源:MathsTest.java
示例19: positionIterator
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
/**
* Simple position iterator.
*/
@Test
public void positionIterator() {
final Dataset data = DatasetFactory.createFromObject(new double[]{1,2,3,4,5,6,7,8}, 2,2,2);
// The position iterator allows you to iterate over dataset but fixing axis 0
PositionIterator it = data.getPositionIterator(0);
while(it.hasNext()) {
System.out.println("Location (Axis=0) = "+Arrays.toString(it.getPos()));
System.out.println("Value (Axis=0) = "+data.getDouble(it.getPos()));
}
// Now iterate over dataset whilst fixing axis 1
it = data.getPositionIterator(1);
while(it.hasNext()) {
System.out.println("Location (Axis=1) = "+Arrays.toString(it.getPos()));
System.out.println("Value (Axis=1) = "+data.getDouble(it.getPos()));
}
}
开发者ID:eclipse,项目名称:january,代码行数:23,代码来源:IterationExamples.java
示例20: testNaNs
import org.eclipse.january.dataset.DatasetFactory; //导入依赖的package包/类
@Test
public void testNaNs() {
Dataset a = DatasetFactory.createRange(1., 7, 1);
assertEquals("Sum", 21, ((Number) a.sum()).doubleValue(), 1e-6);
assertEquals("Product", 720, (Double) Stats.product(a), 1e-6);
a.set(Double.NaN, 0);
assertTrue("Sum", Double.isNaN(((Number) a.sum()).doubleValue()));
assertTrue("Product", Double.isNaN((Double) Stats.product(a)));
assertTrue("Sum", Double.isNaN(((Number) a.sum(false, true)).doubleValue()));
assertTrue("Product", Double.isNaN((Double) Stats.product(a, false, true)));
assertEquals("Sum", 20, ((Number) a.sum(true)).doubleValue(), 1e-6);
assertEquals("Product", 720, (Double) Stats.product(a, true), 1e-6);
assertEquals("Sum", 20, ((Number) a.sum(true, false)).doubleValue(), 1e-6);
assertEquals("Product", 720, (Double) Stats.product(a, true, false), 1e-6);
}
开发者ID:eclipse,项目名称:january,代码行数:17,代码来源:StatsTest.java
注:本文中的org.eclipse.january.dataset.DatasetFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论