List of usage examples for org.apache.commons.lang.math DoubleRange getMaximumDouble
public double getMaximumDouble()
Gets the maximum number in this range as a double.
From source file:com.sciaps.utils.ImportExportSpectrumCSV.java
public void exportSpectrumFile(File saveFile, PiecewiseSpectrum spectrum) throws IOException { if (spectrum == null || saveFile == null) { logger_.warn("", "will not save spectrum csv file"); return;/*from w ww .ja v a 2 s . co m*/ } final UnivariateFunction intensity = spectrum.getIntensityFunction(); BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(saveFile))); try { bout.append("wavelength, intensity"); bout.newLine(); final DoubleRange range = spectrum.getValidRange(); for (double x = range.getMinimumDouble(); x <= range.getMaximumDouble(); x += 1.0 / EXPORT_SAMPLE_RATE) { double y = intensity.value(x); if (Double.isNaN(y)) { y = 0; } bout.append(Double.toString(x)); bout.append(", "); bout.append(Double.toString(y)); bout.newLine(); } } finally { bout.close(); } logger_.info("saved spectrum csv file to " + saveFile.getAbsolutePath()); }