use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class MergedData method getFunctions.
/**
* Insert the method's description here.
* Creation date: (10/11/00 5:16:06 PM)
* @return cbit.vcell.math.Function
* @param name java.lang.String
*/
public AnnotatedFunction[] getFunctions(OutputContext outputContext) {
try {
getFunctionDataIdentifiers(outputContext);
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
ArrayList<AnnotatedFunction> functionsArr = new ArrayList<>();
// Get the functions in annotatedFunctionsList
for (int i = 0; i < annotatedFunctionList.size(); i++) {
// AnnotatedFunction annotatedFunc = (AnnotatedFunction)annotatedFunctionList.elementAt(i);
// functions[i] = new Function(annotatedFunc.getName(), annotatedFunc.getExpression());
functionsArr.add((AnnotatedFunction) annotatedFunctionList.elementAt(i));
}
for (int i = 0; i < datasetsIDList.length; i++) {
VCDataIdentifier vcdid = datasetsIDList[i];
try {
AnnotatedFunction[] myFuncs = getDatasetControllerImpl().getFunctions(outputContext, vcdid);
for (int j = 0; j < myFuncs.length; j++) {
AnnotatedFunction myfunc = new AnnotatedFunction(dataSetPrefix[i] + "." + myFuncs[j].getName(), myFuncs[j].getExpression(), myFuncs[j].getDomain(), myFuncs[j].getErrorString(), myFuncs[j].getFunctionType(), myFuncs[j].getFunctionCatogery());
functionsArr.add(myfunc);
}
} catch (ExpressionBindingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DataAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return functionsArr.toArray(new AnnotatedFunction[0]);
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class MergedData method getDataBlockTimeStamp.
/**
* Insert the method's description here.
* Creation date: (1/19/00 11:52:22 AM)
* @return long
* @param dataType int
* @param timepoint double
* @exception org.vcell.util.DataAccessException The exception description.
*/
public long getDataBlockTimeStamp(int dataType, double timepoint) throws DataAccessException {
long latestTimeStamp = Long.MIN_VALUE;
// use that value to find the max.
try {
for (int i = 0; i < datasetsIDList.length; i++) {
VCData vcdata = getDatasetControllerImpl().getVCData(datasetsIDList[i]);
double[] timeArray = getDatasetControllerImpl().getDataSetTimes(datasetsIDList[i]);
boolean bTimesEqual = checkTimeArrays(timeArray);
int timeArrayCounter = 0;
long datatimeStamp;
if (bTimesEqual) {
datatimeStamp = vcdata.getDataBlockTimeStamp(dataType, timepoint);
} else {
while ((timeArrayCounter < timeArray.length - 2) && (timepoint > timeArray[timeArrayCounter + 1])) {
timeArrayCounter++;
}
datatimeStamp = vcdata.getDataBlockTimeStamp(dataType, timeArray[Math.min(timeArray.length - 1, timeArrayCounter + 1)]);
}
latestTimeStamp = Math.max(latestTimeStamp, datatimeStamp);
}
} catch (IOException e) {
e.printStackTrace(System.out);
throw new DataAccessException("\n Error computing Timestamp for CompositeData! " + e.getMessage());
}
return latestTimeStamp;
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class PDEDataContext method setVariableNameAndTime.
public void setVariableNameAndTime(String varName, double timePoint) throws DataAccessException {
DataIdentifier dataIdentifier = findDataIdentifier(varName);
if (dataIdentifier == null) {
throw new DataAccessException("Couldn't find DataIdentifier for variable name " + varName);
}
setVariableAndTime(dataIdentifier, timePoint);
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class ParticleDataBlock method readParticleData.
private void readParticleData(List<String> lines) throws DataAccessException {
String lastSpecies = null;
List<Coordinate> working = null;
for (String line : lines) {
try {
CommentStringTokenizer st = new CommentStringTokenizer(line);
String sp = st.nextToken();
if (!sp.equals(lastSpecies)) {
lastSpecies = sp;
working = fetch(sp);
}
double x = Double.parseDouble(st.nextToken());
double y = Double.parseDouble(st.nextToken());
double z = Double.parseDouble(st.nextToken());
Coordinate c = new Coordinate(x, y, z);
working.add(c);
} catch (Exception exc) {
throw new DataAccessException("Particle data file invalid. " + exc.getMessage());
}
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class SimDataReader method getNextDataAtCurrentTime0.
private void getNextDataAtCurrentTime0(double[][] returnValues) throws IOException, DataAccessException {
if (masterTimeIndex >= times.length) {
throw new RuntimeException("No More Time Data");
}
try {
// Setup the proper DataInputStream
String currentSimDataFileName = simDataFileNames[masterTimeIndex];
if (zipFilenNames != null && zipFilenNames[masterTimeIndex] != null) {
if (currentZipFile == null || !currentZipFileName.equals(zipFilenNames[masterTimeIndex])) {
if (currentZipFile != null) {
currentZipFile.close();
currentZipFileName = null;
}
currentZipFile = new org.apache.commons.compress.archivers.zip.ZipFile(zipFilenNames[masterTimeIndex]);
currentZipFileName = zipFilenNames[masterTimeIndex];
}
if (dis != null) {
dis.close();
dis = null;
}
ZipEntry ze = currentZipFile.getEntry(currentSimDataFileName);
if (wantsThisTime[masterTimeIndex]) {
InputStream is = currentZipFile.getInputStream((ZipArchiveEntry) ze);
// java.io.BufferedInputStream bis = new java.io.BufferedInputStream(is);
dis = new java.io.DataInputStream(is);
}
} else if (wantsThisTime[masterTimeIndex]) {
File file = new File(currentSimDataFileName);
FileInputStream fis = new java.io.FileInputStream(file);
dis = new java.io.DataInputStream(new java.io.BufferedInputStream(fis));
}
if (wantsThisTime[masterTimeIndex]) {
masterStreamIndex = 0;
// Read the SimDataHeader and SimdataBlock Info
// This will fail if mis-aligned in stream
FileHeader fileHeader = readFileHeader(dis);
// System.out.println(currentSimDataFileName+" numBlocks="+fileHeader.numBlocks);
DataBlock[] dataBlockList = new DataBlock[fileHeader.numBlocks];
for (int j = 0; j < fileHeader.numBlocks; j++) {
DataBlock dataBlock = new DataBlock();
// This will fail if mis-aligned in stream
incrementStreamCounts(dataBlock.readBlockHeader(dis));
// System.out.println("varName="+dataBlock.getVarName()+" Offset="+dataBlock.getDataOffset()+" type="+dataBlock.getVariableTypeInteger());
dataBlockList[j] = dataBlock;
}
// long blockTime = System.currentTimeMillis();
// System.out.println("Time for Blocks="+(blockTime-entryTime));
// Beginning of All SimData(Blocks) (All doubles) check DataBlocks in order (Always move forward in stream)
int variableFoundCount = 0;
for (int j = 0; j < dataBlockList.length; j += 1) {
boolean isBlockIndexAligned = false;
// See if current block is a variable we want
for (int k = 0; k < varNames.length; k += 1) {
if (varNames[k].equals(dataBlockList[j].getVarName())) {
variableFoundCount += 1;
// Align to beginning of current block
if (!isBlockIndexAligned) {
skip(dis, dataBlockList[j].getDataOffset() - masterStreamIndex);
isBlockIndexAligned = true;
}
double val = 0;
for (int l = 0; l < varIndexes[k].length; l += 1) {
long skip = (sortedVarIndexes[k][l][INDEX_VALUE] - (l > 0 ? sortedVarIndexes[k][l - 1][INDEX_VALUE] : 0));
// If current data offset was same as last, re-use val
if ((l == 0) || (skip != 0)) {
// Align to desired data index
skip(dis, (l == 0 ? skip : skip - 1) * 8);
val = dis.readDouble();
incrementStreamCounts(8);
}
// Store value in original order
int unSortedVarIndex = (int) sortedVarIndexes[k][l][INDEX_ORIGINAL_POSITION];
int reMappedVarNameIndex = reMapper[k][unSortedVarIndex][0];
int reMappedVarIndexIndex = reMapper[k][unSortedVarIndex][1];
// System.out.println("k="+k+" l="+l+" uvi="+unSortedVarIndex+" rvni="+reMappedVarNameIndex+" rmvii="+reMappedVarIndexIndex);
returnValues[reMappedVarNameIndex][reMappedVarIndexIndex] = val;
// System.out.println("var="+varNames[k]+" sortindex="+l+
// " unsortindex="+sortedVarIndexes[k][l][INDEX_ORIGINAL_POSITION]+" index="+sortedVarIndexes[k][l][INDEX_VALUE]+" val="+val);
}
}
}
}
if (variableFoundCount != varNames.length) {
throw new DataAccessException(this.getClass().getName() + ".getNextDataAtCurrentTime: At least 1 variable name was not found in Datablock list");
}
// long dataTime = System.currentTimeMillis();
// System.out.println("Time for data="+(dataTime-blockTime)+"\n");
}
if (dis != null) {
dis.close();
dis = null;
}
masterTimeIndex += 1;
if (masterTimeIndex >= times.length) {
close();
}
// long totalTime = System.currentTimeMillis();
// System.out.println("Total Time="+(totalTime-beginTime));
} catch (Throwable e) {
close();
throw new RuntimeException("Error reading SimData: " + (e.getMessage() != null ? e.getMessage() : e.getClass().getName()));
}
}
Aggregations