BinningConfig { public VariableContext createVariableContext() { VariableContextImpl variableContext = new VariableContextImpl(); variableContext.setMaskExpr(maskExpr); if (variableConfigs != null) { for (VariableConfig varConfig : variableConfigs) { variableContext.defineVariable(varConfig.getName(), varConfig.getExpr(), varConfig.getValidExpr()); } } if (aggregatorConfigs != null) { TypedDescriptorsRegistry registry = TypedDescriptorsRegistry.getInstance(); for (AggregatorConfig aggregatorConfig : aggregatorConfigs) { AggregatorDescriptor descriptor = registry.getDescriptor(AggregatorDescriptor.class, aggregatorConfig.getName()); if (descriptor != null) { String[] varNames = descriptor.getSourceVarNames(aggregatorConfig); for (String varName : varNames) { variableContext.defineVariable(varName); } } else { throw new IllegalArgumentException("Unknown aggregator type: " + aggregatorConfig.getName()); } } } if (BinTracer.isActive()) { variableContext.defineVariable("_TRACE_X", "X"); variableContext.defineVariable("_TRACE_Y", "Y"); } return variableContext; }  String getPlanetaryGrid(); void setPlanetaryGrid(String planetaryGrid); int getNumRows(); void setNumRows(int numRows); Double getMinDataHour(); void setMinDataHour(Double minDataHour); String getMaskExpr(); void setMaskExpr(String maskExpr); Integer getSuperSampling(); void setSuperSampling(Integer superSampling); Integer getMaxDistanceOnEarth(); void setMaxDistanceOnEarth(Integer maxDistanceOnEarth); CompositingType getCompositingType(); void setCompositingType(CompositingType type); VariableConfig[] getVariableConfigs(); void setVariableConfigs(VariableConfig... variableConfigs); AggregatorConfig[] getAggregatorConfigs(); void setAggregatorConfigs(AggregatorConfig... aggregatorConfigs); CellProcessorConfig getPostProcessorConfig(); void setPostProcessorConfig(CellProcessorConfig cellProcessorConfig); String getMetadataAggregatorName(); void setMetadataAggregatorName(String metadataAggregatorName); String getStartDateTime(); void setStartDateTime(String startDateTime); Double getPeriodDuration(); void setPeriodDuration(Double periodDuration); BinningOp.TimeFilterMethod getTimeFilterMethod(); void setTimeFilterMethod(BinningOp.TimeFilterMethod timeFilterMethod); String getOutputFile(); void setOutputFile(String outputFile); Geometry getRegion(); void setRegion(Geometry region); static BinningConfig fromXml(String xml); String toXml(); BinningContext createBinningContext(Geometry region, ProductData.UTC startDate, Double periodDuration); PlanetaryGrid createPlanetaryGrid(); Aggregator[] createAggregators(VariableContext variableContext); VariableContext createVariableContext(); static DataPeriod createDataPeriod(ProductData.UTC startUtc, Double periodDuration, Double minDataHour);  }
@Test public void testCreateVariableContext() { VariableContext variableContext = config.createVariableContext(); assertEquals(6, variableContext.getVariableCount()); assertEquals(0, variableContext.getVariableIndex("ndvi")); assertEquals(1, variableContext.getVariableIndex("tsm")); assertEquals(2, variableContext.getVariableIndex("reflec_3")); assertEquals(3, variableContext.getVariableIndex("reflec_7")); assertEquals(4, variableContext.getVariableIndex("reflec_8")); assertEquals(-1, variableContext.getVariableIndex("reflec_6")); assertEquals(-1, variableContext.getVariableIndex("reflec_10")); assertEquals("!l2_flags.INVALID && l2_flags.WATER", variableContext.getValidMaskExpression()); assertEquals("ndvi", variableContext.getVariableName(0)); assertEquals("(reflec_10 - reflec_6) / (reflec_10 + reflec_6)", variableContext.getVariableExpression(0)); assertEquals("reflec_7", variableContext.getVariableName(3)); assertEquals(null, variableContext.getVariableExpression(3)); }