Search in sources :

Example 1 with PlotData

use of cbit.plot.PlotData in project vcell by virtualcell.

the class TimeFunctionPanel method refreshPlot.

private void refreshPlot() throws Exception {
    // try {
    Expression exp = new Expression(funcTextField.getText());
    exp.flatten();
    SimpleSymbolTable symbolTable = new SimpleSymbolTable(new String[] { "t", "pi" /*, "x", "y", "z"*/
    });
    exp.bindExpression(symbolTable);
    double[] valueArray = new double[2];
    valueArray[1] = Math.PI;
    // valueArray[ReservedVariable.Z.getIndex()] = 0 ;
    // valueArray[ReservedVariable.Y.getIndex()] = 0 ;
    // valueArray[ReservedVariable.X.getIndex()] = 0 ;
    int totalTimePoints = 0;
    double beginTime = 0;
    double timeStep = 0;
    double parseEndTime = 0;
    try {
        beginTime = Double.parseDouble(timeBegTextField.getText());
    } catch (Exception e) {
        throw new Exception("Couldn't evaluate 'Time Begin' as number\n" + e.getMessage());
    }
    try {
        timeStep = Double.parseDouble(timeStepTextField.getText());
        if (timeStep <= 0) {
            throw new Exception("timestep value = " + timeStep);
        }
    } catch (Exception e) {
        throw new Exception("'Time Step' must be > 0\n" + e.getMessage());
    }
    try {
        parseEndTime = Double.parseDouble(endTimeTextField.getText());
    } catch (Exception e) {
        throw new Exception("Couldn't evaluate 'Time End' as number\n" + e.getMessage());
    }
    try {
        if (beginTime > parseEndTime || beginTime == parseEndTime) {
            throw new Exception("endTime must be greater than beginTime");
        }
        totalTimePoints = (int) Math.ceil((parseEndTime - beginTime) / timeStep);
    // if(totalTimePoints <= 0){
    // throw new Exception("calculated number of time points ="+totalTimePoints);
    // }
    } catch (Exception e) {
        throw new Exception("check beginTime, endTime and timeStep: ((endTime-beginTime)/timeStep) must be greater than 0" + "\n" + e.getMessage());
    }
    double[] timePoints = new double[totalTimePoints];
    double[] funcVals = new double[totalTimePoints];
    for (int i = 0; i < totalTimePoints; i++) {
        valueArray[ReservedVariable.TIME.getIndex()] = beginTime + i * timeStep;
        timePoints[i] = valueArray[ReservedVariable.TIME.getIndex()];
        funcVals[i] = exp.evaluateVector(valueArray);
    }
    PlotData plotData = new PlotData(timePoints, funcVals);
    Plot2D plot2D = new Plot2D(null, null, new String[] { "Time Function" }, new PlotData[] { plotData }, new String[] { "Time Function Value", "Time", "[" + "Time Function" + "]" });
    plotPane.setPlot2D(plot2D);
// } catch (Exception e) {
// e.printStackTrace();
// DialogUtils.showErrorDialog(this, "Error refreshing Plot:\n"+e.getMessage(), e);
// plotPane.setPlot2D(	null);
// }
}
Also used : PlotData(cbit.plot.PlotData) SimpleSymbolTable(cbit.vcell.parser.SimpleSymbolTable) Expression(cbit.vcell.parser.Expression) Plot2D(cbit.plot.Plot2D)

Example 2 with PlotData

use of cbit.plot.PlotData in project vcell by virtualcell.

the class ODETimePlotMultipleScansPanel method updateScanParamChoices.

/**
 * Insert the method's description here.
 * Creation date: (10/18/2005 12:44:06 AM)
 */
private void updateScanParamChoices() {
    AsynchClientTask task1 = new AsynchClientTask("get ode results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            int[] jobIndexes = scanChoiceTable.getSelectedRows();
            VCSimulationIdentifier vcSimulationIdentifier = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
            int plotCount = jobIndexes.length * variableNames.length;
            SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
            double[][] dataValues = new double[plotCount + 1][];
            PlotData[] plotDatas = new PlotData[plotCount];
            String[] plotNames = new String[plotCount];
            int plotIndex = 0;
            dataValues[0] = null;
            for (int ji = 0; ji < jobIndexes.length; ji++) {
                int jobIndex = jobIndexes[ji];
                final VCDataIdentifier vcdid = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
                ODEDataManager odeDatamanager = ((ODEDataManager) dataManager).createNewODEDataManager(vcdid);
                ODESolverResultSet odeSolverResultSet = odeDatamanager.getODESolverResultSet();
                if (ji == 0) {
                    plotPane.setStepViewVisible(simulation.getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver(), odeSolverResultSet.isMultiTrialData());
                    hashTable.put("bMultiTrial", new Boolean(odeSolverResultSet.isMultiTrialData()));
                }
                double[] tdata = null;
                if (!odeSolverResultSet.isMultiTrialData()) {
                    int tcol = odeSolverResultSet.findColumn(xVarColumnName);
                    tdata = odeSolverResultSet.extractColumn(tcol);
                    if (dataValues[0] == null) {
                        dataValues[0] = tdata;
                    }
                }
                for (int v = 0; v < variableNames.length; v++) {
                    String varname = variableNames[v];
                    int varcol = odeSolverResultSet.findColumn(varname);
                    double[] vdata = odeSolverResultSet.extractColumn(varcol);
                    if (!odeSolverResultSet.isMultiTrialData()) {
                        dataValues[plotIndex + 1] = vdata;
                        // plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                        plotDatas[plotIndex] = new PlotData(tdata, vdata);
                    // symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    } else {
                        Point2D[] histogram = ODESolverPlotSpecificationPanel.generateHistogram(vdata);
                        double[] x = new double[histogram.length];
                        double[] y = new double[histogram.length];
                        for (int j = 0; j < histogram.length; j++) {
                            x[j] = histogram[j].getX();
                            y[j] = histogram[j].getY();
                        }
                        plotDatas[plotIndex] = new PlotData(x, y);
                    }
                    plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                    symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    plotIndex++;
                }
            }
            hashTable.put("dataValues", dataValues);
            hashTable.put("plotDatas", plotDatas);
            hashTable.put("plotNames", plotNames);
            hashTable.put("symbolTableEntries", symbolTableEntries);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            double[][] dataValues = (double[][]) hashTable.get("dataValues");
            PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
            String[] plotNames = (String[]) hashTable.get("plotNames");
            SymbolTableEntry[] symbolTableEntries = (SymbolTableEntry[]) hashTable.get("symbolTableEntries");
            if (plotDatas == null || plotDatas.length == 0 || (plotDatas.length == 1 && plotDatas[0] == null) || plotNames == null) {
                plotPane.setPlot2D(null);
                return;
            }
            Plot2D plot2D = null;
            if (hashTable.get("bMultiTrial") instanceof Boolean && (Boolean) hashTable.get("bMultiTrial")) {
                plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Probability Distribution of Species", "Number of Particles", "" });
            }
            // else if(simulation.getSolverTaskDescription().getOutputTimeSpec() instanceof DefaultOutputTimeSpec)
            // {
            plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Plot", xVarColumnName, /*ReservedVariable.TIME.getName()*/
            "" });
            // }
            // else
            // {
            // plot2D = new SingleXPlot2D(symbolTableEntries, null, ReservedVariable.TIME.getName(), plotNames, dataValues);
            // }
            plotPane.setPlot2D(plot2D);
            plotPane.setHDF5ParamScanParamNames(scanParams);
            plotPane.setHDF5ParamScanParamValues(values);
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : PlotData(cbit.plot.PlotData) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Hashtable(java.util.Hashtable) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Point2D(java.awt.geom.Point2D) ODEDataManager(cbit.vcell.simdata.ODEDataManager) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier)

Example 3 with PlotData

use of cbit.plot.PlotData in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method regeneratePlot2D.

/**
 * Comment
 */
private void regeneratePlot2D() throws ExpressionException, ObjectNotFoundException {
    if (getMyDataInterface() == null) {
        return;
    }
    if (!getMyDataInterface().isMultiTrialData()) {
        if (getXAxisComboBox_frm().getSelectedIndex() < 0) {
            return;
        } else {
            // double[] xData = getOdeSolverResultSet().extractColumn(getPlottableColumnIndices()[getXIndex()]);
            // getUnfilteredSortedXAxisNames
            double[] xData = getMyDataInterface().extractColumn((String) getXAxisComboBox_frm().getSelectedItem());
            double[][] allData = new double[((DefaultListModel) getYAxisChoice().getModel()).size() + 1][xData.length];
            String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
            allData[0] = xData;
            double[] yData = new double[xData.length];
            // double[] yDataMin = new double[xData.length];
            double currParamValue = 0.0;
            double deltaParamValue = 0.0;
            // Extrapolation calculations!
            if (getSensitivityParameter() != null) {
                int val = getSensitivityParameterSlider().getValue();
                double nominalParamValue = getSensitivityParameter().getConstantValue();
                double pMax = nominalParamValue * 1.1;
                double pMin = nominalParamValue * 0.9;
                int iMax = getSensitivityParameterSlider().getMaximum();
                int iMin = getSensitivityParameterSlider().getMinimum();
                double slope = (pMax - pMin) / (iMax - iMin);
                currParamValue = slope * val + pMin;
                deltaParamValue = currParamValue - nominalParamValue;
                getMaxLabel().setText(Double.toString(pMax));
                getMinLabel().setText(Double.toString(pMin));
                getCurLabel().setText(Double.toString(currParamValue));
            }
            if (!getLogSensCheckbox().getModel().isSelected()) {
                // When log sensitivity check box is not selected.
                for (int i = 0; i < allData.length - 1; i++) {
                    // If sensitivity analysis is enabled, extrapolate values for State vars and non-sensitivity functions
                    if (getSensitivityParameter() != null) {
                        ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                        double[] sens = getSensValues(cd);
                        yData = getMyDataInterface().extractColumn(cd.getName());
                        // sens array != null for non-sensitivity state vars and functions, so extrapolate
                        if (sens != null) {
                            for (int j = 0; j < sens.length; j++) {
                                if (Math.abs(yData[j]) > 1e-6) {
                                    // away from zero, exponential extrapolation
                                    allData[i + 1][j] = yData[j] * Math.exp(deltaParamValue * sens[j] / yData[j]);
                                } else {
                                    // around zero - linear extrapolation
                                    allData[i + 1][j] = yData[j] + sens[j] * deltaParamValue;
                                }
                            }
                        // sens array == null for sensitivity state vars and functions, so don't change their original values
                        } else {
                            allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                        }
                    } else {
                        // No sensitivity analysis case, so do not alter the original values for any variable or function
                        allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                    // yDataMin = getMyDataInterface().extractColumnMin((String)((DefaultListModel)getYAxisChoice().getModel()).elementAt(i));
                    }
                    yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
                }
            } else {
                // When log sensitivity checkbox is selected.
                // Get sensitivity parameter and its value to compute log sensitivity
                Constant sensParam = getSensitivityParameter();
                double sensParamValue = sensParam.getConstantValue();
                getJLabelSensitivityParameter().setText("Sensitivity wrt Parameter " + sensParam.getName());
                // 
                for (int i = 0; i < allData.length - 1; i++) {
                    // Finding sensitivity var column for each column in result set.
                    ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                    String sensVarName = null;
                    ColumnDescription[] allColumnDescriptions = getMyDataInterface().getAllColumnDescriptions();
                    for (int j = 0; j < allColumnDescriptions.length; j++) {
                        String obj = "sens_" + cd.getName() + "_wrt_" + sensParam.getName();
                        if (allColumnDescriptions[j].getName().equals(obj)) {
                            sensVarName = obj;
                            break;
                        }
                    }
                    int sensIndex = -1;
                    if (sensVarName != null) {
                        for (int j = 0; j < ((DefaultListModel) getYAxisChoice().getModel()).getSize(); j++) {
                            if (((String) ((DefaultListModel) getYAxisChoice().getModel()).get(j)).equals(sensVarName)) {
                                sensIndex = j;
                                break;
                            }
                        }
                    }
                    yData = getMyDataInterface().extractColumn(cd.getName());
                    // If sensitivity var exists, compute log sensitivity
                    if (sensVarName != null) {
                        double[] sens = getMyDataInterface().extractColumn(sensVarName);
                        for (int k = 0; k < yData.length; k++) {
                            // Extrapolated statevars and functions
                            if (Math.abs(yData[k]) > 1e-6) {
                                // away from zero, exponential extrapolation
                                allData[i + 1][k] = yData[k] * Math.exp(deltaParamValue * sens[k] / yData[k]);
                            } else {
                                // around zero - linear extrapolation
                                allData[i + 1][k] = yData[k] + sens[k] * deltaParamValue;
                            }
                            // Log sensitivity for the state variables and functions
                            // default if floating point problems
                            double logSens = 0.0;
                            if (Math.abs(yData[k]) > 0) {
                                double tempLogSens = sens[k] * sensParamValue / yData[k];
                                if (tempLogSens != Double.NEGATIVE_INFINITY && tempLogSens != Double.POSITIVE_INFINITY && tempLogSens != Double.NaN) {
                                    logSens = tempLogSens;
                                }
                            }
                            if (sensIndex > -1) {
                                allData[sensIndex + 1][k] = logSens;
                            }
                        }
                    // If sensitivity var does not exist, retain  original value of column (var or function).
                    } else {
                        if (!cd.getName().startsWith("sens_")) {
                            allData[i + 1] = yData;
                        }
                    }
                    yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
                }
            }
            String title = "";
            String xLabel = (String) getXAxisComboBox_frm().getSelectedItem();
            String yLabel = "";
            if (yNames.length == 1) {
                yLabel = yNames[0];
            }
            // Update Sensitivity parameter label depending on whether Log sensitivity check box is checked or not.
            if (!getLogSensCheckbox().getModel().isSelected()) {
                getJLabelSensitivityParameter().setText("");
            }
            SymbolTableEntry[] symbolTableEntries = null;
            if (getSymbolTable() != null && yNames != null && yNames.length > 0) {
                symbolTableEntries = new SymbolTableEntry[yNames.length];
                for (int i = 0; i < yNames.length; i += 1) {
                    SymbolTableEntry ste = getSymbolTable().getEntry(yNames[i]);
                    symbolTableEntries[i] = ste;
                }
            }
            SingleXPlot2D plot2D = new SingleXPlot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), xLabel, yNames, allData, new String[] { title, xLabel, yLabel });
            // TODO: populate the extra plot2D fields (for min, max, stdev
            refreshVisiblePlots(plot2D);
            // here fire "singleXPlot2D" event, ODEDataViewer's event handler listens to it.
            setPlot2D(plot2D);
        }
    } else // end of none MultitrialData
    // multitrial data
    {
        // a column of data get from ODESolverRestultSet, which is actually the results for a specific variable during multiple trials
        double[] rowData = new double[getMyDataInterface().getRowCount()];
        PlotData[] plotData = new PlotData[((DefaultListModel) getYAxisChoice().getModel()).size()];
        for (int i = 0; i < plotData.length; i++) {
            ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
            rowData = getMyDataInterface().extractColumn(cd.getName());
            Point2D[] histogram = generateHistogram(rowData);
            double[] x = new double[histogram.length];
            double[] y = new double[histogram.length];
            for (int j = 0; j < histogram.length; j++) {
                x[j] = histogram[j].getX();
                y[j] = histogram[j].getY();
            }
            plotData[i] = new PlotData(x, y);
        }
        SymbolTableEntry[] symbolTableEntries = null;
        if (getSymbolTable() != null && ((DefaultListModel) getYAxisChoice().getModel()).size() > 0) {
            symbolTableEntries = new SymbolTableEntry[((DefaultListModel) getYAxisChoice().getModel()).size()];
            for (int i = 0; i < symbolTableEntries.length; i += 1) {
                symbolTableEntries[i] = getSymbolTable().getEntry((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
            }
        }
        String title = "Probability Distribution of Species";
        String xLabel = "Number of Particles";
        String yLabel = "";
        String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
        ((DefaultListModel) getYAxisChoice().getModel()).copyInto(yNames);
        Plot2D plot2D = new Plot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), yNames, plotData, new String[] { title, xLabel, yLabel });
        refreshVisiblePlots(plot2D);
        setPlot2D(plot2D);
    }
}
Also used : PlotData(cbit.plot.PlotData) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) Constant(cbit.vcell.math.Constant) DefaultListModel(javax.swing.DefaultListModel) SingleXPlot2D(cbit.plot.SingleXPlot2D) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Point2D(java.awt.geom.Point2D) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D)

Example 4 with PlotData

use of cbit.plot.PlotData in project vcell by virtualcell.

the class Plot2DPanel method getSamplePlotData.

public static PlotData getSamplePlotData() {
    int size = 60;
    int scale = 100;
    double[] xArray = new double[size];
    double[] yArray = new double[size];
    double w = 4 * Math.PI / size;
    for (int i = 0; i < size; i++) {
        xArray[i] = w * i;
        yArray[i] = scale * Math.sin(w * i);
    }
    PlotData plotData = new PlotData(xArray, yArray);
    return plotData;
}
Also used : PlotData(cbit.plot.PlotData) Point(java.awt.Point) Paint(java.awt.Paint)

Example 5 with PlotData

use of cbit.plot.PlotData in project vcell by virtualcell.

the class DataSetControllerImpl method getLineScan.

/**
 * This method was created by a SmartGuide.
 * @return cbit.plot.PlotData
 * @param varName java.lang.String
 * @param begin cbit.vcell.math.CoordinateIndex
 * @param end cbit.vcell.math.CoordinateIndex
 */
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdID, String varName, double time, SpatialSelection spatialSelection) throws DataAccessException, MathException {
    try {
        if (spatialSelection == null) {
            throw new IllegalArgumentException("null spatialSelection");
        }
        if (spatialSelection.isPoint()) {
            throw new RuntimeException("'Point' spatialSelection not expected");
        }
        double[] dataTimes = getDataSetTimes(vcdID);
        if (dataTimes == null || dataTimes.length <= 0) {
            return null;
        }
        CartesianMesh mesh = getMesh(vcdID);
        // mesh is transient and is null if we got here by a serialized path (e.g. rmi)
        spatialSelection.setMesh(mesh);
        SimDataBlock simDataBlock = getSimDataBlock(outputContext, vcdID, varName, time);
        if (simDataBlock == null) {
            return null;
        }
        DataIdentifier dataIdentifier = null;
        try {
            DataIdentifier[] dataIdentifiers = getDataIdentifiers(outputContext, vcdID);
            for (int i = 0; i < dataIdentifiers.length; i++) {
                if (dataIdentifiers[i].getName().equals(varName)) {
                    dataIdentifier = dataIdentifiers[i];
                }
            }
        } catch (IOException e) {
            throw new DataAccessException(e.getMessage());
        }
        double[] data = simDataBlock.getData();
        if (data == null) {
            return null;
        }
        if (spatialSelection instanceof SpatialSelectionVolume) {
            SpatialSelectionVolume ssVolume = (SpatialSelectionVolume) spatialSelection;
            SpatialSelection.SSHelper ssvHelper = ssVolume.getIndexSamples(0.0, 1.0);
            if (dataIdentifier.getVariableType().equals(VariableType.VOLUME)) {
                ssvHelper.initializeValues_VOLUME(data);
            } else if (dataIdentifier.getVariableType().equals(VariableType.VOLUME_REGION)) {
                ssvHelper.initializeValues_VOLUMEREGION(data);
            } else {
                throw new RuntimeException(SpatialSelectionVolume.class.getName() + " does not support variableType=" + dataIdentifier.getVariableType());
            }
            try {
                if (ssvHelper.getMembraneIndexesInOut() != null && ssvHelper.getMembraneIndexesInOut().length > 0) {
                    adjustMembraneAdjacentVolumeValues(outputContext, new double[][] { ssvHelper.getSampledValues() }, false, simDataBlock, ssvHelper.getSampledIndexes(), ssvHelper.getMembraneIndexesInOut(), vcdID, varName, mesh, // PostProcess never calls LineScan so send in VCell times
                    new TimeInfo(vcdID, time, 1, time, getDataSetTimes(vcdID)));
                }
            } catch (Exception e) {
                throw new DataAccessException("Error getLineScan adjustingMembraneValues\n" + e.getMessage(), e);
            }
            double[] values = ssvHelper.getSampledValues();
            if (mesh.isChomboMesh()) {
                // convert NaN to 0
                for (int i = 0; i < values.length; i++) {
                    if (Double.isNaN(values[i])) {
                        values[i] = 0;
                    }
                }
            }
            return new PlotData(ssvHelper.getWorldCoordinateLengths(), values);
        } else if (spatialSelection instanceof SpatialSelectionContour) {
            // 
            // get length of span (in microns)
            // 
            double lengthMicrons = spatialSelection.getLengthInMicrons();
            if (lengthMicrons <= 0) {
                return null;
            }
            int sizeScan;
            int[] sampleIndexes = null;
            double[] lineScan = null;
            double[] distance = null;
            SpatialSelectionContour ssContour = (SpatialSelectionContour) spatialSelection;
            sampleIndexes = ssContour.getIndexSamples();
            sizeScan = sampleIndexes.length;
            // 
            if (dataIdentifier.getVariableType().equals(VariableType.CONTOUR_REGION)) {
                for (int i = 0; i < sampleIndexes.length; i++) {
                    sampleIndexes[i] = mesh.getContourRegionIndex(sampleIndexes[i]);
                }
            }
            lineScan = new double[sizeScan];
            distance = new double[sizeScan];
            for (int i = 0; i < sizeScan; i++) {
                lineScan[i] = data[sampleIndexes[i]];
                distance[i] = (((double) i) / (sizeScan - 1)) * lengthMicrons;
            }
            return new PlotData(distance, lineScan);
        } else if (spatialSelection instanceof SpatialSelectionMembrane) {
            SpatialSelectionMembrane ssMembrane = (SpatialSelectionMembrane) spatialSelection;
            SpatialSelection.SSHelper ssmHelper = ssMembrane.getIndexSamples();
            if (dataIdentifier.getVariableType().equals(VariableType.MEMBRANE)) {
                ssmHelper.initializeValues_MEMBRANE(data);
            } else if (dataIdentifier.getVariableType().equals(VariableType.MEMBRANE_REGION)) {
                ssmHelper.initializeValues_MEMBRANEREGION(data);
            } else {
                throw new RuntimeException(SpatialSelectionMembrane.class.getName() + " does not support variableType=" + dataIdentifier.getVariableType());
            }
            return new PlotData(ssmHelper.getWorldCoordinateLengths(), ssmHelper.getSampledValues());
        } else {
            throw new RuntimeException("unexpected SpatialSelection type " + spatialSelection.getClass().toString());
        }
    } catch (DataAccessException e) {
        lg.error(e.getMessage(), e);
        throw e;
    } catch (IOException e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : PlotData(cbit.plot.PlotData) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) IOException(java.io.IOException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) CacheException(org.vcell.util.CacheException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

PlotData (cbit.plot.PlotData)15 Plot2D (cbit.plot.Plot2D)12 SingleXPlot2D (cbit.plot.SingleXPlot2D)4 PlotPane (cbit.plot.gui.PlotPane)4 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)4 Point (java.awt.Point)4 Paint (java.awt.Paint)3 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 VolVariable (cbit.vcell.math.VolVariable)2 Parameter (cbit.vcell.opt.Parameter)2 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 Point2D (java.awt.geom.Point2D)2 JFrame (javax.swing.JFrame)2 ConfidenceInterval (org.vcell.optimization.ConfidenceInterval)2 ProfileDataElement (org.vcell.optimization.ProfileDataElement)2 ProfileSummaryData (org.vcell.optimization.ProfileSummaryData)2 DescriptiveStatistics (org.vcell.util.DescriptiveStatistics)2