@Test public void testLarge() throws Exception { final long start = System.currentTimeMillis(); final List<IDataset> images = new ArrayList<IDataset>(10); final File dir = new File(System.getProperty("GDALargeTestFilesLocation") + "EDFLoaderTest/"); final File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].getName().startsWith("billeA")) { images.add(LoaderFactory.getData(files[i].getAbsolutePath(), null).getDataset(0)); } } final AbstractDataset median = CollectionStats.median(images); final long end = System.currentTimeMillis(); if (median.getShape()[0] != 2048) throw new Exception("Median has wrong size!"); if (median.getShape()[1] != 2048) throw new Exception("Median has wrong size!"); System.out.println("Did median of ten images 2048x2048 in " + ((end - start) / 1000d) + "s"); final AbstractDataset mean = CollectionStats.median(images); final long end1 = System.currentTimeMillis(); if (mean.getShape()[0] != 2048) throw new Exception("Mean has wrong size!"); if (mean.getShape()[1] != 2048) throw new Exception("Mean has wrong size!"); System.out.println("Did mean of ten images 2048x2048 in " + ((end1 - end) / 1000d) + "s"); }
@Test public void test2D() throws Exception { final AbstractDataset median = CollectionStats.median(SETS2D); if (median.getDouble(0, 0) != 1) throw new Exception("Median not calculated correctly!"); if (median.getDouble(1, 1) != 4) throw new Exception("Median not calculated correctly!"); if (median.getShape()[0] != 2) throw new Exception("Median shape not correct!"); if (median.getShape()[1] != 2) throw new Exception("Median shape not correct!"); final AbstractDataset mean = CollectionStats.mean(SETS2D); if (!DoubleUtils.equalsWithinTolerance(mean.getDouble(0, 0), 100.8d, 0.01)) throw new Exception("Mean not calculated correctly!"); if (!DoubleUtils.equalsWithinTolerance(mean.getDouble(1, 1), 103.2d, 0.01)) throw new Exception("Mean not calculated correctly!"); }