当前位置: 首页>>代码示例>>Java>>正文


Java IDataset.getShape方法代码示例

本文整理汇总了Java中org.eclipse.january.dataset.IDataset.getShape方法的典型用法代码示例。如果您正苦于以下问题:Java IDataset.getShape方法的具体用法?Java IDataset.getShape怎么用?Java IDataset.getShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.january.dataset.IDataset的用法示例。


在下文中一共展示了IDataset.getShape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
	}
 
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:PlottingController.java

示例2: getThumbnail

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
public Dataset getThumbnail(final IDataset ds,  final int w, final int h) {

		if (ds!=null && ds.getRank() == 2) { // 2D datasets only!!!
			int width = ds.getShape()[1];
			int height = ds.getShape()[0];

			int[] stepping = new int[2];
			stepping[1] = Math.max(1, width / w);
			stepping[0] = Math.max(1, height / h);
			Downsample down = new Downsample(DownsampleMode.POINT, stepping);
			Dataset ds_downsampled = DatasetUtils.convertToDataset(down.value(ds).get(0));
			ds_downsampled.setName(ds.getName());
			return ds_downsampled;
		}

		return null;
		
	}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:19,代码来源:PlotImageServiceMock.java

示例3: createCoords

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
private int[] createCoords(IDataset image, int[] point, int[] box) {

		int x = point[0];
		int y = point[1];
		int r1 = (int) Math.floor(box[0] / 2d); // for instance 3->1, 5->2, 7->3
		int r2 = (int) Math.floor(box[1] / 2d); // for instance 3->1, 5->2, 7->3

		int minx = x - r1;
		if (minx < 0)
			minx = 0;
		int maxx = x + r1;
		if (maxx >= image.getShape()[0])
			maxx = image.getShape()[0] - 1;

		int miny = y - r2;
		if (miny < 0)
			miny = 0;
		int maxy = y + r2;
		if (maxy >= image.getShape()[1])
			maxy = image.getShape()[1] - 1;

		return new int[] { minx, miny, maxx, maxy };
	}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:24,代码来源:SummedAreaTableTest.java

示例4: testLazyWriteStringArray

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testLazyWriteStringArray() throws Exception {
	int nPoints = 10;

	GroupNode g = nf.getGroup("/test:NXnote", true);
	ILazyWriteableDataset lazy = NexusUtils.createLazyWriteableDataset("stringarray", Dataset.STRING,
			new int[] {ILazyWriteableDataset.UNLIMITED}, null, null);
	nf.createData(g, lazy);
	nf.close();

	for (int i = 0; i < nPoints; i++) {
		lazy.setSlice(null, DatasetFactory.createFromObject("file" + i),
				SliceND.createSlice(lazy, new int[] {i}, new int[] {i+1}));
	}

	nf = NexusTestUtils.openNexusFileReadOnly(FILE_NAME);
	DataNode d = nf.getData("/test/stringarray");
	IDataset ds = d.getDataset().getSlice();
	int[] shape = ds.getShape();
	assertArrayEquals(new int[] {nPoints}, shape);
	for (int i = 0; i < nPoints; i++) {
		assertEquals("file" + i, ds.getString(i));
	}
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:25,代码来源:NexusFileTest.java

示例5: checkCompatibility

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
private void checkCompatibility(IDataset d) {
	final int rank = d.getRank();
	final int[] shape = d.getShape();

	if (rank == bases.length) {
		int i = 0;
		for (; i < rank; i++) {
			if (shape[i] != bases[i].getSize()) {
				break;
			}
		}
		if (i == rank)
			return;
	}
	throw new IllegalArgumentException("Dataset shape does not match given or default coordinate base");
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:17,代码来源:Centroid.java

示例6: checkDark

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
private void checkDark(NXroot rootNode, Collection<String> positionerNames, int... sizes) throws NexusException, ScanningException, DatasetException {
	String detectorName = dark.getName();
	NXentry entry = rootNode.getEntry();
	NXdetector detector = entry.getInstrument().getDetector(detectorName);
	assertNotNull(detector);
	IDataset ds = detector.getDataNode(NXdetector.NX_DATA).getDataset().getSlice();
	int[] shape = ds.getShape();

	double size = 1;
	for (double i : sizes)size*=i;
	size = size / (((AbstractRunnableDevice<DarkImageModel>)dark).getModel().getFrequency());
	assertEquals(shape[0], (int)size);

	checkNXdata(rootNode, detectorName, positionerNames);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:16,代码来源:DarkCurrentTest.java

示例7: MockImageStackLoader

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
public MockImageStackLoader(StringDataset imageFilenames, IDataHolder dh, String directory) throws Exception {
	if (directory != null) {
		File file = new File(directory); 
		if (file.isDirectory()) {
			parent = file;
		}
	}

	filenames = imageFilenames;
	fShape = imageFilenames.getShapeRef();
	int fRank = fShape.length;
	// load the first image to get the shape of the whole thing
	IDataset dataSetFromFile;
	if (dh == null || dh.getNames().length == 0) {
		dataSetFromFile = getDatasetFromFile(new int[fRank], null);
	} else {
		dataSetFromFile = dh.getDataset(0);
		loaderClass = dh.getLoaderClass();
	}
	onlyOne = imageFilenames.getSize() == 1;
	dtype = DTypeUtils.getDType(dataSetFromFile);
	iShape = dataSetFromFile.getShape();
	shape = Arrays.copyOf(fShape, fRank + iShape.length);
	for (int i = 0; i < iShape.length; i++) {
		shape[i + fRank] = iShape[i];
	}
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:28,代码来源:MockImageStackLoader.java

示例8: testFastMDATA

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testFastMDATA() throws Exception {
	System.out.println("> testFastMDATA start");
	System.out.flush();
	final SliceClient<IDataset> client = new SliceClient<IDataset>("localhost", port);
	client.setPath("RANDOM:512x512");
	client.setFormat(Format.MDATA);
	client.setHisto("MEAN");
	client.setSleep(10); // 100Hz - she's a fast one!
	
	int i = 0;
	while(!client.isFinished()) {
		
		final IDataset image = client.take();
		if (image ==null) break; // Last image in stream is null.
		if (image.getShape()[0]!=512) throw new Exception("Unexpected image height '"+image.getShape()[0]+"'");
		if (image.getShape()[1]!=512)  throw new Exception("Unexpected image height '"+image.getShape()[1]+"'");
		++i;
		if (i>100) {
			client.setFinished(true);
			break; // That's enough of that
		}
		
		Thread.sleep(80);// Evil sleep means that take() is not as fast as send and there will be drops.
	}

	// We say
	System.out.println("Received images = "+i);
	System.out.println("Dropped images = "+client.getDroppedImageCount());
	System.out.println("> testFastMDATA ok");
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:32,代码来源:SliceClientTest.java

示例9: testDiagonal

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
private void testDiagonal(IDataset image, SummedAreaTable sum, TestType type, int... box) throws Exception {

		if (!Arrays.equals(sum.getShape(), image.getShape()))
			throw new Exception("Shape not the same! sum is " + Arrays.toString(sum.getShape()));

		int x = 0, y = 0;
		while (x < image.getShape()[0] && y < image.getShape()[1]) {

			double a = 0d, b = 0d;
			if (type == TestType.VALUE) {
				a = sum.getDouble(x, y);
				b = getSum(image, x, y);

			} else if (type == TestType.MEAN) {
				a = sum.getBoxMean(new int[] { x, y }, box);
				b = getBoxMean(image, new int[] { x, y }, box);

			} else if (type == TestType.VARIANCE) {
				a = sum.getBoxVariance(new int[] { x, y }, box);
				b = getBoxVariance(image, new int[] { x, y }, box);

			} else if (type == TestType.FANO) {
				a = sum.getBoxFanoFactor(new int[] { x, y }, box);
				double mean = getBoxMean(image, new int[] { x, y }, box);
				double variance = getBoxVariance(image, new int[] { x, y }, box);
				b = variance / mean;
			}

			TestUtils.assertEquals("a does not equal b", a, b, 1e-6, 1e-6);
			x++;
			y++;
		}
	}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:34,代码来源:SummedAreaTableTest.java

示例10: validateFieldDimensions

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
/**
 * Validate the dimensions of the given field.
 * @param fieldName field name
 * @param dataset dataset to validate
 * @param groupName the name of the group
 * @param dimensions the dimensions, each value must be either an integer, interpreted as the expected size of
 *    that dimension, or a placeholder string, in which case the size of this dimension will be validated
 *    against any previous dimension with the same placeholder string
 * @throws NexusValidationException if a dimension did not have the expected size
 */
protected void validateFieldDimensions(final String fieldName,
		final IDataset dataset, String groupName, Object... dimensions)
		throws NexusValidationException {
	final int[] shape = dataset.getShape();

	for (int i = 0; i < dimensions.length; i++) {
		if (dimensions[i] instanceof Integer) {
			// the dimension value to validate against in an integer specifying exactly the expected dimension size to check
			if (shape[i] != ((Integer) dimensions[i]).intValue()) {
				failValidation(MessageFormat.format("The dimension with index {0} of field ''{1}'' expected to have size {2} was {3}", 
						(i + 1), fieldName, dimensions[i], shape[i]));
			}
		} else if (dimensions[i] instanceof String) {
			// the dimension value to validate against is a string placeholder
			// if the name of the group is specified, then this is defined in the NXDL for the base class for that group type
			// otherwise the placeholder is global across the whole application
			
			// we need to check that all dimensions (across the group or application depending on whether there is a group name)
			// have the same size. To do this, if this is the first time we've seen this placeholder we store the size of the
			// current dimension. On subsequent encounters, we check that the current dimension has the same size as this
			// stored value
			final String dimensionPlaceholder = (String) dimensions[i];
			Integer expectedSize = getDimensionPlaceholderValue(dimensionPlaceholder, groupName != null, shape[i]);
			if (expectedSize != null && shape[i] != expectedSize.intValue()) {
				if (groupName != null) {
					failValidation(MessageFormat.format("The dimension with index {0} of field ''{1}'' expected to have size {2} according to symbol ''{3}'' within group {4}, was {5}",
							(i + 1), fieldName, expectedSize, dimensions[i], groupName, shape[i]));
				} else {
					failValidation(MessageFormat.format("The dimension with index {0} of field ''{1}'' expected to have size {2} according to symbol ''{3}'', was {4}",
							(i + 1), fieldName, expectedSize, dimensions[i], shape[i]));
				}
			}
		} else {
			failValidation("Dimension size value must be an Integer or String, was: " + dimensions[i].getClass().getName());
		}
	}
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:48,代码来源:AbstractNexusValidator.java

示例11: testWriteBooleanDataset

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testWriteBooleanDataset() throws Exception {
	GroupNode g = nf.getGroup("/entry1:NXentry", true);
	NexusUtils.write(nf, g, "bool_array", new boolean[] {true, false});
	nf.close();

	nf = NexusTestUtils.openNexusFileReadOnly(FILE_NAME);
	DataNode d = nf.getData("/entry1/bool_array");
	IDataset ds = d.getDataset().getSlice();
	int[] shape = ds.getShape();
	assertArrayEquals(new int[] {2}, shape);
	assertEquals(Byte.class, ds.getElementClass());
	byte[] buffer = new byte[] {ds.getByte(0), ds.getByte(1)};
	assertArrayEquals(new byte[] {1, 0}, buffer);
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:16,代码来源:NexusFileTest.java

示例12: testWritingSimpleStringArray

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testWritingSimpleStringArray() throws Exception {
	GroupNode g = nf.getGroup("/entry1:NXentry", true);
	NexusUtils.write(nf, g, "stringarray", new String[] {"String", "String Å"});
	nf.close();

	nf = NexusTestUtils.openNexusFileReadOnly(FILE_NAME);
	DataNode d = nf.getData("/entry1/stringarray");
	IDataset ds = d.getDataset().getSlice();
	int[] shape = ds.getShape();
	assertArrayEquals(new int[] {2}, shape);
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:13,代码来源:NexusFileTest.java

示例13: testWriteSimpleString

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testWriteSimpleString() throws Exception {
	GroupNode g = nf.getGroup("/note:NXnote", true);
	NexusUtils.write(nf, g, "somestring", "MyString");
	nf.close();

	nf = NexusTestUtils.openNexusFileReadOnly(FILE_NAME);
	DataNode d = nf.getData("/note/somestring");
	IDataset ds = d.getDataset().getSlice();
	int[] shape = ds.getShape();
	assertArrayEquals(new int[] {}, shape);
	assertEquals("MyString", ds.getString());
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:14,代码来源:NexusFileTest.java

示例14: setDataset

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Override
public void setDataset(IDataset sdata) {
	Dataset data = greyScale ? DatasetUtils.cast(ShortDataset.class, sdata) : DatasetUtils.cast(RGBDataset.class, sdata);
	Serializable buffer = data.getBuffer();
	
	int[] shape = sdata.getShape();
	if (dynamicShape) {
		dataset.overrideInternal(buffer, shape);
	} else {
		dataset.overrideInternal(buffer, null);
		this.transShape = shape;
	}
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:14,代码来源:DynamicImage.java

示例15: testMandelbrotScan

import org.eclipse.january.dataset.IDataset; //导入方法依赖的package包/类
@Test
public void testMandelbrotScan() throws Exception {

	// Create Nexus File
	NexusFile file = createNexusFile();

	// Configure a detector with a collection time.
	final MockWritingMandlebrotModel model = new MockWritingMandlebrotModel();
	model.setFile(file);
	model.setxSize(8); // This could also come from the generator made in createTestScanner(...) but it is hard coded
	model.setySize(5); // This could also come from the generator made in createTestScanner(...) but it is hard coded

	// Make sure that the scannables will write too
	MockScannableModel smod = new MockScannableModel();
	smod.setFile(file);
	smod.setSize(8);
	IScannable<Number> x = connector.getScannable("x");
	((IConfigurable)x).configure(smod);

	smod = new MockScannableModel();
	smod.setFile(file);
	smod.setSize(5);
	IScannable<Number> y = connector.getScannable("y");
	((IConfigurable)y).configure(smod);

	IRunnableDevice<MockWritingMandlebrotModel> det = service.createRunnableDevice(model);
	model.getFile().close();

	IRunnableDevice<ScanModel> scanner = createTestScanner(det, 5, 8);
	scanner.run(null);

	// Check we reached armed (it will normally throw an exception on error)
	assertEquals(DeviceState.ARMED, scanner.getDeviceState());


	// Check what was written. Quite a bit to do here, it is not written in the
	// correct locations or with the correct attributes for now...
	NexusFile nf = factory.newNexusFile(model.getFile().getFilePath());
	nf.openToRead();

	DataNode d = nf.getData("/entry1/instrument/detector/"+model.getName());
	IDataset ds = d.getDataset().getSlice().squeeze();
	int[] shape = ds.getShape();

	assertEquals(8, shape[0]);
	assertEquals(5, shape[1]);

	// Make sure none of the numbers are NaNs. The detector
	// is expected to fill this scan with non-nulls.
       final PositionIterator it = new PositionIterator(shape);
       while(it.hasNext()) {
	int[] next = it.getPos();
	assertFalse(Double.isNaN(ds.getDouble(next)));
       }

	d     = nf.getData("/entry1/instrument/axes/"+x.getName());
	ds    = d.getDataset().getSlice().squeeze();
	shape = ds.getShape();
	assertEquals(8, shape[0]);


	d     = nf.getData("/entry1/instrument/axes/"+y.getName());
	ds    = d.getDataset().getSlice().squeeze();
	shape = ds.getShape();
	assertEquals(5, shape[0]);

}
 
开发者ID:eclipse,项目名称:scanning,代码行数:68,代码来源:LowLevelDetectorPluginTest.java


注:本文中的org.eclipse.january.dataset.IDataset.getShape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。