Search in sources :

Example 11 with VtuVarInfo

use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.

the class CartesianMeshVtkFileWriter method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCData vcData) throws IOException, DataAccessException, MathException {
    CartesianMeshFileReader reader = new CartesianMeshFileReader();
    CartesianMesh mesh = reader.readFromFiles(vcellFiles);
    List<String> volumeDomainNames = mesh.getVolumeDomainNames();
    List<String> membraneDomainNames = mesh.getMembraneDomainNames();
    ArrayList<String> allDomains = new ArrayList<String>();
    allDomains.addAll(volumeDomainNames);
    allDomains.addAll(membraneDomainNames);
    DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
    AnnotatedFunction[] annotationFunctions = vcData.getFunctions(outputContext);
    ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
    for (String domainName : allDomains) {
        VariableDomain varDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
        if (volumeDomainNames.contains(domainName)) {
            varDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
        } else if (membraneDomainNames.contains(domainName)) {
            varDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
        }
        for (DataIdentifier dataID : dataIdentifiers) {
            if (dataID.getDomain() == null || dataID.getDomain().getName().equals(domainName)) {
                boolean bMeshVar = isMeshVar(dataID);
                String expressionString = null;
                if (dataID.isFunction()) {
                    for (AnnotatedFunction f : annotationFunctions) {
                        if (f.getName().equals(dataID.getName())) {
                            expressionString = f.getExpression().infix();
                        }
                    }
                }
                varInfos.add(new VtuVarInfo(dataID.getName(), "(" + domainName + ")  " + dataID.getDisplayName(), domainName, varDomain, expressionString, DataType.CellData, bMeshVar));
            }
        }
        varInfos.add(new VtuVarInfo(GLOBAL_INDEX_VAR, "(" + domainName + ")  " + GLOBAL_INDEX_VAR, domainName, varDomain, null, DataType.CellData, true));
        varInfos.add(new VtuVarInfo(REGION_ID_VAR, "(" + domainName + ")  " + REGION_ID_VAR, domainName, varDomain, null, DataType.CellData, true));
    }
    return varInfos.toArray(new VtuVarInfo[0]);
}
Also used : CartesianMeshFileReader(org.vcell.vis.io.CartesianMeshFileReader) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) ArrayList(java.util.ArrayList) CartesianMesh(org.vcell.vis.vcell.CartesianMesh) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 12 with VtuVarInfo

use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.

the class DisplayTimeSeries method displayImageTimeSeries.

public static void displayImageTimeSeries(final ImageTimeSeries<Image> imageTimeSeries, String title, WindowListener windowListener) throws ImageException, IOException {
    ISize size = imageTimeSeries.getISize();
    int dimension = (size.getZ() > 0) ? (3) : (2);
    Extent extent = imageTimeSeries.getExtent();
    Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
    // don't care ... no surfaces
    double filterCutoffFrequency = 0.5;
    VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
    RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
    final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
    final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
    final DataSetController dataSetController = new DataSetController() {

        @Override
        public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
            double timePoint = time;
            double[] timePoints = getDataSetTimes(vcdataID);
            int index = -1;
            for (int i = 0; i < timePoints.length; i++) {
                if (timePoint == timePoints[i]) {
                    index = i;
                    break;
                }
            }
            double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
            PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
            VariableType varType = VariableType.VOLUME;
            return new SimDataBlock(pdeDataInfo, data, varType);
        }

        @Override
        public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return false;
        }

        @Override
        public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return mesh;
        }

        @Override
        public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return new AnnotatedFunction[0];
        }

        @Override
        public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return imageTimeSeries.getImageTimeStamps();
        }

        @Override
        public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return new DataIdentifier[] { dataIdentifier };
        }

        @Override
        public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {

        @Override
        public DataSetController getDataSetController() throws DataAccessException {
            return dataSetController;
        }
    };
    VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
    OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
    VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {

        public User getOwner() {
            return new User("nouser", null);
        }

        public KeyValue getDataKey() {
            return null;
        }

        public String getID() {
            return "mydata";
        }
    };
    PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
    ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
    PDEDataViewer pdeDataViewer = new PDEDataViewer();
    JFrame jframe = new JFrame();
    jframe.setTitle(title);
    jframe.getContentPane().add(pdeDataViewer);
    jframe.setSize(1000, 600);
    jframe.setVisible(true);
    if (windowListener != null) {
        jframe.addWindowListener(windowListener);
    }
    pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
Also used : Origin(org.vcell.util.Origin) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) User(org.vcell.util.document.User) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) ExportSpecs(cbit.vcell.export.server.ExportSpecs) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) VCImage(cbit.image.VCImage) PDEDataInfo(cbit.vcell.simdata.PDEDataInfo) DataSetControllerProvider(cbit.vcell.server.DataSetControllerProvider) SimDataBlock(cbit.vcell.simdata.SimDataBlock) SpatialSelection(cbit.vcell.simdata.SpatialSelection) JFrame(javax.swing.JFrame) VCDataManager(cbit.vcell.simdata.VCDataManager) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) DataOperation(cbit.vcell.simdata.DataOperation) VariableType(cbit.vcell.math.VariableType) DataSetController(cbit.vcell.server.DataSetController) VCImageUncompressed(cbit.image.VCImageUncompressed) OutputContext(cbit.vcell.simdata.OutputContext) CartesianMesh(cbit.vcell.solvers.CartesianMesh) PDEDataManager(cbit.vcell.simdata.PDEDataManager) RegionImage(cbit.vcell.geometry.RegionImage) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) Domain(cbit.vcell.math.Variable.Domain) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) PDEDataViewer(cbit.vcell.client.data.PDEDataViewer)

Aggregations

VtuVarInfo (org.vcell.vis.io.VtuVarInfo)12 IOException (java.io.IOException)8 DataAccessException (org.vcell.util.DataAccessException)8 ArrayList (java.util.ArrayList)7 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)6 FileNotFoundException (java.io.FileNotFoundException)6 MathException (cbit.vcell.math.MathException)5 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)5 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 DataIdentifier (cbit.vcell.simdata.DataIdentifier)5 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)5 VariableType (cbit.vcell.math.VariableType)4 VariableDomain (cbit.vcell.math.VariableType.VariableDomain)4 OutputContext (cbit.vcell.simdata.OutputContext)4 XmlParseException (cbit.vcell.xml.XmlParseException)4 CacheException (org.vcell.util.CacheException)4 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)4 ExportSpecs (cbit.vcell.export.server.ExportSpecs)3 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)3