use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class ASCIIExporter method sofyaFormat.
private ExportOutput sofyaFormat(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, final VCDataIdentifier orig_vcdID, VariableSpecs variableSpecs, TimeSpecs timeSpecs, GeometrySpecs geometrySpecs, ASCIISpecs asciiSpecs, String contextName, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
ExportSpecs.SimNameSimDataID[] simNameSimDataIDs = asciiSpecs.getSimNameSimDataIDs();
// use mesh to calulate indexes
CartesianMesh mesh = dataServerImpl.getMesh(user, orig_vcdID);
final int SIM_COUNT = simNameSimDataIDs.length;
final int PARAMSCAN_COUNT = (asciiSpecs.getExportMultipleParamScans() != null ? asciiSpecs.getExportMultipleParamScans().length : 1);
final int TIME_COUNT = timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1;
if (PARAMSCAN_COUNT > 1 || geometrySpecs.getModeID() != GEOMETRY_SELECTIONS) /* || geometrySpecs.getCurves().length != 0*/
{
throw new DataAccessException("Alternate csv format cannot have parameter scans and must be 'point selection' type");
}
// millisecodns
final long MESSAGE_LIMIT = 5000;
final long MAX_DATA = 10000000;
long totalPoints = SIM_COUNT * TIME_COUNT * variableSpecs.getVariableNames().length * geometrySpecs.getPointCount();
if (totalPoints > MAX_DATA) {
throw new DataAccessException("Too much data, select fewer (sims or times or variables or samplepoints). Exceeded limit by " + NumberUtils.formatNumber(100 * (((double) totalPoints / (double) MAX_DATA) - 1.0), 6) + "%");
}
ExportOutput exportOutput1 = new ExportOutput(true, ".csv", SIM_COUNT + "_multisims_", variableSpecs.getVariableNames().length + "_Vars_" + TIME_COUNT + "_times", fileDataContainerManager);
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\"Model:'" + contextName + "'\"\n\n");
int[] sampleIndexes = getallSampleIndexes(geometrySpecs, mesh);
int[][] indexes = new int[variableSpecs.getVariableNames().length][];
HashMap<Integer, TSJobResultsNoStats> simData = new HashMap<>();
long lastTime = 0;
double progressCounter = 0;
for (int t = 0; t < TIME_COUNT; t++) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "Time," + timeSpecs.getAllTimes()[timeSpecs.getBeginTimeIndex() + t] + "\n");
for (int simIndex = 0; simIndex < SIM_COUNT; simIndex++) {
progressCounter++;
if ((System.currentTimeMillis() - lastTime) > MESSAGE_LIMIT) {
lastTime = System.currentTimeMillis();
exportServiceImpl.fireExportProgress(jobID, orig_vcdID, "multisim-point", progressCounter / (SIM_COUNT * TIME_COUNT));
}
int simJobIndex = simNameSimDataIDs[simIndex].getDefaultJobIndex();
VCDataIdentifier vcdID = simNameSimDataIDs[simIndex].getVCDataIdentifier(simJobIndex);
if (SIM_COUNT > 1) {
// check times are the same
double[] currentTimes = dataServerImpl.getDataSetTimes(user, vcdID);
if (currentTimes.length != timeSpecs.getAllTimes().length) {
throw new DataAccessException("time sets are different length");
}
for (int i = 0; i < currentTimes.length; i++) {
if (timeSpecs.getAllTimes()[i] != currentTimes[i]) {
throw new DataAccessException("time sets have different values");
}
}
}
SpatialSelection[] spatialSelections = geometrySpecs.getSelections();
mesh = dataServerImpl.getMesh(user, vcdID);
for (int i = 0; i < spatialSelections.length; i++) {
if (spatialSelections[i].getMesh() == null) {
spatialSelections[i].setMesh(mesh);
} else if (!spatialSelections[i].getMesh().getISize().compareEqual(mesh.getISize()) || spatialSelections[i].getMesh().getNumMembraneElements() != mesh.getNumMembraneElements()) {
// check just sizes not areas,normals,etc...
// This will throw fail message
spatialSelections[i].setMesh(mesh);
}
}
if (simIndex == 0) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "Variables-->,");
for (int v = 0; v < variableSpecs.getVariableNames().length; v++) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\"" + variableSpecs.getVariableNames()[v] + "\"");
for (int p = 0; p < sampleIndexes.length; p++) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), ",");
}
}
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\n\"Simulation Name : (point/line)Index-->\",");
for (int v = 0; v < variableSpecs.getVariableNames().length; v++) {
indexes[v] = sampleIndexes;
for (int p = 0; p < sampleIndexes.length; p++) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), sampleIndexes[p] + ",");
}
}
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\n");
}
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\"" + simNameSimDataIDs[simIndex].getSimulationName() + "\"");
TSJobResultsNoStats timeSeriesJobResults = simData.get(simIndex);
if (timeSeriesJobResults == null) {
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(variableSpecs.getVariableNames(), indexes, null, timeSpecs.getAllTimes()[timeSpecs.getBeginTimeIndex()], 1, timeSpecs.getAllTimes()[timeSpecs.getEndTimeIndex()], VCDataJobID.createVCDataJobID(user, false));
timeSeriesJobResults = (TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
simData.put(simIndex, timeSeriesJobResults);
}
// the length of variableValues[n] is allTimes.length
for (int v = 0; v < variableSpecs.getVariableNames().length; v++) {
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableSpecs.getVariableNames()[v]);
for (int p = 0; p < sampleIndexes.length; p++) {
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "," + variableValues[p + 1][t]);
}
}
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\n");
}
fileDataContainerManager.append(exportOutput1.getFileDataContainerID(), "\n");
}
return exportOutput1;
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class PDEDataViewer method showTimePlot.
// private static final String PROPERTY_PDEDC = "pdedc";
/**
* Comment
*/
private void showTimePlot() {
VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
// Collect all sample curves created by user
SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(true, true);
SpatialSelection[] spatialSelectionArr2 = null;
if (varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME) || varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_POSTPROCESSING)) {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType, true, true);
} else {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType.equals(VariableType.MEMBRANE) ? VariableType.MEMBRANE_REGION : VariableType.MEMBRANE, true, true);
}
final Vector<SpatialSelection> singlePointSSOnly = new Vector<SpatialSelection>();
final Vector<SpatialSelection> singlePointSSOnly2 = new Vector<SpatialSelection>();
if (spatialSelectionArr != null && spatialSelectionArr.length > 0) {
for (int i = 0; i < spatialSelectionArr.length; i++) {
if (spatialSelectionArr[i].isPoint() || (spatialSelectionArr[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly.add(spatialSelectionArr[i]);
}
if (spatialSelectionArr2[i].isPoint() || (spatialSelectionArr2[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr2[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly2.add(spatialSelectionArr2[i]);
}
}
}
final String varName = getPdeDataContext().getVariableName();
if (singlePointSSOnly.size() == 0) {
PopupGenerator.showErrorDialog(this, "No Time sampling points match DataType=" + varType);
return;
}
try {
int[] indices = null;
//
indices = new int[singlePointSSOnly.size()];
for (int i = 0; i < singlePointSSOnly.size(); i++) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) singlePointSSOnly.get(i);
indices[i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) singlePointSSOnly.get(i);
indices[i] = ssm.getIndex(0);
}
}
double[] timePoints = getPdeDataContext().getTimePoints();
final TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(new String[] { varName }, new int[][] { indices }, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(getDataViewerManager().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(StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving Data for '" + varName + "'...", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext(), PDEDataViewer.this.getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
}
};
AsynchClientTask task2 = new AsynchClientTask("showing time plot for '" + varName + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
// Make independent Plotviewer that is unaffected by changes (time,var,paramscan) in 'this' PDEDataviewer except to pass-thru OutputContext changes
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = (PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY);
try {
PdeTimePlotMultipleVariablesPanel pdeTimePlotPanel = new PdeTimePlotMultipleVariablesPanel(multiTimePlotHelper, singlePointSSOnly, singlePointSSOnly2, tsJobResultsNoStats);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
String prefix = "Time Plot (" + getPDEPlotControlPanel1().getPlotVariableJList().getSelectedValue().getVariableType().getTypeName() + ") ";
ChildWindow childWindow = childWindowManager.addChildWindow(pdeTimePlotPanel, pdeTimePlotPanel, createContextTitle(PDEDataViewer.this.isPostProcess(), prefix, getPdeDataContext(), getSimulationModelInfo(), getSimulation()));
childWindow.getParent().addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
@Override
public void windowClosed(WindowEvent e) {
super.windowClosed(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
});
// childWindow.addChildWindowListener(new ChildWindowListener() {
// @Override
// public void closing(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// @Override
// public void closed(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// });
childWindow.setSize(900, 550);
childWindow.setIsCenteredOnParent();
childWindow.show();
} catch (Exception e) {
e.printStackTrace();
multiTimePlotHelper.removeallPropertyChangeListeners();
}
}
};
// ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1,multiTimePlotHelperTask, task2 }, true, true, null);
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, multiTimePlotHelperTask, task2 }, null, false, false, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class KymographPanel method initDataManagerVariable.
/**
* Insert the method's description here.
* Creation date: (12/14/2004 9:47:38 AM)
* @param timeSeries double[][]
* @param distances double[]
*/
private void initDataManagerVariable() /*final DataIdentifier dataIdentifer,*/
/*boolean bFromGUI*/
{
final DataIdentifier dataIdentifer = (DataIdentifier) getVarNamesJComboBox().getSelectedItem();
// Thread.dumpStack();
if ((initVariableTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, initVariableTimer, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
initDataManagerVariable();
}
}, "KymographPanel get '" + dataIdentifer.getName() + "'")) != null) {
return;
}
// Create SymbolTableEntry for Copy/Paste functionality
currentSymbolTablEntry = (symbolTable != null ? symbolTable.getEntry(dataIdentifer.getName()) : null);
String taskName = "Retrieving data for variable '" + dataIdentifer.getName() + "'";
AsynchClientTask task1 = new AsynchClientTask(taskName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(final Hashtable<String, Object> hashTable) throws Exception {
double[] timeValues = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
final TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { dataIdentifer.getName() }, new int[][] { dataManagerIndices }, (crossingMembraneIndices != null ? new int[][] { crossingMembraneIndices } : null), resampleStartTimeOrig, resampleStepOrig, timeValues[timeValues.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
hashTable.put(PDEDataViewer.StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
}
};
// new TimeSeriesDataRetrievalTask(title, PDEDataViewer.this, PDEDataViewer.this.getPdeDataContext());//timeSeriesDataRetrievalTask;
AsynchClientTask task2 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
AsynchClientTask task3 = new AsynchClientTask("Showing kymograph", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
Throwable timeSeriesJobFailed = (Throwable) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobException);
if (timeSeriesJobFailed == null) {
timeSeriesJobFailed = (Throwable) hashTable.get(ClientTaskDispatcher.TASK_ABORTED_BY_USER);
}
if (failMethod(timeSeriesJobFailed, dataIdentifer)) {
return;
}
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
currentDataIdentifier = dataIdentifer;
final double[][] timeSeries = tsJobResultsNoStats.getTimesAndValuesForVariable(currentDataIdentifier.getName());
try {
initStandAloneTimeSeries_private(timeSeries, dataManagerAccumDistances);
} catch (Exception e) {
failMethod(e, dataIdentifer);
throw e;
}
if (isInit) {
// set crosshair to init time
// resampleStartTimeOrig;
double initTime = initialLineScanTime;
isInit = false;
int closestTimeIndex = 0;
double closestDiff = Double.MAX_VALUE;
for (int i = 0; i < currentTimes.length; i += 1) {
double diff = Math.abs(initTime - currentTimes[i]);
if (diff < closestDiff) {
closestTimeIndex = i;
closestDiff = diff;
}
}
currentSelectionImg = new Point(0, closestTimeIndex);
currentSelectionUnit = new Point2D.Double(0, (double) closestTimeIndex / (double) (currentTimes.length - 1));
configurePlotData((int) currentSelectionImg.getX(), (int) currentSelectionImg.getY());
// ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(pdeDataViewer);
// // final ChildWindow childWindow = childWindowManager.addChildWindow(new javax.swing.JPanel(),this,title);
// final ChildWindow childWindow = childWindowManager.addChildWindow(KymographPanel.this,KymographPanel.this,title);
// childWindow.setIsCenteredOnParent();
// childWindow.pack();
// childWindow.show();
// Timer timer = new Timer(1000,new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// childWindow.toFront();
// }
// });
// System.out.println("Kymograph panel ChildWindow requesting focus. Answer is: "+childWindow.requestFocusInWindow());
// zoomToFill();
} else {
getImagePaneScroller1().zooming(new ZoomEvent(getimagePaneView1(), 0, 0));
}
}
};
AsynchClientTask[] tasks = (task2 == null ? new AsynchClientTask[] { task1, task3 } : new AsynchClientTask[] { task1, task2, task3 });
ClientTaskDispatcher.dispatch(KymographPanel.this, new Hashtable<String, Object>(), tasks, false, true, true, null, false);
// if(bFromGUI){
// ClientTaskDispatcher.dispatch(KymographPanel.this, new Hashtable<String, Object>(), tasks, false, true, true, null, false);
// System.out.println("Waiting here");
// }else{
// multiTimePlotHelper.addExtraTasks(tasks);
// }
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class DisplayTimeSeries method displayImageTimeSeries.
public static void displayImageTimeSeries(final ImageTimeSeries<Image> imageTimeSeries, String title, WindowListener windowListener) 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 {
throw new RuntimeException("not yet implemented");
}
@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;
}
};
VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {
public User getOwner() {
return new User("nouser", null);
}
public KeyValue getDataKey() {
return null;
}
public String getID() {
return "mydata";
}
};
PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
PDEDataViewer pdeDataViewer = new PDEDataViewer();
JFrame jframe = new JFrame();
jframe.setTitle(title);
jframe.getContentPane().add(pdeDataViewer);
jframe.setSize(1000, 600);
jframe.setVisible(true);
if (windowListener != null) {
jframe.addWindowListener(windowListener);
}
pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
use of org.vcell.util.document.TimeSeriesJobSpec in project vcell by virtualcell.
the class ImportRawTimeSeriesFrom2DVCellConcentrationsOp method importRawTimeSeries.
private static ImageDataset importRawTimeSeries(File vcellSimLogFile, String fluorFunctionName, Double maxIntensity, boolean bNoise, final ClientTaskStatusSupport progressListener) throws Exception {
VCSimulationIdentifier vcSimulationIdentifier = VCellSimReader.getVCSimulationIdentifierFromVCellSimulationData(vcellSimLogFile);
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, 0);
DataSetControllerImpl dataSetControllerImpl = VCellSimReader.getDataSetControllerImplFromVCellSimulationData(vcellSimLogFile);
final DataJobEvent[] bStatus = new DataJobEvent[] { null };
DataJobListener dataJobListener = new DataJobListener() {
public void dataJobMessage(DataJobEvent event) {
bStatus[0] = event;
if (progressListener != null) {
progressListener.setProgress((int) (event.getProgress() / 100.0 * .75));
}
}
};
dataSetControllerImpl.addDataJobListener(dataJobListener);
DataIdentifier[] dataIdentifiers = VCellSimReader.getDataIdentiferListFromVCellSimulationData(vcellSimLogFile, 0);
DataIdentifier variableNameDataIdentifier = null;
for (int i = 0; i < dataIdentifiers.length; i++) {
if (dataIdentifiers[i].getName().equals(fluorFunctionName)) {
variableNameDataIdentifier = dataIdentifiers[i];
break;
}
}
if (variableNameDataIdentifier == null) {
throw new IllegalArgumentException("Variable " + fluorFunctionName + " not found.");
}
if (!variableNameDataIdentifier.getVariableType().equals(VariableType.VOLUME)) {
throw new IllegalArgumentException("Variable " + fluorFunctionName + " is not VOLUME type.");
}
double[] times = dataSetControllerImpl.getDataSetTimes(vcSimulationDataIdentifier);
CartesianMesh cartesianMesh = dataSetControllerImpl.getMesh(vcSimulationDataIdentifier);
BitSet allBitset = new BitSet(cartesianMesh.getNumVolumeElements());
allBitset.set(0, cartesianMesh.getNumVolumeElements() - 1);
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { fluorFunctionName }, new BitSet[] { allBitset }, times[0], 1, times[times.length - 1], true, false, VCDataJobID.createVCDataJobID(VCellSimReader.getDotUser(), true));
TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) dataSetControllerImpl.getTimeSeriesValues(null, vcSimulationDataIdentifier, timeSeriesJobSpec);
// wait for job to finish
while (bStatus[0] == null || bStatus[0].getEventTypeID() != DataJobEvent.DATA_COMPLETE) {
Thread.sleep(100);
}
double allTimesMin = tsJobResultsSpaceStats.getMinimums()[0][0];
double allTimesMax = allTimesMin;
for (int i = 0; i < times.length; i++) {
allTimesMin = Math.min(allTimesMin, tsJobResultsSpaceStats.getMinimums()[0][i]);
allTimesMax = Math.max(allTimesMax, tsJobResultsSpaceStats.getMaximums()[0][i]);
}
// double SCALE_MAX = maxIntensity.doubleValue();/*Math.pow(2,16)-1;*///Scale to 16 bits
double linearScaleFactor = 1;
if (maxIntensity != null) {
linearScaleFactor = maxIntensity.doubleValue() / allTimesMax;
}
System.out.println("alltimesMin=" + allTimesMin + " allTimesMax=" + allTimesMax + " linearScaleFactor=" + linearScaleFactor);
UShortImage[] scaledDataImages = new UShortImage[times.length];
Random rnd = new Random();
int shortMax = 65535;
// set messge to load variable
if (progressListener != null) {
progressListener.setMessage("Loading variable " + fluorFunctionName + "...");
}
for (int i = 0; i < times.length; i++) {
double[] rawData = dataSetControllerImpl.getSimDataBlock(null, vcSimulationDataIdentifier, fluorFunctionName, times[i]).getData();
short[] scaledDataShort = new short[rawData.length];
for (int j = 0; j < scaledDataShort.length; j++) {
double scaledRawDataJ = rawData[j] * linearScaleFactor;
if (bNoise) {
double ran = rnd.nextGaussian();
double scaledRawDataJ_withNoise = Math.max(0, (scaledRawDataJ + ran * Math.sqrt(scaledRawDataJ)));
scaledRawDataJ_withNoise = Math.min(shortMax, scaledRawDataJ_withNoise);
int scaledValue = (int) (scaledRawDataJ_withNoise);
scaledDataShort[j] &= 0x0000;
scaledDataShort[j] |= 0x0000FFFF & scaledValue;
} else {
int scaledValue = (int) (scaledRawDataJ);
scaledDataShort[j] &= 0x0000;
scaledDataShort[j] |= 0x0000FFFF & scaledValue;
}
}
scaledDataImages[i] = new UShortImage(scaledDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
if (progressListener != null) {
int progress = (int) (((i + 1) * 1.0 / times.length) * 100);
progressListener.setProgress(progress);
}
}
ImageDataset rawImageDataSet = new ImageDataset(scaledDataImages, times, cartesianMesh.getSizeZ());
return rawImageDataSet;
}
Aggregations