use of org.vcell.util.document.TSJobResultsSpaceStats in project vcell by virtualcell.
the class PDEDataViewer method roiAction.
private void roiAction() {
BeanUtils.setCursorThroughout(this, Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
final String[] ROI_COLUMN_NAMES = new String[] { "ROI source", "ROI source name", "ROI Description" };
final Vector<Object> auxInfoV = new Vector<Object>();
final DataIdentifier dataIdentifier = getPdeDataContext().getDataIdentifier();
VariableType variableType = dataIdentifier.getVariableType();
final boolean isVolume = variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION);
DefaultTableModel tableModel = new DefaultTableModel() {
public boolean isCellEditable(int row, int column) {
return false;
}
};
for (int i = 0; i < ROI_COLUMN_NAMES.length; i++) {
tableModel.addColumn(ROI_COLUMN_NAMES[i]);
}
// Add Snapshot ROI
if ((isVolume ? volumeSnapshotROI : membraneSnapshotROI) != null) {
tableModel.addRow(new Object[] { (isVolume ? "Volume" : "Membrane") + " Variables and Functions", "Snapshot", (isVolume ? volumeSnapshotROIDescription : membraneSnapshotROIDescription) + ", (values = 1.0)" });
auxInfoV.add((isVolume ? volumeSnapshotROI : membraneSnapshotROI));
}
// Add user ROIs
SpatialSelection[] userROIArr = getPDEDataContextPanel1().fetchSpatialSelections(true, false);
for (int i = 0; userROIArr != null && i < userROIArr.length; i += 1) {
String descr = null;
boolean bPoint = false;
if (isVolume) {
if (userROIArr[i] instanceof SpatialSelectionVolume) {
Curve curve = ((SpatialSelectionVolume) userROIArr[i]).getCurveSelectionInfo().getCurve();
descr = curve.getDescription();
if (curve instanceof SinglePoint) {
bPoint = true;
}
}
} else {
if (userROIArr[i] instanceof SpatialSelectionMembrane) {
SampledCurve selectionSource = ((SpatialSelectionMembrane) userROIArr[i]).getSelectionSource();
descr = selectionSource.getDescription();
if (selectionSource instanceof SinglePoint) {
bPoint = true;
}
}
}
// Add Area User ROI
BitSet fillBitSet = null;
if (userROIArr[i] instanceof SpatialSelectionVolume) {
fillBitSet = getFillROI((SpatialSelectionVolume) userROIArr[i]);
if (fillBitSet != null) {
tableModel.addRow(new Object[] { "User Defined", descr, "Area Enclosed Volume ROI" });
auxInfoV.add(fillBitSet);
}
}
// Add Point and Line User ROI
if (fillBitSet == null) {
tableModel.addRow(new Object[] { "User Defined", descr, (bPoint ? "Point" : "Line") + (isVolume ? " Volume" : " Membrane") + " ROI " });
auxInfoV.add(userROIArr[i]);
}
}
// Add sorted Geometry ROI
final CartesianMesh cartesianMesh = getPdeDataContext().getCartesianMesh();
HashMap<Integer, ?> regionMapSubvolumesHashMap = (isVolume ? cartesianMesh.getVolumeRegionMapSubvolume() : cartesianMesh.getMembraneRegionMapSubvolumesInOut());
Set<?> regionMapSubvolumesEntrySet = regionMapSubvolumesHashMap.entrySet();
Iterator<?> regionMapSubvolumesEntryIter = regionMapSubvolumesEntrySet.iterator();
TreeSet<Object[]> sortedGeomROITreeSet = new TreeSet<Object[]>(new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) {
int result = ((String) ((Object[]) o1[0])[1]).compareToIgnoreCase((String) ((Object[]) o2[0])[1]);
if (result == 0) {
result = (((Entry<Integer, ?>) o1[1]).getKey()).compareTo(((Entry<Integer, ?>) o2[1]).getKey());
}
return result;
}
});
while (regionMapSubvolumesEntryIter.hasNext()) {
Entry<Integer, ?> regionMapSubvolumesEntry = (Entry<Integer, ?>) regionMapSubvolumesEntryIter.next();
sortedGeomROITreeSet.add(new Object[] { new Object[] { "Geometry", (isVolume ? getSimulationModelInfo().getVolumeNamePhysiology(((Integer) regionMapSubvolumesEntry.getValue())) : getSimulationModelInfo().getMembraneName(((int[]) regionMapSubvolumesEntry.getValue())[0], ((int[]) regionMapSubvolumesEntry.getValue())[1], false)), (isVolume ? "(svID=" + regionMapSubvolumesEntry.getValue() + " " : "(") + "vrID=" + regionMapSubvolumesEntry.getKey() + ") Predefined " + (isVolume ? "volume" : "membrane") + " region" }, regionMapSubvolumesEntry });
}
Iterator<Object[]> sortedGeomROIIter = sortedGeomROITreeSet.iterator();
while (sortedGeomROIIter.hasNext()) {
Object[] sortedGeomROIObjArr = (Object[]) sortedGeomROIIter.next();
tableModel.addRow((Object[]) sortedGeomROIObjArr[0]);
auxInfoV.add(sortedGeomROIObjArr[1]);
}
final ScrollTable roiTable = new ScrollTable();
roiTable.setModel(tableModel);
roiTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
roiTable.setPreferredScrollableViewportSize(new Dimension(500, 200));
final JPanel mainJPanel = new JPanel();
BoxLayout mainBL = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
mainJPanel.setLayout(mainBL);
MiniTimePanel timeJPanel = new MiniTimePanel();
ActionListener okAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (((Double) timeJPanel.jcb_time_begin.getSelectedItem()).compareTo((Double) timeJPanel.jcb_time_end.getSelectedItem()) > 0) {
PopupGenerator.showErrorDialog(PDEDataViewer.this, "Selected 'Begin Time' must be less than or equal to 'End Time'");
return;
}
int[] selectedRows = roiTable.getSelectedRows();
if (selectedRows != null) {
try {
BitSet dataBitSet = new BitSet(getPdeDataContext().getDataValues().length);
for (int i = 0; i < selectedRows.length; i++) {
Object auxInfo = auxInfoV.elementAt(selectedRows[i]);
if (auxInfo instanceof BitSet) {
dataBitSet.or((BitSet) auxInfo);
} else if (auxInfo instanceof SpatialSelectionMembrane) {
int[] roiIndexes = ((SpatialSelectionMembrane) auxInfo).getIndexSamples().getSampledIndexes();
for (int j = 0; j < roiIndexes.length; j += 1) {
dataBitSet.set(roiIndexes[j], true);
}
} else if (auxInfo instanceof SpatialSelectionVolume) {
int[] roiIndexes = ((SpatialSelectionVolume) auxInfo).getIndexSamples(0, 1).getSampledIndexes();
for (int j = 0; j < roiIndexes.length; j += 1) {
dataBitSet.set(roiIndexes[j], true);
}
} else if (auxInfo instanceof Entry) {
Entry<Integer, Integer> entry = (Entry<Integer, Integer>) auxInfo;
if (isVolume) {
int volumeRegionID = entry.getKey();
dataBitSet.or(cartesianMesh.getVolumeROIFromVolumeRegionID(volumeRegionID));
} else {
int membraneRegionID = entry.getKey();
dataBitSet.or(cartesianMesh.getMembraneROIFromMembraneRegionID(membraneRegionID));
}
} else if (auxInfo instanceof BitSet) {
dataBitSet.or((BitSet) auxInfo);
} else {
throw new Exception("ROI table, Unknown data type: " + auxInfo.getClass().getName());
}
}
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { dataIdentifier.getName() }, new BitSet[] { dataBitSet }, ((Double) timeJPanel.jcb_time_begin.getSelectedItem()).doubleValue(), 1, ((Double) timeJPanel.jcb_time_end.getSelectedItem()).doubleValue(), true, false, VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieve data for '" + dataIdentifier + "'", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask task2 = new AsynchClientTask("Showing stat for '" + dataIdentifier + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) hashTable.get(StringKey_timeSeriesJobResults);
plotSpaceStats(tsJobResultsSpaceStats);
}
};
ClientTaskDispatcher.dispatch(PDEDataViewer.this, hash, new AsynchClientTask[] { task1, task2 }, true, true, null);
} catch (Exception e1) {
e1.printStackTrace();
PopupGenerator.showErrorDialog(PDEDataViewer.this, "ROI Error.\n" + e1.getMessage(), e1);
}
}
BeanUtils.disposeParentWindow(mainJPanel);
}
};
ActionListener cancelAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
BeanUtils.disposeParentWindow(mainJPanel);
}
};
OkCancelSubPanel okCancelJPanel = new OkCancelSubPanel(okAction, cancelAction);
roiTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (roiTable.getSelectedRows() != null && roiTable.getSelectedRows().length > 0) {
okCancelJPanel.okButton.setEnabled(true);
} else {
okCancelJPanel.okButton.setEnabled(false);
}
}
});
mainJPanel.add(timeJPanel);
mainJPanel.add(roiTable.getEnclosingScrollPane());
mainJPanel.add(okCancelJPanel);
// showComponentInFrame(mainJPanel,
// "Calculate "+(isVolume?"volume":"membrane")+" statistics for '"+getPdeDataContext().getVariableName()+"'."+
// " Choose times and 1 or more ROI(s).");
Frame dialogOwner = JOptionPane.getFrameForComponent(this);
JOptionPane inputDialog = new JOptionPane(mainJPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[0]);
final JDialog d = inputDialog.createDialog(dialogOwner, "Calculate " + (isVolume ? "volume" : "membrane") + " statistics for '" + getPdeDataContext().getVariableName() + "'." + " Choose times and 1 or more ROI(s).");
d.setResizable(true);
try {
DialogUtils.showModalJDialogOnTop(d, PDEDataViewer.this);
} finally {
d.dispose();
}
} finally {
BeanUtils.setCursorThroughout(this, Cursor.getDefaultCursor());
}
}
use of org.vcell.util.document.TSJobResultsSpaceStats in project vcell by virtualcell.
the class PDEDataViewer method updateDataValueSurfaceViewer0.
// private AsynchClientTask[] getDataVlaueSurfaceViewerTasks(){
// AsynchClientTask createDataValueSurfaceViewerTask = new AsynchClientTask("Create surface viewer...",AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// createDataValueSurfaceViewer(getClientTaskStatusSupport());
// }
// }
// };
//
// AsynchClientTask updateDataValueSurfaceViewerTask = new AsynchClientTask("Update surface viewer...",AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// updateDataValueSurfaceViewer0();
// }
// };
//
// AsynchClientTask resetDataValueSurfaceViewerTask = new AsynchClientTask("Reset tab...",AsynchClientTask.TASKTYPE_SWING_NONBLOCKING,false,false) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// viewDataTabbedPane.setSelectedIndex(0);
// }
// }
// };
// return new AsynchClientTask[] {createDataValueSurfaceViewerTask,updateDataValueSurfaceViewerTask,resetDataValueSurfaceViewerTask};
// }
// private Timer dataValueSurfaceTimer;
// //private boolean bPdeIsParamScan=false;
// private void updateDataValueSurfaceViewer(){
// // if((dataValueSurfaceTimer = ClientTaskDispatcher.getBlockingTimer(this,getPdeDataContext(),null,dataValueSurfaceTimer,new ActionListener() {@Override public void actionPerformed(ActionEvent e2) {updateDataValueSurfaceViewer();}}))!=null){
// // return;
// // }
// if(bSkipSurfaceCalc){
// return;
// }
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// if((dataValueSurfaceTimer = ClientTaskDispatcher.getBlockingTimer(this,getPdeDataContext(),null,dataValueSurfaceTimer,new ActionListener() {@Override public void actionPerformed(ActionEvent e2) {updateDataValueSurfaceViewer();}}))!=null){
// return;
// }
// ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), getDataVlaueSurfaceViewerTasks(),true,true,null);
// }else{
// try{
// updateDataValueSurfaceViewer0();
// }catch(Exception e){
// e.printStackTrace();
// DialogUtils.showErrorDialog(this, e.getMessage());
// }
// }
// }
/**
* Insert the method's description here.
* Creation date: (9/25/2005 2:00:05 PM)
*/
private void updateDataValueSurfaceViewer0() {
// viewDataTabbedPane.addTab(CurrentView.SURFACE_VIEW.title, getDataValueSurfaceViewer());
if (viewDataTabbedPane.getSelectedIndex() != CurrentView.SURFACE_VIEW.ordinal()) {
return;
}
// SurfaceColors and DataValues
if (getDataValueSurfaceViewer().getSurfaceCollectionDataInfo() == null) {
// happens with PostProcessingImageData version of PDEDataViewer
return;
}
SurfaceCollection surfaceCollection = getDataValueSurfaceViewer().getSurfaceCollectionDataInfo().getSurfaceCollection();
DisplayAdapterService das = getPDEDataContextPanel1().getdisplayAdapterService1();
final int[][] surfaceColors = new int[surfaceCollection.getSurfaceCount()][];
final double[][] surfaceDataValues = new double[surfaceCollection.getSurfaceCount()][];
boolean bMembraneVariable = getPdeDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE);
RecodeDataForDomainInfo recodeDataForDomainInfo = getPDEDataContextPanel1().getRecodeDataForDomainInfo();
double[] membraneValues = (recodeDataForDomainInfo.isRecoded() ? recodeDataForDomainInfo.getRecodedDataForDomain() : getPdeDataContext().getDataValues());
for (int i = 0; i < surfaceCollection.getSurfaceCount(); i += 1) {
Surface surface = surfaceCollection.getSurfaces(i);
surfaceColors[i] = new int[surface.getPolygonCount()];
surfaceDataValues[i] = new double[surface.getPolygonCount()];
for (int j = 0; j < surface.getPolygonCount(); j += 1) {
int membraneIndexForPolygon = meshRegionSurfaces.getMembraneIndexForPolygon(i, j);
if (bMembraneVariable) {
surfaceDataValues[i][j] = membraneValues[membraneIndexForPolygon];
} else {
// get membrane region index from membrane index
surfaceDataValues[i][j] = membraneValues[getPdeDataContext().getCartesianMesh().getMembraneRegionIndex(membraneIndexForPolygon)];
}
surfaceColors[i][j] = das.getColorFromValue(surfaceDataValues[i][j]);
}
}
DataValueSurfaceViewer.SurfaceCollectionDataInfoProvider svdp = new DataValueSurfaceViewer.SurfaceCollectionDataInfoProvider() {
private DisplayAdapterService updatedDAS = new DisplayAdapterService(getPDEDataContextPanel1().getdisplayAdapterService1());
private String updatedVariableName = getPdeDataContext().getVariableName();
private double updatedTimePoint = getPdeDataContext().getTimePoint();
private double[] updatedVariableValues = getPdeDataContext().getDataValues();
private VCDataIdentifier updatedVCDataIdentifier = getPdeDataContext().getVCDataIdentifier();
public void makeMovie(SurfaceCanvas surfaceCanvas) {
makeSurfaceMovie(surfaceCanvas, updatedVariableValues.length, updatedVariableName, updatedDAS, updatedVCDataIdentifier);
}
public double getValue(int surfaceIndex, int polygonIndex) {
return updatedVariableValues[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)];
}
public String getValueDescription(int surfaceIndex, int polygonIndex) {
return updatedVariableName;
}
public int[][] getSurfacePolygonColors() {
return surfaceColors;
}
public Coordinate getCentroid(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getCentroid();
}
public float getArea(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getArea();
}
public Vect3d getNormal(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getNormal();
}
public int getMembraneIndex(int surfaceIndex, int polygonIndex) {
return meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex);
}
public Color getROIHighlightColor() {
return new Color(getPDEDataContextPanel1().getdisplayAdapterService1().getSpecialColors()[cbit.image.DisplayAdapterService.FOREGROUND_HIGHLIGHT_COLOR_OFFSET]);
}
@Override
public boolean isMembrIndexInVarDomain(int membrIndex) {
return (getPDEDataContextPanel1().getRecodeDataForDomainInfo() != null ? getPDEDataContextPanel1().getRecodeDataForDomainInfo().isIndexInDomain(membrIndex) : true);
}
// public void showComponentInFrame(Component comp,String title){
// PDEDataViewer.this.showComponentInFrame(comp,title);
// }
public void plotTimeSeriesData(int[][] indices, boolean bAllTimes, boolean bTimeStats, boolean bSpaceStats) throws DataAccessException {
double[] timePoints = getPdeDataContext().getTimePoints();
double beginTime = (bAllTimes ? timePoints[0] : updatedTimePoint);
double endTime = (bAllTimes ? timePoints[timePoints.length - 1] : beginTime);
String[] varNames = new String[indices.length];
for (int i = 0; i < varNames.length; i += 1) {
varNames[i] = updatedVariableName;
}
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(varNames, indices, beginTime, 1, endTime, bSpaceStats, bTimeStats, VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieve data", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask task2 = new AsynchClientTask("Showing surface", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) hashTable.get(StringKey_timeSeriesJobResults);
plotSpaceStats(tsJobResultsSpaceStats);
}
};
ClientTaskDispatcher.dispatch(PDEDataViewer.this, hash, new AsynchClientTask[] { task1, task2 }, true, true, null);
}
};
getDataValueSurfaceViewer().setSurfaceCollectionDataInfoProvider(svdp);
}
use of org.vcell.util.document.TSJobResultsSpaceStats in project vcell by virtualcell.
the class FrapDataUtils method importFRAPDataFromVCellSimulationData.
public static FRAPData importFRAPDataFromVCellSimulationData(File vcellSimLogFile, String variableName, String bleachedMaskVarName, Double maxIntensity, boolean bNoise, final ClientTaskStatusSupport progressListener) throws Exception {
// bleachedMaskVarName = "laserMask_cell";
VCSimulationIdentifier vcSimulationIdentifier = getVCSimulationIdentifierFromVCellSimulationData(vcellSimLogFile);
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, 0);
DataSetControllerImpl dataSetControllerImpl = 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 = getDataIdentiferListFromVCellSimulationData(vcellSimLogFile, 0);
DataIdentifier variableNameDataIdentifier = null;
for (int i = 0; i < dataIdentifiers.length; i++) {
if (dataIdentifiers[i].getName().equals(variableName)) {
variableNameDataIdentifier = dataIdentifiers[i];
break;
}
}
if (variableNameDataIdentifier == null) {
throw new IllegalArgumentException("Variable " + variableName + " not found.");
}
if (!variableNameDataIdentifier.getVariableType().equals(VariableType.VOLUME)) {
throw new IllegalArgumentException("Variable " + variableName + " 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[] { variableName }, new BitSet[] { allBitset }, times[0], 1, times[times.length - 1], true, false, VCDataJobID.createVCDataJobID(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 " + variableName + "...");
}
for (int i = 0; i < times.length; i++) {
double[] rawData = dataSetControllerImpl.getSimDataBlock(null, vcSimulationDataIdentifier, variableName, 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 imageDataSet = new ImageDataset(scaledDataImages, times, cartesianMesh.getSizeZ());
FRAPData frapData = new FRAPData(imageDataSet, new String[] { FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name(), FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name(), FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name() });
// get rois from log file
if (bleachedMaskVarName != null) {
// set message to load cell ROI variable
if (progressListener != null) {
progressListener.setMessage("Loading ROIs...");
}
double[] rawROIBleached = dataSetControllerImpl.getSimDataBlock(null, vcSimulationDataIdentifier, bleachedMaskVarName, 0).getData();
short[] scaledCellDataShort = new short[rawROIBleached.length];
short[] scaledBleachedDataShort = new short[rawROIBleached.length];
short[] scaledBackgoundDataShort = new short[rawROIBleached.length];
for (int j = 0; j < scaledCellDataShort.length; j++) {
boolean isCell = cartesianMesh.getCompartmentSubdomainNamefromVolIndex(j).equals("subVolume1");
boolean isBackground = cartesianMesh.getCompartmentSubdomainNamefromVolIndex(j).equals("subVolume0");
if (isCell) {
scaledCellDataShort[j] = 1;
}
if (isBackground) {
scaledBackgoundDataShort[j] = 1;
}
if (rawROIBleached[j] > 0.2) {
scaledBleachedDataShort[j] = 1;
}
}
UShortImage cellImage = new UShortImage(scaledCellDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
UShortImage bleachedImage = new UShortImage(scaledBleachedDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
UShortImage backgroundImage = new UShortImage(scaledBackgoundDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
if (progressListener != null) {
progressListener.setProgress(100);
}
frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).setROIImages(new UShortImage[] { cellImage });
frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).setROIImages(new UShortImage[] { bleachedImage });
frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name()).setROIImages(new UShortImage[] { backgroundImage });
}
return frapData;
}
use of org.vcell.util.document.TSJobResultsSpaceStats in project vcell by virtualcell.
the class DataSetControllerImpl method getSpecialTimeSeriesValues.
private TimeSeriesJobResults getSpecialTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdID, TimeSeriesJobSpec timeSeriesJobSpec, TimeInfo timeInfo) throws Exception {
String[] variableNames = timeSeriesJobSpec.getVariableNames();
CartesianMesh mesh = getMesh(vcdID);
// Automatically 'special' (non-optimized timedata retrieval) if isAllowOptimizedTimeDataRetrieval() == false
boolean bIsSpecial = !isAllowOptimizedTimeDataRetrieval();
if (!bIsSpecial) {
VCData simData = getVCData(vcdID);
//
// Gradient and FieldData functions are special.
// They have to be evaluated using the 'full data' method using evaluateFunction(...).
// They cannot be evaluated using the fast findFunctionIndexes(...) method.
// Also if the 'roi' is a significant fraction of the whole dataset then
// the 'full data' method of evaluation is more efficient
// a guess for best efficiency
final double SIGNIFICANT_ROI_FRACTION = .2;
final int ABSOLUTE_SIZE_LIMIT = 10000;
for (int i = 0; i < variableNames.length; i += 1) {
DataSetIdentifier dsi = (DataSetIdentifier) simData.getEntry(variableNames[i]);
if (dsi.getVariableType().equals(VariableType.VOLUME)) {
if (timeSeriesJobSpec.getIndices()[i].length > mesh.getNumVolumeElements() * SIGNIFICANT_ROI_FRACTION) {
bIsSpecial = true;
break;
}
} else if (dsi.getVariableType().equals(VariableType.MEMBRANE)) {
if (timeSeriesJobSpec.getIndices()[i].length > mesh.getNumMembraneElements() * SIGNIFICANT_ROI_FRACTION) {
bIsSpecial = true;
break;
}
}
AnnotatedFunction functionFromVarName = getFunction(outputContext, vcdID, variableNames[i]);
if (functionFromVarName != null) {
FieldFunctionArguments[] fieldFunctionArgumentsArr = FieldUtilities.getFieldFunctionArguments(functionFromVarName.getExpression());
if (hasGradient(functionFromVarName.getExpression()) || (fieldFunctionArgumentsArr != null && fieldFunctionArgumentsArr.length > 0)) {
bIsSpecial = true;
break;
}
// check function absolute size limit
Expression exp = functionFromVarName.getExpression();
String[] funcSymbols = exp.getSymbols();
int varCount = 0;
if (funcSymbols != null) {
for (int j = 0; j < funcSymbols.length; j++) {
SymbolTableEntry ste = exp.getSymbolBinding(funcSymbols[j]);
if (ste instanceof DataSetIdentifier) {
varCount += 1;
}
}
}
varCount = Math.max(varCount, 1);
if (varCount * timeSeriesJobSpec.getIndices()[i].length > ABSOLUTE_SIZE_LIMIT) {
bIsSpecial = true;
break;
}
} else if (timeSeriesJobSpec.getIndices()[i].length > ABSOLUTE_SIZE_LIMIT) {
bIsSpecial = true;
break;
}
}
}
if (!bIsSpecial) {
return null;
}
TimeSeriesJobResults tsjr = null;
if (timeSeriesJobSpec.isCalcTimeStats()) {
throw new RuntimeException("Time Stats Not yet implemented for 'special' data");
} else if (timeSeriesJobSpec.isCalcSpaceStats()) {
// Get spatial statistics at each time point
SpatialStatsInfo ssi = calcSpatialStatsInfo(outputContext, timeSeriesJobSpec, vcdID);
double[][] /*time*/
argMin = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[][] argMax = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[][] argUnweightedMean = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[][] argWeightedMean = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[][] argUnweightedSum = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[][] argWeightedSum = new double[variableNames.length][timeInfo.desiredTimeValues.length];
double[] /*varName*/
argTotalSpace = new double[variableNames.length];
double[][][] indicesForVarForOneTimepoint = new double[1][][];
for (int varNameIndex = 0; varNameIndex < variableNames.length; varNameIndex += 1) {
int[] dataIndices = timeSeriesJobSpec.getIndices()[varNameIndex];
indicesForVarForOneTimepoint[0] = new double[dataIndices.length + 1][1];
for (int timeIndex = 0; timeIndex < timeInfo.desiredTimeValues.length; timeIndex += 1) {
indicesForVarForOneTimepoint[0][0] = new double[] { timeInfo.desiredTimeValues[timeIndex] };
int num = varNameIndex * timeInfo.desiredTimeValues.length + timeIndex;
int denom = variableNames.length * timeInfo.desiredTimeValues.length;
double progressTime = 100.0 * (double) num / (double) denom;
fireDataJobEventIfNecessary(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_PROGRESS, vcdID, new Double(progressTime), null, null);
SimDataBlock simDatablock = getSimDataBlock(outputContext, vcdID, variableNames[varNameIndex], timeInfo.desiredTimeValues[timeIndex]);
double[] data = simDatablock.getData();
// Put indices in format expected by calcStats (SHOULD BE CHANGED)
for (int dataIndex = 0; dataIndex < dataIndices.length; dataIndex += 1) {
indicesForVarForOneTimepoint[0][dataIndex + 1][0] = data[dataIndices[dataIndex]];
}
if (timeSeriesJobSpec.getCrossingMembraneIndices() != null && timeSeriesJobSpec.getCrossingMembraneIndices().length > 0) {
adjustMembraneAdjacentVolumeValues(outputContext, indicesForVarForOneTimepoint[0], true, simDatablock, timeSeriesJobSpec.getIndices()[varNameIndex], timeSeriesJobSpec.getCrossingMembraneIndices()[varNameIndex], vcdID, variableNames[varNameIndex], mesh, timeInfo);
}
tsjr = calculateStatisticsFromWhole(timeSeriesJobSpec, indicesForVarForOneTimepoint, indicesForVarForOneTimepoint[0][0], ssi);
argMin[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getMinimums()[0][0];
argMax[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getMaximums()[0][0];
argUnweightedMean[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getUnweightedMean()[0][0];
if (((TSJobResultsSpaceStats) tsjr).getWeightedMean() == null) {
argWeightedMean = null;
} else {
argWeightedMean[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getWeightedMean()[0][0];
}
argUnweightedSum[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getUnweightedSum()[0][0];
if (((TSJobResultsSpaceStats) tsjr).getWeightedSum() == null) {
argWeightedSum = null;
} else {
argWeightedSum[varNameIndex][timeIndex] = ((TSJobResultsSpaceStats) tsjr).getWeightedSum()[0][0];
}
if (((TSJobResultsSpaceStats) tsjr).getTotalSpace() == null) {
argTotalSpace = null;
} else {
argTotalSpace[varNameIndex] = ((TSJobResultsSpaceStats) tsjr).getTotalSpace()[0];
}
}
}
tsjr = new TSJobResultsSpaceStats(timeSeriesJobSpec.getVariableNames(), timeSeriesJobSpec.getIndices(), timeInfo.desiredTimeValues, argMin, argMax, argUnweightedMean, argWeightedMean, argUnweightedSum, argWeightedSum, argTotalSpace);
} else {
// Get the values for for all the variables and indices
double[][][] varIndicesTimesArr = new double[variableNames.length][][];
for (int varNameIndex = 0; varNameIndex < variableNames.length; varNameIndex += 1) {
int[] dataIndices = timeSeriesJobSpec.getIndices()[varNameIndex];
varIndicesTimesArr[varNameIndex] = new double[dataIndices.length + 1][timeInfo.desiredTimeValues.length];
varIndicesTimesArr[varNameIndex][0] = timeInfo.desiredTimeValues;
for (int timeIndex = 0; timeIndex < timeInfo.desiredTimeValues.length; timeIndex += 1) {
int num = varNameIndex * timeInfo.desiredTimeValues.length + timeIndex;
int denom = variableNames.length * timeInfo.desiredTimeValues.length;
double progressTime = 100.0 * (double) num / (double) denom;
fireDataJobEventIfNecessary(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_PROGRESS, vcdID, new Double(progressTime), null, null);
SimDataBlock simDatablock = getSimDataBlock(outputContext, vcdID, variableNames[varNameIndex], timeInfo.desiredTimeValues[timeIndex]);
double[] data = simDatablock.getData();
for (int dataIndex = 0; dataIndex < dataIndices.length; dataIndex += 1) {
varIndicesTimesArr[varNameIndex][dataIndex + 1][timeIndex] = data[dataIndices[dataIndex]];
}
if (timeSeriesJobSpec.getCrossingMembraneIndices() != null && timeSeriesJobSpec.getCrossingMembraneIndices().length > 0) {
adjustMembraneAdjacentVolumeValues(outputContext, varIndicesTimesArr[varNameIndex], true, simDatablock, timeSeriesJobSpec.getIndices()[varNameIndex], timeSeriesJobSpec.getCrossingMembraneIndices()[varNameIndex], vcdID, variableNames[varNameIndex], mesh, timeInfo);
}
}
}
tsjr = new TSJobResultsNoStats(timeSeriesJobSpec.getVariableNames(), timeSeriesJobSpec.getIndices(), timeInfo.desiredTimeValues, varIndicesTimesArr);
}
return tsjr;
}
use of org.vcell.util.document.TSJobResultsSpaceStats in project vcell by virtualcell.
the class DataSetControllerImpl method getTimeSeriesValues_private.
private TimeSeriesJobResults getTimeSeriesValues_private(OutputContext outputContext, final VCDataIdentifier vcdID, final TimeSeriesJobSpec timeSeriesJobSpec) throws DataAccessException {
double[] dataTimes = null;
boolean isPostProcessing = false;
try {
if (getVCData(vcdID) instanceof SimulationData && ((SimulationData) getVCData(vcdID)).isPostProcessing(outputContext, timeSeriesJobSpec.getVariableNames()[0])) {
isPostProcessing = true;
dataTimes = ((SimulationData) getVCData(vcdID)).getDataTimesPostProcess(outputContext);
}
} catch (Exception e) {
// ignore
e.printStackTrace();
}
if (dataTimes == null) {
dataTimes = getDataSetTimes(vcdID);
}
TimeInfo timeInfo = new TimeInfo(vcdID, timeSeriesJobSpec.getStartTime(), timeSeriesJobSpec.getStep(), timeSeriesJobSpec.getEndTime(), dataTimes);
if (dataTimes.length <= 0) {
return null;
}
boolean[] wantsTheseTimes = new boolean[dataTimes.length];
double[] desiredTimeValues = null;
int desiredNumTimes = 0;
Arrays.fill(wantsTheseTimes, false);
double[] tempTimes = new double[dataTimes.length];
int stepCounter = 0;
for (int i = 0; i < dataTimes.length; i += 1) {
if (dataTimes[i] > timeSeriesJobSpec.getEndTime()) {
break;
}
if (dataTimes[i] == timeSeriesJobSpec.getStartTime()) {
tempTimes[desiredNumTimes] = dataTimes[i];
desiredNumTimes += 1;
stepCounter = 0;
wantsTheseTimes[i] = true;
if (timeSeriesJobSpec.getStep() == 0) {
break;
}
} else if (desiredNumTimes > 0 && stepCounter % timeSeriesJobSpec.getStep() == 0) {
tempTimes[desiredNumTimes] = dataTimes[i];
desiredNumTimes += 1;
wantsTheseTimes[i] = true;
}
stepCounter += 1;
}
if (desiredNumTimes == 0) {
throw new IllegalArgumentException("Couldn't find startTime " + timeSeriesJobSpec.getStartTime());
}
desiredTimeValues = new double[desiredNumTimes];
System.arraycopy(tempTimes, 0, desiredTimeValues, 0, desiredNumTimes);
// Check timeInfo
if (desiredTimeValues.length != timeInfo.getDesiredTimeValues().length) {
throw new DataAccessException("timeInfo check failed");
}
for (int i = 0; i < desiredTimeValues.length; i++) {
if (desiredTimeValues[i] != timeInfo.getDesiredTimeValues()[i]) {
throw new DataAccessException("timeInfo check failed");
}
}
for (int i = 0; i < wantsTheseTimes.length; i++) {
if (wantsTheseTimes[i] != timeInfo.getWantsTheseTimes()[i]) {
throw new DataAccessException("timeInfo check failed");
}
}
try {
timeSeriesJobSpec.initIndices();
// See if we need special processing
TimeSeriesJobResults specialTSJR = getSpecialTimeSeriesValues(outputContext, vcdID, timeSeriesJobSpec, timeInfo);
if (specialTSJR != null) {
return specialTSJR;
}
//
VCData vcData = getVCData(vcdID);
//
// Determine Memory Usage for this job to protect server
//
// No TimeSeries jobs larger than this
final long MAX_MEM_USAGE = 20000000;
long memUsage = 0;
// efficient function stats are not yet implemented so check to adjust calculation
boolean bHasFunctionVars = false;
for (int i = 0; i < timeSeriesJobSpec.getVariableNames().length; i += 1) {
bHasFunctionVars = bHasFunctionVars || (getFunction(outputContext, vcdID, timeSeriesJobSpec.getVariableNames()[i]) != null);
}
for (int i = 0; i < timeSeriesJobSpec.getIndices().length; i += 1) {
memUsage += (timeSeriesJobSpec.isCalcSpaceStats() && !bHasFunctionVars ? NUM_STATS : timeSeriesJobSpec.getIndices()[i].length);
}
memUsage *= desiredNumTimes * 8 * 2;
System.out.println("DataSetControllerImpl.getTimeSeriesValues: job memory=" + memUsage);
if (memUsage > MAX_MEM_USAGE) {
throw new DataAccessException("DataSetControllerImpl.getTimeSeriesValues: Job too large" + (bHasFunctionVars ? "(has function vars)" : "") + ", requires approx. " + memUsage + " bytes of memory (only " + MAX_MEM_USAGE + " bytes allowed). Choose fewer datapoints or times.");
}
//
Vector<double[][]> valuesV = new Vector<double[][]>();
SpatialStatsInfo spatialStatsInfo = null;
if (timeSeriesJobSpec.isCalcSpaceStats()) {
spatialStatsInfo = calcSpatialStatsInfo(outputContext, timeSeriesJobSpec, vcdID);
}
final EventRateLimiter eventRateLimiter = new EventRateLimiter();
for (int k = 0; k < timeSeriesJobSpec.getVariableNames().length; k += 1) {
double[][] timeSeries = null;
String varName = timeSeriesJobSpec.getVariableNames()[k];
int[] indices = timeSeriesJobSpec.getIndices()[k];
if (timeSeriesJobSpec.isCalcSpaceStats() && !bHasFunctionVars) {
timeSeries = new double[NUM_STATS + 1][desiredNumTimes];
} else {
timeSeries = new double[indices.length + 1][desiredNumTimes];
}
timeSeries[0] = desiredTimeValues;
ProgressListener progressListener = new ProgressListener() {
public void updateProgress(double progress) {
// System.out.println("Considering firing progress event at "+new Date());
if (eventRateLimiter.isOkayToFireEventNow()) {
// System.out.println("ACTUALLY firing Progress event at "+new Date());
fireDataJobEventIfNecessary(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_PROGRESS, vcdID, new Double(progress), null, null);
}
}
public void updateMessage(String message) {
// ignore
}
};
AnnotatedFunction function = getFunction(outputContext, vcdID, varName);
if (function != null) {
if (vcData instanceof SimulationData) {
function = ((SimulationData) vcData).simplifyFunction(function);
} else {
throw new Exception("DataSetControllerImpl::getTimeSeriesValues_private(): has to be SimulationData to get time plot.");
}
MultiFunctionIndexes mfi = new MultiFunctionIndexes(vcdID, function, indices, wantsTheseTimes, progressListener, outputContext);
for (int i = 0; i < desiredTimeValues.length; i++) {
fireDataJobEventIfNecessary(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_PROGRESS, vcdID, new Double(NumberUtils.formatNumber(100.0 * (double) (k * desiredTimeValues.length + i) / (double) (timeSeriesJobSpec.getVariableNames().length * desiredTimeValues.length), 3)), null, null);
for (int j = 0; j < indices.length; j++) {
timeSeries[j + 1][i] = mfi.evaluateTimeFunction(outputContext, i, j);
}
}
} else {
double[][][] valuesOverTime = null;
if (timeSeriesJobSpec.isCalcSpaceStats() && !bHasFunctionVars) {
valuesOverTime = vcData.getSimDataTimeSeries(outputContext, new String[] { varName }, new int[][] { indices }, wantsTheseTimes, spatialStatsInfo, progressListener);
} else {
valuesOverTime = vcData.getSimDataTimeSeries(outputContext, new String[] { varName }, new int[][] { indices }, wantsTheseTimes, progressListener);
}
for (int i = 0; i < desiredTimeValues.length; i++) {
fireDataJobEventIfNecessary(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_PROGRESS, vcdID, new Double(NumberUtils.formatNumber(100.0 * (double) (k * desiredTimeValues.length + i) / (double) (timeSeriesJobSpec.getVariableNames().length * desiredTimeValues.length), 3)), null, null);
if (timeSeriesJobSpec.isCalcSpaceStats() && !bHasFunctionVars) {
// min
timeSeries[MIN_OFFSET + 1][i] = valuesOverTime[i][0][MIN_OFFSET];
// max
timeSeries[MAX_OFFSET + 1][i] = valuesOverTime[i][0][MAX_OFFSET];
// mean
timeSeries[MEAN_OFFSET + 1][i] = valuesOverTime[i][0][MEAN_OFFSET];
// wmean
timeSeries[WMEAN_OFFSET + 1][i] = valuesOverTime[i][0][WMEAN_OFFSET];
// sum
timeSeries[SUM_OFFSET + 1][i] = valuesOverTime[i][0][SUM_OFFSET];
// wsum
timeSeries[WSUM_OFFSET + 1][i] = valuesOverTime[i][0][WSUM_OFFSET];
} else {
for (int j = 0; j < indices.length; j++) {
timeSeries[j + 1][i] = valuesOverTime[i][0][j];
}
}
}
}
valuesV.add(timeSeries);
}
if (timeSeriesJobSpec.isCalcSpaceStats() && !bHasFunctionVars) {
double[][] min = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
double[][] max = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
double[][] mean = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
double[][] wmean = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
double[][] sum = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
double[][] wsum = new double[timeSeriesJobSpec.getVariableNames().length][desiredTimeValues.length];
for (int i = 0; i < valuesV.size(); i += 1) {
double[][] timeStat = (double[][]) valuesV.elementAt(i);
for (int j = 0; j < desiredTimeValues.length; j += 1) {
min[i][j] = timeStat[MIN_OFFSET + 1][j];
max[i][j] = timeStat[MAX_OFFSET + 1][j];
mean[i][j] = timeStat[MEAN_OFFSET + 1][j];
wmean[i][j] = timeStat[WMEAN_OFFSET + 1][j];
sum[i][j] = timeStat[SUM_OFFSET + 1][j];
wsum[i][j] = timeStat[WSUM_OFFSET + 1][j];
}
}
return new TSJobResultsSpaceStats(timeSeriesJobSpec.getVariableNames(), timeSeriesJobSpec.getIndices(), desiredTimeValues, min, max, mean, (spatialStatsInfo.bWeightsValid ? wmean : null), sum, (spatialStatsInfo.bWeightsValid ? wsum : null), (spatialStatsInfo.bWeightsValid ? spatialStatsInfo.totalSpace : null));
} else if (timeSeriesJobSpec.isCalcSpaceStats() && bHasFunctionVars) {
double[][][] timeSeriesFormatedValuesArr = new double[valuesV.size()][][];
valuesV.copyInto(timeSeriesFormatedValuesArr);
return calculateStatisticsFromWhole(timeSeriesJobSpec, timeSeriesFormatedValuesArr, desiredTimeValues, spatialStatsInfo);
} else {
double[][][] timeSeriesFormatedValuesArr = new double[valuesV.size()][][];
valuesV.copyInto(timeSeriesFormatedValuesArr);
TSJobResultsNoStats tsJobResultsNoStats = new TSJobResultsNoStats(timeSeriesJobSpec.getVariableNames(), timeSeriesJobSpec.getIndices(), desiredTimeValues, timeSeriesFormatedValuesArr);
if (!isPostProcessing && timeSeriesJobSpec.getCrossingMembraneIndices() != null && timeSeriesJobSpec.getCrossingMembraneIndices().length > 0) {
adjustMembraneAdjacentVolumeValues(outputContext, tsJobResultsNoStats.getTimesAndValuesForVariable(timeSeriesJobSpec.getVariableNames()[0]), true, null, timeSeriesJobSpec.getIndices()[0], timeSeriesJobSpec.getCrossingMembraneIndices()[0], vcdID, timeSeriesJobSpec.getVariableNames()[0], getMesh(vcdID), timeInfo);
}
return tsJobResultsNoStats;
}
} catch (DataAccessException e) {
lg.error(e.getMessage(), e);
throw e;
} catch (Throwable e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("DataSetControllerImpl.getTimeSeriesValues: " + (e.getMessage() == null ? e.getClass().getName() : e.getMessage()));
}
}
Aggregations