use of cbit.vcell.simdata.SimulationDataSpatialHdf5.SimDataSet in project vcell by virtualcell.
the class ChomboSimpleDataViewer method retrieveTimePlot.
private void retrieveTimePlot() {
if (solTable.getSelectedRow() < 0 || varList.getSelectedIndex() < 0) {
return;
}
final int index = (Integer) solTable.getValueAt(solTable.getSelectedRow(), SolTableModel.COL_INDEX);
DataSetIdentifier selectedVar = (DataSetIdentifier) varList.getSelectedValue();
final String varName = selectedVar.getName();
AsynchClientTask task0 = new AsynchClientTask("clear", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
timePlotTableModel.setTimesAndValues(new double[0], new double[0]);
}
};
AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
double[] times = simData.getDataTimes();
double[] values = new double[times.length];
for (int i = 0; i < times.length; ++i) {
SimDataSet simDataBlock = simData.retrieveSimDataSet(times[i], varName);
values[i] = simDataBlock.solValues[index];
}
hashTable.put("values", values);
}
};
AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
timePlotLabel.setText("Varaible " + varName + " @ Index " + index);
double[] times = simData.getDataTimes();
double[] values = (double[]) hashTable.get("values");
timePlotTableModel.setTimesAndValues(times, values);
dataTabbedPane.setSelectedComponent(timePlotPanel);
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task0, task1, task2 }, false);
}
use of cbit.vcell.simdata.SimulationDataSpatialHdf5.SimDataSet in project vcell by virtualcell.
the class ChomboSimpleDataViewer method retrieveData.
// private void readMeshMetricsFile(File userDir, VCSimulationDataIdentifier vcDataId, String simId) throws IOException
// {
// File meshMetricsFile = new File(userDir, vcDataId.getID() + ".chombo.memmetrics");
// if (!meshMetricsFile.exists())
// {
// return;
// }
// BufferedReader br = null;
// try
// {
// br = new BufferedReader(new FileReader(meshMetricsFile));
// List<String> cols = new ArrayList<String>();
// List<double[]> values = new ArrayList<double[]>();
// String line = br.readLine();
// if (line != null)
// {
// StringTokenizer st = new StringTokenizer(line, ",");
// while (st.hasMoreTokens())
// {
// String token = st.nextToken();
// cols.add(token);
// }
// }
// while (true)
// {
// line = br.readLine();
// if (line == null)
// {
// break;
// }
// double[] dvalues = new double[cols.size()];
// StringTokenizer st = new StringTokenizer(line, ",");
// int cnt = 0;
// while (st.hasMoreTokens())
// {
// String token = st.nextToken();
// dvalues[cnt] = Double.parseDouble(token);
// ++ cnt;
// }
// assert cnt == cols.size();
// values.add(dvalues);
// }
// meshMetricsTableModel.setData(cols, values);
// }
// finally
// {
// if (br != null)
// {
// br.close();
// }
// }
// }
private void retrieveData() {
final Double time = (Double) timeComboBox.getSelectedItem();
if (time == null) {
return;
}
DataSetIdentifier selectedVar = (DataSetIdentifier) varList.getSelectedValue();
if (selectedVar == null) {
return;
}
final String varName = selectedVar.getName();
AsynchClientTask task0 = new AsynchClientTask("clear", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
solTableModel.clear();
timePlotTableModel.clear();
solLabel.setText("Solution");
timePlotLabel.setText("Time Plot");
meanTextField.setText(null);
maxErrorTextField.setText(null);
sumVolFracTextField.setText(null);
l2ErrorTextField.setText(null);
}
};
AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (timeComboBox.getSelectedIndex() < 0 || varList.getSelectedIndex() < 0) {
return;
}
SimDataSet simDataSet = simData.retrieveSimDataSet(time, varName);
hashTable.put("simDataSet", simDataSet);
}
};
AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
SimDataSet simDataSet = (SimDataSet) hashTable.get("simDataSet");
if (simDataSet == null) {
return;
}
solLabel.setText("Variable " + varName + " @ Time " + time);
solTableModel.setValues(simDataSet.solValues);
meanTextField.setText(simDataSet.mean == null ? "" : simDataSet.mean.toString());
sumVolFracTextField.setText(simDataSet.sumVolFrac == null ? "" : simDataSet.sumVolFrac.toString());
maxErrorTextField.setText(simDataSet.maxError == null ? "" : simDataSet.maxError.toString());
l2ErrorTextField.setText(simDataSet.l2Error == null ? "" : simDataSet.l2Error + "".toString());
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task0, task1, task2 }, false);
}
Aggregations