final Matrix A = Maths.createVandermondeMatrix(timeArray, polyDegree); final double[] xPosCoeff = Maths.polyFit(A, xPosArray); final double[] yPosCoeff = Maths.polyFit(A, yPosArray); final double[] zPosCoeff = Maths.polyFit(A, zPosArray); final double[] xVelCoeff = Maths.polyFit(A, xVelArray); final double[] yVelCoeff = Maths.polyFit(A, yVelArray); final double[] zVelCoeff = Maths.polyFit(A, zVelArray); Maths.polyVal(normalizedTime, xPosCoeff), Maths.polyVal(normalizedTime, yPosCoeff), Maths.polyVal(normalizedTime, zPosCoeff), Maths.polyVal(normalizedTime, xVelCoeff), Maths.polyVal(normalizedTime, yVelCoeff), Maths.polyVal(normalizedTime, zVelCoeff));
final double lowerBoundSlantRange = Maths.computePolynomialValue(lowerBound, srgrCoeff); if (slantRange < lowerBoundSlantRange) { return -1.0; final double upperBoundSlantRange = Maths.computePolynomialValue(upperBound, srgrCoeff); if (slantRange > upperBoundSlantRange) { return -1.0; midSlantRange = Maths.computePolynomialValue(mid, srgrCoeff); final double a = midSlantRange - slantRange; if ((a > 0 && a < 0.1) || (a <= 0.0D && 0.0D - a < 0.1)) {
private void getSensorPosition(final double time, double[] senPos) { final int numVectors = orbitStateVectors.length; final int numVectorsUsed = Math.min(orbitStateVectors.length, 5); final int d = numVectors / numVectorsUsed; final double[] timeArray = new double[numVectorsUsed]; final double[] xPosArray = new double[numVectorsUsed]; final double[] yPosArray = new double[numVectorsUsed]; final double[] zPosArray = new double[numVectorsUsed]; for (int i = 0; i < numVectorsUsed; i++) { timeArray[i] = orbitStateVectors[i * d].time_mjd; xPosArray[i] = orbitStateVectors[i * d].x_pos; // m yPosArray[i] = orbitStateVectors[i * d].y_pos; // m zPosArray[i] = orbitStateVectors[i * d].z_pos; // m } senPos[0] = Maths.lagrangeInterpolatingPolynomial(timeArray, xPosArray, time); senPos[1] = Maths.lagrangeInterpolatingPolynomial(timeArray, yPosArray, time); senPos[2] = Maths.lagrangeInterpolatingPolynomial(timeArray, zPosArray, time); }
private static double[] computePolynomialCoefficients( double slantRangeToFirstPixel, double slantRangeToMidPixel, double slantRangeToLastPixel, int imageWidth) { final int firstPixel = 0; final int midPixel = imageWidth / 2; final int lastPixel = imageWidth - 1; final double[] idxArray = {firstPixel, midPixel, lastPixel}; final double[] rangeArray = {slantRangeToFirstPixel, slantRangeToMidPixel, slantRangeToLastPixel}; final Matrix A = Maths.createVandermondeMatrix(idxArray, 2); final Matrix b = new Matrix(rangeArray, 3); final Matrix x = A.solve(b); return x.getColumnPackedCopy(); }
/** * Get the SRGR coefficients for given zero Doppler time. * * @param zeroDopplerTime The zero Doppler time in MJD. * @return The SRGR coefficients. */ private AbstractMetadata.SRGRCoefficientList getSRGRCoefficientsForARangeLine(final double zeroDopplerTime) { if (srgrConvParams.length == 1) { return srgrConvParams[0]; } int idx = 0; for (int i = 0; i < srgrConvParams.length && zeroDopplerTime >= srgrConvParams[i].timeMJD; i++) { idx = i; } if (idx == srgrConvParams.length - 1) { idx--; } AbstractMetadata.SRGRCoefficientList srgrConvParam = new AbstractMetadata.SRGRCoefficientList(); srgrConvParam.timeMJD = zeroDopplerTime; srgrConvParam.ground_range_origin = srgrConvParams[idx].ground_range_origin; srgrConvParam.coefficients = new double[srgrConvParams[idx].coefficients.length]; final double mu = (zeroDopplerTime - srgrConvParams[idx].timeMJD) / (srgrConvParams[idx + 1].timeMJD - srgrConvParams[idx].timeMJD); for (int i = 0; i < srgrConvParam.coefficients.length; i++) { srgrConvParam.coefficients[i] = Maths.interpolationLinear( srgrConvParams[idx].coefficients[i], srgrConvParams[idx + 1].coefficients[i], mu); } return srgrConvParam; }
for (int i = 0; i <= m; i++) { sltRgTime[i] = firstPixelTime + (lastPixelTime - firstPixelTime) * i / m; groundRange[i] = Maths.computePolynomialValue(sltRgTime[i] - referencePoint, s2gCoef); final Matrix G = Maths.createVandermondeMatrix(deltaGroundRange, m); final Matrix tau = new Matrix(sltRgTime, m + 1); final Matrix s = G.solve(tau);
Maths.normalizeVector(n); if (Maths.innerProduct(n, c) < 0) { n.x = -n.x; n.y = -n.y; lg.sensorPos.y - lg.centrePoint.y, lg.sensorPos.z - lg.centrePoint.z); Maths.normalizeVector(s); final double nsInnerProduct = Maths.innerProduct(n, s); localIncidenceAngles[0] = FastMath.acos(nsInnerProduct) * Constants.RTOD; Maths.normalizeVector(m); final double mnInnerProduct = Maths.innerProduct(m, n); final PosVector n1 = new PosVector(n.x - m.x * mnInnerProduct, n.y - m.y * mnInnerProduct, n.z - m.z * mnInnerProduct); Maths.normalizeVector(n1); localIncidenceAngles[1] = FastMath.acos(Maths.innerProduct(n1, s)) * Constants.RTOD; Maths.normalizeVector(n); if (Maths.innerProduct(n, c) < 0) { n.x = -n.x; n.y = -n.y; lg.sensorPos.y - centrePoint.y, lg.sensorPos.z - centrePoint.z); Maths.normalizeVector(s); final double nsInnerProduct = Maths.innerProduct(n, s); localIncidenceAngles[0] = FastMath.acos(nsInnerProduct) * Constants.RTOD;
Maths.lagrangeEightOrderInterpolation(xPosArray, ref), Maths.lagrangeEightOrderInterpolation(yPosArray, ref), Maths.lagrangeEightOrderInterpolation(zPosArray, ref), Maths.lagrangeEightOrderInterpolation(xVelArray, ref), Maths.lagrangeEightOrderInterpolation(yVelArray, ref), Maths.lagrangeEightOrderInterpolation(zVelArray, ref));
/** * Compute calibration LUTs for the given range line. * * @param y Index of the given range line. * @param x0 X coordinate of the upper left corner pixel of the given tile. * @param w Tile width. * @param calInfo Object of CalibrationInfo class. * @param lut LUT for calibration. */ public static void computeTileCalibrationLUTs(final int y, final int x0, final int w, final Sentinel1Calibrator.CalibrationInfo calInfo, final double azT0, final double azT1, final float[] vec0LUT, final float[] vec1LUT, final int[] vec0Pixels, int pixelIdx0, final double[] lut) { final double azTime = calInfo.firstLineTime + y * calInfo.lineTimeInterval; double muX, muY = (azTime - azT0) / (azT1 - azT0); int pixelIdx = pixelIdx0; final int maxX = x0 + w; for (int x = x0; x < maxX; x++) { if (x > vec0Pixels[pixelIdx + 1]) { pixelIdx++; } muX = (double) (x - vec0Pixels[pixelIdx]) / (double) (vec0Pixels[pixelIdx + 1] - vec0Pixels[pixelIdx]); lut[x - x0] = Maths.interpolationBiLinear( vec0LUT[pixelIdx], vec0LUT[pixelIdx + 1], vec1LUT[pixelIdx], vec1LUT[pixelIdx + 1], muX, muY); } }
private static double[] computePolynomialCoefficients( double slantRangeToFirstPixel, double slantRangeToMidPixel, double slantRangeToLastPixel, int imageWidth) { final int firstPixel = 0; final int midPixel = imageWidth / 2; final int lastPixel = imageWidth - 1; final double[] idxArray = {firstPixel, midPixel, lastPixel}; final double[] rangeArray = {slantRangeToFirstPixel, slantRangeToMidPixel, slantRangeToLastPixel}; final Matrix A = Maths.createVandermondeMatrix(idxArray, 2); final Matrix b = new Matrix(rangeArray, 3); final Matrix x = A.solve(b); return x.getColumnPackedCopy(); }
mu = (double) (y - y1) / (double) (y2 - y1); tileNoise[y - y0][x - x0] = Maths.interpolationLinear(n1, n2, mu);
double[] phiLamHeight = new double[3]; xyz[0] = Maths.lagrangeEightOrderInterpolation(xPosArray, ref); xyz[1] = Maths.lagrangeEightOrderInterpolation(yPosArray, ref); xyz[2] = Maths.lagrangeEightOrderInterpolation(zPosArray, ref);
private static double[] computePolynomialCoefficients( double slantRangeToFirstPixel, double slantRangeToMidPixel, double slantRangeToLastPixel, int imageWidth) { final int firstPixel = 0; final int midPixel = imageWidth / 2; final int lastPixel = imageWidth - 1; final double[] idxArray = {firstPixel, midPixel, lastPixel}; final double[] rangeArray = {slantRangeToFirstPixel, slantRangeToMidPixel, slantRangeToLastPixel}; final Matrix A = Maths.createVandermondeMatrix(idxArray, 2); final Matrix b = new Matrix(rangeArray, 3); final Matrix x = A.solve(b); return x.getColumnPackedCopy(); }
final int x01 = noiseVector0.pixels[pixelIdx0 + 1]; final double muX0 = (double) (x - x00) / (double) (x01 - x00); final double noise0 = Maths.interpolationLinear( noiseVector0.noiseLUT[pixelIdx0], noiseVector0.noiseLUT[pixelIdx0 + 1], muX0); final int x11 = noiseVector1.pixels[pixelIdx1 + 1]; final double muX1 = (double) (x - x10) / (double) (x11 - x10); final double noise1 = Maths.interpolationLinear( noiseVector1.noiseLUT[pixelIdx1], noiseVector1.noiseLUT[pixelIdx1 + 1], muX1); lut[x - x0] = Maths.interpolationLinear(noise0, noise1, muY);
final Matrix A = Maths.createVandermondeMatrix(timeArray, polyDegree); final double[] xPosCoeff = Maths.polyFit(A, xPosArray); final double[] yPosCoeff = Maths.polyFit(A, yPosArray); final double[] zPosCoeff = Maths.polyFit(A, zPosArray); final double[] xVelCoeff = Maths.polyFit(A, xVelArray); final double[] yVelCoeff = Maths.polyFit(A, yVelArray); final double[] zVelCoeff = Maths.polyFit(A, zVelArray); Maths.polyVal(normalizedTime, xPosCoeff), Maths.polyVal(normalizedTime, yPosCoeff), Maths.polyVal(normalizedTime, zPosCoeff), Maths.polyVal(normalizedTime, xVelCoeff), Maths.polyVal(normalizedTime, yVelCoeff), Maths.polyVal(normalizedTime, zVelCoeff));
/** * Get orbit information for given time. * * @param utc The UTC in days. * @param timeArray Array holding zeros Doppler times for all state vectors. * @param xPosArray Array holding x coordinates for sensor positions in all state vectors. * @param yPosArray Array holding y coordinates for sensor positions in all state vectors. * @param zPosArray Array holding z coordinates for sensor positions in all state vectors. * @param xVelArray Array holding x velocities for sensor positions in all state vectors. * @param yVelArray Array holding y velocities for sensor positions in all state vectors. * @param zVelArray Array holding z velocities for sensor positions in all state vectors. * @return The orbit information. */ private static Orbits.OrbitVector getOrbitData(final double utc, final double[] timeArray, final double[] xPosArray, final double[] yPosArray, final double[] zPosArray, final double[] xVelArray, final double[] yVelArray, final double[] zVelArray) { // Lagrange polynomial interpolation return new Orbits.OrbitVector(utc, Maths.lagrangeInterpolatingPolynomial(timeArray, xPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, yPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, zPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, xVelArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, yVelArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, zVelArray, utc)); } }
/** * Compute slant range for given pixel. * * @param x The x coordinate of the pixel in the source image. * @param y The y coordinate of the pixel in the source image. * @param srgrConvParam The SRGR coefficients. * @return The slant range (in meters). */ private double computeSlantRange(int x, int y, AbstractMetadata.SRGRCoefficientList srgrConvParam, final TiePointInterpolator slantRangeTPGInterp) { if (srgrFlag) { // for ground detected product, compute slant range from SRGR coefficients return Maths.computePolynomialValue( x * rangeSpacing + srgrConvParam.ground_range_origin, srgrConvParam.coefficients); } else { // for slant range product, compute slant range from slant range time final double time = slantRangeTPGInterp.getPixelDouble(x, y, TiePointInterpolator.InterpMode.QUADRATIC) / Constants.oneBillion; //convert ns to s return time * Constants.halfLightSpeed; // in m } }
private static double[] computePolynomialCoefficients( double slantRangeToFirstPixel, double slantRangeToMidPixel, double slantRangeToLastPixel, int imageWidth) { final int firstPixel = 0; final int midPixel = imageWidth / 2; final int lastPixel = imageWidth - 1; final double[] idxArray = {firstPixel, midPixel, lastPixel}; final double[] rangeArray = {slantRangeToFirstPixel, slantRangeToMidPixel, slantRangeToLastPixel}; final Matrix A = Maths.createVandermondeMatrix(idxArray, 2); final Matrix b = new Matrix(rangeArray, 3); final Matrix x = A.solve(b); return x.getColumnPackedCopy(); }
/** * Compute antenna pattern gains for the given elevation angle using linear interpolation. * * @param elevAngle The elevation angle (in degree) of a given pixel. * @param refElevationAngle The reference elevation angle (in degree). * @param antPatArray The antenna pattern array. * @return The antenna pattern gain (in linear scale). */ public static double computeAntPatGain(double elevAngle, double refElevationAngle, float[] antPatArray) { final double delta = 0.05; int k0 = (int) ((elevAngle - refElevationAngle + 5.0) / delta); if (k0 < 0) { k0 = 0; } else if (k0 >= antPatArray.length - 1) { k0 = antPatArray.length - 2; } final double theta0 = refElevationAngle - 5.0 + k0 * delta; final double theta1 = theta0 + delta; final double gain0 = FastMath.pow(10, (double) antPatArray[k0] / 10.0); // convert dB to linear scale final double gain1 = FastMath.pow(10, (double) antPatArray[k0 + 1] / 10.0); final double mu = (elevAngle - theta0) / (theta1 - theta0); return Maths.interpolationLinear(gain0, gain1, mu); }
/** * Get orbit information for given time. * * @param utc The UTC in days. * @param timeArray Array holding zeros Doppler times for all state vectors. * @param xPosArray Array holding x coordinates for sensor positions in all state vectors. * @param yPosArray Array holding y coordinates for sensor positions in all state vectors. * @param zPosArray Array holding z coordinates for sensor positions in all state vectors. * @param xVelArray Array holding x velocities for sensor positions in all state vectors. * @param yVelArray Array holding y velocities for sensor positions in all state vectors. * @param zVelArray Array holding z velocities for sensor positions in all state vectors. * @return The orbit information. */ private static Orbits.OrbitVector getOrbitData(final double utc, final double[] timeArray, final double[] xPosArray, final double[] yPosArray, final double[] zPosArray, final double[] xVelArray, final double[] yVelArray, final double[] zVelArray) { // Lagrange polynomial interpolation return new Orbits.OrbitVector(utc, Maths.lagrangeInterpolatingPolynomial(timeArray, xPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, yPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, zPosArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, xVelArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, yVelArray, utc), Maths.lagrangeInterpolatingPolynomial(timeArray, zVelArray, utc)); }