use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class DisplayTimeSeriesOp method getDataSetControllerProvider.
private DataSetControllerProvider getDataSetControllerProvider(final ImageTimeSeries<? extends Image> imageTimeSeries, final PDEDataViewer pdeDataViewer) throws ImageException, IOException {
ISize size = imageTimeSeries.getISize();
int dimension = (size.getZ() > 0) ? (3) : (2);
Extent extent = imageTimeSeries.getExtent();
Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
// don't care ... no surfaces
double filterCutoffFrequency = 0.5;
VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
final DataSetController dataSetController = new DataSetController() {
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_START, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
if (!timeSeriesJobSpec.isCalcSpaceStats() && !timeSeriesJobSpec.isCalcTimeStats()) {
int[][] indices = timeSeriesJobSpec.getIndices();
double[] timeStamps = imageTimeSeries.getImageTimeStamps();
// [var][dataindex+1][timeindex]
double[][][] dataValues = new double[1][indices[0].length + 1][timeStamps.length];
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
// index 0 is time
dataValues[0][0][timeIndex] = timeStamps[timeIndex];
}
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
float[] pixelValues = imageTimeSeries.getAllImages()[timeIndex].getFloatPixels();
for (int samplePointIndex = 0; samplePointIndex < indices[0].length; samplePointIndex++) {
int pixelIndex = indices[0][samplePointIndex];
dataValues[0][samplePointIndex + 1][timeIndex] = pixelValues[pixelIndex];
}
}
TSJobResultsNoStats timeSeriesJobResults = new TSJobResultsNoStats(new String[] { "var" }, indices, timeStamps, dataValues);
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_COMPLETE, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
return timeSeriesJobResults;
}
return null;
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
double timePoint = time;
double[] timePoints = getDataSetTimes(vcdataID);
int index = -1;
for (int i = 0; i < timePoints.length; i++) {
if (timePoint == timePoints[i]) {
index = i;
break;
}
}
double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
VariableType varType = VariableType.VOLUME;
return new SimDataBlock(pdeDataInfo, data, varType);
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return mesh;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return new AnnotatedFunction[0];
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return imageTimeSeries.getImageTimeStamps();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return new DataIdentifier[] { dataIdentifier };
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return dataSetController;
}
};
return dataSetControllerProvider;
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class VCellProxyHandler method getDataSetFileOfVariableAtTimeIndex.
@Override
public String getDataSetFileOfVariableAtTimeIndex(SimulationDataSetRef simulationDataSetRef, VariableInfo var, int timeIndex) throws ThriftDataAccessException {
try {
if (var.isMeshVar) {
return getEmptyMeshFile(simulationDataSetRef, var.domainName, timeIndex).getAbsolutePath();
}
File meshFileForVariableAndTime = getPopulatedMeshFileLocation(simulationDataSetRef, var, timeIndex);
if (meshFileForVariableAndTime.exists()) {
return meshFileForVariableAndTime.getAbsolutePath();
}
//
// get data from server for this variable, domain, time
//
VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
VariableDomain variableDomainType = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
if (var.variableDomainType == DomainType.MEMBRANE) {
variableDomainType = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
} else if (var.variableDomainType == DomainType.VOLUME) {
variableDomainType = VariableDomain.VARIABLEDOMAIN_VOLUME;
}
org.vcell.vis.io.VtuVarInfo.DataType dataType = org.vcell.vis.io.VtuVarInfo.DataType.CellData;
if (var.isSetDataType() && var.dataType == DataType.CELLDATA) {
dataType = org.vcell.vis.io.VtuVarInfo.DataType.CellData;
} else if (var.isSetDataType() && var.dataType == DataType.POINTDATA) {
dataType = org.vcell.vis.io.VtuVarInfo.DataType.PointData;
}
VtuVarInfo vtuVarInfo = new VtuVarInfo(var.getVariableVtuName(), var.getVariableDisplayName(), var.getDomainName(), variableDomainType, var.getExpressionString(), dataType, var.isMeshVar);
List<Double> times = getTimePoints(simulationDataSetRef);
double time = (double) times.get(timeIndex);
double[] data = vtkManager.getVtuMeshData(vtuVarInfo, time);
//
// get empty mesh file for this domain (getEmptyMeshFile() will ensure that the file exists or create it).
//
File emptyMeshFile = getEmptyMeshFile(simulationDataSetRef, var.getDomainName(), timeIndex);
if (var.getDataType() == DataType.CELLDATA) {
VisMeshUtils.writeCellDataToVtu(emptyMeshFile, var.getVariableVtuName(), data, meshFileForVariableAndTime);
} else if (var.getDataType() == DataType.POINTDATA) {
VisMeshUtils.writePointDataToVtu(emptyMeshFile, var.getVariableVtuName(), data, meshFileForVariableAndTime);
}
return meshFileForVariableAndTime.getAbsolutePath();
} catch (Exception e) {
e.printStackTrace();
throw new ThriftDataAccessException("failed to retrieve data file for variable " + var.getVariableVtuName() + " at time index " + timeIndex);
}
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class DataSetControllerImpl method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(MovingBoundarySimFiles movingBoundaryFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
try {
DataIdentifier[] dataIdentifiers = getDataIdentifiers(outputContext, vcdataID);
if (dataIdentifiers == null) {
return null;
}
ArrayList<VtuVarInfo> vtuVarInfos = new ArrayList<VtuVarInfo>();
for (DataIdentifier di : dataIdentifiers) {
String name = di.getName();
String displayName = di.getDisplayName();
if (di.getDomain() != null) {
System.err.println("DataSetControllerImpl.getVtuVarInfos(movingboundary): need to support proper domain names now");
}
String domainName = MovingBoundaryReader.getFakeInsideDomainName();
VariableDomain variableDomain = null;
VariableType variableType = di.getVariableType();
if (variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
} else if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
} else if (variableType.equals(VariableType.POINT_VARIABLE)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POINT;
} else if (variableType.equals(VariableType.CONTOUR) || variableType.equals(VariableType.CONTOUR_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_CONTOUR;
} else if (variableType.equals(VariableType.NONSPATIAL)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
} else if (variableType.equals(VariableType.POSTPROCESSING)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POSTPROCESSING;
} else {
System.err.print("skipping var " + di + ", unsupported data type");
}
String functionExpression = null;
boolean bMeshVariable = false;
if (name.toUpperCase().contains("SIZE")) {
System.err.println("Skipping Moving Boundary variable '" + name + "' because it is a size ... change later");
continue;
}
vtuVarInfos.add(new VtuVarInfo(name, displayName, domainName, variableDomain, functionExpression, DataType.CellData, bMeshVariable));
}
return vtuVarInfos.toArray(new VtuVarInfo[0]);
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
}
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class DataSetControllerImpl method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(ChomboFiles chomboFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
try {
ChomboVtkFileWriter chomboVTKFileWriter = new ChomboVtkFileWriter();
VtuVarInfo[] vtuVarInfos = chomboVTKFileWriter.getVtuVarInfos(chomboFiles, outputContext, getVCData(vcdataID));
return vtuVarInfos;
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
}
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class ChomboVtkFileWriter method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(ChomboFiles chomboFiles, OutputContext outputContext, VCData vcData) throws DataAccessException, IOException {
//
// read the time=0 chombo dataset into memory to get the var names (probably a more efficient way of doing this).
//
ChomboDataset chomboDataset;
try {
int timeIndex = 0;
chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
} catch (Exception e) {
throw new DataAccessException("failed to read chombo dataset: " + e.getMessage(), e);
}
DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
for (DataIdentifier di : dataIdentifiers) {
System.out.println(((di.getDomain() != null) ? di.getDomain().getName() : "none") + "::" + di.getName() + "-" + di.getVariableType());
}
//
// for each ChomboDomain get list of built-in (mesh) variables, component (regular) volume variables, and Membrane Variables (still tied to the volume).
//
ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
for (ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain : chomboDataset.getCombinedVolumeMembraneDomains()) {
ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
//
// process Volume variables for this combined domain (chombo stores membrane data with volume)
//
{
String volumeDomainName = chomboCombinedVolumeMembraneDomain.getVolumeDomainName();
VariableDomain volVariableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
for (String builtinVarName : chomboMeshData.getVolumeBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String componentVarName : chomboMeshData.getVisibleVolumeDataNames()) {
String varName = componentVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_VOLUME && (dataID.getDomain() == null || dataID.getDomain().getName().equals(volumeDomainName))) {
String displayName = "(" + volumeDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
//
// process membrane variables for this combined domain (chombo stores membrane data with volume)
//
{
String memDomainName = chomboCombinedVolumeMembraneDomain.getMembraneDomainName();
VariableDomain memVariableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
for (ChomboMembraneVarData membraneVarData : chomboMeshData.getMembraneVarData()) {
String varName = membraneVarData.getName();
String displayName = "(" + membraneVarData.getDomainName() + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String builtinVarName : chomboMeshData.getMembraneBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + memDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_MEMBRANE && (dataID.getDomain() == null || dataID.getDomain().getName().equals(memDomainName))) {
String displayName = "(" + memDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
}
return varInfos.toArray(new VtuVarInfo[0]);
}
Aggregations