use of ncsa.hdf.object.h5.H5ScalarDS in project vcell by virtualcell.
the class VH5Dataset method info.
public static void info(H5ScalarDS ds) throws Exception {
Datatype dt = ds.getDatatype();
System.out.println(dt.getFullName());
System.out.println(dt.getDatatypeDescription());
int n = dt.toNative();
Datatype nt = new H5Datatype(n);
// dt = dt.getBasetype();
System.out.println(nt.getFullName());
System.out.println(nt.getDatatypeDescription());
System.out.println(H5Client.parseMeta(dt));
// ds.init();
// int did = ds.open();
// ds.read();
//
// int cdt = H5.H5Tcreate(HDF5Constants.H5T_COMPOUND,128);
// int vtype = H5.H5Tvlen_create(cdt);
// int ndims = ds.getRank();
// long dims[] = new long[ndims];
// long maxdims[] = new long[ndims];
// int space = H5.H5Dget_space(did);
// H5.H5Sget_simple_extent_dims(space, dims,maxdims);
// System.out.println(StringUtils.join(dims));
// long bsize = H5.H5Dvlen_get_buf_size_long(did,vtype,space);
//
// double bdata[][] = new double[2][(int)dims[0]];
// int status = H5.H5Dread(did,vtype,HDF5Constants.H5S_ALL,HDF5Constants.H5S_ALL,HDF5Constants.H5P_DEFAULT,bdata);
// System.out.println(status);
}
use of ncsa.hdf.object.h5.H5ScalarDS in project vcell by virtualcell.
the class VH5Dataset method info.
public void info() {
try {
System.out.println(dataset.getName());
System.out.println(dataset.getFullName());
H5ScalarDS sds = BeanUtils.downcast(H5ScalarDS.class, dataset);
if (sds != null) {
info(sds);
}
H5CompoundDS cds = BeanUtils.downcast(H5CompoundDS.class, dataset);
int rank = dataset.getRank();
long[] d = dataset.getDims();
long[] s = dataset.getSelectedDims();
for (int i = 0; i < rank; i++) {
s[i] = d[i];
}
if (cds != null) {
info(cds);
} else {
Object obj = dataset.read();
analyze(obj);
}
String[] names = dataset.getDimNames();
if (names == null) {
names = new String[rank];
}
long[] dims = dataset.getMaxDims();
for (int i = 0; i < rank; i++) {
System.out.println("n " + StringUtils.defaultString(names[i]) + " has " + dims[i]);
}
System.out.println("current dims " + Arrays.toString(dataset.getDims()));
System.out.println("chunk size " + Arrays.toString(dataset.getChunkSize()));
System.out.println("selected " + Arrays.toString(dataset.getSelectedDims()));
System.out.println("start " + Arrays.toString(dataset.getStartDims()));
System.out.println("stride " + Arrays.toString(dataset.getStride()));
} catch (Exception e) {
e.printStackTrace();
}
}
use of ncsa.hdf.object.h5.H5ScalarDS in project vcell by virtualcell.
the class Hdf5Reader method getDataTable.
public static Hdf5Reader.DataColumn[] getDataTable(Group group, String name) throws Exception {
List<HObject> memberList = group.getMemberList();
for (HObject member : memberList) {
if (member.getName().equals(name)) {
if (member instanceof H5CompoundDS) {
H5CompoundDS compoundDataSet = (H5CompoundDS) member;
Vector columnValueArrays = (Vector) compoundDataSet.read();
String[] columnNames = compoundDataSet.getMemberNames();
ArrayList<Hdf5Reader.DataColumn> dataColumns = new ArrayList<Hdf5Reader.DataColumn>();
for (int c = 0; c < columnNames.length; c++) {
Object column = columnValueArrays.get(c);
if (column instanceof int[]) {
dataColumns.add(new Hdf5Reader.IntColumn(columnNames[c], (int[]) columnValueArrays.get(c)));
} else if (column instanceof double[]) {
dataColumns.add(new Hdf5Reader.DoubleColumn(columnNames[c], (double[]) columnValueArrays.get(c)));
} else {
throw new RuntimeException("unexpected type '" + column.getClass().getName() + "' for group member '" + name + "'");
}
}
return dataColumns.toArray(new Hdf5Reader.DataColumn[0]);
} else if (member instanceof H5ScalarDS) {
H5ScalarDS compoundDataSet = (H5ScalarDS) member;
Object column = compoundDataSet.read();
if (column instanceof int[]) {
return new Hdf5Reader.DataColumn[] { new Hdf5Reader.IntColumn("col", (int[]) column) };
} else if (column instanceof double[]) {
return new Hdf5Reader.DataColumn[] { new Hdf5Reader.DoubleColumn("col", (double[]) column) };
} else if (column instanceof long[]) {
return new Hdf5Reader.DataColumn[] { new Hdf5Reader.LongColumn("col", (long[]) column) };
} else {
throw new RuntimeException("unexpected type '" + column.getClass().getName() + "' for group member '" + name + "'");
}
} else {
throw new RuntimeException("expecting type H5CompoundDS for group member '" + name + "', found type " + member.getClass().getName());
}
}
}
throw new RuntimeException("group member '" + name + "' not found");
}
use of ncsa.hdf.object.h5.H5ScalarDS in project vcell by virtualcell.
the class DataSetControllerImpl method processDims.
private static void processDims(HObject hObject, DataProcessingHelper dataProcessingHelper, boolean bInfoOnly) throws Exception {
H5ScalarDS h5ScalarDS = (H5ScalarDS) hObject;
h5ScalarDS.init();
dataProcessingHelper.tempDims = h5ScalarDS.getDims();
// make sure all dimensions are selected for loading if 3D
// note: for 3D, only 1st slice selected by default
long[] selectedDims = h5ScalarDS.getSelectedDims();
if (selectedDims != null && selectedDims.length > 2) {
// changes internal class variable used during read
selectedDims[2] = dataProcessingHelper.tempDims[2];
}
if (!bInfoOnly) {
// load all data
dataProcessingHelper.tempData = h5ScalarDS.read();
}
if (dataProcessingHelper.tempDims != null) {
if (dataProcessingHelper.tempDims.length > 1) {
// For HDF5View (x stored in index 1) and (y stored in index 0) so must switch back to normal assumption
long dimsY = dataProcessingHelper.tempDims[0];
dataProcessingHelper.tempDims[0] = dataProcessingHelper.tempDims[1];
dataProcessingHelper.tempDims[1] = dimsY;
}
// //uncomment for Debug
// System.out.print(" dims=(");
// for (int j = 0; j < dataProcessingHelper.tempDims.length; j++) {
// System.out.print((j>0?"x":"")+dataProcessingHelper.tempDims[j]);
// }
// System.out.print(")");
}
}
use of ncsa.hdf.object.h5.H5ScalarDS in project vcell by virtualcell.
the class MovingBoundaryReader method getBoundaryIndexes.
public int[] getBoundaryIndexes(int timeIndex) {
try {
VCAssert.assertTrue(timeIndex >= 0, "negative time index");
validateTimeIndex(timeIndex);
VH5TypedPath<H5ScalarDS> path = new VH5TypedPath<>(root, H5ScalarDS.class, "boundaries");
H5ScalarDS hsd = path.get();
hsd.init();
long[] start = hsd.getStartDims();
long[] stride = hsd.getStride();
long[] sdims = hsd.getSelectedDims();
stride[0] = 1;
start[0] = timeIndex;
sdims[0] = 1;
String[] data = (String[]) hsd.read();
String blob = data[0];
return getPointIndexes(blob, 0);
} catch (Exception e) {
throw new RuntimeException("Exception building outer boundary indexes", e);
}
}
Aggregations