comparison artifacts/src/main/java/org/dive4elements/river/utils/DoubleUtil.java @ 8587:07c9ac22f611

(issue1755) Generalise BedQuality result handling The bedquality calculation now produces a result for each time period which has BedQualityResultValues for each specific result type. Formally this was split up in density, porosity and diameter classes with some bedload diameter classes mixed in for extra fun. The intent of this commit is to allow more shared code and generic access patterns to the BedQuality results.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 18 Mar 2015 18:42:08 +0100
parents 073ea4bcea58
children b486812f4f14
comparison
equal deleted inserted replaced
8586:19fde13e2db4 8587:07c9ac22f611
314 } 314 }
315 315
316 /** Convieniance function for results to get an interpolator. 316 /** Convieniance function for results to get an interpolator.
317 * This is basically a static wrapper to for LinearInterpolator.interpolate 317 * This is basically a static wrapper to for LinearInterpolator.interpolate
318 * with error handling. Returns null on error.*/ 318 * with error handling. Returns null on error.*/
319 public static PolynomialSplineFunction getLinearInterpolator(TDoubleArrayList x, TDoubleArrayList y) { 319 public static PolynomialSplineFunction getLinearInterpolator(double[] x, double[] y) {
320 LinearInterpolator lpol = new LinearInterpolator(); 320 LinearInterpolator lpol = new LinearInterpolator();
321 try { 321 try {
322 return lpol.interpolate(x.toNativeArray(), y.toNativeArray()); 322 return lpol.interpolate(x, y);
323 } catch (DimensionMismatchException e) { 323 } catch (DimensionMismatchException e) {
324 log.error("KMs and Result values have different sizes. Failed to interpolate: " + 324 log.error("KMs and Result values have different sizes. Failed to interpolate: " +
325 e.getMessage()); 325 e.getMessage());
326 } catch (NonMonotonousSequenceException e) { 326 } catch (NonMonotonousSequenceException e) {
327 log.error("KMs are not monotonous. Failed to interpolate: " + e.getMessage()); 327 log.error("KMs are not monotonous. Failed to interpolate: " + e.getMessage());
328 } catch (NumberIsTooSmallException e) { 328 } catch (NumberIsTooSmallException e) {
329 log.error("Result is to small. Failed to interpolate: " + e.getMessage()); 329 log.error("Result is to small. Failed to interpolate: " + e.getMessage());
330 } 330 }
331 return null; 331 return null;
332 } 332 }
333
334 public static PolynomialSplineFunction getLinearInterpolator(TDoubleArrayList x, TDoubleArrayList y) {
335 return getLinearInterpolator(x.toNativeArray(), y.toNativeArray());
336 }
333 } 337 }
334 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 338 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org