@Test public void testCalculateSmile() throws Exception { SmileCorrectionAuxdata auxdata = SmileCorrectionAuxdata.loadAuxdata("MER_F"); SmileCorrectionAlgorithm algorithm = new SmileCorrectionAlgorithm(auxdata); double correct = algorithm.correct(0, 1, new double[]{412.691, 412.891}, true); assertEquals(412.691988282132,correct,1e-8); }
public double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand) { double originalValue = radianceSamples[bandIndex]; if (detectorIndex < 0 || detectorIndex >= auxdata.getDetectorWavelengths().length) { return originalValue; } boolean[] shouldCorrect; int[] lowerIndexes; int[] upperIndexes; if (isLand) { shouldCorrect = auxdata.getRadCorrFlagsLand(); lowerIndexes = auxdata.getLowerBandIndexesLand(); upperIndexes = auxdata.getUpperBandIndexesLand(); } else { shouldCorrect = auxdata.getRadCorrFlagsWater(); lowerIndexes = auxdata.getLowerBandIndexesWater(); upperIndexes = auxdata.getUpperBandIndexesWater(); } double[] detectorE0s = auxdata.getDetectorSunSpectralFluxes()[detectorIndex]; double[] detectorWLs = auxdata.getDetectorWavelengths()[detectorIndex]; double[] theoretWLs = auxdata.getTheoreticalWavelengths(); double[] theoretE0s = auxdata.getTheoreticalSunSpectralFluxes(); double r0 = originalValue / detectorE0s[bandIndex]; double rc = r0 * theoretE0s[bandIndex]; if (shouldCorrect[bandIndex]) { int lowerIndex = lowerIndexes[bandIndex]; int upperIndex = upperIndexes[bandIndex]; double r1 = radianceSamples[lowerIndex] / detectorE0s[lowerIndex]; double r2 = radianceSamples[upperIndex] / detectorE0s[upperIndex]; double dl = (theoretWLs[bandIndex] - detectorWLs[bandIndex]) / (detectorWLs[upperIndex] - detectorWLs[lowerIndex]); double dr = (r2 - r1) * dl * theoretE0s[bandIndex]; rc += dr; } return rc; }
SmileCorrectionAlgorithm { public double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand) { double originalValue = radianceSamples[bandIndex]; if (detectorIndex < 0 || detectorIndex >= auxdata.getDetectorWavelengths().length) { return originalValue; } boolean[] shouldCorrect; int[] lowerIndexes; int[] upperIndexes; if (isLand) { shouldCorrect = auxdata.getRadCorrFlagsLand(); lowerIndexes = auxdata.getLowerBandIndexesLand(); upperIndexes = auxdata.getUpperBandIndexesLand(); } else { shouldCorrect = auxdata.getRadCorrFlagsWater(); lowerIndexes = auxdata.getLowerBandIndexesWater(); upperIndexes = auxdata.getUpperBandIndexesWater(); } double[] detectorE0s = auxdata.getDetectorSunSpectralFluxes()[detectorIndex]; double[] detectorWLs = auxdata.getDetectorWavelengths()[detectorIndex]; double[] theoretWLs = auxdata.getTheoreticalWavelengths(); double[] theoretE0s = auxdata.getTheoreticalSunSpectralFluxes(); double r0 = originalValue / detectorE0s[bandIndex]; double rc = r0 * theoretE0s[bandIndex]; if (shouldCorrect[bandIndex]) { int lowerIndex = lowerIndexes[bandIndex]; int upperIndex = upperIndexes[bandIndex]; double r1 = radianceSamples[lowerIndex] / detectorE0s[lowerIndex]; double r2 = radianceSamples[upperIndex] / detectorE0s[upperIndex]; double dl = (theoretWLs[bandIndex] - detectorWLs[bandIndex]) / (detectorWLs[upperIndex] - detectorWLs[lowerIndex]); double dr = (r2 - r1) * dl * theoretE0s[bandIndex]; rc += dr; } return rc; } }
SmileCorrectionAlgorithm { public double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand) { double originalValue = radianceSamples[bandIndex]; if (detectorIndex < 0 || detectorIndex >= auxdata.getDetectorWavelengths().length) { return originalValue; } boolean[] shouldCorrect; int[] lowerIndexes; int[] upperIndexes; if (isLand) { shouldCorrect = auxdata.getRadCorrFlagsLand(); lowerIndexes = auxdata.getLowerBandIndexesLand(); upperIndexes = auxdata.getUpperBandIndexesLand(); } else { shouldCorrect = auxdata.getRadCorrFlagsWater(); lowerIndexes = auxdata.getLowerBandIndexesWater(); upperIndexes = auxdata.getUpperBandIndexesWater(); } double[] detectorE0s = auxdata.getDetectorSunSpectralFluxes()[detectorIndex]; double[] detectorWLs = auxdata.getDetectorWavelengths()[detectorIndex]; double[] theoretWLs = auxdata.getTheoreticalWavelengths(); double[] theoretE0s = auxdata.getTheoreticalSunSpectralFluxes(); double r0 = originalValue / detectorE0s[bandIndex]; double rc = r0 * theoretE0s[bandIndex]; if (shouldCorrect[bandIndex]) { int lowerIndex = lowerIndexes[bandIndex]; int upperIndex = upperIndexes[bandIndex]; double r1 = radianceSamples[lowerIndex] / detectorE0s[lowerIndex]; double r2 = radianceSamples[upperIndex] / detectorE0s[upperIndex]; double dl = (theoretWLs[bandIndex] - detectorWLs[bandIndex]) / (detectorWLs[upperIndex] - detectorWLs[lowerIndex]); double dr = (r2 - r1) * dl * theoretE0s[bandIndex]; rc += dr; } return rc; } SmileCorrectionAlgorithm(SmileCorrectionAuxdata auxdata); }
SmileCorrectionAlgorithm { public double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand) { double originalValue = radianceSamples[bandIndex]; if (detectorIndex < 0 || detectorIndex >= auxdata.getDetectorWavelengths().length) { return originalValue; } boolean[] shouldCorrect; int[] lowerIndexes; int[] upperIndexes; if (isLand) { shouldCorrect = auxdata.getRadCorrFlagsLand(); lowerIndexes = auxdata.getLowerBandIndexesLand(); upperIndexes = auxdata.getUpperBandIndexesLand(); } else { shouldCorrect = auxdata.getRadCorrFlagsWater(); lowerIndexes = auxdata.getLowerBandIndexesWater(); upperIndexes = auxdata.getUpperBandIndexesWater(); } double[] detectorE0s = auxdata.getDetectorSunSpectralFluxes()[detectorIndex]; double[] detectorWLs = auxdata.getDetectorWavelengths()[detectorIndex]; double[] theoretWLs = auxdata.getTheoreticalWavelengths(); double[] theoretE0s = auxdata.getTheoreticalSunSpectralFluxes(); double r0 = originalValue / detectorE0s[bandIndex]; double rc = r0 * theoretE0s[bandIndex]; if (shouldCorrect[bandIndex]) { int lowerIndex = lowerIndexes[bandIndex]; int upperIndex = upperIndexes[bandIndex]; double r1 = radianceSamples[lowerIndex] / detectorE0s[lowerIndex]; double r2 = radianceSamples[upperIndex] / detectorE0s[upperIndex]; double dl = (theoretWLs[bandIndex] - detectorWLs[bandIndex]) / (detectorWLs[upperIndex] - detectorWLs[lowerIndex]); double dr = (r2 - r1) * dl * theoretE0s[bandIndex]; rc += dr; } return rc; } SmileCorrectionAlgorithm(SmileCorrectionAuxdata auxdata); double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand); }
SmileCorrectionAlgorithm { public double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand) { double originalValue = radianceSamples[bandIndex]; if (detectorIndex < 0 || detectorIndex >= auxdata.getDetectorWavelengths().length) { return originalValue; } boolean[] shouldCorrect; int[] lowerIndexes; int[] upperIndexes; if (isLand) { shouldCorrect = auxdata.getRadCorrFlagsLand(); lowerIndexes = auxdata.getLowerBandIndexesLand(); upperIndexes = auxdata.getUpperBandIndexesLand(); } else { shouldCorrect = auxdata.getRadCorrFlagsWater(); lowerIndexes = auxdata.getLowerBandIndexesWater(); upperIndexes = auxdata.getUpperBandIndexesWater(); } double[] detectorE0s = auxdata.getDetectorSunSpectralFluxes()[detectorIndex]; double[] detectorWLs = auxdata.getDetectorWavelengths()[detectorIndex]; double[] theoretWLs = auxdata.getTheoreticalWavelengths(); double[] theoretE0s = auxdata.getTheoreticalSunSpectralFluxes(); double r0 = originalValue / detectorE0s[bandIndex]; double rc = r0 * theoretE0s[bandIndex]; if (shouldCorrect[bandIndex]) { int lowerIndex = lowerIndexes[bandIndex]; int upperIndex = upperIndexes[bandIndex]; double r1 = radianceSamples[lowerIndex] / detectorE0s[lowerIndex]; double r2 = radianceSamples[upperIndex] / detectorE0s[upperIndex]; double dl = (theoretWLs[bandIndex] - detectorWLs[bandIndex]) / (detectorWLs[upperIndex] - detectorWLs[lowerIndex]); double dr = (r2 - r1) * dl * theoretE0s[bandIndex]; rc += dr; } return rc; } SmileCorrectionAlgorithm(SmileCorrectionAuxdata auxdata); double correct(int bandIndex, int detectorIndex, double[] radianceSamples, boolean isLand);  }