@Test public void testCoherence2() throws Exception { String fileTestDataName_1 = testDataLocationCoh + "CINT_input" + ".cr4.swap"; String fileTestDataName_2 = testDataLocationCoh + "NORMS_input" + ".cr4.swap"; final int nRows = 128; final int nCols = 512; final ComplexDoubleMatrix masterCplx = readCplxFloatData(fileTestDataName_1, nRows, nCols); final ComplexDoubleMatrix slaveCplx = readCplxFloatData(fileTestDataName_2, nRows, nCols); final int[] cohWinAz = new int[]{2, 10, 10, 20}; final int[] cohWinRg = new int[]{2, 2, 10, 4}; for (int i = 0; i < cohWinAz.length; i++) { int winAz = cohWinAz[i]; int winRg = cohWinRg[i]; DoubleMatrix coh_ACTUAL = SarUtils.coherence2(masterCplx, slaveCplx, winAz, winRg); int cohRows = coh_ACTUAL.rows; int cohCols = coh_ACTUAL.columns; String fileName = testDataLocationCoh + "coherence_output_" + winAz + "_" + winRg + ".r4.swap"; FloatMatrix coh_EXPECTED = readFloatData(fileName, cohRows, cohCols); Assert.assertArrayEquals(coh_EXPECTED.toArray(), coh_ACTUAL.toFloat().toArray(), (float) DELTA_04); } }
public static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP) { logger.trace("coherence ver #2"); if (!(winL >= winP)) { logger.warn("coherence: estimator window size L<P not very efficiently programmed."); } if (input.rows != norms.rows || input.rows != input.rows) { logger.error("coherence: not same dimensions."); throw new IllegalArgumentException("coherence: not the same dimensions."); } final int extent_RG = input.columns; final int extent_AZ = input.rows - winL + 1; DoubleMatrix result = new DoubleMatrix(input.rows - winL + 1, input.columns - winP + 1); int i, j, k, l; ComplexDouble sum; ComplexDouble power; int leadingZeros = (winP - 1) / 2; int trailingZeros = (winP) / 2; for (j = leadingZeros; j < extent_RG - trailingZeros; j++) { sum = new ComplexDouble(0); power = new ComplexDouble(0); for (k = 0; k < winL; k++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(k, l)); power.addi(norms.get(k, l)); } } result.put(0, j - leadingZeros, coherenceProduct(sum, power)); for (i = 0; i < extent_AZ - 1; i++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(i + winL, l).sub(input.get(i, l))); power.addi(norms.get(i + winL, l).sub(norms.get(i, l))); } result.put(i + 1, j - leadingZeros, coherenceProduct(sum, power)); } } return result; }
SarUtils { public static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP) { logger.trace("coherence ver #2"); if (!(winL >= winP)) { logger.warn("coherence: estimator window size L<P not very efficiently programmed."); } if (input.rows != norms.rows || input.rows != input.rows) { logger.error("coherence: not same dimensions."); throw new IllegalArgumentException("coherence: not the same dimensions."); } final int extent_RG = input.columns; final int extent_AZ = input.rows - winL + 1; DoubleMatrix result = new DoubleMatrix(input.rows - winL + 1, input.columns - winP + 1); int i, j, k, l; ComplexDouble sum; ComplexDouble power; int leadingZeros = (winP - 1) / 2; int trailingZeros = (winP) / 2; for (j = leadingZeros; j < extent_RG - trailingZeros; j++) { sum = new ComplexDouble(0); power = new ComplexDouble(0); for (k = 0; k < winL; k++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(k, l)); power.addi(norms.get(k, l)); } } result.put(0, j - leadingZeros, coherenceProduct(sum, power)); for (i = 0; i < extent_AZ - 1; i++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(i + winL, l).sub(input.get(i, l))); power.addi(norms.get(i + winL, l).sub(norms.get(i, l))); } result.put(i + 1, j - leadingZeros, coherenceProduct(sum, power)); } } return result; } }
SarUtils { public static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP) { logger.trace("coherence ver #2"); if (!(winL >= winP)) { logger.warn("coherence: estimator window size L<P not very efficiently programmed."); } if (input.rows != norms.rows || input.rows != input.rows) { logger.error("coherence: not same dimensions."); throw new IllegalArgumentException("coherence: not the same dimensions."); } final int extent_RG = input.columns; final int extent_AZ = input.rows - winL + 1; DoubleMatrix result = new DoubleMatrix(input.rows - winL + 1, input.columns - winP + 1); int i, j, k, l; ComplexDouble sum; ComplexDouble power; int leadingZeros = (winP - 1) / 2; int trailingZeros = (winP) / 2; for (j = leadingZeros; j < extent_RG - trailingZeros; j++) { sum = new ComplexDouble(0); power = new ComplexDouble(0); for (k = 0; k < winL; k++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(k, l)); power.addi(norms.get(k, l)); } } result.put(0, j - leadingZeros, coherenceProduct(sum, power)); for (i = 0; i < extent_AZ - 1; i++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(i + winL, l).sub(input.get(i, l))); power.addi(norms.get(i + winL, l).sub(norms.get(i, l))); } result.put(i + 1, j - leadingZeros, coherenceProduct(sum, power)); } } return result; }  }
SarUtils { public static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP) { logger.trace("coherence ver #2"); if (!(winL >= winP)) { logger.warn("coherence: estimator window size L<P not very efficiently programmed."); } if (input.rows != norms.rows || input.rows != input.rows) { logger.error("coherence: not same dimensions."); throw new IllegalArgumentException("coherence: not the same dimensions."); } final int extent_RG = input.columns; final int extent_AZ = input.rows - winL + 1; DoubleMatrix result = new DoubleMatrix(input.rows - winL + 1, input.columns - winP + 1); int i, j, k, l; ComplexDouble sum; ComplexDouble power; int leadingZeros = (winP - 1) / 2; int trailingZeros = (winP) / 2; for (j = leadingZeros; j < extent_RG - trailingZeros; j++) { sum = new ComplexDouble(0); power = new ComplexDouble(0); for (k = 0; k < winL; k++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(k, l)); power.addi(norms.get(k, l)); } } result.put(0, j - leadingZeros, coherenceProduct(sum, power)); for (i = 0; i < extent_AZ - 1; i++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(i + winL, l).sub(input.get(i, l))); power.addi(norms.get(i + winL, l).sub(norms.get(i, l))); } result.put(i + 1, j - leadingZeros, coherenceProduct(sum, power)); } } return result; }  static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol); static DoubleMatrix intensity(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix magnitude(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix angle(final ComplexDoubleMatrix cplxData); @Deprecated static DoubleMatrix coherence(final ComplexDoubleMatrix inputMatrix, final ComplexDoubleMatrix normsMatrix, final int winL, final int winP); static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP); static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static void computeIfg_inplace(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData,
                                                 final int ovsFactorAz, final int ovsFactorRg); }
SarUtils { public static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP) { logger.trace("coherence ver #2"); if (!(winL >= winP)) { logger.warn("coherence: estimator window size L<P not very efficiently programmed."); } if (input.rows != norms.rows || input.rows != input.rows) { logger.error("coherence: not same dimensions."); throw new IllegalArgumentException("coherence: not the same dimensions."); } final int extent_RG = input.columns; final int extent_AZ = input.rows - winL + 1; DoubleMatrix result = new DoubleMatrix(input.rows - winL + 1, input.columns - winP + 1); int i, j, k, l; ComplexDouble sum; ComplexDouble power; int leadingZeros = (winP - 1) / 2; int trailingZeros = (winP) / 2; for (j = leadingZeros; j < extent_RG - trailingZeros; j++) { sum = new ComplexDouble(0); power = new ComplexDouble(0); for (k = 0; k < winL; k++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(k, l)); power.addi(norms.get(k, l)); } } result.put(0, j - leadingZeros, coherenceProduct(sum, power)); for (i = 0; i < extent_AZ - 1; i++) { for (l = j - leadingZeros; l < j - leadingZeros + winP; l++) { sum.addi(input.get(i + winL, l).sub(input.get(i, l))); power.addi(norms.get(i + winL, l).sub(norms.get(i, l))); } result.put(i + 1, j - leadingZeros, coherenceProduct(sum, power)); } } return result; }  static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol); static DoubleMatrix intensity(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix magnitude(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix angle(final ComplexDoubleMatrix cplxData); @Deprecated static DoubleMatrix coherence(final ComplexDoubleMatrix inputMatrix, final ComplexDoubleMatrix normsMatrix, final int winL, final int winP); static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP); static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static void computeIfg_inplace(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData,
                                                 final int ovsFactorAz, final int ovsFactorRg);  }