use of cbit.vcell.solver.ode.ODESolverResultSet in project vcell by virtualcell.
the class ODEDataInterfaceImpl method extractColumnMin.
@Override
public double[] extractColumnMin(String columnName) throws ExpressionException, ObjectNotFoundException {
FileFormat hdf5FileFormat = null;
File to = null;
try {
ODESolverResultSet osrs = getOdeSolverResultSet();
if (osrs instanceof ODESimData) {
byte[] hdf5FileBytes = ((ODESimData) getOdeSolverResultSet()).getHdf5FileBytes();
if (hdf5FileBytes != null) {
to = File.createTempFile("odeStats_" + simulationModelInfo.getSimulationName(), ".hdf5");
Files.write(hdf5FileBytes, to);
FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
if (fileFormat == null) {
throw new Exception("Cannot find HDF5 FileFormat.");
}
// open the file with read-only access
hdf5FileFormat = fileFormat.createInstance(to.getAbsolutePath(), FileFormat.READ);
// open the file and retrieve the file structure
hdf5FileFormat.open();
Group root = (Group) ((javax.swing.tree.DefaultMutableTreeNode) hdf5FileFormat.getRootNode()).getUserObject();
List<HObject> postProcessMembers = ((Group) root).getMemberList();
for (HObject nextHObject : postProcessMembers) {
System.out.println(nextHObject.getName() + " " + nextHObject.getClass().getName());
H5ScalarDS h5ScalarDS = (H5ScalarDS) nextHObject;
h5ScalarDS.init();
try {
long[] dims = h5ScalarDS.getDims();
System.out.println("---" + nextHObject.getName() + " " + nextHObject.getClass().getName() + " Dimensions=" + Arrays.toString(dims));
Object obj = h5ScalarDS.read();
if (dims.length == 2) {
double[] columns = new double[(int) dims[1]];
for (int row = 0; row < dims[0]; row++) {
System.arraycopy(obj, row * columns.length, columns, 0, columns.length);
System.out.println(Arrays.toString(columns));
}
return null;
// return columns;
} else {
return null;
}
} catch (Exception e) {
return null;
}
}
}
}
} catch (Exception e) {
} finally {
if (hdf5FileFormat != null) {
try {
hdf5FileFormat.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
if (to != null) {
try {
to.delete();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
return null;
}
Aggregations