@Test public void testSchwabisch() throws Exception{ int nPoints = 200; int nHeights = 3; int degree1d = 2; int degree2d = 5; DoubleMatrix inputTile = unwrappedPhase.dup(); StopWatch watch = new StopWatch(); watch.start(); final Slant2Height slant = new Slant2Height(nPoints, nHeights, degree1d, degree2d, master, masterOrbit, slave, slaveOrbit); slant.setDataWindow(dataWindow); slant.schwabisch(); slant.applySchwabisch(tileWindow, inputTile); watch.stop(); logger.info("Total processing time for Slant2Height Schwabisch method: {} milli-seconds", watch.getElapsedTime()); Assert.assertArrayEquals(heights.toArray(), inputTile.toArray(), DELTA_02); }
public void schwabisch() throws Exception { logger.trace("slant2h Schwabisch (PM 01-Apr-2011)"); final int heightStep = MAXHEIGHT / (nHeights - 1); DoubleMatrix refPhaseMatrix = new DoubleMatrix(nPoints, nHeights); int[][] positionArray = MathUtils.distributePoints(nPoints, dataWindow); DoubleMatrix Position = new DoubleMatrix(nPoints, 2); for (int i = 0; i < nPoints; i++) { Position.put(i, 0, positionArray[i][0]); Position.put(i, 1, positionArray[i][1]); } logger.debug("S2H: schwabisch: STEP1: compute reference refPhase for nHeights."); DoubleMatrix refPhaseZero = new DoubleMatrix(nPoints); for (int heightIdx = 0; heightIdx < nHeights; heightIdx++) { int height = heightIdx * heightStep; DoubleMatrix refPhase = new DoubleMatrix(nPoints); for (int i = 0; i < nPoints; i++) { double phase = computeReferencePhase((double) positionArray[i][0], (double) positionArray[i][1], height, master, slave, masterOrbit, slaveOrbit); refPhase.put(i, phase); } if (height == 0) { refPhaseZero = refPhase; } refPhaseMatrix.putColumn(heightIdx, refPhase.sub(refPhaseZero)); } logger.debug("S2H: schwabisch: STEP2: estimate coefficients 1d polynomial."); DoubleMatrix alphas = new DoubleMatrix(nPoints, degree1D + 1); DoubleMatrix hei = new DoubleMatrix(nHeights, 1); for (int i = 0; i < nHeights; i++) { hei.put(i, 0, i * heightStep); } minPhi = refPhaseMatrix.min(); maxPhi = refPhaseMatrix.max(); normalize(refPhaseMatrix, minPhi, maxPhi); for (int i = 0; i < nPoints; i++) { alphas.putRow(i, new DoubleMatrix(polyFit(refPhaseMatrix.getRow(i), hei, degree1D))); } logger.debug("S2H: schwabisch: STEP3: estimate coefficients for 2d polynomial."); final int Nunk = PolyUtils.numberOfCoefficients(degree2D); if (nPoints < Nunk) { logger.error("slant2hschwabisch: N_observations<N_unknowns (increase S2H_NPOINTS or decrease S2H_DEGREE2D."); throw new IllegalArgumentException(); } DoubleMatrix A = new DoubleMatrix(nPoints, Nunk); double minL = dataWindow.linelo; double maxL = dataWindow.linehi; double minP = dataWindow.pixlo; double maxP = dataWindow.pixhi; for (int i = 0; i < nPoints; i++) { double posL = normalize2(Position.get(i, 0), minL, maxL); double posP = normalize2(Position.get(i, 1), minP, maxP); int index = 0; for (int j = 0; j <= degree2D; j++) { for (int k = 0; k <= j; k++) { A.put(i, index, Math.pow(posL, j - k) * Math.pow(posP, k)); index++; } } } DoubleMatrix N = matTxmat(A, A); rhs = matTxmat(A, alphas); DoubleMatrix Qx_hat = N; for (int i = 0; i < rhs.getColumns(); ++i) { DoubleMatrix rhs_alphai = rhs.getColumn(i); rhs.putColumn(i, Solve.solveSymmetric(Qx_hat, rhs_alphai)); } Qx_hat = Solve.solveSymmetric(Qx_hat, DoubleMatrix.eye(Qx_hat.getRows())); double maxdev = (N.mmul(Qx_hat).sub(DoubleMatrix.eye(Qx_hat.getRows()))).normmax(); logger.debug("s2h schwaebisch: max(abs(N*inv(N)-I)) = {}", maxdev); if (maxdev > 0.01) { logger.warn("slant2h: possibly wrong solution. deviation from unity AtA*inv(AtA) = {} > 0.01", maxdev); } }
Slant2Height { public void schwabisch() throws Exception { logger.trace("slant2h Schwabisch (PM 01-Apr-2011)"); final int heightStep = MAXHEIGHT / (nHeights - 1); DoubleMatrix refPhaseMatrix = new DoubleMatrix(nPoints, nHeights); int[][] positionArray = MathUtils.distributePoints(nPoints, dataWindow); DoubleMatrix Position = new DoubleMatrix(nPoints, 2); for (int i = 0; i < nPoints; i++) { Position.put(i, 0, positionArray[i][0]); Position.put(i, 1, positionArray[i][1]); } logger.debug("S2H: schwabisch: STEP1: compute reference refPhase for nHeights."); DoubleMatrix refPhaseZero = new DoubleMatrix(nPoints); for (int heightIdx = 0; heightIdx < nHeights; heightIdx++) { int height = heightIdx * heightStep; DoubleMatrix refPhase = new DoubleMatrix(nPoints); for (int i = 0; i < nPoints; i++) { double phase = computeReferencePhase((double) positionArray[i][0], (double) positionArray[i][1], height, master, slave, masterOrbit, slaveOrbit); refPhase.put(i, phase); } if (height == 0) { refPhaseZero = refPhase; } refPhaseMatrix.putColumn(heightIdx, refPhase.sub(refPhaseZero)); } logger.debug("S2H: schwabisch: STEP2: estimate coefficients 1d polynomial."); DoubleMatrix alphas = new DoubleMatrix(nPoints, degree1D + 1); DoubleMatrix hei = new DoubleMatrix(nHeights, 1); for (int i = 0; i < nHeights; i++) { hei.put(i, 0, i * heightStep); } minPhi = refPhaseMatrix.min(); maxPhi = refPhaseMatrix.max(); normalize(refPhaseMatrix, minPhi, maxPhi); for (int i = 0; i < nPoints; i++) { alphas.putRow(i, new DoubleMatrix(polyFit(refPhaseMatrix.getRow(i), hei, degree1D))); } logger.debug("S2H: schwabisch: STEP3: estimate coefficients for 2d polynomial."); final int Nunk = PolyUtils.numberOfCoefficients(degree2D); if (nPoints < Nunk) { logger.error("slant2hschwabisch: N_observations<N_unknowns (increase S2H_NPOINTS or decrease S2H_DEGREE2D."); throw new IllegalArgumentException(); } DoubleMatrix A = new DoubleMatrix(nPoints, Nunk); double minL = dataWindow.linelo; double maxL = dataWindow.linehi; double minP = dataWindow.pixlo; double maxP = dataWindow.pixhi; for (int i = 0; i < nPoints; i++) { double posL = normalize2(Position.get(i, 0), minL, maxL); double posP = normalize2(Position.get(i, 1), minP, maxP); int index = 0; for (int j = 0; j <= degree2D; j++) { for (int k = 0; k <= j; k++) { A.put(i, index, Math.pow(posL, j - k) * Math.pow(posP, k)); index++; } } } DoubleMatrix N = matTxmat(A, A); rhs = matTxmat(A, alphas); DoubleMatrix Qx_hat = N; for (int i = 0; i < rhs.getColumns(); ++i) { DoubleMatrix rhs_alphai = rhs.getColumn(i); rhs.putColumn(i, Solve.solveSymmetric(Qx_hat, rhs_alphai)); } Qx_hat = Solve.solveSymmetric(Qx_hat, DoubleMatrix.eye(Qx_hat.getRows())); double maxdev = (N.mmul(Qx_hat).sub(DoubleMatrix.eye(Qx_hat.getRows()))).normmax(); logger.debug("s2h schwaebisch: max(abs(N*inv(N)-I)) = {}", maxdev); if (maxdev > 0.01) { logger.warn("slant2h: possibly wrong solution. deviation from unity AtA*inv(AtA) = {} > 0.01", maxdev); } } }
Slant2Height { public void schwabisch() throws Exception { logger.trace("slant2h Schwabisch (PM 01-Apr-2011)"); final int heightStep = MAXHEIGHT / (nHeights - 1); DoubleMatrix refPhaseMatrix = new DoubleMatrix(nPoints, nHeights); int[][] positionArray = MathUtils.distributePoints(nPoints, dataWindow); DoubleMatrix Position = new DoubleMatrix(nPoints, 2); for (int i = 0; i < nPoints; i++) { Position.put(i, 0, positionArray[i][0]); Position.put(i, 1, positionArray[i][1]); } logger.debug("S2H: schwabisch: STEP1: compute reference refPhase for nHeights."); DoubleMatrix refPhaseZero = new DoubleMatrix(nPoints); for (int heightIdx = 0; heightIdx < nHeights; heightIdx++) { int height = heightIdx * heightStep; DoubleMatrix refPhase = new DoubleMatrix(nPoints); for (int i = 0; i < nPoints; i++) { double phase = computeReferencePhase((double) positionArray[i][0], (double) positionArray[i][1], height, master, slave, masterOrbit, slaveOrbit); refPhase.put(i, phase); } if (height == 0) { refPhaseZero = refPhase; } refPhaseMatrix.putColumn(heightIdx, refPhase.sub(refPhaseZero)); } logger.debug("S2H: schwabisch: STEP2: estimate coefficients 1d polynomial."); DoubleMatrix alphas = new DoubleMatrix(nPoints, degree1D + 1); DoubleMatrix hei = new DoubleMatrix(nHeights, 1); for (int i = 0; i < nHeights; i++) { hei.put(i, 0, i * heightStep); } minPhi = refPhaseMatrix.min(); maxPhi = refPhaseMatrix.max(); normalize(refPhaseMatrix, minPhi, maxPhi); for (int i = 0; i < nPoints; i++) { alphas.putRow(i, new DoubleMatrix(polyFit(refPhaseMatrix.getRow(i), hei, degree1D))); } logger.debug("S2H: schwabisch: STEP3: estimate coefficients for 2d polynomial."); final int Nunk = PolyUtils.numberOfCoefficients(degree2D); if (nPoints < Nunk) { logger.error("slant2hschwabisch: N_observations<N_unknowns (increase S2H_NPOINTS or decrease S2H_DEGREE2D."); throw new IllegalArgumentException(); } DoubleMatrix A = new DoubleMatrix(nPoints, Nunk); double minL = dataWindow.linelo; double maxL = dataWindow.linehi; double minP = dataWindow.pixlo; double maxP = dataWindow.pixhi; for (int i = 0; i < nPoints; i++) { double posL = normalize2(Position.get(i, 0), minL, maxL); double posP = normalize2(Position.get(i, 1), minP, maxP); int index = 0; for (int j = 0; j <= degree2D; j++) { for (int k = 0; k <= j; k++) { A.put(i, index, Math.pow(posL, j - k) * Math.pow(posP, k)); index++; } } } DoubleMatrix N = matTxmat(A, A); rhs = matTxmat(A, alphas); DoubleMatrix Qx_hat = N; for (int i = 0; i < rhs.getColumns(); ++i) { DoubleMatrix rhs_alphai = rhs.getColumn(i); rhs.putColumn(i, Solve.solveSymmetric(Qx_hat, rhs_alphai)); } Qx_hat = Solve.solveSymmetric(Qx_hat, DoubleMatrix.eye(Qx_hat.getRows())); double maxdev = (N.mmul(Qx_hat).sub(DoubleMatrix.eye(Qx_hat.getRows()))).normmax(); logger.debug("s2h schwaebisch: max(abs(N*inv(N)-I)) = {}", maxdev); if (maxdev > 0.01) { logger.warn("slant2h: possibly wrong solution. deviation from unity AtA*inv(AtA) = {} > 0.01", maxdev); } } Slant2Height(int nPoints, int nHeights, int degree1d, int degree2d,
                        SLCImage master, Orbit masterOrbit, SLCImage slave, Orbit slaveOrbit); }
Slant2Height { public void schwabisch() throws Exception { logger.trace("slant2h Schwabisch (PM 01-Apr-2011)"); final int heightStep = MAXHEIGHT / (nHeights - 1); DoubleMatrix refPhaseMatrix = new DoubleMatrix(nPoints, nHeights); int[][] positionArray = MathUtils.distributePoints(nPoints, dataWindow); DoubleMatrix Position = new DoubleMatrix(nPoints, 2); for (int i = 0; i < nPoints; i++) { Position.put(i, 0, positionArray[i][0]); Position.put(i, 1, positionArray[i][1]); } logger.debug("S2H: schwabisch: STEP1: compute reference refPhase for nHeights."); DoubleMatrix refPhaseZero = new DoubleMatrix(nPoints); for (int heightIdx = 0; heightIdx < nHeights; heightIdx++) { int height = heightIdx * heightStep; DoubleMatrix refPhase = new DoubleMatrix(nPoints); for (int i = 0; i < nPoints; i++) { double phase = computeReferencePhase((double) positionArray[i][0], (double) positionArray[i][1], height, master, slave, masterOrbit, slaveOrbit); refPhase.put(i, phase); } if (height == 0) { refPhaseZero = refPhase; } refPhaseMatrix.putColumn(heightIdx, refPhase.sub(refPhaseZero)); } logger.debug("S2H: schwabisch: STEP2: estimate coefficients 1d polynomial."); DoubleMatrix alphas = new DoubleMatrix(nPoints, degree1D + 1); DoubleMatrix hei = new DoubleMatrix(nHeights, 1); for (int i = 0; i < nHeights; i++) { hei.put(i, 0, i * heightStep); } minPhi = refPhaseMatrix.min(); maxPhi = refPhaseMatrix.max(); normalize(refPhaseMatrix, minPhi, maxPhi); for (int i = 0; i < nPoints; i++) { alphas.putRow(i, new DoubleMatrix(polyFit(refPhaseMatrix.getRow(i), hei, degree1D))); } logger.debug("S2H: schwabisch: STEP3: estimate coefficients for 2d polynomial."); final int Nunk = PolyUtils.numberOfCoefficients(degree2D); if (nPoints < Nunk) { logger.error("slant2hschwabisch: N_observations<N_unknowns (increase S2H_NPOINTS or decrease S2H_DEGREE2D."); throw new IllegalArgumentException(); } DoubleMatrix A = new DoubleMatrix(nPoints, Nunk); double minL = dataWindow.linelo; double maxL = dataWindow.linehi; double minP = dataWindow.pixlo; double maxP = dataWindow.pixhi; for (int i = 0; i < nPoints; i++) { double posL = normalize2(Position.get(i, 0), minL, maxL); double posP = normalize2(Position.get(i, 1), minP, maxP); int index = 0; for (int j = 0; j <= degree2D; j++) { for (int k = 0; k <= j; k++) { A.put(i, index, Math.pow(posL, j - k) * Math.pow(posP, k)); index++; } } } DoubleMatrix N = matTxmat(A, A); rhs = matTxmat(A, alphas); DoubleMatrix Qx_hat = N; for (int i = 0; i < rhs.getColumns(); ++i) { DoubleMatrix rhs_alphai = rhs.getColumn(i); rhs.putColumn(i, Solve.solveSymmetric(Qx_hat, rhs_alphai)); } Qx_hat = Solve.solveSymmetric(Qx_hat, DoubleMatrix.eye(Qx_hat.getRows())); double maxdev = (N.mmul(Qx_hat).sub(DoubleMatrix.eye(Qx_hat.getRows()))).normmax(); logger.debug("s2h schwaebisch: max(abs(N*inv(N)-I)) = {}", maxdev); if (maxdev > 0.01) { logger.warn("slant2h: possibly wrong solution. deviation from unity AtA*inv(AtA) = {} > 0.01", maxdev); } } Slant2Height(int nPoints, int nHeights, int degree1d, int degree2d,
                        SLCImage master, Orbit masterOrbit, SLCImage slave, Orbit slaveOrbit); synchronized void setTile(DoubleMatrix tile); synchronized void setTileWindow(Window window); void setDataWindow(Window window); Window getTileWindow(); DoubleMatrix getTile(); void schwabisch(); void applySchwabisch(final Window tileWindow, DoubleMatrix tile); @Deprecated void schwabischTotal(); }
Slant2Height { public void schwabisch() throws Exception { logger.trace("slant2h Schwabisch (PM 01-Apr-2011)"); final int heightStep = MAXHEIGHT / (nHeights - 1); DoubleMatrix refPhaseMatrix = new DoubleMatrix(nPoints, nHeights); int[][] positionArray = MathUtils.distributePoints(nPoints, dataWindow); DoubleMatrix Position = new DoubleMatrix(nPoints, 2); for (int i = 0; i < nPoints; i++) { Position.put(i, 0, positionArray[i][0]); Position.put(i, 1, positionArray[i][1]); } logger.debug("S2H: schwabisch: STEP1: compute reference refPhase for nHeights."); DoubleMatrix refPhaseZero = new DoubleMatrix(nPoints); for (int heightIdx = 0; heightIdx < nHeights; heightIdx++) { int height = heightIdx * heightStep; DoubleMatrix refPhase = new DoubleMatrix(nPoints); for (int i = 0; i < nPoints; i++) { double phase = computeReferencePhase((double) positionArray[i][0], (double) positionArray[i][1], height, master, slave, masterOrbit, slaveOrbit); refPhase.put(i, phase); } if (height == 0) { refPhaseZero = refPhase; } refPhaseMatrix.putColumn(heightIdx, refPhase.sub(refPhaseZero)); } logger.debug("S2H: schwabisch: STEP2: estimate coefficients 1d polynomial."); DoubleMatrix alphas = new DoubleMatrix(nPoints, degree1D + 1); DoubleMatrix hei = new DoubleMatrix(nHeights, 1); for (int i = 0; i < nHeights; i++) { hei.put(i, 0, i * heightStep); } minPhi = refPhaseMatrix.min(); maxPhi = refPhaseMatrix.max(); normalize(refPhaseMatrix, minPhi, maxPhi); for (int i = 0; i < nPoints; i++) { alphas.putRow(i, new DoubleMatrix(polyFit(refPhaseMatrix.getRow(i), hei, degree1D))); } logger.debug("S2H: schwabisch: STEP3: estimate coefficients for 2d polynomial."); final int Nunk = PolyUtils.numberOfCoefficients(degree2D); if (nPoints < Nunk) { logger.error("slant2hschwabisch: N_observations<N_unknowns (increase S2H_NPOINTS or decrease S2H_DEGREE2D."); throw new IllegalArgumentException(); } DoubleMatrix A = new DoubleMatrix(nPoints, Nunk); double minL = dataWindow.linelo; double maxL = dataWindow.linehi; double minP = dataWindow.pixlo; double maxP = dataWindow.pixhi; for (int i = 0; i < nPoints; i++) { double posL = normalize2(Position.get(i, 0), minL, maxL); double posP = normalize2(Position.get(i, 1), minP, maxP); int index = 0; for (int j = 0; j <= degree2D; j++) { for (int k = 0; k <= j; k++) { A.put(i, index, Math.pow(posL, j - k) * Math.pow(posP, k)); index++; } } } DoubleMatrix N = matTxmat(A, A); rhs = matTxmat(A, alphas); DoubleMatrix Qx_hat = N; for (int i = 0; i < rhs.getColumns(); ++i) { DoubleMatrix rhs_alphai = rhs.getColumn(i); rhs.putColumn(i, Solve.solveSymmetric(Qx_hat, rhs_alphai)); } Qx_hat = Solve.solveSymmetric(Qx_hat, DoubleMatrix.eye(Qx_hat.getRows())); double maxdev = (N.mmul(Qx_hat).sub(DoubleMatrix.eye(Qx_hat.getRows()))).normmax(); logger.debug("s2h schwaebisch: max(abs(N*inv(N)-I)) = {}", maxdev); if (maxdev > 0.01) { logger.warn("slant2h: possibly wrong solution. deviation from unity AtA*inv(AtA) = {} > 0.01", maxdev); } } Slant2Height(int nPoints, int nHeights, int degree1d, int degree2d,
                        SLCImage master, Orbit masterOrbit, SLCImage slave, Orbit slaveOrbit); synchronized void setTile(DoubleMatrix tile); synchronized void setTileWindow(Window window); void setDataWindow(Window window); Window getTileWindow(); DoubleMatrix getTile(); void schwabisch(); void applySchwabisch(final Window tileWindow, DoubleMatrix tile); @Deprecated void schwabischTotal();  }