@Override protected void tearDown() throws Exception { JAI.getDefaultInstance().setTileScheduler(jaiTileScheduler); GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OP2_SPI); GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OP3_SPI); GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OUTPUT_OP_SPI); }
@Override protected void setUp() throws Exception { context = new GraphCommandLineContext(); clTool = new CommandLineTool(context); GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OP2_SPI); GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OP3_SPI); GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OUTPUT_OP_SPI); JAI jai = JAI.getDefaultInstance(); jaiTileScheduler = jai.getTileScheduler(); SunTileScheduler tileScheduler = new SunTileScheduler(); tileScheduler.setParallelism(Runtime.getRuntime().availableProcessors()); jai.setTileScheduler(tileScheduler); }
@Override protected Product createTargetProduct() throws Exception { final Product sourceProduct = form.getSourceProduct(); final Product radioCorrProduct = GPF.createProduct(alias, parameterSupport.getParameterMap(), sourceProduct); if (isEnvisatFormatSelected() && getTargetProductSelector().getModel().isSaveToFileSelected()) { final HashMap<String, Object> n1Parameters = new HashMap<String, Object>(); n1Parameters.put("patchedFile", getTargetProductSelector().getModel().getProductFile()); final HashMap<String, Product> sourceProductMap = new HashMap<String, Product>(); sourceProductMap.put("n1", form.getSourceProduct()); sourceProductMap.put("input", radioCorrProduct); return GPF.createProduct("Meris.N1Patcher", n1Parameters, sourceProductMap); } return radioCorrProduct; }
@Override protected Product createTargetProduct() throws Exception { final Map<String, Product> productMap = form.getProductMap(); final Map<String, Object> parameterMap = new HashMap<String, Object>(); form.updateParameterMap(parameterMap); return GPF.createProduct(OPERATOR_NAME, parameterMap, productMap); }
@Override protected Product createTargetProduct() throws Exception { if (validateUI()) { opUI.updateParameters(); final HashMap<String, Product> sourceProducts = ioParametersPanel.createSourceProductsMap(); return GPF.createProduct(operatorName, parameterSupport.getParameterMap(), sourceProducts); } return null; }
ReprojectionDialog( boolean orthorectify, final String title, final String helpID, AppContext appContext) { super(appContext, title, ID_APPLY_CLOSE, helpID); form = new ReprojectionForm(getTargetProductSelector(), orthorectify, appContext); final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(OPERATOR_NAME); ParameterUpdater parameterUpdater = new ReprojectionParameterUpdater(); OperatorParameterSupport parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorClass(), null, null, parameterUpdater); OperatorMenu operatorMenu = new OperatorMenu( this.getJDialog(), operatorSpi.getOperatorClass(), parameterSupport, helpID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); }
private Map<String, Object> convertParameterMap( String operatorName, Map<String, String> parameterMap) throws ValidationException { HashMap<String, Object> parameters = new HashMap<String, Object>(); PropertyContainer container = ParameterDescriptorFactory.createMapBackedOperatorPropertyContainer( operatorName, parameters); // explicitly set default values for putting them into the backing map container.setDefaultValues(); // handle xml parameters Object parametersObject = metadataResourceEngine.getVelocityContext().get("parameterFile"); if (parametersObject instanceof Resource) { Resource paramatersResource = (Resource) parametersObject; if (paramatersResource.isXml()) { OperatorSpiRegistry operatorSpiRegistry = GPF.getDefaultInstance().getOperatorSpiRegistry(); OperatorSpi operatorSpi = operatorSpiRegistry.getOperatorSpi(operatorName); Class<? extends Operator> operatorClass = operatorSpi.getOperatorClass(); DefaultDomConverter domConverter = new DefaultDomConverter(operatorClass, new ParameterDescriptorFactory()); DomElement parametersElement = createDomElement(paramatersResource.getContent()); try { domConverter.convertDomToValue(parametersElement, container); } catch (ConversionException e) { String msgPattern = "Can not convert XML parameters for operator '%s'"; throw new RuntimeException(String.format(msgPattern, operatorName)); } } } for (Entry<String, String> entry : parameterMap.entrySet()) { String paramName = entry.getKey(); String paramValue = entry.getValue(); final Property property = container.getProperty(paramName); if (property != null) { property.setValueFromText(paramValue); } else { throw new RuntimeException( String.format("Parameter '%s' is not known by operator '%s'", paramName, operatorName)); } } return parameters; }
RadiometryDialog(String alias, AppContext appContext, String title, String helpId) { super( appContext, title, ID_APPLY_CLOSE, helpId, TargetProductSelectorModel.createEnvisatTargetProductSelectorModel()); this.alias = alias; final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(alias); parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorClass()); form = new RadiometryForm( appContext, operatorSpi, parameterSupport.getPopertySet(), getTargetProductSelector()); OperatorMenu operatorMenu = new OperatorMenu( this.getJDialog(), operatorSpi.getOperatorClass(), parameterSupport, helpId); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); }
public NestSingleTargetProductDialog( String operatorName, AppContext appContext, String title, String helpID) { super(operatorName, appContext, title, helpID); final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operatorName); if (operatorSpi == null) { throw new IllegalArgumentException("operatorName " + operatorName); } opUI = operatorSpi.createOperatorUI(); addParameters(operatorSpi, appContext, helpID); getJDialog().setMinimumSize(new Dimension(450, 450)); getJDialog().setIconImage(ResourceUtils.esaPlanetIcon.getImage()); statusLabel = new JLabel(""); statusLabel.setForeground(new Color(255, 0, 0)); this.getJDialog().getContentPane().add(statusLabel, BorderLayout.NORTH); }
static { GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis(); }
private void runGraph() throws Exception { final OperatorSpiRegistry operatorSpiRegistry = GPF.getDefaultInstance().getOperatorSpiRegistry(); Map<String, String> templateVariables = getRawParameterMap(); Map<String, String> sourceNodeIdMap = getSourceNodeIdMap(); templateVariables.putAll(sourceNodeIdMap); // todo - use Velocity and the current Velocity context for reading the graph XML! (nf, // 20120610) Graph graph = readGraph(commandLineArgs.getGraphFilePath(), templateVariables); Node lastNode = graph.getNode(graph.getNodeCount() - 1); SortedMap<String, String> sourceFilePathsMap = commandLineArgs.getSourceFilePathMap(); // For each source path add a ReadOp to the graph String readOperatorAlias = OperatorSpi.getOperatorAlias(ReadOp.class); for (Entry<String, String> entry : sourceFilePathsMap.entrySet()) { String sourceId = entry.getKey(); String sourceFilePath = entry.getValue(); String sourceNodeId = sourceNodeIdMap.get(sourceId); if (graph.getNode(sourceNodeId) == null) { DomElement configuration = new DefaultDomElement("parameters"); configuration.createChild("file").setValue(sourceFilePath); Node sourceNode = new Node(sourceNodeId, readOperatorAlias); sourceNode.setConfiguration(configuration); graph.addNode(sourceNode); } } final String operatorName = lastNode.getOperatorName(); final OperatorSpi lastOpSpi = operatorSpiRegistry.getOperatorSpi(operatorName); if (lastOpSpi == null) { throw new GraphException( String.format("Unknown operator name '%s'. No SPI found.", operatorName)); } if (!Output.class.isAssignableFrom(lastOpSpi.getOperatorClass())) { // If the graph's last node does not implement Output, then add a WriteOp String writeOperatorAlias = OperatorSpi.getOperatorAlias(WriteOp.class); DomElement configuration = new DefaultDomElement("parameters"); configuration.createChild("file").setValue(commandLineArgs.getTargetFilePath()); configuration.createChild("formatName").setValue(commandLineArgs.getTargetFormatName()); configuration .createChild("clearCacheAfterRowWrite") .setValue(Boolean.toString(commandLineArgs.isClearCacheAfterRowWrite())); Node targetNode = new Node(WRITE_OP_ID_PREFIX + lastNode.getId(), writeOperatorAlias); targetNode.addSource(new NodeSource("source", lastNode.getId())); targetNode.setConfiguration(configuration); graph.addNode(targetNode); } executeGraph(graph); VelocityContext velocityContext = metadataResourceEngine.getVelocityContext(); File graphFile = new File(commandLineArgs.getGraphFilePath()); velocityContext.put("graph", graph); metadataResourceEngine.readResource("graphXml", graphFile.getPath()); }
public void initialize() throws OperatorException { // System.out.println("starting..."); if (new File(SynergyConstants.SYNERGY_AUXDATA_HOME_DEFAULT).exists()) { auxdataPath = SynergyConstants.SYNERGY_AUXDATA_HOME_DEFAULT + File.separator + "aerosolLUTs" + File.separator + "ocean"; } else { // try this one (in case of calvalus processing) auxdataPath = SynergyConstants.SYNERGY_AUXDATA_CALVALUS_DEFAULT; } noDataVal = (float) SynergyConstants.OUTPUT_AOT_BAND_NODATAVALUE; // get the glint product... Map<String, Product> glintInput = new HashMap<String, Product>(3); glintInput.put("l1bSynergy", synergyProduct); Map<String, Object> glintAveParams = new HashMap<String, Object>(2); glintAveParams.put("aveBlock", aveBlock); glintProduct = GPF.createProduct( OperatorSpi.getOperatorAlias(GlintAveOp.class), glintAveParams, glintInput); scalingFactor = aveBlock; aveBlock /= 2; minNAve = (int) (scalingFactor * scalingFactor - 1); noDataVal = (float) SynergyConstants.OUTPUT_AOT_BAND_NODATAVALUE; createTargetProduct(); // targetProduct = glintProduct; // test // correction of azimuth discontinuity: // set up tiles for MERIS and AATSR which cover the whole scene... final int sceneWidth = synergyProduct.getSceneRasterWidth(); final int sceneHeight = synergyProduct.getSceneRasterHeight(); final Rectangle rect = new Rectangle(0, 0, sceneWidth, sceneHeight); vaMerisTileComplete = getSourceTile(synergyProduct.getTiePointGrid("view_azimuth"), rect); vaAatsrNadirTileComplete = getSourceTile( synergyProduct.getBand( "view_azimuth_nadir" + "_" + SynergyConstants.INPUT_BANDS_SUFFIX_AATSR + ""), rect); aot550Result = new float[sceneWidth][sceneHeight]; angResult = new float[sceneWidth][sceneHeight]; aot550ErrorResult = new float[sceneWidth][sceneHeight]; angErrorResult = new float[sceneWidth][sceneHeight]; glintResult = new float[sceneWidth][sceneHeight]; wsResult = new float[sceneWidth][sceneHeight]; // read aerosol class table try { aerosolClassTable = AerosolAuxData.getInstance().createAerosolClassTable(); } catch (IOException e) { throw new OperatorException("Failed to read aerosol class table:\n" + e.getMessage(), e); } // read aerosol models try { aerosolModelTable = AerosolAuxData.getInstance().createAerosolModelTable(auxdataPath); } catch (IOException e) { throw new OperatorException("Failed to read aerosol class table:\n" + e.getMessage(), e); } // wvl=[ 865, 885,1610, 885,1610, 885] wvl = new float[] {865.0f, 885.0f, 1610.0f, 885.0f, 1610.0f, 885.0f}; wvlWeight = new float[] {1.0f, 1.0f, 3.0f, 1.0f, 3.0f, 3.0f}; wvlIndex = new int[] {0, 3, 5}; // at this point, just use 1 MERIS and 1 AATSR channel... // todo: clarify with RP which we should finally use // find model indices belonging to aerosol classes... final List<Integer> modelIndices = aerosolModelTable.getMaritimeAndDesertIndices(); nMod = modelIndices.size(); nWvl = wvlIndex.length; try { aerosolLookupTables = AerosolAuxData.getInstance() .createAerosolOceanLookupTables( auxdataPath, modelIndices, wvl, wvlIndex); } catch (IOException e) { throw new OperatorException("Failed to create aerosol lookup tables:\n" + e.getMessage(), e); // String msg = SynergyConstants.AUXDATA_ERROR_MESSAGE; // SynergyUtils.logErrorMessage(msg); } nTauLut = aerosolLookupTables[0][0].getDimensions()[4].getSequence().length; interpol5DResultLow = new double[nMod][nWvl][nTauLut]; interpol5DResultHigh = new double[nMod][nWvl][nTau]; interpolAngResult = new float[nWvl][nTau][nAng]; costFunction = new float[nWvl][nTau][nAng]; vectorTauLut = new double[nTauLut]; for (int i = 0; i < nTauLut; i++) { vectorTauLut[i] = i * 2.0 / (nTauLut - 1); } vectorTauLutHigh = new double[nTau]; for (int i = 0; i < nTau; i++) { vectorTauLutHigh[i] = i * 2.0 / (nTau - 1); } final float[] angArray = aerosolModelTable.getAngArray(modelIndices, 0); angstroemParameters = AerosolHelpers.getInstance().getAngstroemParameters(angArray, nAng); // read corresponding small LUTs and make a big LUT... // correct azimuths in these tiles for later usage... GlintPreparation.correctViewAzimuthLinear(vaMerisTileComplete, rect); GlintPreparation.correctViewAzimuthLinear(vaAatsrNadirTileComplete, rect); }