private static List<TemporalBin> doTemporalBinning(BinningContext binningContext, SortedMap<Long, List<SpatialBin>> spatialBinMap) throws IOException { StopWatch stopWatch = new StopWatch(); stopWatch.start(); final TemporalBinner temporalBinner = new TemporalBinner(binningContext); final ArrayList<TemporalBin> temporalBins = new ArrayList<TemporalBin>(); for (Map.Entry<Long, List<SpatialBin>> entry : spatialBinMap.entrySet()) { final TemporalBin temporalBin = temporalBinner.processSpatialBins(entry.getKey(), entry.getValue()); temporalBins.add(temporalBin); } stopWatch.stopAndTrace("Temporal binning took"); return temporalBins; }
private void processSource(Product sourceProduct, SpatialBinner spatialBinner) throws IOException { final StopWatch stopWatch = new StopWatch(); stopWatch.start();
private TemporalBinList doTemporalBinning(SpatialBinCollection spatialBinMap) throws IOException { StopWatch stopWatch = new StopWatch(); stopWatch.start(); long numberOfBins = spatialBinMap.size(); final TemporalBinner temporalBinner = new TemporalBinner(binningContext); final CellProcessorChain cellChain = new CellProcessorChain(binningContext); final TemporalBinList temporalBins = new TemporalBinList((int) numberOfBins); Iterable<List<SpatialBin>> spatialBinListCollection = spatialBinMap.getBinCollection(); int binCounter = 0; int percentCounter = 0; long hundredthOfNumBins = numberOfBins / 100; for (List<SpatialBin> spatialBinList : spatialBinListCollection) { binCounter += spatialBinList.size(); SpatialBin spatialBin = spatialBinList.get(0); long spatialBinIndex = spatialBin.getIndex(); TemporalBin temporalBin = temporalBinner.processSpatialBins(spatialBinIndex, spatialBinList); temporalBin = temporalBinner.computeOutput(spatialBinIndex, temporalBin); temporalBin = cellChain.process(temporalBin); temporalBins.add(temporalBin); if (binCounter >= hundredthOfNumBins) { binCounter = 0; getLogger().info(String.format("Finished %d%% of temporal bins", ++percentCounter)); } } stopWatch.stop(); getLogger().info(String.format("Temporal binning of %d bins done, took %s", numberOfBins, stopWatch)); return temporalBins; }
/** * Tests the functionality of getTimeDiffString() */ public void testGetTimeDiffString() { StopWatch watch = new StopWatch(); watch.stop(); // just check that we don't get an empty string assertTrue("" != watch.getTimeDiffString()); }
/** * Tests the functionality of toString() */ public void testToString() { StopWatch watch = new StopWatch(); try { Thread.sleep(10); } catch (InterruptedException e) { } watch.stop(); assertEquals(watch.getTimeDiffString(), watch.toString()); } }
private void writeOutput(List<TemporalBin> temporalBins, ProductData.UTC startTime, ProductData.UTC stopTime) throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start();
private static SortedMap<Long, List<SpatialBin>> doSpatialBinning(BinningContext binningContext, File[] sourceFiles) throws IOException { final SpatialBinStore spatialBinStore = new SpatialBinStore(); final SpatialBinner spatialBinner = new SpatialBinner(binningContext, spatialBinStore); for (File sourceFile : sourceFiles) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); System.out.println("reading " + sourceFile); final Product product = ProductIO.readProduct(sourceFile); System.out.println("processing " + sourceFile); final long numObs = SpatialProductBinner.processProduct(product, spatialBinner, new HashMap<Product, List<Band>>(), ProgressMonitor.NULL); System.out.println("done, " + numObs + " observations processed"); stopWatch.stopAndTrace("Spatial binning of product took"); } return spatialBinStore.getSpatialBinMap(); }
/** * Tests the functionality for getEndTime */ public void testGetEndTime() { StopWatch watch = new StopWatch(); long endTime; try { Thread.sleep(10); } catch (InterruptedException e) { } // check if stop time is different from start watch.stop(); endTime = watch.getEndTime(); assertTrue(0 != endTime); // check if end time now is the same (we haven't started the timer agaiin assertEquals(endTime, watch.getEndTime()); }
/** * Tests the functionality of getTimeDiff */ public void testGetTimeDiff() { StopWatch watch = new StopWatch(); long startTime; long endTime; startTime = watch.getStartTime(); watch.stop(); endTime = watch.getEndTime(); assertEquals(endTime - startTime, watch.getTimeDiff()); }
public static void main(String[] args) throws Exception { String sourceDirFile = args[0]; String regionWktFile = args[1]; String binnerConfigFile = args[2]; String[] outputterConfigFiles = new String[args.length - 3]; System.arraycopy(args, 3, outputterConfigFiles, 0, outputterConfigFiles.length); File[] sourceFiles = new File(sourceDirFile).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".N1"); } }); String regionWkt = FileUtils.readText(new File(regionWktFile)); BinningConfig binningConfig = BinningConfig.fromXml(FileUtils.readText(new File(binnerConfigFile))); Debug.setEnabled(true); StopWatch stopWatch = new StopWatch(); stopWatch.start(); BinningContext binningContext = binningConfig.createBinningContext(null, null, null); // Step 1: Spatial binning - creates time-series of spatial bins for each bin ID ordered by ID. The tree map structure is <ID, time-series> SortedMap<Long, List<SpatialBin>> spatialBinMap = doSpatialBinning(binningContext, sourceFiles); // Step 2: Temporal binning - creates a list of temporal bins, sorted by bin ID List<TemporalBin> temporalBins = doTemporalBinning(binningContext, spatialBinMap); // Step 3: Formatting for (String outputterConfigFile : outputterConfigFiles) { FormatterConfig formatterConfig = FormatterConfig.fromXml(FileUtils.readText(new File(outputterConfigFile))); doOutputting(regionWkt, formatterConfig, binningContext, temporalBins); } stopWatch.stopAndTrace(String.format("Total time for binning %d product(s)", sourceFiles.length)); }
final BitRaster validMask = new BitRaster(productWidth, productHeight); final StopWatch stopWatch = new StopWatch(); stopWatch.start();
StopWatch stopWatch = new StopWatch(); stopWatch.start();
final Logger logger = BeamLogManager.getSystemLogger(); for (int idx = 0; idx < sliceRectangles.length; idx++) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); numObsTotal += processSlice(spatialBinner, progressMonitor, superSamplingSteps, maskImage, varImages,
private static void doOutputting(String regionWKT, FormatterConfig formatterConfig, BinningContext binningContext, List<TemporalBin> temporalBins) throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start(); PlanetaryGrid planetaryGrid = binningContext.getPlanetaryGrid(); String[] resultFeatureNames = binningContext.getBinManager().getResultFeatureNames(); org.esa.beam.binning.operator.Formatter.format(planetaryGrid, new MyTemporalBinSource(temporalBins), resultFeatureNames, formatterConfig, new WKTReader().read(regionWKT), new ProductData.UTC(), new ProductData.UTC(), new MetadataElement("TODO_add_metadata_here") ); stopWatch.stopAndTrace("Writing output took"); }