本文整理汇总了Java中org.eclipse.january.metadata.AxesMetadata.setAxis方法的典型用法代码示例。如果您正苦于以下问题:Java AxesMetadata.setAxis方法的具体用法?Java AxesMetadata.setAxis怎么用?Java AxesMetadata.setAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.january.metadata.AxesMetadata
的用法示例。
在下文中一共展示了AxesMetadata.setAxis方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAxesMetadataReshape
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testAxesMetadataReshape() throws MetadataException {
final int[] shape = new int[] { 1, 2, 3, 1 };
final int[] reshape = new int[] { 1, 1, 2, 3, 1 };
int r = shape.length;
int[] nShape = new int[r];
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
for (int i = 0; i < r; i++) {
Arrays.fill(nShape, 1);
nShape[i] = shape[i];
DoubleDataset array = Random.randn(nShape);
amd.setAxis(i, array);
}
ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
dataset.addMetadata(amd);
dataset.setShape(reshape);
}
示例2: testAxesMetadataTranspose
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testAxesMetadataTranspose() throws Exception {
final int[] shape = new int[] { 1, 2, 3, 4 };
int r = shape.length;
int[] nShape = new int[r];
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
for (int i = 0; i < r; i++) {
Arrays.fill(nShape, 1);
nShape[i] = shape[i];
DoubleDataset array = Random.randn(nShape);
amd.setAxis(i, array);
}
Dataset dataset = Random.rand(shape);
dataset.addMetadata(amd);
int[] map = new int[] {3, 1, 2, 0};
Dataset t = dataset.getTransposedView(map);
assertArrayEquals(new int[]{4, 2, 3, 1}, t.getShape());
amd = t.getMetadata(AxesMetadata.class).get(0);
for (int i = 0; i < r; i++) {
ILazyDataset a = amd.getAxis(i)[0];
assertEquals(shape[map[i]], a.getSize());
}
}
示例3: testSliceFromView
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的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);
}
示例4: getOperation
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Override
protected IOperationPerformer getOperation()
{
return new InterpolatedMaths.IOperationPerformer()
{
@Override
public Dataset
perform(final Dataset a, final Dataset b, final Dataset o)
{
// ok, we're going to use dataset a as the new index units,
// so we've just got to set them in a copy of b
final Dataset output = b.clone();
// clear any existing metadata
output.clearMetadata(AxesMetadata.class);
// now store the new metadata
final AxesMetadata am = new AxesMetadataImpl();
am.initialize(1);
am.setAxis(0, a);
output.addMetadata(am);
return output;
}
};
}
示例5: testLoader
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testLoader() throws Exception {
Dataset range = DatasetFactory.createRange(LongDataset.class, 10*13*20*20);
range.setShape(new int[]{10,13,20,20} );
LazyDynamicDataset dataset = getDataset(range,2,"data");
AxesMetadata ax = MetadataFactory.createMetadata(AxesMetadata.class, 4);
ax.setAxis(0, DatasetFactory.createRange(LongDataset.class, 10));
ax.setAxis(1, DatasetFactory.createRange(LongDataset.class, 13));
dataset.addMetadata(ax);
int max = 399;
for (int i = 0 ; i < (10*13); i++) {
SliceND slice = new SliceND(dataset.getShape());
int[] shape = dataset.getShape();
slice.setSlice(0, shape[0]-1, shape[0], 1);
slice.setSlice(1, shape[1]-1, shape[1], 1);
IDataset s = dataset.getSlice(slice);
Assert.assertEquals(max, s.max().intValue());
max+=400;
AxesMetadata axm = s.getFirstMetadata(AxesMetadata.class);
Assert.assertEquals(axm.getAxis(0)[0].getSlice().getInt(0, 0, 0, 0), shape[0]-1);
Assert.assertEquals(axm.getAxis(1)[0].getSlice().getInt(0, 0, 0, 0), shape[1]-1);
dataset.refreshShape();
}
Assert.assertArrayEquals(new int[]{10,13,20,20},dataset.getShape());
}
示例6: testAxesMetadataRecursion
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testAxesMetadataRecursion() throws MetadataException {
final int[] shape = new int[] { 1, 2, 3, 1 };
int r = shape.length;
ILazyDataset axis = Random.lazyRand(Dataset.INT32, "axis", 2);
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, 1);
amd.setAxis(0, Random.lazyRand(Dataset.INT32, "axis2", 2));
axis.addMetadata(amd);
amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
amd.setAxis(1, axis);
ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
dataset.addMetadata(amd);
dataset.setShape(2,3,1,1);
ErrorMetadata emd = MetadataFactory.createMetadata(ErrorMetadata.class);
ILazyDataset axisErr = Random.lazyRand(Dataset.INT32, "axis2_err", 2);
emd.setError(axisErr);
axis.addMetadata(emd);
amd = MetadataFactory.createMetadata(AxesMetadata.class, 1);
amd.setAxis(0, axis);
axisErr.addMetadata(amd);
axisErr.setShape(2,1);
axisErr.getSliceView(new Slice(1));
axisErr.getTransposedView();
}
示例7: testAxesMetadataError
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testAxesMetadataError() throws DatasetException {
final int[] shape = new int[] { 1, 2, 3, 1 };
int r = shape.length;
ILazyDataset axis = Random.lazyRand(Dataset.INT32, "axis", 2);
AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, 1);
amd.setAxis(0, Random.lazyRand(Dataset.INT32, "axis2", 2));
axis.addMetadata(amd);
amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
amd.setAxis(1, axis);
ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
dataset.addMetadata(amd);
ILazyDataset datasetErr = Random.lazyRand(Dataset.INT32, "dataset_err", 1, 2, 1, 1);
dataset.setErrors(datasetErr);
dataset.setShape(2,3,1,1);
ILazyDataset axisErr = Random.lazyRand(Dataset.INT32, "axis2_err", 2);
amd = MetadataFactory.createMetadata(AxesMetadata.class, 1);
amd.setAxis(0, axis);
axisErr.addMetadata(amd);
axis.setErrors(axisErr);
ILazyDataset d = dataset.getSliceView();
d.squeezeEnds();
IDataset slice = d.getSlice();
assertTrue(slice != null);
}
示例8: assignOutputIndices
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
protected void assignOutputIndices(final IDataset output,
final Dataset outputIndices)
{
if (outputIndices != null)
{
// now insert the new one
final AxesMetadata am = new AxesMetadataImpl();
am.initialize(1);
am.setAxis(0, outputIndices);
output.addMetadata(am);
}
}
示例9: storeMetadata
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
private static void storeMetadata(final Dataset indicesTrimmed,
final Dataset datasetA, final Dataset datasetB)
{
final AxesMetadata newAxis = new AxesMetadataImpl();
newAxis.initialize(1);
newAxis.setAxis(0, indicesTrimmed);
datasetA.addMetadata(newAxis);
datasetB.addMetadata(newAxis);
}
示例10: testDynamicAxesMetadata
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testDynamicAxesMetadata() throws Exception {
int[] maxShape = new int[]{10,13,20,20};
Dataset range = DatasetFactory.createRange(LongDataset.class, 10*13*20*20);
range.setShape(maxShape);
LazyDynamicDataset dataset = getDataset(range,2,"data");
LazyDynamicDataset ax1 = getDataset(DatasetFactory.createRange(LongDataset.class, 10),0,"ax0");
LazyDynamicDataset ax2 = getDataset(DatasetFactory.createRange(LongDataset.class, 13),0,"ax1");
AxesMetadata ax = MetadataFactory.createMetadata(AxesMetadata.class, 4);
ax.setAxis(0, ax1);
ax.setAxis(1, ax2);
dataset.addMetadata(ax);
int max = 399;
SliceND slice = new SliceND(dataset.getShape(),maxShape);
int[] axShape = new int[]{1,1,1,1};
for (int i = 0 ; i < (10*13); i++) {
int[] shape = dataset.getShape();
@SuppressWarnings("unused")
int[] so = DynamicMetadataUtils.refreshDynamicAxesMetadata(dataset.getMetadata(AxesMetadata.class), shape);
slice.setSlice(0, shape[0]-1, shape[0], 1);
slice.setSlice(1, shape[1]-1, shape[1], 1);
IDataset s = dataset.getSlice(slice);
Assert.assertEquals((long) max, s.max().longValue());
max+=400;
AxesMetadata axm = s.getFirstMetadata(AxesMetadata.class);
IDataset s0 = axm.getAxis(0)[0].getSlice();
Assert.assertArrayEquals(axShape, s0.getShape());
Assert.assertEquals(s0.getInt(0, 0, 0, 0), shape[0]-1);
s0 = axm.getAxis(1)[0].getSlice();
Assert.assertArrayEquals(axShape, s0.getShape());
Assert.assertEquals(axm.getAxis(1)[0].getSlice().getInt(0, 0, 0, 0), shape[1]-1);
dataset.refreshShape();
}
Assert.assertArrayEquals(new int[]{10,13,20,20},dataset.getShape());
}
示例11: testAxisReverseInterpolation
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Test
public void testAxisReverseInterpolation()
{
// configure Dataset A
final Dataset elevationA_m =
DatasetFactory
.createFromList(Arrays.asList(150d, 125d, 100d, 75d, 50d));
elevationA_m.setName("A elevation (m)");
Dataset temperatureA_C =
DatasetFactory.createFromList(Arrays.asList(5d, 10d, 15d, 20d, 25d));
final AxesMetadata axesMetadataA = new AxesMetadataImpl();
axesMetadataA.initialize(1);
axesMetadataA.setAxis(0, elevationA_m);
temperatureA_C.addMetadata(axesMetadataA);
temperatureA_C.setName("A temperature (deg C)");
// configure Dataset B
final Dataset elevationB_m =
DatasetFactory
.createFromList(Arrays.asList(130d, 125d, 100d, 70d, 40d));
elevationB_m.setName("B elevation (m)");
final Dataset temperatureB_C =
DatasetFactory.createFromList(Arrays
.asList(15d, 17.5d, 20d, 22.5d, 25d));
final AxesMetadata axesMetadataB = new AxesMetadataImpl();
axesMetadataB.initialize(1);
axesMetadataB.setAxis(0, elevationB_m);
temperatureB_C.addMetadata(axesMetadataB);
temperatureB_C.setName("B temperature (deg C)");
// wrap mathematical operation
final IOperationPerformer doAdd = new IOperationPerformer()
{
@Override
public Dataset perform(Dataset a, Dataset b, Dataset o)
{
return Maths.add(a, b, o).idivide(2d);
}
};
final Dataset meanTemperature =
NewMaths.performWithInterpolation(temperatureA_C, temperatureB_C, null,
doAdd);
assertNotNull(meanTemperature);
meanTemperature.setName("Interpolated sum of dataset A and dataset B");
// check that the resulting dataset has the correctly intersecting times
printIndexedDataset(temperatureA_C);
printIndexedDataset(temperatureB_C);
Dataset interElevations =
(Dataset) meanTemperature.getFirstMetadata(AxesMetadata.class).getAxis(
0)[0];
assertEquals("first elevation correct", 130d, interElevations.getDouble(0),
0.001);
assertEquals("last elevation correct", 70d, interElevations
.getDouble(interElevations.getSize() - 1), 0.001);
printIndexedDataset(meanTemperature);
}
示例12: testNonSyncedContainedAxesOperation
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
/**
* test we interpolate data when one set of axis measurements spans the region covered by the
* other
*/
@Test
public void testNonSyncedContainedAxesOperation()
{
// configure Dataset A
final Dataset elevationA_m =
DatasetFactory.createFromList(Arrays.asList(50d, 100d, 150d));
elevationA_m.setName("A elevation (m)");
Dataset temperatureA_C =
DatasetFactory.createFromList(Arrays.asList(5d, 10d, 15d));
final AxesMetadata axesMetadataA = new AxesMetadataImpl();
axesMetadataA.initialize(1);
axesMetadataA.setAxis(0, elevationA_m);
temperatureA_C.addMetadata(axesMetadataA);
temperatureA_C
.setName("A temperature (deg C), with elevations (t = e / 10)");
// configure Dataset B
final Dataset elevationB_m =
DatasetFactory
.createFromList(Arrays.asList(50d, 75d, 100d, 125d, 150d));
elevationB_m.setName("B elevation (m)");
final Dataset temperatureB_C =
DatasetFactory.createFromList(Arrays
.asList(15d, 17.5d, 20d, 22.5d, 25d));
final AxesMetadata axesMetadataB = new AxesMetadataImpl();
axesMetadataB.initialize(1);
axesMetadataB.setAxis(0, elevationB_m);
temperatureB_C.addMetadata(axesMetadataB);
temperatureB_C
.setName("B temperature (deg C), with elevations (t = e / 10 + 10)");
// show initial values
printIndexedDataset(temperatureA_C);
printIndexedDataset(temperatureB_C);
// wrap mathematical operation
final IOperationPerformer doAdd = new IOperationPerformer()
{
@Override
public Dataset perform(Dataset a, Dataset b, Dataset o)
{
return Maths.add(a, b, o).idivide(2d);
}
};
// apply our operation to the two datasets
final Dataset meanTemperature =
NewMaths.performWithInterpolation(temperatureA_C, temperatureB_C, null,
doAdd);
meanTemperature
.setName("Mean of A and B, taken at B elevations (should be t = e / 10 + 5)");
printIndexedDataset(meanTemperature);
final AxesMetadata elevations =
meanTemperature.getFirstMetadata(AxesMetadata.class);
assertNotNull("elevations present in results", elevations);
assertEquals("correct elevations", elevationB_m, elevations.getAxis(0)[0]);
// check results, via sampling
assertEquals("correct value", 12.5d, meanTemperature.getDouble(1), 0.001); // mean temp at 75m
assertEquals("correct value", 17.5d, meanTemperature.getDouble(3), 0.001); // mean temp at 125m
}
示例13: testNonSyncedOverlappingAxesOperation
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
/**
* test we interpolate data when the two sets of axis measurements overlap
*
* @throws DatasetException
*/
@Test
public void testNonSyncedOverlappingAxesOperation() throws DatasetException
{
// configure Dataset A
final Dataset elevationA_m =
DatasetFactory.createFromList(Arrays.asList(50d, 100d, 150d));
elevationA_m.setName("A elevation (m)");
Dataset temperatureA_C =
DatasetFactory.createFromList(Arrays.asList(5d, 10d, 15d));
final AxesMetadata axesMetadataA = new AxesMetadataImpl();
axesMetadataA.initialize(1);
axesMetadataA.setAxis(0, elevationA_m);
temperatureA_C.addMetadata(axesMetadataA);
temperatureA_C
.setName("A temperature (deg C), with elevations (t = e / 10)");
// configure Dataset B
final Dataset elevationB_m =
DatasetFactory
.createFromList(Arrays.asList(40d, 75d, 100d, 125d, 140d));
elevationB_m.setName("B elevation (m)");
final Dataset temperatureB_C =
DatasetFactory.createFromList(Arrays
.asList(14d, 17.5d, 20d, 22.5d, 24d));
final AxesMetadata axesMetadataB = new AxesMetadataImpl();
axesMetadataB.initialize(1);
axesMetadataB.setAxis(0, elevationB_m);
temperatureB_C.addMetadata(axesMetadataB);
temperatureB_C
.setName("B temperature (deg C), with elevations (t = e / 10 + 10)");
// show initial values
printIndexedDataset(temperatureA_C);
printIndexedDataset(temperatureB_C);
// wrap mathematical operation
final IOperationPerformer doAdd = new IOperationPerformer()
{
@Override
public Dataset perform(Dataset a, Dataset b, Dataset o)
{
return Maths.add(a, b, o).idivide(2d);
}
};
// apply our operation to the two datasets
final Dataset meanTemperature =
NewMaths.performWithInterpolation(temperatureA_C, temperatureB_C, null,
doAdd);
meanTemperature
.setName("Mean of A and B, taken at intersecting elevations (should be t = e / 10 + 5)");
printIndexedDataset(meanTemperature);
final AxesMetadata elevations =
meanTemperature.getFirstMetadata(AxesMetadata.class);
assertNotNull("elevations present in results", elevations);
assertEquals("correct elevations", 4, elevations.getAxis(0)[0].getSize());
Dataset elevationValues =
DatasetUtils.sliceAndConvertLazyDataset(elevations.getAxis(0)[0]);
assertEquals("correct start elevation", 75, elevationValues.getDouble(0),
0.001);
// check results, via sampling
assertEquals("correct value", 12.5, meanTemperature.getDouble(0), 0.001); // mean temp at 75m
assertEquals("correct value", 17.5, meanTemperature.getDouble(2), 0.001); // mean temp at 125m
assertEquals("correct value", 19.0, meanTemperature.getDouble(3), 0.001); // mean temp at 140m
}
示例14: toDocument
import org.eclipse.january.metadata.AxesMetadata; //导入方法依赖的package包/类
@Override
public D toDocument()
{
final D res;
if (_values.size() > 0)
{
// ok, start with the dataset
final IDataset dataset = getDataset(_values);
dataset.setName(_name);
// do we have any indices to add?
if (_indices != null)
{
// yes, store them
final DoubleDataset indexData =
(DoubleDataset) DatasetFactory.createFromObject(_indices);
final AxesMetadata index = new AxesMetadataImpl();
index.initialize(1);
index.setAxis(0, indexData);
dataset.addMetadata(index);
}
// get the output document
res = getDocument(dataset, _predecessor);
// do we indices?
if (_indices != null)
{
if (_indexUnits == null)
{
System.err.println("Setting index, but do not have units");
}
// ok, set the index units
res.setIndexUnits(_indexUnits);
}
else
{
if (_indexUnits != null)
{
throw new IllegalArgumentException("Have index units, but no index");
}
}
// ok, any last minute tidying
finishOff(res);
}
else
{
res = null;
}
return res;
}