Search in sources :

Example 6 with VCDataIdentifier

use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.

the class ClientRequestManager method getDataViewerController.

/**
 * Insert the method's description here.
 * Creation date: (6/11/2004 10:53:47 AM)
 * @return cbit.vcell.desktop.controls.DataManager
 * @param vcDataIdentifier cbit.vcell.server.VCDataIdentifier
 */
public DataViewerController getDataViewerController(OutputContext outputContext, Simulation simulation, int jobIndex) throws DataAccessException {
    VCSimulationIdentifier vcSimulationIdentifier = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
    final VCDataIdentifier vcdataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
    DataManager dataManager = getDataManager(outputContext, vcdataIdentifier, simulation.isSpatial());
    return new SimResultsViewerController(dataManager, simulation);
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) VCDataManager(cbit.vcell.simdata.VCDataManager) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier)

Example 7 with VCDataIdentifier

use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.

the class ASCIIExporter method exportParticleData.

/**
 * Insert the method's description here.
 * Creation date: (1/12/00 5:00:28 PM)
 * @return cbit.vcell.export.server.ExportOutput[]
 * @param dsc cbit.vcell.server.DataSetController
 * @param timeSpecs cbit.vcell.export.server.TimeSpecs
 * @throws IOException
 */
private List<ExportOutput> exportParticleData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, ASCIISpecs asciiSpecs, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
    VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
    String simID = vcdID.getID();
    String dataType = ".csv";
    // in switched format, how many rows for each particle
    final int N_PARTICLE_PIECES = 1;
    // get parameters
    boolean switchRowsColumns = asciiSpecs.getSwitchRowsColumns();
    double[] allTimes = timeSpecs.getAllTimes();
    int beginIndex = timeSpecs.getBeginTimeIndex();
    int endIndex = timeSpecs.getEndTimeIndex();
    ParticleDataBlock particleDataBlk = dataServerImpl.getParticleDataBlock(user, vcdID, allTimes[beginIndex]);
    VariableSpecs vs = exportSpecs.getVariableSpecs();
    VCAssert.assertValid(vs);
    String[] vnames = vs.getVariableNames();
    if (vnames.length == 0) {
        throw new IllegalArgumentException("No variables selected");
    }
    // need array for SimulationDescription, later
    final String[] currentVariableName = new String[1];
    ArrayList<ExportOutput> rval = new ArrayList<>(vnames.length);
    Set<String> species = particleDataBlk.getSpecies();
    ParticleProgress particleProgress = null;
    for (String vcellName : vnames) {
        String smoldynSpecies = null;
        for (int i = 0; smoldynSpecies == null && i < SMOLDYN_KEYWORDS_USED.length; i++) {
            SmoldynKeyword kw = SMOLDYN_KEYWORDS_USED[i];
            String smoldynName = SmoldynVCellMapper.vcellToSmoldyn(vcellName, kw);
            if (species.contains(smoldynName)) {
                smoldynSpecies = smoldynName;
            }
        }
        if (smoldynSpecies == null) {
            throw new DataAccessException("Unable to find match for variable name " + vcellName + " in " + StringUtils.join(species, ", "));
        }
        List<Coordinate> particles = particleDataBlk.getCoordinates(smoldynSpecies);
        int numberOfParticles = particles.size();
        int numberOfTimes = endIndex - beginIndex + 1;
        if (particleProgress != null) {
            particleProgress.nextName();
        } else {
            particleProgress = new ParticleProgress(jobID, vcdID, vnames.length, numberOfTimes, numberOfParticles);
        }
        // now make csv formatted data
        StringBuilder header = new StringBuilder();
        StringBuilder[] dataLines = null;
        final int NUMBER_HEADING_LINES = SwitchedRowsHeading.DATA.ordinal();
        if (switchRowsColumns) {
            dataLines = stringBuilderArray(numberOfParticles * N_PARTICLE_PIECES + NUMBER_HEADING_LINES);
            dataLines[SwitchedRowsHeading.TIME.ordinal()].append("Time,");
            final String particleLine = "Particle" + StringUtils.repeat(",x,y,z", numberOfTimes);
            dataLines[SwitchedRowsHeading.PARTICLE.ordinal()].append(particleLine);
            dataLines[SwitchedRowsHeading.XYZ.ordinal()].append("#,");
            // "first data line"
            final int FDL = SwitchedRowsHeading.DATA.ordinal();
            for (int i = 0; i < numberOfParticles; i++) {
                dataLines[FDL + N_PARTICLE_PIECES * i].append(i);
                dataLines[FDL + N_PARTICLE_PIECES * i].append(',');
            }
        } else {
            dataLines = stringBuilderArray(numberOfTimes);
        }
        currentVariableName[0] = vcellName;
        SimulationDescription simulationDescription = new SimulationDescription(outputContext, user, dataServerImpl, vcdID, false, currentVariableName);
        header.append(simulationDescription.getHeader(dataType));
        if (switchRowsColumns) {
        // implemented using first few data lines
        } else {
            header.append(",Time\n");
            header.append("Particle #,,");
            for (int k = 0; k < numberOfParticles; k++) {
                header.append(k + StringUtils.repeat(',', N_PARTICLE_PIECES));
            }
            header.append("\n,,");
            for (int k = 0; k < numberOfParticles; k++) {
                header.append("x,y,z,");
            }
        }
        final char COMMA = ',';
        int nextTimeIndex = particleProgress.nextTimeIndex(0, false);
        for (int i = beginIndex; i <= endIndex; i++) {
            particleDataBlk = dataServerImpl.getParticleDataBlock(user, vcdID, allTimes[i]);
            particles = particleDataBlk.getCoordinates(smoldynSpecies);
            if (i >= nextTimeIndex) {
                nextTimeIndex = particleProgress.nextTimeIndex(i, true);
            }
            if (switchRowsColumns) {
                // "first data line"
                final int FDL = SwitchedRowsHeading.DATA.ordinal();
                StringBuilder timeSb = dataLines[SwitchedRowsHeading.TIME.ordinal()];
                timeSb.append(allTimes[i]);
                timeSb.append(",,,");
                for (int j = 0; j < numberOfParticles; j++) {
                    StringBuilder sb = dataLines[FDL + N_PARTICLE_PIECES * j];
                    Coordinate coordinate = particles.get(j);
                    sb.append(coordinate.getX());
                    sb.append(COMMA);
                    sb.append(coordinate.getY());
                    sb.append(COMMA);
                    sb.append(coordinate.getZ());
                    sb.append(COMMA);
                }
            } else {
                StringBuilder particleSb = dataLines[i - beginIndex];
                particleSb.append(COMMA);
                particleSb.append(allTimes[i]);
                particleSb.append(COMMA);
                for (int j = 0; j < numberOfParticles; j++) {
                    Coordinate coordinate = particles.get(j);
                    particleSb.append(coordinate.getX());
                    particleSb.append(COMMA);
                    particleSb.append(coordinate.getY());
                    particleSb.append(COMMA);
                    particleSb.append(coordinate.getZ());
                }
            }
        }
        particleProgress.endOfTimes();
        final String dataID = vcellName + "_Particles";
        ExportOutput exportOutputCSV = new ExportOutput(true, dataType, simID, dataID, fileDataContainerManager);
        fileDataContainerManager.append(exportOutputCSV.getFileDataContainerID(), header.toString());
        int nextDataIndex = particleProgress.nextDataIndex(0, false);
        StringBuilder all = new StringBuilder();
        for (int i = 0; i < dataLines.length; i++) {
            final char NEWLINE = '\n';
            all.append(dataLines[i]);
            // kill reference to allow garbage collection
            dataLines[i] = null;
            all.append(NEWLINE);
            if (i >= nextDataIndex) {
                nextDataIndex = particleProgress.nextDataIndex(i, true);
            }
        }
        fileDataContainerManager.append(exportOutputCSV.getFileDataContainerID(), all.toString());
        rval.add(exportOutputCSV);
    }
    return rval;
}
Also used : ArrayList(java.util.ArrayList) SmoldynKeyword(org.vcell.solver.smoldyn.SmoldynVCellMapper.SmoldynKeyword) SinglePoint(cbit.vcell.geometry.SinglePoint) Coordinate(org.vcell.util.Coordinate) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataAccessException(org.vcell.util.DataAccessException) ParticleDataBlock(cbit.vcell.simdata.ParticleDataBlock)

Example 8 with VCDataIdentifier

use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.

the class IMGExporter method makeMedia.

// private ParticleInfo checkParticles_unused(final ExportSpecs exportSpecs,User user,DataServerImpl dataServerImpl,final long jobID) throws Exception{
// int particleMode = FormatSpecificSpecs.PARTICLE_NONE;
// if(exportSpecs.getFormatSpecificSpecs() instanceof ImageSpecs){
// particleMode = ((ImageSpecs)exportSpecs.getFormatSpecificSpecs()).getParticleMode();
// }else if (exportSpecs.getFormatSpecificSpecs() instanceof MovieSpecs){
// particleMode = ((MovieSpecs)exportSpecs.getFormatSpecificSpecs()).getParticleMode();
// }
// if(particleMode == FormatSpecificSpecs.PARTICLE_NONE){
// return null;
// }
// 
// final VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
// CartesianMesh cartesianMesh = dataServerImpl.getMesh(user, vcdID);
// int dimension = cartesianMesh.getGeometryDimension();
// 
// String[] variableNames = exportSpecs.getVariableSpecs().getVariableNames();
// 
// File visitExeLocation =
// new File(PropertyLoader.getRequiredProperty(PropertyLoader.visitSmoldynVisitExecutableProperty));
// File visitSmoldynScriptLocation =
// new File(PropertyLoader.getRequiredProperty(PropertyLoader.visitSmoldynScriptPathProperty));
// final File visitSmoldynScriptTempDir = PropertyLoader.getSystemTemporaryDirectory();
// 
// //-----Get all data (from archive if necessary)
// SimulationData.SimDataAmplistorInfo simDataAmplistorInfo = AmplistorUtils.getSimDataAmplistorInfoFromPropertyLoader();
// SimulationData simData = new SimulationData(vcdID,
// new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty),vcdID.getOwner().getName()),
// new File(PropertyLoader.getProperty(PropertyLoader.primarySimDataDirInternalProperty,null),vcdID.getOwner().getName()),
// simDataAmplistorInfo);
// 
// File logFile = simData.getLogFile();
// if(!logFile.exists()){
// throw new Exception("ImgExport particle, Couldn't find Log file "+logFile.getAbsolutePath());
// }
// simData.getMesh();//gets mesh and meshmetrics files from archive if necessary
// simData.getSubdomainFile();
// simData.getFunctionsFile(false);
// int timeIndex = 1;//smoldyn always begins at timeindex 1
// while(true){
// if(!simData.getSmoldynOutputFile(timeIndex).exists()){//get smoldynOutput files
// break;
// }
// timeIndex++;
// }
// //-----
// 
// File visitDataPathFragment = new File(logFile.getParent(),vcdID.getID()+"_");
// System.out.println(visitExeLocation.getAbsolutePath());
// System.out.println(visitSmoldynScriptLocation.getAbsolutePath());
// System.out.println(visitSmoldynScriptTempDir.getAbsolutePath());
// System.out.println(visitDataPathFragment.getAbsolutePath());
// 
// //if(true){return new ParticleInfo(visitSmoldynScriptTempDir);}
// if(exportSpecs.getTimeSpecs().getAllTimes().length == 1){
// throw new IllegalArgumentException("Time zero not valid for smoldyn particle data");
// }
// int beginIndexTime = exportSpecs.getTimeSpecs().getBeginTimeIndex();
// int endIndexTime = exportSpecs.getTimeSpecs().getEndTimeIndex();
// 
// System.out.println("beginIndexTime="+beginIndexTime+" endIndexTime="+endIndexTime);
// 
// ArrayList<String> args = new ArrayList<String>();
// args.add(visitExeLocation.getAbsolutePath());//location of visit
// args.add("-nowin");
// args.add("-cli");
// args.add("-s");
// 
// args.add(visitSmoldynScriptLocation.getAbsolutePath());//location of the script
// args.add(visitDataPathFragment.getAbsolutePath()); //location of the SimID
// args.add(visitSmoldynScriptTempDir.getAbsolutePath());  // where frames are dumped
// args.add(dimension+""); //dimension
// args.add(beginIndexTime+"");
// args.add(endIndexTime+"");
// args.add(4+"");//particle sphere size
// args.add(FormatSpecificSpecs.SMOLDYN_DEFAULT_FRAME_SIZE.width+"");//frame size X
// args.add(FormatSpecificSpecs.SMOLDYN_DEFAULT_FRAME_SIZE.height+"");//frame size Y
// args.add(variableNames.length+""); // 0 = show all the particles.  >0 == show n different particles, to be listed below
// for (int i = 0; i < variableNames.length; i++) {
// args.add(variableNames[i]);
// }
// 
// final String tempFilePrefix = vcdID.getID()+"_p3d";
// 
// //Monitor progress of smoldyn script
// exportServiceImpl.fireExportProgress(jobID, vcdID, "MEDIA", 0.0);
// final boolean[] finishedFlag = new boolean[] {false};
// final int numTimePoints = exportSpecs.getTimeSpecs().getEndTimeIndex()-exportSpecs.getTimeSpecs().getBeginTimeIndex()+1;
// Thread progressThread = new Thread(new Runnable() {
// public void run() {
// System.out.println("smoldyn progress monitor started");
// while(!finishedFlag[0]){
// int count = 0;
// File[] tempFiles = visitSmoldynScriptTempDir.listFiles();
// for (int i = 0; i < tempFiles.length; i++) {
// if(tempFiles[i].getName().startsWith(tempFilePrefix) ||
// (tempFiles[i].getName().startsWith(vcdID.getID()) &&
// tempFiles[i].getName().endsWith(".jpeg"))){
// count+= 1;
// }
// }
// double progress = .5 * (double)count / (double)(2*numTimePoints);
// exportServiceImpl.fireExportProgress(jobID, vcdID, "MEDIA", progress);
// //System.out.println("All files read="+tempFiles.length+" Files counted="+count+" progress="+progress);
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// return;//This shouldn't happen but if so just quit
// }
// }
// System.out.println("smoldyn progress monitor finished");
// }
// });
// progressThread.start();
// 
// 
// try{
// final long TIME_OUT = 1200000; //20 minutes
// Executable executable = new Executable(args.toArray(new String[0]),TIME_OUT);
// executable.start();//blocking, internal monitoring, return after timeout
// if(!executable.getStatus().equals(ExecutableStatus.COMPLETE)){
// System.out.println(executable.getStderrString());
// System.out.println(executable.getStdoutString());
// throw new Exception("Particle data exporter did not complete normally. "+(executable.getStatus()==null?"":executable.getStatus().toString()));
// }
// }finally{
// finishedFlag[0] = true;
// //Remove temp files created by smoldyn script
// File[] tempFiles = visitSmoldynScriptTempDir.listFiles();
// for (int i = 0; i < tempFiles.length; i++) {
// if(tempFiles[i].getName().startsWith(tempFilePrefix)){
// tempFiles[i].delete();
// }
// }
// }
// return new ParticleInfo(visitSmoldynScriptTempDir);
// }
private static ExportOutput[] makeMedia(ExportServiceImpl exportServiceImpl, OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, ClientTaskStatusSupport clientTaskStatusSupport, ParticleInfo particleInfo, FileDataContainerManager fileDataContainerManager) throws RemoteException, IOException, GIFFormatException, DataAccessException, Exception {
    boolean bOverLay = false;
    int sliceIndicator = 0;
    if (particleInfo == null) {
        sliceIndicator = (exportSpecs.getGeometrySpecs().getModeID() == ExportConstants.GEOMETRY_FULL ? FULL_MODE_ALL_SLICES : exportSpecs.getGeometrySpecs().getSliceNumber());
    }
    int imageScale = 0;
    int meshMode = 0;
    int mirroringType = 0;
    int membraneScale = 0;
    double duration = 1.0;
    DisplayPreferences[] displayPreferences = null;
    int volVarMembrOutlineThickness = 1;
    if (exportSpecs.getFormatSpecificSpecs() instanceof ImageSpecs) {
        bOverLay = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getOverlayMode();
        imageScale = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getImageScaling();
        volVarMembrOutlineThickness = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getVolVarMembrOutlineThickness();
        meshMode = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getMeshMode();
        mirroringType = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getMirroringType();
        membraneScale = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getMembraneScaling();
        displayPreferences = ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getDisplayPreferences();
        // convert from milliseconds to seconds
        duration = (double) ((ImageSpecs) exportSpecs.getFormatSpecificSpecs()).getDuration() / 1000.0;
    } else if (exportSpecs.getFormatSpecificSpecs() instanceof MovieSpecs) {
        bOverLay = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getOverlayMode();
        imageScale = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getImageScaling();
        volVarMembrOutlineThickness = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getVolVarMembrOutlineThickness();
        meshMode = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getMeshMode();
        mirroringType = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getMirroringType();
        membraneScale = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getMembraneScaling();
        displayPreferences = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getDisplayPreferences();
        // convert from milliseconds to seconds
        duration = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).getDuration() / 1000.0;
    } else {
        throw new DataFormatException("Unknown FormatSpecificSpec " + exportSpecs.getFormatSpecificSpecs().getClass().getName());
    }
    Vector<ExportOutput> exportOutputV = new Vector<ExportOutput>();
    VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    int beginTimeIndex = exportSpecs.getTimeSpecs().getBeginTimeIndex();
    int endTimeIndex = exportSpecs.getTimeSpecs().getEndTimeIndex();
    boolean bSingleTimePoint = beginTimeIndex == endTimeIndex;
    String[] varNames = (particleInfo == null ? exportSpecs.getVariableSpecs().getVariableNames() : new String[] { "smoldynParticleDummy" });
    double[] allTimes = dataServerImpl.getDataSetTimes(user, vcdID);
    int startSlice = (sliceIndicator == FULL_MODE_ALL_SLICES ? 0 : sliceIndicator);
    int sliceCount = FormatSpecificSpecs.getSliceCount(sliceIndicator == FULL_MODE_ALL_SLICES, exportSpecs.getGeometrySpecs().getAxis(), dataServerImpl.getMesh(user, vcdID));
    double progressIncr = 1.0 / (sliceCount * (endTimeIndex - beginTimeIndex + 1) * varNames.length);
    double progress = 0.0;
    MovieHolder movieHolder = new MovieHolder();
    Dimension imageDimension = FormatSpecificSpecs.getImageDimension(meshMode, imageScale, dataServerImpl.getMesh(user, vcdID), exportSpecs.getGeometrySpecs().getAxis());
    int originalWidth = (int) imageDimension.getWidth();
    int originalHeight = (int) imageDimension.getHeight();
    ExportRenderInfo exportRenderInfo = null;
    try {
        for (int sliceNumber = startSlice; sliceNumber < startSlice + sliceCount; sliceNumber++) {
            if (particleInfo == null) {
                PDEOffscreenRenderer offScreenRenderer = new PDEOffscreenRenderer(outputContext, user, dataServerImpl, vcdID);
                offScreenRenderer.setNormalAxis(exportSpecs.getGeometrySpecs().getAxis());
                offScreenRenderer.setSlice(sliceNumber);
                exportRenderInfo = new ExportRenderInfo(offScreenRenderer);
            } else {
                exportRenderInfo = new ExportRenderInfo(particleInfo, allTimes, vcdID, beginTimeIndex);
                Dimension particleImageSize = particleInfo.getImageFrameSize(vcdID);
                originalWidth = particleImageSize.width;
                originalHeight = particleImageSize.height;
            }
            int varNameIndex0 = 0;
            int timeIndex0 = beginTimeIndex;
            int[] overLayPixels = null;
            // set default time if only 1 timepoint
            movieHolder.setSampleDurationSeconds(duration);
            boolean bEndslice = sliceNumber == (startSlice + sliceCount - 1);
            while (true) {
                if (clientTaskStatusSupport != null) {
                    clientTaskStatusSupport.setProgress((int) (progress * 100));
                    if (clientTaskStatusSupport.isInterrupted()) {
                        throw UserCancelException.CANCEL_GENERIC;
                    }
                }
                exportServiceImpl.fireExportProgress(jobID, vcdID, "MEDIA", (particleInfo == null ? progress : .5 + (progress / 2.0)));
                progress += progressIncr;
                MirrorInfo currentSliceTimeMirrorInfo = renderAndMirrorSliceTimePixels(exportRenderInfo, varNames[varNameIndex0], allTimes[timeIndex0], displayPreferences[varNameIndex0], imageScale, membraneScale, meshMode, volVarMembrOutlineThickness, originalWidth, originalHeight, mirroringType);
                if (bOverLay) {
                    if (varNames.length == 1) {
                        overLayPixels = currentSliceTimeMirrorInfo.getPixels();
                    } else {
                        // Overlay append in Y-direction
                        if (overLayPixels == null) {
                            overLayPixels = new int[currentSliceTimeMirrorInfo.getPixels().length * varNames.length];
                        }
                        int appendIndex = currentSliceTimeMirrorInfo.getPixels().length * varNameIndex0;
                        System.arraycopy(currentSliceTimeMirrorInfo.getPixels(), 0, overLayPixels, appendIndex, currentSliceTimeMirrorInfo.getPixels().length);
                    }
                }
                if (timeIndex0 != endTimeIndex) {
                    // calculate duration for each timepoint
                    movieHolder.setSampleDurationSeconds((allTimes[timeIndex0 + 1] - allTimes[timeIndex0]) / (allTimes[endTimeIndex + (endTimeIndex == allTimes.length - 1 ? 0 : 1)] - allTimes[beginTimeIndex]) * duration);
                } else {
                    // when last or only 1 timepoint, use last duration set
                    movieHolder.setSampleDurationSeconds(movieHolder.getSampleDurationSeconds());
                }
                // Index var and time properly
                boolean bBegintime = timeIndex0 == beginTimeIndex;
                boolean bEndTime = timeIndex0 == endTimeIndex;
                if (bOverLay) {
                    varNameIndex0++;
                    if (varNameIndex0 == varNames.length) {
                        String dataID = createDataID(exportSpecs, sliceNumber, "overlay", timeIndex0);
                        createMedia(exportOutputV, vcdID, dataID, exportSpecs, true, bEndslice, bBegintime, bEndTime, bSingleTimePoint, varNames, displayPreferences, movieHolder, overLayPixels, currentSliceTimeMirrorInfo.getMirrorWidth(), currentSliceTimeMirrorInfo.getMirrorHeight() * varNames.length, fileDataContainerManager);
                        varNameIndex0 = 0;
                        timeIndex0++;
                        if (timeIndex0 > endTimeIndex) {
                            break;
                        }
                    }
                } else {
                    String dataID = createDataID(exportSpecs, sliceNumber, varNames[varNameIndex0], timeIndex0);
                    boolean bEndVars = varNameIndex0 == varNames.length - 1;
                    createMedia(exportOutputV, vcdID, dataID, exportSpecs, bEndVars, bEndslice, bBegintime, bEndTime, bSingleTimePoint, new String[] { varNames[varNameIndex0] }, new DisplayPreferences[] { displayPreferences[varNameIndex0] }, movieHolder, currentSliceTimeMirrorInfo.getPixels(), currentSliceTimeMirrorInfo.getMirrorWidth(), currentSliceTimeMirrorInfo.getMirrorHeight(), fileDataContainerManager);
                    timeIndex0++;
                    if (timeIndex0 > endTimeIndex) {
                        timeIndex0 = beginTimeIndex;
                        varNameIndex0++;
                        if (varNameIndex0 == varNames.length) {
                            break;
                        }
                    }
                }
            }
        }
    } finally {
        if (exportRenderInfo != null) {
            exportRenderInfo.cleanup();
        }
    }
    return exportOutputV.toArray(new ExportOutput[0]);
}
Also used : Dimension(java.awt.Dimension) DataFormatException(java.util.zip.DataFormatException) DisplayPreferences(cbit.image.DisplayPreferences) Vector(java.util.Vector) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier)

Example 9 with VCDataIdentifier

use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.

the class RasterExporter method makeVTKUnstructuredData0.

public ExportOutput[] makeVTKUnstructuredData0(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
    VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    boolean bChombo = dataServerImpl.isChombo(user, vcdID);
    final File tmpDir = PropertyLoader.getSystemTemporaryDirectory();
    if (bChombo) {
        return makeVTKUnstructuredData_Chombo(outputContext, jobRequest, user, dataServerImpl, exportSpecs, tmpDir, fileDataContainerManager);
    } else {
        return makeVTKUnstructuredData_VCell(outputContext, jobRequest, user, dataServerImpl, exportSpecs, tmpDir, fileDataContainerManager);
    }
}
Also used : VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) File(java.io.File)

Example 10 with VCDataIdentifier

use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.

the class RasterExporter method makeUCDData.

public ExportOutput[] makeUCDData(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
    String simID = exportSpecs.getVCDataIdentifier().getID();
    VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
    TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
    cbit.vcell.solvers.CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
    CartesianMesh.UCDInfo ucdInfo = mesh.getUCDInfo();
    CartesianMesh.UCDInfo ucdInfoReduced = ucdInfo.removeNonMembraneGridNodes();
    Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
    // for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
    for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
        exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "UCD", (double) (j - timeSpecs.getBeginTimeIndex()) / (double) (timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1));
        // String fileID = simID + "_Full_" + formatTime(timeSpecs.getAllTimes()[j]) + "time_" + variableSpecs.getVariableNames().length + "vars";
        // File datafile = new File(tempDir, fileID + "_data.ucd");
        // FileWriter fileWriter = new FileWriter(datafile);
        Vector<double[]> volumeDataV = new Vector<double[]>();
        Vector<String> volumeDataNameV = new Vector<String>();
        Vector<String> volumeDataUnitV = new Vector<String>();
        Vector<double[]> membraneDataV = new Vector<double[]>();
        Vector<String> membraneDataNameV = new Vector<String>();
        Vector<String> membraneDataUnitV = new Vector<String>();
        for (int k = 0; k < variableSpecs.getVariableNames().length; k++) {
            SimDataBlock simDataBlock = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[k], timeSpecs.getAllTimes()[j]);
            if (simDataBlock.getVariableType().equals(VariableType.VOLUME)) {
                volumeDataNameV.add(variableSpecs.getVariableNames()[k]);
                volumeDataUnitV.add("unknown");
                volumeDataV.add(simDataBlock.getData());
            } else {
                membraneDataNameV.add(variableSpecs.getVariableNames()[k]);
                membraneDataUnitV.add("unknown");
                membraneDataV.add(simDataBlock.getData());
            }
        }
        if (volumeDataV.size() > 0) {
            StringWriter stringWriter = new StringWriter();
            AVS_UCD_Exporter.writeUCDVolGeomAndData(ucdInfo, volumeDataNameV.toArray(new String[0]), volumeDataUnitV.toArray(new String[0]), volumeDataV.toArray(new double[0][]), stringWriter);
            ExportOutput exportOut = new ExportOutput(true, ".ucd", simID.toString(), "_vol_" + j, fileDataContainerManager);
            fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
            exportOutV.add(exportOut);
        }
        if (membraneDataV.size() > 0) {
            StringWriter stringWriter = new StringWriter();
            AVS_UCD_Exporter.writeUCDMembGeomAndData(ucdInfoReduced, /*ucdInfo*/
            membraneDataNameV.toArray(new String[0]), membraneDataUnitV.toArray(new String[0]), membraneDataV.toArray(new double[0][]), stringWriter);
            ExportOutput exportOut = new ExportOutput(true, ".ucd", simID.toString(), "_memb_" + j, fileDataContainerManager);
            fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
            exportOutV.add(exportOut);
        }
    // AVS_UCD_Exporter.writeUCD(mesh,
    // (volumeDataNameV.size() == 0?null:volumeDataNameV.toArray(new String[0])),
    // (volumeDataUnitV.size() == 0?null:volumeDataUnitV.toArray(new String[0])),
    // (volumeDataV.size() == 0?null:volumeDataV.toArray(new double[0][])),
    // 
    // (membraneDataNameV.size() == 0?null:membraneDataNameV.toArray(new String[0])),
    // (membraneDataUnitV.size() == 0?null:membraneDataUnitV.toArray(new String[0])),
    // (membraneDataV.size() == 0?null:membraneDataV.toArray(new double[0][])),
    // stringWriter);
    // ExportOutput exportOut = new ExportOutput(true,".ucd",simID.toString(),fileID,stringWriter.toString().getBytes());
    // exportOutV.add(exportOut);
    }
    // }
    ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
    return exportOutputArr;
// String fileID = simID + "_Full_" + NUM_TIMES + "times_" + variableSpecs.getVariableNames().length + "vars";
// File datafile = new File(tempDir, fileID + "_data.nrrd");
// nrrdInfo.setDatafile(datafile.getName());
// DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(datafile)));
// try {
// for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
// for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++){
// double[] data = dataServerImpl.getSimDataBlock(user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
// for (int k = 0; k < data.length; k++){
// out.writeDouble(data[k]);
// }
// }
// }
// } catch (IOException exc) {
// throw new DataAccessException(exc.toString());
// } finally {
// out.close();
// }
}
Also used : Point(java.awt.Point) CartesianMesh(cbit.vcell.solvers.CartesianMesh) SimDataBlock(cbit.vcell.simdata.SimDataBlock) StringWriter(java.io.StringWriter) CartesianMesh(cbit.vcell.solvers.CartesianMesh) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) Vector(java.util.Vector)

Aggregations

VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)49 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)20 CartesianMesh (cbit.vcell.solvers.CartesianMesh)17 DataAccessException (org.vcell.util.DataAccessException)15 Vector (java.util.Vector)12 IOException (java.io.IOException)11 User (org.vcell.util.document.User)11 File (java.io.File)10 ArrayList (java.util.ArrayList)10 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)10 SimDataBlock (cbit.vcell.simdata.SimDataBlock)9 KeyValue (org.vcell.util.document.KeyValue)9 MathException (cbit.vcell.math.MathException)8 DataIdentifier (cbit.vcell.simdata.DataIdentifier)8 PDEDataManager (cbit.vcell.simdata.PDEDataManager)8 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)8 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)8 ExportSpecs (cbit.vcell.export.server.ExportSpecs)7 VariableType (cbit.vcell.math.VariableType)7 OutputContext (cbit.vcell.simdata.OutputContext)7