Gianpaolo Coro 2014-02-26 15:55:38 +00:00
parent 0cb1b7941b
commit 4910092ee2
1 changed files with 35 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import ucar.ma2.ArrayByte;
import ucar.ma2.ArrayDouble;
import ucar.ma2.IndexIterator;
public class VectorTransformations {
public class VectorOperations {
public static ArrayDouble.D2 arrayByte2DArrayDouble(ArrayByte bytes) {
int[] shapeD = bytes.getShape();
@ -62,6 +62,9 @@ public class VectorTransformations {
valuesForGrid.add(Double.NaN);
}
// AnalysisLogger.getLogger().debug("Grid contains: "+grid3d.size()+" values");
// AnalysisLogger.getLogger().debug("Dataset contains: "+coordinates5d.size()+" values");
for (Tuple<Double> coord5d : coordinates5d) {
double rx = coord5d.getElements().get(0);
double ry = coord5d.getElements().get(1);
@ -92,4 +95,35 @@ public class VectorTransformations {
return Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2)) + ((t1 - t2) * (t1 - t2)));
}
public static List<Tuple<Double>> generateCoordinateTripletsInBoundingBox(double x1, double x2, double y1, double y2, double z, double xResolution, double yResolution) {
int ysteps = (int) ((y2 - y1) / yResolution);
int xsteps = (int) ((x2 - x1) / xResolution);
List<Tuple<Double>> tuples = new ArrayList<Tuple<Double>>();
AnalysisLogger.getLogger().debug("Building the points grid according to YRes:" + yResolution + " and XRes:" + xResolution);
// build the tuples according to the desired resolution
for (int i = 0; i < ysteps + 1; i++) {
double y = (i * yResolution) + y1;
if (i == ysteps)
y = y2;
for (int j = 0; j < xsteps + 1; j++) {
double x = (j * xResolution) + x1;
if (j == xsteps)
x = x2;
tuples.add(new Tuple<Double>(x, y, z));
}
}
return tuples;
}
public void applyNearestNeighbor() {
/*
* AnalysisLogger.getLogger().debug("Applying nearest Neighbor to all the rows"); //apply nearest neighbor to each row AlgorithmConfiguration config = new AlgorithmConfiguration(); config.setConfigPath(configDir); boolean rapidinit = false;
*
*
* for (int i=0;i<slice.length;i++){ // AnalysisLogger.getLogger().debug("Checking for unfilled values"); boolean tofill = false; for (int j=0;j<slice[i].length;j++) { if (new Double(slice[i][j]).equals(Double.NaN)) tofill = true; } if (tofill){ if (!rapidinit){ config.initRapidMiner(); rapidinit=true; } AnalysisLogger.getLogger().debug("Filling signal"); double[] ssliced = SignalProcessing.fillSignal(slice[i]); slice[i] = ssliced; } // else // AnalysisLogger.getLogger().debug("Signal yet complete"); }
*/
}
}