@Test public void thirdTest_shiftSpectrum() throws Exception { processingPath = "/d2/test.processing/unit_tests/etna.volcano/process/crop/01486_21159.cpm/"; dataPath = "fineCoreg/magFFT/"; masterFileName = "master_patch.32x32.cr4"; slaveFileName = "slave_patch.32x32.cr4"; rows = 32; cols = 32; masterCplx = DataReader.readCplxFloatData(processingPath + dataPath + masterFileName, rows, cols, littleEndian); slaveCplx = DataReader.readCplxFloatData(processingPath + dataPath + slaveFileName, rows, cols, littleEndian); SLCImage minfo = new SLCImage(); minfo.parseResFile(new File(processingPath + "01486.res")); SLCImage sinfo = new SLCImage(); sinfo.parseResFile(new File(processingPath + "21159.res")); final int m_pixlo = 1212; final double s_pixlo = 1214; final double mPrf = minfo.getPRF(); final double sPrf = sinfo.getPRF(); final double mRsr2x = minfo.getRsr2x(); final double sRsr2x = sinfo.getRsr2x(); double[] mFdc = new double[3]; mFdc[0] = minfo.doppler.getF_DC_a0(); mFdc[1] = minfo.doppler.getF_DC_a1(); mFdc[2] = minfo.doppler.getF_DC_a2(); double[] sFdc = new double[3]; sFdc[0] = sinfo.doppler.getF_DC_a0(); sFdc[1] = sinfo.doppler.getF_DC_a1(); sFdc[2] = sinfo.doppler.getF_DC_a2(); Coregistration coreg = new Coregistration(); clock.start(); coreg.shiftazispectrum(masterCplx, mPrf, mRsr2x, mFdc, -m_pixlo); clock.stop(); logger.info("Computation Time for shifting of spectra [ms]: {}", clock.getElapsedTime()); clock.start(); coreg.shiftazispectrum(slaveCplx, mPrf, mRsr2x, mFdc, -m_pixlo); clock.stop(); logger.info("Computation Time for shifting of spectra [ms]: {}", clock.getElapsedTime()); }
public void shiftazispectrum(final ComplexDoubleMatrix data, final double prf, final double rsr2x, final double[] doppler, final double shift) { if (doppler[0] == 0 && doppler[1] == 0 && doppler[2] == 0) return; final int NLINES = data.rows; final int NCOLS = data.columns; final int SIGN = (shift < 0) ? -1 : 1; final double PIXLO = Math.abs(shift) - 1; DoubleMatrix FDC = new DoubleMatrix(1, NCOLS); FDC.fill(doppler[0]); if (doppler[1] != 0 || doppler[2] != 0) { DoubleMatrix xaxis = DoubleMatrix.linspace((int) PIXLO, (int) (PIXLO + NCOLS - 1), NCOLS); xaxis.divi(rsr2x / 2); FDC.addi(xaxis.mul(doppler[1])); FDC.addi(MatrixFunctions.pow(xaxis, 2).mul(doppler[2])); } logger.debug("fDC of first pixel: " + FDC.get(0, 0)); if (SIGN == 1) logger.debug("Shifting from zero to fDC."); else logger.debug("Shifting from fDC to zero."); DoubleMatrix trend = DoubleMatrix.linspace(0, NLINES - 1, NLINES); trend.muli(2 * Constants.PI / prf); trend.assertMultipliesWith(FDC); DoubleMatrix P = trend.mmul(FDC); ComplexDoubleMatrix cplxTrend = (SIGN == -1) ? new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P).neg()) : new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P)); data.muli(cplxTrend); }
Coregistration implements ICoregistration { public void shiftazispectrum(final ComplexDoubleMatrix data, final double prf, final double rsr2x, final double[] doppler, final double shift) { if (doppler[0] == 0 && doppler[1] == 0 && doppler[2] == 0) return; final int NLINES = data.rows; final int NCOLS = data.columns; final int SIGN = (shift < 0) ? -1 : 1; final double PIXLO = Math.abs(shift) - 1; DoubleMatrix FDC = new DoubleMatrix(1, NCOLS); FDC.fill(doppler[0]); if (doppler[1] != 0 || doppler[2] != 0) { DoubleMatrix xaxis = DoubleMatrix.linspace((int) PIXLO, (int) (PIXLO + NCOLS - 1), NCOLS); xaxis.divi(rsr2x / 2); FDC.addi(xaxis.mul(doppler[1])); FDC.addi(MatrixFunctions.pow(xaxis, 2).mul(doppler[2])); } logger.debug("fDC of first pixel: " + FDC.get(0, 0)); if (SIGN == 1) logger.debug("Shifting from zero to fDC."); else logger.debug("Shifting from fDC to zero."); DoubleMatrix trend = DoubleMatrix.linspace(0, NLINES - 1, NLINES); trend.muli(2 * Constants.PI / prf); trend.assertMultipliesWith(FDC); DoubleMatrix P = trend.mmul(FDC); ComplexDoubleMatrix cplxTrend = (SIGN == -1) ? new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P).neg()) : new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P)); data.muli(cplxTrend); } }
Coregistration implements ICoregistration { public void shiftazispectrum(final ComplexDoubleMatrix data, final double prf, final double rsr2x, final double[] doppler, final double shift) { if (doppler[0] == 0 && doppler[1] == 0 && doppler[2] == 0) return; final int NLINES = data.rows; final int NCOLS = data.columns; final int SIGN = (shift < 0) ? -1 : 1; final double PIXLO = Math.abs(shift) - 1; DoubleMatrix FDC = new DoubleMatrix(1, NCOLS); FDC.fill(doppler[0]); if (doppler[1] != 0 || doppler[2] != 0) { DoubleMatrix xaxis = DoubleMatrix.linspace((int) PIXLO, (int) (PIXLO + NCOLS - 1), NCOLS); xaxis.divi(rsr2x / 2); FDC.addi(xaxis.mul(doppler[1])); FDC.addi(MatrixFunctions.pow(xaxis, 2).mul(doppler[2])); } logger.debug("fDC of first pixel: " + FDC.get(0, 0)); if (SIGN == 1) logger.debug("Shifting from zero to fDC."); else logger.debug("Shifting from fDC to zero."); DoubleMatrix trend = DoubleMatrix.linspace(0, NLINES - 1, NLINES); trend.muli(2 * Constants.PI / prf); trend.assertMultipliesWith(FDC); DoubleMatrix P = trend.mmul(FDC); ComplexDoubleMatrix cplxTrend = (SIGN == -1) ? new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P).neg()) : new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P)); data.muli(cplxTrend); }  }
Coregistration implements ICoregistration { public void shiftazispectrum(final ComplexDoubleMatrix data, final double prf, final double rsr2x, final double[] doppler, final double shift) { if (doppler[0] == 0 && doppler[1] == 0 && doppler[2] == 0) return; final int NLINES = data.rows; final int NCOLS = data.columns; final int SIGN = (shift < 0) ? -1 : 1; final double PIXLO = Math.abs(shift) - 1; DoubleMatrix FDC = new DoubleMatrix(1, NCOLS); FDC.fill(doppler[0]); if (doppler[1] != 0 || doppler[2] != 0) { DoubleMatrix xaxis = DoubleMatrix.linspace((int) PIXLO, (int) (PIXLO + NCOLS - 1), NCOLS); xaxis.divi(rsr2x / 2); FDC.addi(xaxis.mul(doppler[1])); FDC.addi(MatrixFunctions.pow(xaxis, 2).mul(doppler[2])); } logger.debug("fDC of first pixel: " + FDC.get(0, 0)); if (SIGN == 1) logger.debug("Shifting from zero to fDC."); else logger.debug("Shifting from fDC to zero."); DoubleMatrix trend = DoubleMatrix.linspace(0, NLINES - 1, NLINES); trend.muli(2 * Constants.PI / prf); trend.assertMultipliesWith(FDC); DoubleMatrix P = trend.mmul(FDC); ComplexDoubleMatrix cplxTrend = (SIGN == -1) ? new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P).neg()) : new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P)); data.muli(cplxTrend); }  @Override void coarseporbit(Ellipsoid ell, SLCImage master, SLCImage slave, Orbit masterorbit, Orbit slaveorbit, Baseline baseline); @Override void coarsecorrel(Input.CoarseCorr input, SLCImage minfo, SLCImage sinfo); @Override void coarsecorrelfft(Input.CoarseCorr coarsecorrinput, SLCImage minfo, SLCImage sinfo); @Override void mtiming_correl(Input.MasterTiming input, SLCImage minfo, todo_classes.productinfo sinfo); @Override void mtiming_correlfft(Input.MasterTiming input, SLCImage minfo, todo_classes.productinfo sinfo); @Override int[][] distributepoints(float numberofpoints, Window win); @Override void getoffset(DoubleMatrix Result, long offsetLines, long offsetPixels); @Override void getmodeoffset(float[][] Result, long offsetLines, long offsetPixels); @Override void finecoreg(Input.FineCorr fineinput, SLCImage minfo, SLCImage sinfo); @Override double coherencefft(ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask, int ovsfactor, int AccL,
                               int AccP, double offsetL, double offsetP); @Override double crosscorrelate(ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask,
                                 int ovsfactor,
                                 int AccL, int AccP,
                                 double offsetL, double offsetP); @Override double coherencespace(final int AccL, final int AccP, final int osfactor,
                                 ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask,
                                 double offsetL, double offsetP); @Override void coregpm(SLCImage master, SLCImage slave, String i_resfile, Input.CoregPM coregpminput,
                        int demassist); @Override DoubleMatrix getofffile(String file, float threshold); @Override void resample(Input.Resample resampleinput,
                         SLCImage master, SLCImage slave,
                         double[] cpmL, double[] cpmP,
                         int demassist); @Override void ms_timing_error(SLCImage master, String i_resfile, Input.RelTiming timinginput,
                                int coarse_orbit_offsetL, int coarse_orbit_offsetP); DoubleMatrix correlate(DoubleMatrix A, DoubleMatrix Mask); void shiftazispectrum(final ComplexDoubleMatrix data, // slcData in space domain
                                 final double prf,
                                 final double rsr2x,
                                 final double[] doppler,   // polynomial fDC
                                 final double shift); @Deprecated static Window getOverlap(final Window master, final Window slave); static Window getOverlap(final SLCImage master, final SLCImage slave, final double[] cpmL, final double[] cpmP); static Window getOverlap(final SLCImage master, final SLCImage slave,
                                    final double Npointsd2, final double timing_L, final double timing_P); }
Coregistration implements ICoregistration { public void shiftazispectrum(final ComplexDoubleMatrix data, final double prf, final double rsr2x, final double[] doppler, final double shift) { if (doppler[0] == 0 && doppler[1] == 0 && doppler[2] == 0) return; final int NLINES = data.rows; final int NCOLS = data.columns; final int SIGN = (shift < 0) ? -1 : 1; final double PIXLO = Math.abs(shift) - 1; DoubleMatrix FDC = new DoubleMatrix(1, NCOLS); FDC.fill(doppler[0]); if (doppler[1] != 0 || doppler[2] != 0) { DoubleMatrix xaxis = DoubleMatrix.linspace((int) PIXLO, (int) (PIXLO + NCOLS - 1), NCOLS); xaxis.divi(rsr2x / 2); FDC.addi(xaxis.mul(doppler[1])); FDC.addi(MatrixFunctions.pow(xaxis, 2).mul(doppler[2])); } logger.debug("fDC of first pixel: " + FDC.get(0, 0)); if (SIGN == 1) logger.debug("Shifting from zero to fDC."); else logger.debug("Shifting from fDC to zero."); DoubleMatrix trend = DoubleMatrix.linspace(0, NLINES - 1, NLINES); trend.muli(2 * Constants.PI / prf); trend.assertMultipliesWith(FDC); DoubleMatrix P = trend.mmul(FDC); ComplexDoubleMatrix cplxTrend = (SIGN == -1) ? new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P).neg()) : new ComplexDoubleMatrix(MatrixFunctions.cos(P), MatrixFunctions.sin(P)); data.muli(cplxTrend); }  @Override void coarseporbit(Ellipsoid ell, SLCImage master, SLCImage slave, Orbit masterorbit, Orbit slaveorbit, Baseline baseline); @Override void coarsecorrel(Input.CoarseCorr input, SLCImage minfo, SLCImage sinfo); @Override void coarsecorrelfft(Input.CoarseCorr coarsecorrinput, SLCImage minfo, SLCImage sinfo); @Override void mtiming_correl(Input.MasterTiming input, SLCImage minfo, todo_classes.productinfo sinfo); @Override void mtiming_correlfft(Input.MasterTiming input, SLCImage minfo, todo_classes.productinfo sinfo); @Override int[][] distributepoints(float numberofpoints, Window win); @Override void getoffset(DoubleMatrix Result, long offsetLines, long offsetPixels); @Override void getmodeoffset(float[][] Result, long offsetLines, long offsetPixels); @Override void finecoreg(Input.FineCorr fineinput, SLCImage minfo, SLCImage sinfo); @Override double coherencefft(ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask, int ovsfactor, int AccL,
                               int AccP, double offsetL, double offsetP); @Override double crosscorrelate(ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask,
                                 int ovsfactor,
                                 int AccL, int AccP,
                                 double offsetL, double offsetP); @Override double coherencespace(final int AccL, final int AccP, final int osfactor,
                                 ComplexDoubleMatrix Master, ComplexDoubleMatrix Mask,
                                 double offsetL, double offsetP); @Override void coregpm(SLCImage master, SLCImage slave, String i_resfile, Input.CoregPM coregpminput,
                        int demassist); @Override DoubleMatrix getofffile(String file, float threshold); @Override void resample(Input.Resample resampleinput,
                         SLCImage master, SLCImage slave,
                         double[] cpmL, double[] cpmP,
                         int demassist); @Override void ms_timing_error(SLCImage master, String i_resfile, Input.RelTiming timinginput,
                                int coarse_orbit_offsetL, int coarse_orbit_offsetP); DoubleMatrix correlate(DoubleMatrix A, DoubleMatrix Mask); void shiftazispectrum(final ComplexDoubleMatrix data, // slcData in space domain
                                 final double prf,
                                 final double rsr2x,
                                 final double[] doppler,   // polynomial fDC
                                 final double shift); @Deprecated static Window getOverlap(final Window master, final Window slave); static Window getOverlap(final SLCImage master, final SLCImage slave, final double[] cpmL, final double[] cpmP); static Window getOverlap(final SLCImage master, final SLCImage slave,
                                    final double Npointsd2, final double timing_L, final double timing_P);  }