/** * @param lMin * @param lMax * @param formular constant value to classify the used formular to calculate the correct gain value of the band * * @return gain value of the band */ private static double calculateGain(final double lMin, final double lMax, final int formular) { Guardian.assertTrue("formular == AFTER1990 || formular == BEFORE1990", formular == AFTER1990 || formular == BEFORE1990); double gain = 0; if (formular == AFTER1990) { gain = ((lMax - lMin) / 255); } if (formular == BEFORE1990) { gain = (lMax / 254) - (lMin / 244); } return gain; }
/** * @param gain * @param Lmin * @param formularUsed * * @return an array with calculated maximale radiances from the given gain and minimal radiance values. */ private static double[] calculateLmax(final double[] gain, final double[] Lmin, int formularUsed) { Guardian.assertTrue("Lmin.length == gain.length", Lmin.length == gain.length); Guardian.assertTrue("formularUsed == AFTER1990 || formularUsed == BEFORE1990", formularUsed == AFTER1990 || formularUsed == BEFORE1990); double[] Lmax = new double[Lmin.length]; for (int i = 0; i < Lmax.length; i++) { if (formularUsed == AFTER1990) { Lmax[i] = gain[i] * 255 + Lmin[i]; } else if (formularUsed == BEFORE1990) { Lmax[i] = gain[i] * 254 + (254 * Lmin[i]) / 255; } } return Lmax; }
/** * @param io - LandsatImageInputStream or LandsatStreamReader value * @param offset - the entrypoint of the inputstream * @param size - the size of the needed data * checks if the io object parameter value is not null * checks if the offset is greater then 0 * checks if the sizei is greater then 0 */ private static void assertParameters(final Object io, final int offset, final int size) { Guardian.assertNotNull("io", io); Guardian.assertTrue("size > 0", size > 0); Guardian.assertTrue("offset > 0", offset > 0); }
/** * @param foundRadiometricValues * @param nominalRadiometricValues * * @return caluclates the euclidian distance between found and nominal values to classifier if the values stored in the header are bias, gain, lmin, lmax */ private static double getDistance(final double[] foundRadiometricValues, final double[] nominalRadiometricValues) { Guardian.assertTrue("foundRadiometricValues.length == nominalRadiometricValues.length", foundRadiometricValues.length == nominalRadiometricValues.length); double distance = 0; for (int i = 0; i < nominalRadiometricValues.length; i++) { //euclidian distance distance = distance + Math.pow(foundRadiometricValues[i] - nominalRadiometricValues[i], 2); } return Math.sqrt(distance); }
private void assertSameWidthAndHeightForAllImages() throws IOException, IllegalCeosFormatException { for (int i = 0; i < imageFiles.length; i++) { final Avnir2ImageFile imageFile = imageFiles[i]; Guardian.assertTrue("_sceneWidth == imageFile[" + i + "].getRasterWidth()", sceneWidth == imageFile.getRasterWidth()); Guardian.assertTrue("_sceneHeight == imageFile[" + i + "].getRasterHeight()", sceneHeight == imageFile.getRasterHeight()); } }
/** * @param index * @param date * * @return a collection of nominal radiance data */ public static NomRadiance getConstantRadAt(final int index, final int date) { Guardian.assertTrue("date == AFTER_5_MAY_2003 || date == BEFORE_5_MAY_2003", date == AFTER_5_MAY_2003 || date == BEFORE_5_MAY_2003); List<NomRadiance> radianceConstants; if (date == AFTER_5_MAY_2003) { radianceConstants = after2003Radiances; } else { radianceConstants = before2003Radiances; } for (Iterator<NomRadiance> iter = radianceConstants.iterator(); iter.hasNext();) { NomRadiance element = iter.next(); if (index == element.getBandNumber()) { return element; } } Debug.trace("no Radiance data found at index: " + index); return null; }
public static double getEarthSunDistance(final int julianDay) { Guardian.assertGreaterThan("julianDay <= 0", julianDay, 0); Guardian.assertTrue("julianDay < 367", julianDay < 367); final EarthSunDistance firstElement = distanceCollection.get(0); double distance = firstElement.getDistance(); for (Iterator<EarthSunDistance> iter = distanceCollection.iterator(); iter.hasNext();) { EarthSunDistance element = iter.next(); if (element.getJulianDay() > julianDay) { return distance; } distance = element.getDistance(); } final EarthSunDistance lastElement = distanceCollection.get( distanceCollection.size() - 1); return lastElement.getDistance(); }
/** * Search for FAST.REV B header files * * @return File * if a header file exists * <code>false</code> if no header file exists in the given folder */ private File findLandsat5HeaderInFolder() { Guardian.assertNotNull("inputFile", inputFile); Guardian.assertTrue("inputFile.isFile()", inputFile.isFile()); String folderPathName = getFolderOfFile(inputFile); File folder = new File(folderPathName); if (!folder.exists() || !folder.isDirectory()) { return null; } File filesInFolder[] = folder.listFiles(); for (int i = 0; i < filesInFolder.length; i++) { if (filesInFolder[i].length() == Landsat5FASTConstants.FAST_FORMAT_HEADER_SIZE && format == Landsat5FASTConstants.FAST_L5) { return filesInFolder[i]; } else if (isFastCEOSHeader(FileUtils.getFilenameWithoutExtension( filesInFolder[i].getName())) && format == Landsat5FASTConstants.CEOS) { return filesInFolder[i]; } } return null; }
final LandsatImageInputStream input, int[] bandsAvailable) throws IOException { Guardian.assertTrue("maxRadOffset.length == minRadOffset.length", maxRadOffset.length == minRadOffset.length); Guardian.assertTrue("maxRadOffset.length >= bandsAvailable.length", maxRadOffset.length >= bandsAvailable.length); final int length = bandsAvailable.length;
Guardian.assertTrue("maxRad.length == minRad.length", maxRad.length == minRad.length); double[] nominalLmax; double[] nominalLmin;