use of org.jlinda.core.geom.TopoPhase in project s1tbx by senbox-org.
the class InterferogramOp method computeTileStackForNormalProduct.
private void computeTileStackForNormalProduct(final Map<Band, Tile> targetTileMap, Rectangle targetRectangle, final ProgressMonitor pm) throws OperatorException {
try {
final BorderExtender border = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
final int y0 = targetRectangle.y;
final int yN = y0 + targetRectangle.height - 1;
final int x0 = targetRectangle.x;
final int xN = targetRectangle.x + targetRectangle.width - 1;
final Window tileWindow = new Window(y0, yN, x0, xN);
DemTile demTile = null;
if (subtractTopographicPhase) {
demTile = TopoPhase.getDEMTile(tileWindow, targetMap, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
if (demTile.getData().length < 3 || demTile.getData()[0].length < 3) {
throw new OperatorException("The resolution of the selected DEM is too low, " + "please select DEM with higher resolution.");
}
}
// parameters for coherence calculation
final int cohx0 = targetRectangle.x - (cohWinRg - 1) / 2;
final int cohy0 = targetRectangle.y - (cohWinAz - 1) / 2;
final int cohw = targetRectangle.width + cohWinRg - 1;
final int cohh = targetRectangle.height + cohWinAz - 1;
final Rectangle rect = new Rectangle(cohx0, cohy0, cohw, cohh);
final Window cohTileWindow = new Window(cohy0, cohy0 + cohh - 1, cohx0, cohx0 + cohw - 1);
DemTile cohDemTile = null;
if (subtractTopographicPhase) {
cohDemTile = TopoPhase.getDEMTile(cohTileWindow, targetMap, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
}
for (String ifgKey : targetMap.keySet()) {
final ProductContainer product = targetMap.get(ifgKey);
final Tile mstTileReal = getSourceTile(product.sourceMaster.realBand, targetRectangle, border);
final Tile mstTileImag = getSourceTile(product.sourceMaster.imagBand, targetRectangle, border);
final ComplexDoubleMatrix dataMaster = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal, mstTileImag);
final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, targetRectangle, border);
final Tile slvTileImag = getSourceTile(product.sourceSlave.imagBand, targetRectangle, border);
final ComplexDoubleMatrix dataSlave = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal, slvTileImag);
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(x0, xN, dataMaster.columns, y0, yN, dataMaster.rows, 0, sourceImageWidth - 1, 0, sourceImageHeight - 1, product.sourceSlave.name);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave.muli(complexReferencePhase);
if (OUTPUT_PHASE) {
saveFlatEarthPhase(x0, xN, y0, yN, flatEarthPhase, product, targetTileMap);
}
}
if (subtractTopographicPhase) {
final TopoPhase topoPhase = TopoPhase.computeTopoPhase(product, tileWindow, demTile, outputElevation, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave.muli(ComplexTopoPhase);
if (OUTPUT_PHASE) {
saveTopoPhase(x0, xN, y0, yN, topoPhase.demPhase, product, targetTileMap);
}
if (outputElevation) {
saveElevation(x0, xN, y0, yN, topoPhase.elevation, product, targetTileMap);
}
if (outputLatLon) {
final TopoPhase topoPhase1 = TopoPhase.computeTopoPhase(product, tileWindow, demTile, false, true);
saveLatLon(x0, xN, y0, yN, topoPhase1.latitude, topoPhase1.longitude, product, targetTileMap);
}
}
dataMaster.muli(dataSlave.conji());
saveInterferogram(dataMaster, product, targetTileMap, targetRectangle);
// coherence calculation
if (includeCoherence) {
final Tile mstTileReal2 = getSourceTile(product.sourceMaster.realBand, rect, border);
final Tile mstTileImag2 = getSourceTile(product.sourceMaster.imagBand, rect, border);
final Tile slvTileReal2 = getSourceTile(product.sourceSlave.realBand, rect, border);
final Tile slvTileImag2 = getSourceTile(product.sourceSlave.imagBand, rect, border);
final ComplexDoubleMatrix dataMaster2 = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal2, mstTileImag2);
final ComplexDoubleMatrix dataSlave2 = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal2, slvTileImag2);
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(cohx0, cohx0 + cohw - 1, cohw, cohy0, cohy0 + cohh - 1, cohh, 0, sourceImageWidth - 1, 0, sourceImageHeight - 1, product.sourceSlave.name);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave2.muli(complexReferencePhase);
}
if (subtractTopographicPhase) {
final TopoPhase topoPhase = TopoPhase.computeTopoPhase(product, cohTileWindow, cohDemTile, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave2.muli(ComplexTopoPhase);
}
for (int i = 0; i < dataMaster2.length; i++) {
double tmp = norm(dataMaster2.get(i));
dataMaster2.put(i, dataMaster2.get(i).mul(dataSlave2.get(i).conj()));
dataSlave2.put(i, new ComplexDouble(norm(dataSlave2.get(i)), tmp));
}
DoubleMatrix cohMatrix = SarUtils.coherence2(dataMaster2, dataSlave2, cohWinAz, cohWinRg);
saveCoherence(cohMatrix, product, targetTileMap, targetRectangle);
}
}
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
} finally {
pm.done();
}
}
use of org.jlinda.core.geom.TopoPhase in project s1tbx by senbox-org.
the class CoherenceOp method computePartialTile.
private void computePartialTile(final int subSwathIndex, final int burstIndex, final int firstLineIdx, final Rectangle targetRectangle, final Map<Band, Tile> targetTileMap) throws OperatorException {
try {
final BorderExtender border = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
final int y0 = targetRectangle.y;
final int yN = y0 + targetRectangle.height - 1;
final int x0 = targetRectangle.x;
final int xN = x0 + targetRectangle.width - 1;
final int cohx0 = targetRectangle.x - (cohWinRg - 1) / 2;
final int cohy0 = targetRectangle.y - (cohWinAz - 1) / 2;
final int cohw = targetRectangle.width + cohWinRg - 1;
final int cohh = targetRectangle.height + cohWinAz - 1;
final Rectangle extRect = new Rectangle(cohx0, cohy0, cohw, cohh);
final org.jlinda.core.Window tileWindow = new org.jlinda.core.Window(cohy0 - firstLineIdx, cohy0 + cohh - 1 - firstLineIdx, cohx0, cohx0 + cohw - 1);
final SLCImage mstMeta = targetMap.values().iterator().next().sourceMaster.metaData.clone();
updateMstMetaData(burstIndex, mstMeta);
final Orbit mstOrbit = targetMap.values().iterator().next().sourceMaster.orbit;
DemTile demTile = null;
if (subtractTopographicPhase) {
demTile = TopoPhase.getDEMTile(tileWindow, mstMeta, mstOrbit, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
if (demTile == null) {
throw new OperatorException("The selected DEM has no overlap with the image or is invalid.");
}
if (demTile.getData().length < 3 || demTile.getData()[0].length < 3) {
throw new OperatorException("The resolution of the selected DEM is too low, " + "please select DEM with higher resolution.");
}
}
final int minLine = 0;
final int maxLine = subSwath[subSwathIndex - 1].linesPerBurst - 1;
final int minPixel = 0;
final int maxPixel = subSwath[subSwathIndex - 1].samplesPerBurst - 1;
for (String cohKey : targetMap.keySet()) {
final ProductContainer product = targetMap.get(cohKey);
final SLCImage slvMeta = product.sourceSlave.metaData.clone();
updateSlvMetaData(product, burstIndex, slvMeta);
final Orbit slvOrbit = product.sourceSlave.orbit;
final Tile mstTileReal = getSourceTile(product.sourceMaster.realBand, extRect, border);
final Tile mstTileImag = getSourceTile(product.sourceMaster.imagBand, extRect, border);
final ComplexDoubleMatrix dataMaster = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal, mstTileImag);
final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, extRect, border);
final Tile slvTileImag = getSourceTile(product.sourceSlave.imagBand, extRect, border);
final ComplexDoubleMatrix dataSlave = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal, slvTileImag);
final String polynomialName = product.sourceSlave.name + '_' + (subSwathIndex - 1) + '_' + burstIndex;
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(cohx0, cohx0 + cohw - 1, cohw, cohy0 - firstLineIdx, cohy0 + cohh - 1 - firstLineIdx, cohh, minPixel, maxPixel, minLine, maxLine, polynomialName);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave.muli(complexReferencePhase);
if (OUTPUT_PHASE) {
saveFlatEarthPhase(x0, xN, y0, yN, flatEarthPhase, product, targetTileMap);
}
}
if (subtractTopographicPhase) {
TopoPhase topoPhase = TopoPhase.computeTopoPhase(mstMeta, mstOrbit, slvMeta, slvOrbit, tileWindow, demTile, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave.muli(ComplexTopoPhase);
if (OUTPUT_PHASE) {
saveTopoPhase(x0, xN, y0, yN, topoPhase.demPhase, product, targetTileMap);
}
}
for (int i = 0; i < dataMaster.length; i++) {
double tmp = norm(dataMaster.get(i));
dataMaster.put(i, dataMaster.get(i).mul(dataSlave.get(i).conj()));
dataSlave.put(i, new ComplexDouble(norm(dataSlave.get(i)), tmp));
}
DoubleMatrix cohMatrix = SarUtils.coherence2(dataMaster, dataSlave, cohWinAz, cohWinRg);
saveCoherence(cohMatrix, product, targetTileMap, targetRectangle);
}
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
}
}
use of org.jlinda.core.geom.TopoPhase in project s1tbx by senbox-org.
the class CoherenceOp method computeTileForNormalProduct.
private void computeTileForNormalProduct(final Map<Band, Tile> targetTileMap, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
try {
final BorderExtender border = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
final int y0 = targetRectangle.y;
final int yN = y0 + targetRectangle.height - 1;
final int x0 = targetRectangle.x;
final int xN = targetRectangle.x + targetRectangle.width - 1;
// System.out.println("x0 = " + x0 +", y0 = " + y0 + ", w = " + targetRectangle.width + ", h = " + targetRectangle.height);
final int cohx0 = targetRectangle.x - (cohWinRg - 1) / 2;
final int cohy0 = targetRectangle.y - (cohWinAz - 1) / 2;
final int cohw = targetRectangle.width + cohWinRg - 1;
final int cohh = targetRectangle.height + cohWinAz - 1;
final Rectangle extRect = new Rectangle(cohx0, cohy0, cohw, cohh);
final org.jlinda.core.Window tileWindow = new org.jlinda.core.Window(cohy0, cohy0 + cohh - 1, cohx0, cohx0 + cohw - 1);
DemTile demTile = null;
if (subtractTopographicPhase) {
demTile = TopoPhase.getDEMTile(tileWindow, targetMap, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
if (demTile.getData().length < 3 || demTile.getData()[0].length < 3) {
throw new OperatorException("The resolution of the selected DEM is too low, " + "please select DEM with higher resolution.");
}
}
for (String cohKey : targetMap.keySet()) {
final ProductContainer product = targetMap.get(cohKey);
final Tile mstTileReal = getSourceTile(product.sourceMaster.realBand, extRect, border);
final Tile mstTileImag = getSourceTile(product.sourceMaster.imagBand, extRect, border);
final ComplexDoubleMatrix dataMaster = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal, mstTileImag);
final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, extRect, border);
final Tile slvTileImag = getSourceTile(product.sourceSlave.imagBand, extRect, border);
final ComplexDoubleMatrix dataSlave = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal, slvTileImag);
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(cohx0, cohx0 + cohw - 1, cohw, cohy0, cohy0 + cohh - 1, cohh, 0, sourceImageWidth - 1, 0, sourceImageHeight - 1, product.sourceSlave.name);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave.muli(complexReferencePhase);
if (OUTPUT_PHASE) {
saveFlatEarthPhase(x0, xN, y0, yN, flatEarthPhase, product, targetTileMap);
}
}
if (subtractTopographicPhase) {
final TopoPhase topoPhase = TopoPhase.computeTopoPhase(product, tileWindow, demTile, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave.muli(ComplexTopoPhase);
if (OUTPUT_PHASE) {
saveTopoPhase(x0, xN, y0, yN, topoPhase.demPhase, product, targetTileMap);
}
}
for (int i = 0; i < dataMaster.length; i++) {
double tmp = norm(dataMaster.get(i));
dataMaster.put(i, dataMaster.get(i).mul(dataSlave.get(i).conj()));
dataSlave.put(i, new ComplexDouble(norm(dataSlave.get(i)), tmp));
}
DoubleMatrix cohMatrix = SarUtils.coherence2(dataMaster, dataSlave, cohWinAz, cohWinRg);
saveCoherence(cohMatrix, product, targetTileMap, targetRectangle);
}
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
} finally {
pm.done();
}
}
use of org.jlinda.core.geom.TopoPhase in project s1tbx by senbox-org.
the class InterferogramOp method computePartialTile.
private void computePartialTile(final int subSwathIndex, final int burstIndex, final int firstLineIdx, final Rectangle targetRectangle, final Map<Band, Tile> targetTileMap) {
try {
final BorderExtender border = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
final int y0 = targetRectangle.y;
final int yN = y0 + targetRectangle.height - 1;
final int x0 = targetRectangle.x;
final int xN = x0 + targetRectangle.width - 1;
final Window tileWindow = new Window(y0 - firstLineIdx, yN - firstLineIdx, x0, xN);
final SLCImage mstMeta = targetMap.values().iterator().next().sourceMaster.metaData.clone();
updateMstMetaData(burstIndex, mstMeta);
final Orbit mstOrbit = targetMap.values().iterator().next().sourceMaster.orbit;
DemTile demTile = null;
if (subtractTopographicPhase) {
demTile = TopoPhase.getDEMTile(tileWindow, mstMeta, mstOrbit, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
if (demTile == null) {
throw new OperatorException("The selected DEM has no overlap with the image or is invalid.");
}
if (demTile.getData().length < 3 || demTile.getData()[0].length < 3) {
throw new OperatorException("The resolution of the selected DEM is too low, " + "please select DEM with higher resolution.");
}
}
final int cohx0 = targetRectangle.x - (cohWinRg - 1) / 2;
final int cohy0 = targetRectangle.y - (cohWinAz - 1) / 2;
final int cohw = targetRectangle.width + cohWinRg - 1;
final int cohh = targetRectangle.height + cohWinAz - 1;
final Rectangle rect = new Rectangle(cohx0, cohy0, cohw, cohh);
final Window cohTileWindow = new Window(cohy0 - firstLineIdx, cohy0 + cohh - 1 - firstLineIdx, cohx0, cohx0 + cohw - 1);
DemTile cohDemTile = null;
if (subtractTopographicPhase) {
cohDemTile = TopoPhase.getDEMTile(cohTileWindow, mstMeta, mstOrbit, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
}
final int minLine = 0;
final int maxLine = subSwath[subSwathIndex - 1].linesPerBurst - 1;
final int minPixel = 0;
final int maxPixel = subSwath[subSwathIndex - 1].samplesPerBurst - 1;
for (String ifgKey : targetMap.keySet()) {
final ProductContainer product = targetMap.get(ifgKey);
final SLCImage slvMeta = product.sourceSlave.metaData.clone();
updateSlvMetaData(product, burstIndex, slvMeta);
final Orbit slvOrbit = product.sourceSlave.orbit;
// / check out results from master ///
final Tile mstTileReal = getSourceTile(product.sourceMaster.realBand, targetRectangle, border);
final Tile mstTileImag = getSourceTile(product.sourceMaster.imagBand, targetRectangle, border);
final ComplexDoubleMatrix dataMaster = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal, mstTileImag);
// / check out results from slave ///
final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, targetRectangle, border);
final Tile slvTileImag = getSourceTile(product.sourceSlave.imagBand, targetRectangle, border);
final ComplexDoubleMatrix dataSlave = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal, slvTileImag);
final String polynomialName = product.sourceSlave.name + '_' + (subSwathIndex - 1) + '_' + burstIndex;
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(x0, xN, dataMaster.columns, y0 - firstLineIdx, yN - firstLineIdx, dataMaster.rows, minPixel, maxPixel, minLine, maxLine, polynomialName);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave.muli(complexReferencePhase);
if (OUTPUT_PHASE) {
saveFlatEarthPhase(x0, xN, y0, yN, flatEarthPhase, product, targetTileMap);
}
}
if (subtractTopographicPhase) {
TopoPhase topoPhase = TopoPhase.computeTopoPhase(mstMeta, mstOrbit, slvMeta, slvOrbit, tileWindow, demTile, outputElevation, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave.muli(ComplexTopoPhase);
if (OUTPUT_PHASE) {
saveTopoPhase(x0, xN, y0, yN, topoPhase.demPhase, product, targetTileMap);
}
if (outputElevation) {
saveElevation(x0, xN, y0, yN, topoPhase.elevation, product, targetTileMap);
}
if (outputLatLon) {
TopoPhase topoPhase1 = TopoPhase.computeTopoPhase(mstMeta, mstOrbit, slvMeta, slvOrbit, tileWindow, demTile, false, true);
saveLatLon(x0, xN, y0, yN, topoPhase1.latitude, topoPhase1.longitude, product, targetTileMap);
}
}
dataMaster.muli(dataSlave.conji());
saveInterferogram(dataMaster, product, targetTileMap, targetRectangle);
// coherence calculation
if (includeCoherence) {
final Tile mstTileReal2 = getSourceTile(product.sourceMaster.realBand, rect, border);
final Tile mstTileImag2 = getSourceTile(product.sourceMaster.imagBand, rect, border);
final Tile slvTileReal2 = getSourceTile(product.sourceSlave.realBand, rect, border);
final Tile slvTileImag2 = getSourceTile(product.sourceSlave.imagBand, rect, border);
final ComplexDoubleMatrix dataMaster2 = TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal2, mstTileImag2);
final ComplexDoubleMatrix dataSlave2 = TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal2, slvTileImag2);
if (subtractFlatEarthPhase) {
final DoubleMatrix flatEarthPhase = computeFlatEarthPhase(cohx0, cohx0 + cohw - 1, cohw, cohy0 - firstLineIdx, cohy0 + cohh - 1 - firstLineIdx, cohh, minPixel, maxPixel, minLine, maxLine, polynomialName);
final ComplexDoubleMatrix complexReferencePhase = new ComplexDoubleMatrix(MatrixFunctions.cos(flatEarthPhase), MatrixFunctions.sin(flatEarthPhase));
dataSlave2.muli(complexReferencePhase);
}
if (subtractTopographicPhase) {
TopoPhase topoPhase = TopoPhase.computeTopoPhase(mstMeta, mstOrbit, slvMeta, slvOrbit, cohTileWindow, cohDemTile, false);
final ComplexDoubleMatrix ComplexTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
dataSlave2.muli(ComplexTopoPhase);
}
for (int i = 0; i < dataMaster2.length; i++) {
double tmp = norm(dataMaster2.get(i));
dataMaster2.put(i, dataMaster2.get(i).mul(dataSlave2.get(i).conj()));
dataSlave2.put(i, new ComplexDouble(norm(dataSlave2.get(i)), tmp));
}
DoubleMatrix cohMatrix = SarUtils.coherence2(dataMaster2, dataSlave2, cohWinAz, cohWinRg);
saveCoherence(cohMatrix, product, targetTileMap, targetRectangle);
}
}
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
}
}
use of org.jlinda.core.geom.TopoPhase in project s1tbx by senbox-org.
the class SubtRefDemOp method computeTileStack.
/**
* Called by the framework in order to compute a tile for the given target band.
* <p>The default implementation throws a runtime exception with the message "not implemented".</p>
*
* @param targetTileMap The target tiles associated with all target bands to be computed.
* @param targetRectangle The rectangle of target tile.
* @param pm A progress monitor which should be used to determine computation cancelation requests.
* @throws OperatorException
* If an error occurs during computation of the target raster.
*/
@Override
public void computeTileStack(Map<Band, Tile> targetTileMap, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
try {
int y0 = targetRectangle.y;
int yN = y0 + targetRectangle.height - 1;
int x0 = targetRectangle.x;
int xN = targetRectangle.x + targetRectangle.width - 1;
final Window tileWindow = new Window(y0, yN, x0, xN);
if (!demDefined) {
defineDEM();
}
DemTile demTile = TopoPhase.getDEMTile(tileWindow, targetMap, dem, demNoDataValue, demSamplingLat, demSamplingLon, tileExtensionPercent);
if (demTile == null) {
return;
}
Band topoPhaseBand, targetBand_I, targetBand_Q, elevBand, latBand, lonBand;
for (String ifgKey : targetMap.keySet()) {
ProductContainer product = targetMap.get(ifgKey);
TopoPhase topoPhase = TopoPhase.computeTopoPhase(product, tileWindow, demTile, outputElevationBand, false);
Tile tileReal = getSourceTile(product.sourceSlave.realBand, targetRectangle);
Tile tileImag = getSourceTile(product.sourceSlave.imagBand, targetRectangle);
ComplexDoubleMatrix complexIfg = TileUtilsDoris.pullComplexDoubleMatrix(tileReal, tileImag);
final ComplexDoubleMatrix cplxTopoPhase = new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)), MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
complexIfg.muli(cplxTopoPhase.conji());
targetBand_I = targetProduct.getBand(product.getBandName(Unit.REAL));
Tile tileOutReal = targetTileMap.get(targetBand_I);
TileUtilsDoris.pushDoubleMatrix(complexIfg.real(), tileOutReal, targetRectangle);
targetBand_Q = targetProduct.getBand(product.getBandName(Unit.IMAGINARY));
Tile tileOutImag = targetTileMap.get(targetBand_Q);
TileUtilsDoris.pushDoubleMatrix(complexIfg.imag(), tileOutImag, targetRectangle);
if (outputTopoPhaseBand) {
topoPhaseBand = targetProduct.getBand(product.getBandName(Unit.PHASE));
Tile tileOutTopoPhase = targetTileMap.get(topoPhaseBand);
TileUtilsDoris.pushDoubleArray2D(topoPhase.demPhase, tileOutTopoPhase, targetRectangle);
}
if (outputElevationBand) {
elevBand = targetProduct.getBand("elevation");
Tile tileElevBand = targetTileMap.get(elevBand);
TileUtilsDoris.pushDoubleArray2D(topoPhase.elevation, tileElevBand, targetRectangle);
}
if (outputLatLonBands) {
TopoPhase topoPhase1 = TopoPhase.computeTopoPhase(product, tileWindow, demTile, false, true);
latBand = targetProduct.getBand("orthorectifiedLat");
Tile tileLatBand = targetTileMap.get(latBand);
convertToDegree(topoPhase1.latitude);
TileUtilsDoris.pushDoubleArray2D(topoPhase1.latitude, tileLatBand, targetRectangle);
lonBand = targetProduct.getBand("orthorectifiedLon");
Tile tileLonBand = targetTileMap.get(lonBand);
convertToDegree(topoPhase1.longitude);
TileUtilsDoris.pushDoubleArray2D(topoPhase1.longitude, tileLonBand, targetRectangle);
}
}
} catch (Exception e) {
throw new OperatorException(e);
}
}
Aggregations