/** Creates Metadata nodes for all the necessary information. */ protected MetadataElement[] getMetadata() { MetadataElement[] metadata = new MetadataElement[2]; MetadataElement fileList = new MetadataElement("Input_Products"); final String[] productList = context.getProcessedProducts(); String keyString; for (int n = 0; n < productList.length; n++) { keyString = "Product." + n; fileList.addAttribute( new MetadataAttribute(keyString, ProductData.createInstance(productList[n]), true)); } metadata[0] = fileList; MetadataElement binParams = new MetadataElement("Binning_Parameter"); binParams.addAttribute( new MetadataAttribute( "Resampling_Type", ProductData.createInstance(context.getResamplingType()), true)); final String cellSizeName; if (L3Constants.RESAMPLING_TYPE_VALUE_BINNING.equals(context.getResamplingType())) { cellSizeName = "Bin_Size_In_Km"; } else { cellSizeName = "Bins_Per_Degree"; } binParams.addAttribute( new MetadataAttribute( cellSizeName, ProductData.createInstance(new float[] {context.getGridCellSize()}), true)); final L3Context.BandDefinition[] bandDefs = context.getBandDefinitions(); for (int bandIndex = 0; bandIndex < bandDefs.length; bandIndex++) { final L3Context.BandDefinition bandDef = bandDefs[bandIndex]; binParams.addAttribute( new MetadataAttribute( "Geophysical_Parameter_" + bandIndex, ProductData.createInstance(bandDef.getBandName()), true)); binParams.addAttribute( new MetadataAttribute( "Bitmask_" + bandIndex, ProductData.createInstance(bandDef.getBitmaskExp()), true)); binParams.addAttribute( new MetadataAttribute( "Algorithm_" + bandIndex, ProductData.createInstance(bandDef.getAlgorithm().getTypeString()), true)); } metadata[1] = binParams; return metadata; }
/** Interpretes the bins of the temporal database if algorithm needs this to be done. */ protected void processBinIterpretation(ProgressMonitor pm) throws IOException { getLogger().info(L3Constants.LOG_MSG_INTERPRETE_BIN_CONTENT); final int rowOffset = temporalDB.getRowOffset(); final int colOffset = temporalDB.getColOffset(); final int width = temporalDB.getWidth(); final int height = temporalDB.getHeight(); Point rowcol = new Point(); Bin tempBin = temporalDB.createBin(); Bin finalBin = finalDB.createBin(); pm.beginTask(L3Constants.LOG_MSG_INTERPRETE_BIN_CONTENT, height - rowOffset); try { for (int row = rowOffset; row < rowOffset + height; row++) { rowcol.y = row; for (int col = colOffset; col < colOffset + width; col++) { rowcol.x = col; temporalDB.read(rowcol, tempBin); final L3Context.BandDefinition[] bandDefinitions = context.getBandDefinitions(); for (int bandIndex = 0; bandIndex < bandDefinitions.length; bandIndex++) { final L3Context.BandDefinition bandDef = bandDefinitions[bandIndex]; final Algorithm algo = bandDef.getAlgorithm(); tempBin.setBandIndex(bandIndex); finalBin.setBandIndex(bandIndex); algo.interprete(tempBin, finalBin); } finalDB.write(rowcol, finalBin); } // update progressbar pm.worked(1); if (pm.isCanceled()) { getLogger().warning(L3Constants.LOG_MSG_PROC_CANCELED); setCurrentState(L3Constants.STATUS_ABORTED); break; } } } finally { pm.done(); finalDB.flush(); } getLogger().info(ProcessorConstants.LOG_MSG_SUCCESS); }