use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class PdeTimePlotMultipleVariablesPanel method showTimePlot.
public void showTimePlot() {
if ((plotChangeTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, plotChangeTimer, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e2) {
showTimePlot();
}
}, "PdeTimePlotMultipleVariablesPanel update...")) != null) {
return;
}
VariableType varType = multiTimePlotHelper.getVariableType();
Object[] selectedValues = variableJList.getSelectedValues();
DataIdentifier[] selectedDataIdentifiers = new DataIdentifier[selectedValues.length];
System.arraycopy(selectedValues, 0, selectedDataIdentifiers, 0, selectedValues.length);
if (selectedDataIdentifiers.length > 1) {
for (DataIdentifier selectedDataIdentifier : selectedDataIdentifiers) {
if (!selectedDataIdentifier.getVariableType().getVariableDomain().equals(varType.getVariableDomain())) {
PopupGenerator.showErrorDialog(this, "Please choose VOLUME variables or MEMBRANE variables only");
variableJList.clearSelection();
variableJList.setSelectedValue(multiTimePlotHelper.getPdeDatacontext().getVariableName(), true);
return;
}
}
}
try {
final int numSelectedVariables = selectedDataIdentifiers.length;
final int numSelectedSpatialPoints = pointVector.size();
int[][] indices = new int[numSelectedVariables][numSelectedSpatialPoints];
//
for (int i = 0; i < numSelectedSpatialPoints; i++) {
for (int v = 0; v < numSelectedVariables; v++) {
if (selectedDataIdentifiers[v].getVariableType().equals(varType)) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector.get(i);
indices[v][i] = ssm.getIndex(0);
}
} else {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector2.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector2.get(i);
indices[v][i] = ssm.getIndex(0);
}
}
}
}
final String[] selectedVarNames = new String[numSelectedVariables];
for (int i = 0; i < selectedVarNames.length; i++) {
selectedVarNames[i] = selectedDataIdentifiers[i].getName();
}
final double[] timePoints = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(selectedVarNames, indices, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
if (!tsjs.getVcDataJobID().isBackgroundTask()) {
throw new RuntimeException("Use getTimeSeries(...) if not a background job");
}
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(PDEDataViewer.StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
AsynchClientTask task2 = new AsynchClientTask("showing time plot", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
int plotCount = numSelectedVariables * numSelectedSpatialPoints;
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
String[] plotNames = new String[plotCount];
double[][] plotDatas = new double[1 + plotCount][];
plotDatas[0] = timePoints;
int plotIndex = 0;
for (int v = 0; v < numSelectedVariables; v++) {
String varName = selectedVarNames[v];
double[][] data = tsJobResultsNoStats.getTimesAndValuesForVariable(varName);
for (int i = 1; i < data.length; i++) {
symbolTableEntries[plotIndex] = multiTimePlotHelper.getsimulation().getMathDescription().getEntry(varName);
plotNames[plotIndex] = varName + " at P[" + (i - 1) + "]";
plotDatas[plotIndex + 1] = data[i];
plotIndex++;
}
}
Plot2D plot2D = new SingleXPlot2D(symbolTableEntries, multiTimePlotHelper.getDataSymbolMetadataResolver(), ReservedVariable.TIME.getName(), plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
plotPane.setPlot2D(plot2D);
}
};
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2 }, false, true, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class ASCIIExporter method getPointsTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getPointsTimeSeries(OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, GeometrySpecs geometrySpecs, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { geometrySpecs.getPointIndexes() }, null, allTimes[beginIndex], 1, allTimes[endIndex], VCDataJobID.createVCDataJobID(user, false));
org.vcell.util.document.TSJobResultsNoStats timeSeriesJobResults = (org.vcell.util.document.TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
// variableValues[0] is time array
// variableValues[1] is values for 1st spatial point.
// variableValues[2] is values for 2nd spatial point.
// variableValues[n] (n>=1) is values for nth spatial point.
// the length of variableValues should always be 1 + pointIndexes.length
// the length of variableValues[n] is allTimes.length
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableName);
//
// put data in csv format
//
SpatialSelection[] pointSpatialSelections = geometrySpecs.getPointSpatialSelections();
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
// FileDataContainer container = fileDataContainerManager.getFileDataContainer(fileDataContainerID);
// buffer.append(
// "\"Time Series for variable '" + variableName + "'\" over the range " + allTimes[beginIndex] + " to " + allTimes[endIndex] + "\n");
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + /*+getSpatialSelectionDescription(curve)*/
"\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Coordinates\n");
fileDataContainerManager.append(fileDataContainerID, "Time,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + getSpatialSelectionDescription(pointSpatialSelections[k]));
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[k + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Time\n");
fileDataContainerManager.append(fileDataContainerID, "Coordinates,");
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + getSpatialSelectionDescription(pointSpatialSelections[k]));
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
for (int k = 0; k < pointSpatialSelections.length; k++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[k + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
return fileDataContainerID;
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class ASCIIExporter method getCurveTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getCurveTimeSeries(OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, SpatialSelection curve, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
int[] pointIndexes = null;
double[] distances = null;
int[] crossingMembraneIndexes = null;
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
pointIndexes = new int[] { ssh.getSampledIndexes()[0] };
distances = new double[] { 0 };
} else {
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
}
}
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { pointIndexes }, new int[][] { crossingMembraneIndexes }, allTimes[beginIndex], 1, allTimes[endIndex], VCDataJobID.createVCDataJobID(user, false));
org.vcell.util.document.TSJobResultsNoStats timeSeriesJobResults = (org.vcell.util.document.TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
// variableValues[0] is time array
// variableValues[1] is values for 1st spatial point.
// variableValues[2] is values for 2nd spatial point.
// variableValues[n] (n>=1) is values for nth spatial point.
// the length of variableValues should always be 1 + pointIndexes.length
// the length of variableValues[n] is allTimes.length
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableName);
//
// put data in csv format
//
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + getSpatialSelectionDescription(curve) + "\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Distances\n");
fileDataContainerManager.append(fileDataContainerID, "Times,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[j]);
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Times\n");
fileDataContainerManager.append(fileDataContainerID, "Distances,");
for (int i = 0; i < distances.length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
return fileDataContainerID;
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class DataSetControllerImpl method getDataProcessingOutput.
public static DataOperationResults getDataProcessingOutput(DataOperation dataOperation, File dataProcessingOutputFileHDF5) throws Exception {
DataOperationResults dataProcessingOutputResults = null;
FileFormat hdf5FileFormat = null;
try {
if (dataProcessingOutputFileHDF5.exists()) {
// retrieve an instance of H5File
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.open(dataProcessingOutputFileHDF5.getAbsolutePath(), FileFormat.READ);
hdf5FileFormat.setMaxMembers(Simulation.MAX_LIMIT_SPATIAL_TIMEPOINTS);
// open the file and retrieve the file structure
hdf5FileFormat.open();
Group root = (Group) ((javax.swing.tree.DefaultMutableTreeNode) hdf5FileFormat.getRootNode()).getUserObject();
if (dataOperation instanceof DataProcessingOutputInfoOP) {
DataProcessingHelper dataProcessingHelper = new DataProcessingHelper();
iterateHDF5(root, "", dataProcessingHelper);
dataProcessingOutputResults = new DataOperationResults.DataProcessingOutputInfo(dataOperation.getVCDataIdentifier(), dataProcessingHelper.getVarNames(), dataProcessingHelper.getVarISizes(), dataProcessingHelper.times, dataProcessingHelper.getVarUnits(), dataProcessingHelper.getPostProcessDataTypes(), dataProcessingHelper.getVarOrigins(), dataProcessingHelper.getVarExtents(), dataProcessingHelper.getVarStatValues());
// map function names to PostProcess state variable name
ArrayList<String> postProcessImageVarNames = new ArrayList<String>();
for (int i = 0; i < ((DataOperationResults.DataProcessingOutputInfo) dataProcessingOutputResults).getVariableNames().length; i++) {
String variableName = ((DataOperationResults.DataProcessingOutputInfo) dataProcessingOutputResults).getVariableNames()[i];
if (((DataOperationResults.DataProcessingOutputInfo) dataProcessingOutputResults).getPostProcessDataType(variableName).equals(DataOperationResults.DataProcessingOutputInfo.PostProcessDataType.image)) {
postProcessImageVarNames.add(variableName);
}
}
HashMap<String, String> mapFunctionNameToStateVarName = null;
if (((DataProcessingOutputInfoOP) dataOperation).getOutputContext() != null) {
mapFunctionNameToStateVarName = new HashMap<String, String>();
for (int i = 0; i < ((DataProcessingOutputInfoOP) dataOperation).getOutputContext().getOutputFunctions().length; i++) {
AnnotatedFunction annotatedFunction = ((DataProcessingOutputInfoOP) dataOperation).getOutputContext().getOutputFunctions()[i];
if (annotatedFunction.getFunctionType().equals(VariableType.POSTPROCESSING)) {
String[] symbols = annotatedFunction.getExpression().flatten().getSymbols();
// Find any PostProcess state var that matches a symbol in the function
for (int j = 0; j < symbols.length; j++) {
if (postProcessImageVarNames.contains(symbols[j])) {
mapFunctionNameToStateVarName.put(annotatedFunction.getName(), symbols[j]);
break;
}
}
}
}
}
if (mapFunctionNameToStateVarName != null && mapFunctionNameToStateVarName.size() > 0) {
dataProcessingOutputResults = new DataOperationResults.DataProcessingOutputInfo(((DataOperationResults.DataProcessingOutputInfo) dataProcessingOutputResults), mapFunctionNameToStateVarName);
}
} else {
OutputContext outputContext = dataOperation.getOutputContext();
String[] variableNames = null;
DataIndexHelper dataIndexHelper = null;
TimePointHelper timePointHelper = null;
if (dataOperation instanceof DataOperation.DataProcessingOutputDataValuesOP) {
variableNames = new String[] { ((DataOperation.DataProcessingOutputDataValuesOP) dataOperation).getVariableName() };
dataIndexHelper = ((DataOperation.DataProcessingOutputDataValuesOP) dataOperation).getDataIndexHelper();
timePointHelper = ((DataOperation.DataProcessingOutputDataValuesOP) dataOperation).getTimePointHelper();
} else if (dataOperation instanceof DataOperation.DataProcessingOutputTimeSeriesOP) {
variableNames = ((DataOperation.DataProcessingOutputTimeSeriesOP) dataOperation).getTimeSeriesJobSpec().getVariableNames();
TimeSeriesJobSpec timeSeriesJobSpec = ((DataOperation.DataProcessingOutputTimeSeriesOP) dataOperation).getTimeSeriesJobSpec();
double[] specificTimepoints = extractTimeRange(((DataOperation.DataProcessingOutputTimeSeriesOP) dataOperation).getAllDatasetTimes(), timeSeriesJobSpec.getStartTime(), timeSeriesJobSpec.getEndTime());
timePointHelper = TimePointHelper.createSpecificTimePointHelper(specificTimepoints);
timeSeriesJobSpec.initIndices();
dataIndexHelper = DataIndexHelper.createSpecificDataIndexHelper(timeSeriesJobSpec.getIndices()[0]);
} else {
throw new Exception("Unknown Dataoperation " + dataOperation.getClass().getName());
}
if (variableNames.length != 1) {
throw new Exception("Only 1 variable request at a time");
}
AnnotatedFunction[] annotatedFunctions = (outputContext == null ? null : outputContext.getOutputFunctions());
AnnotatedFunction foundFunction = null;
if (annotatedFunctions != null) {
for (int i = 0; i < annotatedFunctions.length; i++) {
if (annotatedFunctions[i].getName().equals(variableNames[0])) {
foundFunction = annotatedFunctions[i];
break;
}
}
}
double[] alltimes = null;
if (foundFunction != null) {
DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) getDataProcessingOutput(new DataOperation.DataProcessingOutputInfoOP(dataOperation.getVCDataIdentifier(), false, dataOperation.getOutputContext()), dataProcessingOutputFileHDF5);
alltimes = dataProcessingOutputInfo.getVariableTimePoints();
FunctionHelper functionHelper = getPostProcessStateVariables(foundFunction, dataProcessingOutputInfo);
DataProcessingHelper dataProcessingHelper = new DataProcessingHelper(functionHelper.postProcessStateVars, timePointHelper, dataIndexHelper);
iterateHDF5(root, "", dataProcessingHelper);
dataProcessingOutputResults = evaluatePostProcessFunction(dataProcessingOutputInfo, functionHelper.postProcessStateVars, dataProcessingHelper.specificDataValues, dataIndexHelper, timePointHelper, functionHelper.flattenedBoundExpression, variableNames[0]);
} else {
DataProcessingHelper dataProcessingHelper = new DataProcessingHelper(new String[] { variableNames[0] }, timePointHelper, dataIndexHelper);
iterateHDF5(root, "", dataProcessingHelper);
alltimes = dataProcessingHelper.times;
if (dataProcessingHelper.specificDataValues == null) {
throw new Exception("Couldn't find postprocess data as specified for var=" + variableNames[0]);
}
dataProcessingOutputResults = new DataOperationResults.DataProcessingOutputDataValues(dataOperation.getVCDataIdentifier(), variableNames[0], timePointHelper, dataIndexHelper, dataProcessingHelper.specificDataValues[0]);
}
if (dataOperation instanceof DataOperation.DataProcessingOutputTimeSeriesOP) {
TimeSeriesJobResults timeSeriesJobResults = null;
DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = (DataOperation.DataProcessingOutputTimeSeriesOP) dataOperation;
// [time][data]
double[][] dataValues = ((DataOperationResults.DataProcessingOutputDataValues) dataProcessingOutputResults).getDataValues();
double[] desiredTimes = (timePointHelper.isAllTimePoints() ? alltimes : timePointHelper.getTimePoints());
double[][][] timeSeriesFormatedValuesArr = new double[variableNames.length][dataIndexHelper.getDataIndexes().length + 1][desiredTimes.length];
for (int i = 0; i < timeSeriesFormatedValuesArr.length; i++) {
// var
for (int j = 0; j < timeSeriesFormatedValuesArr[i].length; j++) {
// index
if (j == 0) {
timeSeriesFormatedValuesArr[i][j] = desiredTimes;
continue;
}
for (int k = 0; k < timeSeriesFormatedValuesArr[i][j].length; k++) {
// time
// assume 1 variable for now
timeSeriesFormatedValuesArr[i][j][k] = dataValues[k][j - 1];
}
}
}
if (dataProcessingOutputTimeSeriesOP.getTimeSeriesJobSpec().isCalcSpaceStats()) {
SpatialStatsInfo spatialStatsInfo = new SpatialStatsInfo();
spatialStatsInfo.bWeightsValid = false;
timeSeriesJobResults = calculateStatisticsFromWhole(dataProcessingOutputTimeSeriesOP.getTimeSeriesJobSpec(), timeSeriesFormatedValuesArr, timePointHelper.getTimePoints(), spatialStatsInfo);
} else {
timeSeriesJobResults = new TSJobResultsNoStats(variableNames, new int[][] { dataIndexHelper.getDataIndexes() }, timePointHelper.getTimePoints(), timeSeriesFormatedValuesArr);
}
dataProcessingOutputResults = new DataOperationResults.DataProcessingOutputTimeSeriesValues(dataOperation.getVCDataIdentifier(), timeSeriesJobResults);
}
}
} else {
throw new FileNotFoundException("Data Processing Output file '" + dataProcessingOutputFileHDF5.getPath() + "' not found");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (hdf5FileFormat != null) {
try {
hdf5FileFormat.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return dataProcessingOutputResults;
}
use of org.vcell.util.document.TimeSeriesJobSpec 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;
}
Aggregations