Search in sources :

Example 6 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class FRAPStudyPanel method showMovie.

private void showMovie() {
    AsynchClientTask createMovieTask = new AsynchClientTask("Buffering movie data...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
            if (fStudy == null) {
                return;
            }
            if (fStudy.getMovieURLString() != null && fStudy.getMovieFileString() != null) {
                hashTable.put("FrapStudy", fStudy);
                return;
            }
            // create export specs
            Simulation sim = null;
            if (fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
                return;
            } else {
                sim = fStudy.getBioModel().getSimulations()[0];
            }
            FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
            FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
            for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
                fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
            }
            ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
            ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
            // add sim
            int jobIndex = 0;
            SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
            VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
            VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
            PDEDataManager dataManager = new PDEDataManager(null, getLocalWorkspace().getVCDataManager(), vcDataId);
            PDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
            ExportFormat format = ExportFormat.QUICKTIME;
            String[] variableNames = new String[] { NORM_FLUOR_VAR, NORM_SIM_VAR };
            VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
            // int endTimeIndex = (int)Math.round(sim.getSolverTaskDescription().getTimeBounds().getEndingTime()/((UniformOutputTimeSpec)sim.getSolverTaskDescription().getOutputTimeSpec()).getOutputTimeStep());
            int endTimeIndex = getFRAPSimDataViewerPanel().getOriginalDataViewer().getPdeDataContext().getTimePoints().length - 1;
            TimeSpecs timeSpecs = new TimeSpecs(0, endTimeIndex, pdeDataContext.getTimePoints(), ExportConstants.TIME_RANGE);
            int geoMode = ExportConstants.GEOMETRY_SLICE;
            GeometrySpecs geometrySpecs = new GeometrySpecs(null, Coordinate.Z_AXIS, 0, geoMode);
            // 10s
            double duration = 10000;
            DisplayPreferences pref1 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
            DisplayPreferences pref2 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
            DisplayPreferences[] displayPref = new DisplayPreferences[] { pref1, pref2 };
            int imageScale = 1;
            int membraneScale = 1;
            int scaleMode = ImagePaneModel.MESH_MODE;
            // the default setting in MediaSettingsPanel.
            int volVarMemOutlineThickness = 1;
            MovieSpecs mSpec = new MovieSpecs(duration, true, displayPref, ExportFormat.QUICKTIME, ExportConstants.NO_MIRRORING, volVarMemOutlineThickness, imageScale, membraneScale, scaleMode, FormatSpecificSpecs.CODEC_JPEG, 1.0f, /*lossless*/
            false, FormatSpecificSpecs.PARTICLE_NONE);
            // mSpec.setViewZoom(1);
            ExportSpecs exSpecs = new ExportSpecs(vcDataId, format, variableSpecs, timeSpecs, geometrySpecs, mSpec, fStudy.getName(), null);
            // pass the request
            ExportEvent exportEvt = ((VirtualFrapWindowManager) getFlourDataViewer().getDataViewerManager()).startExportMovie(exSpecs, outputContext, this.getClientTaskStatusSupport());
            hashTable.put("ExportEvt", exportEvt);
            hashTable.put("FrapStudy", fStudy);
        }
    };
    AsynchClientTask showMovieTask = new AsynchClientTask("Showing movie ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ExportEvent exportEvt = (ExportEvent) hashTable.get("ExportEvt");
            FRAPStudy fStudy = (FRAPStudy) hashTable.get("FrapStudy");
            // show movie if successfully exported
            if (exportEvt != null) {
                final String fileURLString = System.getProperty(PropertyLoader.exportBaseURLProperty) + exportEvt.getJobID() + ".mov";
                final String fileString = System.getProperty(PropertyLoader.exportBaseDirInternalProperty) + exportEvt.getJobID() + ".mov";
                fStudy.setMovieURLString(fileURLString);
                fStudy.setMovieFileString(fileString);
            }
            showMovieInDialog(fStudy.getMovieURLString(), fStudy.getMovieFileString());
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { createMovieTask, showMovieTask }, true, true, null, true);
}
Also used : ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) PDEDataContext(cbit.vcell.simdata.PDEDataContext) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ExportEvent(cbit.rmi.event.ExportEvent) GeometrySpecs(cbit.vcell.export.server.GeometrySpecs) MergedDataInfo(cbit.vcell.simdata.MergedDataInfo) DisplayPreferences(cbit.image.DisplayPreferences) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) TimeSpecs(cbit.vcell.export.server.TimeSpecs) SimulationJob(cbit.vcell.solver.SimulationJob) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) Hashtable(java.util.Hashtable) ExportFormat(cbit.vcell.export.server.ExportFormat) Range(org.vcell.util.Range) Point(java.awt.Point) VariableSpecs(cbit.vcell.export.server.VariableSpecs) MovieSpecs(cbit.vcell.export.server.MovieSpecs) Simulation(cbit.vcell.solver.Simulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier)

Example 7 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class TestingFrameworkWindowManager method generateTestCriteriaReport.

/**
 * Insert the method's description here.
 * Creation date: (8/18/2003 5:36:47 PM)
 */
private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew testCriteria, Simulation testSim, TFGenerateReport.VCDocumentAndSimInfo userSelectedRefSimInfo) /*,VCDocument refDoc,VCDocument testDocument*/
{
    if (testSim.getScanCount() != 1) {
        throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
    }
    SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(testSim, 0);
    String simReportStatus = null;
    String simReportStatusMessage = null;
    StringBuffer reportTCBuffer = new StringBuffer();
    VariableComparisonSummary[] failVarSummaries = null;
    VariableComparisonSummary[] allVarSummaries = null;
    double absErr = 0;
    double relErr = 0;
    if (testCriteria != null) {
        absErr = testCriteria.getMaxAbsError().doubleValue();
        relErr = testCriteria.getMaxRelError().doubleValue();
    }
    try {
        VCDocument testDoc = null;
        if (testCase instanceof TestCaseNewMathModel) {
            MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
            MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
            testDoc = mathModel;
        } else if (testCase instanceof TestCaseNewBioModel) {
            TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
            // bioTestCase.
            BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
            BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
            testDoc = bioModel;
        }
        TFGenerateReport.VCDocumentAndSimInfo refVCDocumentAndSimInfo = null;
        if (userSelectedRefSimInfo == null) {
            SimulationInfo refSimInfo = testCriteria.getRegressionSimInfo();
            if (refSimInfo != null) {
                VCDocument refDoc = null;
                if (testCriteria instanceof TestCriteriaNewMathModel) {
                    MathModelInfo mmInfo = ((TestCriteriaNewMathModel) testCriteria).getRegressionMathModelInfo();
                    MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
                    refDoc = mathModel;
                } else if (testCriteria instanceof TestCriteriaNewBioModel) {
                    BioModelInfo bmInfo = ((TestCriteriaNewBioModel) testCriteria).getRegressionBioModelInfo();
                    BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
                    refDoc = bioModel;
                }
                refVCDocumentAndSimInfo = new TFGenerateReport.VCDocumentAndSimInfo(refSimInfo, refDoc);
            }
            reportTCBuffer.append("\t\t" + testSim.getName() + (refVCDocumentAndSimInfo != null ? " (Using TestCrit RegrRefSim)" : "") + " : " + "\n");
        } else {
            refVCDocumentAndSimInfo = userSelectedRefSimInfo;
            reportTCBuffer.append("\t\t" + testSim.getName() + " (Using UserDefined RegrRefSim '" + userSelectedRefSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier() + "') : " + "\n");
        }
        if (testCase.getType().equals(TestCaseNew.REGRESSION) && refVCDocumentAndSimInfo == null) {
            reportTCBuffer.append("\t\t\tNo reference SimInfo, SimInfoKey=" + testCriteria.getSimInfo().getVersion().getName() + ". Cannot perform Regression Test!\n");
            simReportStatus = TestCriteriaNew.TCRIT_STATUS_NOREFREGR;
        } else {
            VCDataIdentifier vcdID = new VCSimulationDataIdentifier(testSim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
            DataManager simDataManager = getRequestManager().getDataManager(null, vcdID, testSim.isSpatial());
            double[] timeArray = null;
            // can be histogram, so there won't be time array
            try {
                timeArray = simDataManager.getDataSetTimes();
            } catch (Exception ex) {
                ex.printStackTrace(System.out);
            }
            NonspatialStochSimOptions stochOpt = testSim.getSolverTaskDescription().getStochOpt();
            if ((stochOpt == null || stochOpt.getNumOfTrials() == 1) && (timeArray == null || timeArray.length == 0)) {
                reportTCBuffer.append("\t\t\tNO DATA : Simulation not run yet.\n");
                simReportStatus = TestCriteriaNew.TCRIT_STATUS_NODATA;
            } else {
                // SPATIAL simulation
                if (testSim.getMathDescription().isSpatial()) {
                    PDEDataManager pdeDataManager = (PDEDataManager) simDataManager;
                    // Get EXACT solution if test case type is EXACT, Compare with numerical
                    if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    // Get CONSTRUCTED solution if test case type is CONSTRUCTED, Compare with numerical
                    } else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    } else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
                        Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(refVCDocumentAndSimInfo.getSimInfo());
                        VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        PDEDataManager refDataManager = (PDEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
                        if (refSim.getScanCount() != 1) {
                            throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
                        }
                        SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResults(simSymbolTable, pdeDataManager, refSimSymbolTable, refDataManager, varsToCompare, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), refVCDocumentAndSimInfo.getVCDocument(), getDataInfoProvider(refVCDocumentAndSimInfo.getVCDocument(), refDataManager.getPDEDataContext(), refSim.getName()), testDoc, getDataInfoProvider(testDoc, pdeDataManager.getPDEDataContext(), testSim.getName()));
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    }
                } else {
                    // NON-SPATIAL CASE
                    ODEDataManager odeDataManager = (ODEDataManager) simDataManager;
                    ODESolverResultSet numericalResultSet = odeDataManager.getODESolverResultSet();
                    // Get EXACT result set if test case type is EXACT, Compare with numerical
                    if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
                        ODESolverResultSet exactResultSet = MathTestingUtilities.getExactResultSet(testSim.getMathDescription(), timeArray, testSim.getSolverTaskDescription().getSensitivityParameter());
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
                        SimulationComparisonSummary simCompSummary_exact = MathTestingUtilities.compareResultSets(numericalResultSet, exactResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Get all the variable comparison summaries and the failed ones to print out report for EXACT solution comparison.
                        failVarSummaries = simCompSummary_exact.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_exact.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    // Get CONSTRUCTED result set if test case type is CONSTRUCTED , compare with numerical
                    } else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
                        ODESolverResultSet constructedResultSet = MathTestingUtilities.getConstructedResultSet(testSim.getMathDescription(), timeArray);
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
                        SimulationComparisonSummary simCompSummary_constr = MathTestingUtilities.compareResultSets(numericalResultSet, constructedResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
                        failVarSummaries = simCompSummary_constr.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_constr.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    } else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
                        Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(testCriteria.getRegressionSimInfo());
                        if (refSim.getScanCount() != 1) {
                            throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
                        }
                        SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
                        String[] varsToTest = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
                        VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        ODEDataManager refDataManager = (ODEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
                        ODESolverResultSet referenceResultSet = refDataManager.getODESolverResultSet();
                        SimulationComparisonSummary simCompSummary_regr = null;
                        int interpolationOrder = 1;
                        SolverTaskDescription solverTaskDescription = refSim.getSolverTaskDescription();
                        if (solverTaskDescription.getOutputTimeSpec().isDefault() && ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepEvery() == 1) {
                            SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
                            if ((!solverDescription.supportsAll(SolverDescription.DiscontinutiesFeatures)) || !refSim.getMathDescription().hasDiscontinuities()) {
                                interpolationOrder = solverDescription.getTimeOrder();
                            }
                        }
                        simCompSummary_regr = MathTestingUtilities.compareUnEqualResultSets(numericalResultSet, referenceResultSet, varsToTest, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), interpolationOrder);
                        // Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
                        failVarSummaries = simCompSummary_regr.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_regr.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        simReportStatus = TestCriteriaNew.TCRIT_STATUS_RPERROR;
        simReportStatusMessage = e.getClass().getName() + " " + e.getMessage();
        reportTCBuffer.append("\t\t" + simReportStatusMessage + "\n");
        e.printStackTrace(System.out);
    }
    if (userSelectedRefSimInfo == null) {
        try {
            // Remove any test results already present for testCriteria
            RemoveTestResultsOP removeResultsOP = new RemoveTestResultsOP(new BigDecimal[] { testCriteria.getTCritKey() });
            // testResultsOPsVector.add(removeResultsOP);
            getRequestManager().getDocumentManager().doTestSuiteOP(removeResultsOP);
            // Create new AddTestREsultsOP object for the current simulation./testCriteria.
            if (allVarSummaries != null) {
                AddTestResultsOP testResultsOP = new AddTestResultsOP(testCriteria.getTCritKey(), allVarSummaries);
                // testResultsOPsVector.add(testResultsOP);
                // Write the testResults for simulation/TestCriteria into the database ...
                getRequestManager().getDocumentManager().doTestSuiteOP(testResultsOP);
            }
            // Update report status
            updateTCritStatus(testCriteria, simReportStatus, simReportStatusMessage);
        } catch (Throwable e) {
            reportTCBuffer.append("\t\tUpdate DB Results failed. " + e.getClass().getName() + " " + e.getMessage() + "\n");
            try {
                getRequestManager().getDocumentManager().doTestSuiteOP(new EditTestCriteriaOPReportStatus(testCriteria.getTCritKey(), TestCriteriaNew.TCRIT_STATUS_RPERROR, e.getClass().getName() + " " + e.getMessage()));
            } catch (Throwable e2) {
            // Nothing more can be done
            }
        }
    }
    return reportTCBuffer.toString();
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) SolverDescription(cbit.vcell.solver.SolverDescription) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) RemoveTestResultsOP(cbit.vcell.numericstest.RemoveTestResultsOP) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) AddTestResultsOP(cbit.vcell.numericstest.AddTestResultsOP) SimulationComparisonSummary(cbit.vcell.solver.test.SimulationComparisonSummary) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) EditTestCriteriaOPReportStatus(cbit.vcell.numericstest.EditTestCriteriaOPReportStatus) VCDocument(org.vcell.util.document.VCDocument) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) BioModelInfo(org.vcell.util.document.BioModelInfo) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) MathModelInfo(org.vcell.util.document.MathModelInfo) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) Simulation(cbit.vcell.solver.Simulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) BioModel(cbit.vcell.biomodel.BioModel) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) ODEDataManager(cbit.vcell.simdata.ODEDataManager) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 8 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class MergedDatasetViewer method createDataViewer.

/**
 * Insert the method's description here.
 * Creation date: (6/11/2004 2:33:44 PM)
 * @return javax.swing.JPanel
 */
private DataViewer createDataViewer() {
    try {
        if (isODEData) {
            ODEDataManager odeDataManager = (ODEDataManager) dataManager;
            odeDataViewer = new ODEDataViewer();
            odeDataViewer.setOdeSolverResultSet(odeDataManager.getODESolverResultSet());
            odeDataViewer.setVcDataIdentifier(dataManager.getVCDataIdentifier());
            return odeDataViewer;
        } else {
            PDEDataManager pdeDataManager = (PDEDataManager) dataManager;
            pdeDataViewer = new PDEDataViewer();
            pdeDataViewer.setPdeDataContext(pdeDataManager.getPDEDataContext());
            return pdeDataViewer;
        }
    } catch (org.vcell.util.DataAccessException exc) {
        DialogUtils.showErrorDialog(this, "Could not fetch requested data.\nJCompare may have failed.\n" + exc.getMessage());
        exc.printStackTrace();
    }
    return null;
}
Also used : PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataAccessException(org.vcell.util.DataAccessException)

Example 9 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class SimResultsViewer method updateScanParamChoices.

private void updateScanParamChoices(final String message, ListReset listReset) {
    if ((paramScanChoiceTimer = ClientTaskDispatcher.getBlockingTimer(this, null, null, paramScanChoiceTimer, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e2) {
            updateScanParamChoices(message, listReset);
        }
    }, message)) != null) {
        return;
    }
    int selectedJobIndex = getSelectedParamScanJobIndex();
    // update viewer
    if (selectedJobIndex == -1) {
        if (isODEData) {
            if (listReset != null && odeDataViewer != null && odeDataViewer.getVcDataIdentifier() != null) {
                listReset.reset(odeDataViewer.getVcDataIdentifier());
            } else {
                odeDataViewer.setOdeSolverResultSet(null);
            }
        } else {
            if (listReset != null && pdeDataViewer != null && pdeDataViewer.getPdeDataContext() != null && pdeDataViewer.getPdeDataContext().getVCDataIdentifier() != null) {
                listReset.reset(pdeDataViewer.getPdeDataContext().getVCDataIdentifier());
            } else {
                pdeDataViewer.setPdeDataContext(null);
            }
        }
        return;
    }
    final VCSimulationDataIdentifier vcdid = new VCSimulationDataIdentifier(getSimulation().getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), selectedJobIndex);
    if (isODEData) {
        AsynchClientTask task1 = new AsynchClientTask("get ode results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                ODEDataManager odeDatamanager = ((ODEDataManager) dataManager).createNewODEDataManager(vcdid);
                hashTable.put("odeDatamanager", odeDatamanager);
            }
        };
        AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                if (hashTable.get(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR) == null) {
                    ODEDataManager odeDatamanager = (ODEDataManager) hashTable.get("odeDatamanager");
                    odeDataViewer.setOdeSolverResultSet(odeDatamanager.getODESolverResultSet());
                    odeDataViewer.setVcDataIdentifier(vcdid);
                } else {
                    odeDataViewer.setOdeSolverResultSet(null);
                }
            }
        };
        ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
    } else {
        AsynchClientTask task1 = new AsynchClientTask("get pde results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                PDEDataManager pdeDatamanager = ((PDEDataManager) dataManager).createNewPDEDataManager(vcdid, null);
                PDEDataContext newPDEDC = pdeDatamanager.getPDEDataContext();
                PDEDataContext oldPDEDC = pdeDataViewer.getPdeDataContext();
                hashTable.put("newPDEDC", newPDEDC);
                if (oldPDEDC != null && oldPDEDC.getTimePoints().length <= newPDEDC.getTimePoints().length) {
                    DataIdentifier setDid = (newPDEDC.getDataIdentifier() == null ? newPDEDC.getDataIdentifiers()[0] : newPDEDC.getDataIdentifier());
                    if (Arrays.asList(newPDEDC.getDataIdentifiers()).contains(oldPDEDC.getDataIdentifier())) {
                        setDid = oldPDEDC.getDataIdentifier();
                        newPDEDC.setVariableAndTime(setDid, newPDEDC.getTimePoints()[BeanUtils.firstIndexOf(oldPDEDC.getTimePoints(), oldPDEDC.getTimePoint())]);
                    }
                }
            }
        };
        AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                if (hashTable.get(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR) == null) {
                    ClientPDEDataContext newPDEDC = (ClientPDEDataContext) hashTable.get("newPDEDC");
                    pdeDataViewer.setPdeDataContext(newPDEDC);
                    pdeDataViewer.setSimNameSimDataID(new ExportSpecs.SimNameSimDataID(getSimulation().getName(), getSimulation().getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), SimResultsViewer.getParamScanInfo(getSimulation(), vcdid.getJobIndex())));
                } else {
                    if (listReset != null && pdeDataViewer != null && pdeDataViewer.getPdeDataContext() != null && pdeDataViewer.getPdeDataContext().getVCDataIdentifier() != null) {
                        listReset.reset(pdeDataViewer.getPdeDataContext().getVCDataIdentifier());
                    } else {
                        pdeDataViewer.setPdeDataContext(null);
                        pdeDataViewer.setSimNameSimDataID(null);
                    }
                }
            }
        };
        // AsynchClientTask refreshTask = new AsynchClientTask("",AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
        // @Override
        // public void run(Hashtable<String, Object> hashTable) throws Exception {
        // ((ArrayList<AsynchClientTask>)hashTable.get(ClientTaskDispatcher.INTERMEDIATE_TASKS)).addAll(Arrays.asList(pdeDataViewer.getRefreshTasks()));
        // }
        // };
        ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 /*,refreshTask*/
        });
    }
}
Also used : PDEDataContext(cbit.vcell.simdata.PDEDataContext) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) ActionEvent(java.awt.event.ActionEvent) Hashtable(java.util.Hashtable) ExportSpecs(cbit.vcell.export.server.ExportSpecs) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ActionListener(java.awt.event.ActionListener) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext)

Example 10 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class VCellClientDataServiceImpl method displayPostProcessingDataInVCell.

@Override
public void displayPostProcessingDataInVCell(SimulationDataSetRef simulationDataSetRef) throws NumberFormatException, DataAccessException {
    User vcUser = vcellClient.getRequestManager().getDocumentManager().getUser();
    VCSimulationIdentifier vcSimId = new VCSimulationIdentifier(new KeyValue(simulationDataSetRef.getSimId()), vcUser);
    ClientDocumentManager clientDocumentManager = (ClientDocumentManager) vcellClient.getClientServerManager().getDocumentManager();
    SimulationOwner simulationOwner = null;
    if (simulationDataSetRef.isMathModel) {
        simulationOwner = clientDocumentManager.getMathModel(new KeyValue(simulationDataSetRef.getModelId()));
    } else {
        BioModel bioModel = clientDocumentManager.getBioModel(new KeyValue(simulationDataSetRef.getModelId()));
        simulationOwner = bioModel.getSimulationContext(simulationDataSetRef.getSimulationContextName());
    }
    ArrayList<AnnotatedFunction> outputFunctionsList = simulationOwner.getOutputFunctionContext().getOutputFunctionsList();
    OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
    VCSimulationDataIdentifier vcSimDataId = new VCSimulationDataIdentifier(vcSimId, simulationDataSetRef.getJobIndex());
    PDEDataManager pdeDataManager = (PDEDataManager) vcellClient.getRequestManager().getDataManager(outputContext, vcSimDataId, true);
    final ClientPDEDataContext newClientPDEDataContext = pdeDataManager.getPDEDataContext();
    // this was the code before the windows refactoring; appears to just always get the first window???
    // Enumeration<TopLevelWindowManager> windowManagers = vcellClient.getMdiManager().getWindowManagers();
    // final Window window = FindWindow.getWindow(windowManagers.nextElement().getComponent());
    Optional<TopLevelWindowManager> first = vcellClient.getMdiManager().getWindowManagers().stream().findFirst();
    VCAssert.assertTrue(first.isPresent(), "window manager not present?");
    final Window window = getWindow(first.get().getComponent());
    AsynchClientTask task = new AsynchClientTask("Display Post Processing Statistics", AsynchClientTask.TASKTYPE_SWING_NONBLOCKING, false, false) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            DataProcessingResultsPanel dataProcessingResultsPanel = new DataProcessingResultsPanel();
            dataProcessingResultsPanel.update(newClientPDEDataContext);
            DialogUtils.showComponentOKCancelDialog(window, dataProcessingResultsPanel, "Post Processing Statistics");
        }
    };
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
    tasksV.add(task);
    AsynchClientTask[] tasks = new AsynchClientTask[tasksV.size()];
    tasksV.copyInto(tasks);
    ClientTaskDispatcher.dispatch(window, hash, tasks, true);
}
Also used : Window(java.awt.Window) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) Hashtable(java.util.Hashtable) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier) OutputContext(cbit.vcell.simdata.OutputContext) SimulationOwner(cbit.vcell.solver.SimulationOwner) PDEDataManager(cbit.vcell.simdata.PDEDataManager) BioModel(cbit.vcell.biomodel.BioModel) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) Vector(java.util.Vector) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

PDEDataManager (cbit.vcell.simdata.PDEDataManager)13 ClientPDEDataContext (cbit.vcell.simdata.ClientPDEDataContext)7 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)7 OutputContext (cbit.vcell.simdata.OutputContext)6 VCDataManager (cbit.vcell.simdata.VCDataManager)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 ExportSpecs (cbit.vcell.export.server.ExportSpecs)5 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)5 Hashtable (java.util.Hashtable)5 ODEDataManager (cbit.vcell.simdata.ODEDataManager)4 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)4 User (org.vcell.util.document.User)4 BioModel (cbit.vcell.biomodel.BioModel)3 PDEDataViewer (cbit.vcell.client.data.PDEDataViewer)3 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)3 DataIdentifier (cbit.vcell.simdata.DataIdentifier)3 Simulation (cbit.vcell.solver.Simulation)3 ArrayList (java.util.ArrayList)3 ExportEvent (cbit.rmi.event.ExportEvent)2 SimulationWorkspaceModelInfo (cbit.vcell.client.data.SimulationWorkspaceModelInfo)2