use of cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo in project vcell by virtualcell.
the class PDEDataViewerPostProcess method dispatchPostProcessUpdate.
private void dispatchPostProcessUpdate(ClientPDEDataContext newClientPDEDataContext) {
ArrayList<AsynchClientTask> allTasks = new ArrayList<>();
final String SPATIAL_ERROR_KEY = "SPATIAL_ERROR_KEY";
AsynchClientTask postProcessInfoTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (postProcessPDEDataViewer != null) {
// already initialized
return;
}
if (getClientTaskStatusSupport() != null) {
getClientTaskStatusSupport().setMessage("Getting Simulation status...");
}
SimulationStatus simStatus = PDEDataViewerPostProcess.this.getDataViewerManager().getRequestManager().getServerSimulationStatus(PDEDataViewerPostProcess.this.getSimulation().getSimulationInfo());
if (simStatus == null) {
hashTable.put(SPATIAL_ERROR_KEY, "PostProcessing Image, no simulation status");
return;
} else if (!simStatus.isCompleted()) {
// sim still busy, no postprocessing data
hashTable.put(SPATIAL_ERROR_KEY, "PostProcessing Image, waiting for completed simulation: " + simStatus.toString());
return;
}
if (getClientTaskStatusSupport() != null) {
getClientTaskStatusSupport().setMessage("Getting Post Process Info...");
}
// Get PostProcess Image state variables info
DataProcessingOutputInfoOP dataProcessingOutputInfoOP = new DataProcessingOutputInfoOP(PDEDataViewerPostProcess.this.getParentPdeDataContext().getVCDataIdentifier(), false, null);
DataProcessingOutputInfo dataProcessingOutputInfo = (DataProcessingOutputInfo) PDEDataViewerPostProcess.this.getParentPdeDataContext().doDataOperation(dataProcessingOutputInfoOP);
boolean bFoundImageStateVariables = false;
if (dataProcessingOutputInfo != null && dataProcessingOutputInfo.getVariableNames() != null) {
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(DataProcessingOutputInfo.PostProcessDataType.image)) {
bFoundImageStateVariables = true;
break;
}
}
}
if (!bFoundImageStateVariables) {
hashTable.put(SPATIAL_ERROR_KEY, "No spatial PostProcessing variables found. (see Application->Protocols->Microscope Measurement)");
}
}
};
AsynchClientTask addPanelTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (postProcessPDEDataViewer != null) {
return;
}
if (hashTable.get(SPATIAL_ERROR_KEY) != null) {
if (PDEDataViewerPostProcess.this.getComponentCount() == 0) {
PDEDataViewerPostProcess.this.add(new JLabel((String) hashTable.get(SPATIAL_ERROR_KEY)), BorderLayout.CENTER);
} else {
((JLabel) PDEDataViewerPostProcess.this.getComponent(0)).setText((String) hashTable.get(SPATIAL_ERROR_KEY));
}
throw UserCancelException.CANCEL_GENERIC;
}
postProcessPDEDataViewer = new PDEDataViewer();
parentDataJobListenerHolder.addDataJobListener(postProcessPDEDataViewer);
PDEDataViewerPostProcess.this.postProcessPDEDataViewer.setPostProcessingPanelVisible(false);
PDEDataViewerPostProcess.this.add(PDEDataViewerPostProcess.this.postProcessPDEDataViewer, BorderLayout.CENTER);
postProcessPDEDataViewer.setDataViewerManager(getDataViewerManager());
postProcessPDEDataViewer.setSimulationModelInfo(getSimulationModelInfo());
postProcessPDEDataViewer.setSimulation(getSimulation());
}
};
allTasks.addAll(Arrays.asList(PDEDataViewerPostProcess.this.getUpdateTasks()));
// AsynchClientTask refreshTask = new AsynchClientTask("refreshPostProcess",AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// ((ArrayList<AsynchClientTask>)hashTable.get(ClientTaskDispatcher.INTERMEDIATE_TASKS)).addAll(Arrays.asList(PDEDataViewerPostProcess.this.postProcessPDEDataViewer.getRefreshTasks()));
// }
// };
// allTasks.add(refreshTask);
allTasks.add(0, addPanelTask);
allTasks.add(0, postProcessInfoTask);
ClientTaskDispatcher.dispatch(this, new Hashtable<>(), allTasks.toArray(new AsynchClientTask[0]), false, false, false, null, true);
}
use of cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo in project vcell by virtualcell.
the class PDEDataViewerPostProcess method createPostProcessPDEDataContext.
public static PostProcessDataPDEDataContext createPostProcessPDEDataContext(final ClientPDEDataContext parentPDEDataContext) throws Exception {
final DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputInfoOP(parentPDEDataContext.getVCDataIdentifier(), false, parentPDEDataContext.getDataManager().getOutputContext()));
if (dataProcessingOutputInfo == null) {
return null;
}
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return new DataSetController() {
// DataIdentifier[] dataIdentifiers;
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new DataAccessException("Not implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getTimeSeriesValues(timeSeriesJobSpec);
DataOperation.DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = new DataOperation.DataProcessingOutputTimeSeriesOP(vcdataID, timeSeriesJobSpec, outputContext, getDataSetTimes(vcdataID));
DataOperationResults.DataProcessingOutputTimeSeriesValues dataopDataProcessingOutputTimeSeriesValues = (DataOperationResults.DataProcessingOutputTimeSeriesValues) parentPDEDataContext.doDataOperation(dataProcessingOutputTimeSeriesOP);
return dataopDataProcessingOutputTimeSeriesValues.getTimeSeriesJobResults();
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getSimDataBlock(varName, time);
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputValues = (DataOperationResults.DataProcessingOutputDataValues) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(vcdataID, varName, TimePointHelper.createSingleTimeTimePointHelper(time), DataIndexHelper.createAllDataIndexesDataIndexHelper(), outputContext, null));
PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdataID.getOwner(), vcdataID.getID(), varName, time, Long.MIN_VALUE);
SimDataBlock simDataBlock = new SimDataBlock(pdeDataInfo, dataProcessingOutputValues.getDataValues()[0], VariableType.POSTPROCESSING);
return simDataBlock;
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// throw new DataAccessException("PostProcessData mesh not available at this level");
return null;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new DataAccessException("Remote getLineScan method should not be called for PostProcess");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return outputContext.getOutputFunctions();
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return dataProcessingOutputInfo.getVariableTimePoints();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataIdentifiers();
ArrayList<DataIdentifier> postProcessDataIDs = new ArrayList<DataIdentifier>();
if (outputContext != null && outputContext.getOutputFunctions() != null) {
for (int i = 0; i < outputContext.getOutputFunctions().length; i++) {
if (outputContext.getOutputFunctions()[i].isPostProcessFunction()) {
postProcessDataIDs.add(new DataIdentifier(outputContext.getOutputFunctions()[i].getName(), VariableType.POSTPROCESSING, null, false, outputContext.getOutputFunctions()[i].getDisplayName()));
}
}
}
// get 'state' variables
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(PostProcessDataType.image)) {
DataIdentifier dataIdentifier = new DataIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null, false, dataProcessingOutputInfo.getVariableNames()[i]);
postProcessDataIDs.add(dataIdentifier);
}
}
if (postProcessDataIDs.size() > 0) {
return postProcessDataIDs.toArray(new DataIdentifier[0]);
}
return null;
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return parentPDEDataContext.doDataOperation(dataOperation);
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@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) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
}
};
VCDataManager postProcessVCDataManager = new VCDataManager(dataSetControllerProvider);
PDEDataManager postProcessPDEDataManager = new PDEDataManager(((ClientPDEDataContext) parentPDEDataContext).getDataManager().getOutputContext(), postProcessVCDataManager, parentPDEDataContext.getVCDataIdentifier());
PostProcessDataPDEDataContext postProcessDataPDEDataContext = new PostProcessDataPDEDataContext(postProcessPDEDataManager);
return postProcessDataPDEDataContext;
}
use of cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo in project vcell by virtualcell.
the class LoadFRAPData_PostProcessingDataDescriptor method preNextProcess.
public ArrayList<AsynchClientTask> preNextProcess() {
final String LOADING_MESSAGE = "Loading variable data " + postProcessingDataPanel.getSelectedVariableName() + "...";
AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("Updating status message...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (postProcessingDataPanel.getSelectedVariableName() == null || postProcessingDataPanel.getSelectedDataManager() == null) {
throw new RuntimeException("Post Processing Data variable not selected");
}
VirtualFrapMainFrame.updateStatus(LOADING_MESSAGE);
}
};
AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
String selectedVariableName = postProcessingDataPanel.getSelectedVariableName();
int selectedSlice = postProcessingDataPanel.getSelectedSlice();
DataProcessingOutputInfo dataProcessingOutputInfo = postProcessingDataPanel.getSelectedDataProcessingOutputInfo();
PDEDataManager pdeDataManager = postProcessingDataPanel.getSelectedDataManager();
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputDataValues = (DataOperationResults.DataProcessingOutputDataValues) pdeDataManager.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(pdeDataManager.getVCDataIdentifier(), selectedVariableName, TimePointHelper.createAllTimeTimePointHelper(), DataIndexHelper.createSliceDataIndexHelper(selectedSlice), null, null));
ArrayList<SourceDataInfo> sdiArr = dataProcessingOutputDataValues.createSourceDataInfos(dataProcessingOutputInfo.getVariableISize(selectedVariableName), dataProcessingOutputInfo.getVariableOrigin(selectedVariableName), dataProcessingOutputInfo.getVariableExtent(selectedVariableName));
FRAPStudy newFRAPStudy = FRAPWorkspace.loadFRAPDataFromDataProcessingOutput(sdiArr, dataProcessingOutputInfo.getVariableTimePoints(), 0, /*data already sliced*/
65535.0, this.getClientTaskStatusSupport());
isFileLoaded = true;
hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
}
};
AsynchClientTask afterLoadingSwingTask = new AsynchClientTask("Setting FrapWorkspace FrapStudy...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
// setFrapStudy fires property change, so we have to put it in Swing thread.
getFrapWorkspace().setFrapStudy(newFRAPStudy, true);
VirtualFrapLoader.mf.setMainFrameTitle("");
VirtualFrapMainFrame.updateProgress(0);
if (isFileLoaded) {
VirtualFrapMainFrame.updateStatus("Loaded " + postProcessingDataPanel.getSelectedVariableName());
} else {
VirtualFrapMainFrame.updateStatus("Failed loading " + postProcessingDataPanel.getSelectedVariableName() + ".");
}
}
};
ArrayList<AsynchClientTask> tasks = new ArrayList<AsynchClientTask>();
tasks.add(updateUIBeforeLoadTask);
tasks.add(loadTask);
tasks.add(afterLoadingSwingTask);
return tasks;
}
use of cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo in project vcell by virtualcell.
the class RasterExporter method exportPDEData.
private NrrdInfo[] exportPDEData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, VariableSpecs variableSpecs, TimeSpecs timeSpecs2, GeometrySpecs geometrySpecs, RasterSpecs rasterSpecs, FileDataContainerManager fileDataContainerManager) throws RemoteException, DataAccessException, IOException {
CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
DataProcessingOutputInfo dataProcessingOutputInfo = null;
// check if any of export variables are PostProcess and if so try to get PostProcessOutputInfo
exportServiceImpl.fireExportProgress(jobID, vcdID, "Check PostProcess", 0.0);
DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
for (int i = 0; i < dataIdentifiers.length; i++) {
for (int j = 0; j < variableSpecs.getVariableNames().length; j++) {
if (variableSpecs.getVariableNames()[j].equals(dataIdentifiers[i].getName()) && VariableType.POSTPROCESSING.equals(dataIdentifiers[i].getVariableType())) {
try {
// we need PostProcessOutputInfo
exportServiceImpl.fireExportProgress(jobID, vcdID, "Read PostProcess", 0.0);
dataProcessingOutputInfo = (DataProcessingOutputInfo) dataServerImpl.doDataOperation(user, new DataOperation.DataProcessingOutputInfoOP(vcdID, false, outputContext));
break;
} catch (Exception e) {
throw new DataAccessException("Export variable '" + variableSpecs.getVariableNames()[j] + "' is PostProcessing type. Error reading PostProcessing data: " + e.getClass().getName() + " " + e.getMessage());
}
}
}
}
long lastUpdateTime = 0;
switch(rasterSpecs.getFormat()) {
case NRRD_SINGLE:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
NrrdInfo nrrdInfo = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
}
nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
return new NrrdInfo[] { nrrdInfo };
}
case GEOMETRY_SLICE:
{
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglslice", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
}
sliceNrrdInfo = NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
return new NrrdInfo[] { sliceNrrdInfo };
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
case NRRD_BY_TIME:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
NRRDHelper nrrdHelper = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timefull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
NrrdInfo nrrdInfo = nrrdHelper.createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
nrrdinfoV.add(nrrdInfo);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
case GEOMETRY_SLICE:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timeslice", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
nrrdinfoV.add(sliceNrrdInfo);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
case NRRD_BY_VARIABLE:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
NRRDHelper nrrdhelHelper = new NRRDHelper(variableSpecs.getVariableNames()[i], mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
NrrdInfo nrrdInfo = nrrdhelHelper.createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
nrrdinfoV.add(nrrdInfo);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
case GEOMETRY_SLICE:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
nrrdinfoV.add(sliceNrrdInfo);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
default:
{
throw new DataAccessException("Multiple NRRD file export not yet supported");
}
}
}
use of cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo in project vcell by virtualcell.
the class PDEDataViewer method calcAutoAllTimes.
private void calcAutoAllTimes() throws Exception {
HashSet<String> stateVarNames = null;
Variable theVariable = null;
boolean bStateVar = true;
boolean isFieldData = getPdeDataContext().getVCDataIdentifier() instanceof ExternalDataIdentifier || getPdeDataContext().getVCDataIdentifier() instanceof MergedDataInfo;
if (isFieldData) {
// fielddata
DataIdentifier[] dataids = getPdeDataContext().getDataIdentifiers();
stateVarNames = new HashSet<>();
for (int i = 0; i < dataids.length; i++) {
if (!dataids[i].isFunction()) {
stateVarNames.add(dataids[i].getName());
}
// System.out.println("name:'"+dataids[i].getName()+"' type:"+dataids[i].getVariableType()+" func:"+dataids[i].isFunction());
}
bStateVar = !getPdeDataContext().getDataIdentifier().isFunction();
if (bStateVar) {
theVariable = new VolVariable(getPdeDataContext().getDataIdentifier().getName(), getPdeDataContext().getDataIdentifier().getDomain());
} else {
AnnotatedFunction[] funcs = getPdeDataContext().getFunctions();
for (int i = 0; i < funcs.length; i++) {
if (funcs[i].getName().equals(getPdeDataContext().getDataIdentifier().getName())) {
theVariable = funcs[i];
break;
}
}
}
} else {
stateVarNames = getSimulation().getMathDescription().getStateVariableNames();
theVariable = getSimulation().getMathDescription().getVariable(getPdeDataContext().getVariableName());
if (theVariable == null) {
theVariable = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext().getOutputFunction(getPdeDataContext().getVariableName());
}
if (theVariable == null) {
DataProcessingOutputInfo dataProcessingOutputInfo = DataProcessingResultsPanel.getDataProcessingOutputInfo(getPdeDataContext());
if (dataProcessingOutputInfo != null && Arrays.asList(dataProcessingOutputInfo.getVariableNames()).contains(getPdeDataContext().getVariableName())) {
// PostProcess Variable
return;
}
}
bStateVar = stateVarNames.contains(getPdeDataContext().getVariableName());
}
if (theVariable == null) {
throw new Exception("Unexpected Alltimes... selected variable '" + getPdeDataContext().getVariableName() + "' is not stateVariable or OutputFunction");
}
if (getPDEDataContextPanel1().getdisplayAdapterService1().getAllTimes()) {
// min-max over all timepoints (allTimes)
if (theVariable.isConstant()) {
getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
double constVal = theVariable.getExpression().evaluateConstant();
getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(constVal, constVal));
} else if (bStateVar) {
getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), new String[] { theVariable.getName() });
if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
// no postprocessinfo
return;
}
FunctionStatistics functionStatistics = new FunctionStatistics(varStatsArr.get(0).minValuesOverTime, varStatsArr.get(0).maxValuesOverTime);
getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
} else if (theVariable instanceof Function) {
getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
Function flattened = MathDescription.getFlattenedFunctions(SimulationSymbolTable.createMathSymbolTableFactory(), getSimulation().getMathDescription(), new String[] { theVariable.getName() })[0];
if (flattened == null) {
flattened = (Function) theVariable;
}
ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), stateVarNames.toArray(new String[0]));
if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
// check for no postprocessinfo
return;
}
if (varStatsArr.size() == stateVarNames.size()) {
if (getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().getRegionImage() == null) {
getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().updateAll();
}
FunctionStatistics functionStatistics = FunctionRangeGenerator.getFunctionStatistics(flattened.getExpression(), varStatsArr.toArray(new VarStatistics[0]), getPdeDataContext().getTimePoints(), getPdeDataContext().getCartesianMesh(), calcInDomainBitSet(), getPdeDataContext().getDataIdentifier().getVariableType());
getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
} else {
throw new Exception("Unexpectede AllTimes... calculated state var stats size != mathdescr state var size");
}
} else {
throw new Exception("Unexpected AllTimes... not constant, stateVar or function");
}
} else {
// min-max at each timepoint (currTime)
if (!(theVariable instanceof Function)) {
getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
} else {
getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
}
getPDEDataContextPanel1().setFunctionStatisticsRange(null);
}
}
Aggregations