private static boolean checkPolarisation(final Product product, final String tag, final String polarisation) { for (String name:product.getBandNames()) { if (name.toLowerCase().contains(tag.toLowerCase()) && name.toLowerCase().contains(polarisation.toLowerCase())) { return true; } } return false; }
private String[] getTrainingBands() { final ArrayList<String> bandNames = new ArrayList<>(5); if (sourceProducts != null) { if (sourceProducts.length > 1) { for (String name : sourceProducts[0].getBandNames()) { bandNames.add(name + "::" + sourceProducts[0].getName()); } } else { bandNames.addAll(Arrays.asList(sourceProducts[0].getBandNames())); } } return bandNames.toArray(new String[bandNames.size()]); }
protected String[] getBandNames() { final ArrayList<String> bandNames = new ArrayList<>(5); if (sourceProducts != null) { for (Product prod : sourceProducts) { if (sourceProducts.length > 1) { for (String name : prod.getBandNames()) { bandNames.add(name + "::" + prod.getName()); } } else { bandNames.addAll(Arrays.asList(prod.getBandNames())); } } } return bandNames.toArray(new String[bandNames.size()]); }
private static Band getFeatureBand(final Product product, final String idStr) throws OperatorException { for(String name : product.getBandNames()) { if(name.contains(idStr)) { return product.getBand(name); } } return null; }
private String[] getBandNames(final String[] names) { final Set<String> bandNames = new HashSet<>(); for(String name : names) { final String suffix = StackUtils.getBandSuffix(name); for(String srcBandName : sourceProduct.getBandNames()) { if(srcBandName.endsWith(suffix)) { bandNames.add(srcBandName); } } } return bandNames.toArray(new String[bandNames.size()]); }
/** * Create a target band name to CalibrationInfo map. */ private void createTargetBandToCalInfoMap() { final String[] targetBandNames = targetProduct.getBandNames(); for (CalibrationInfo cal : calibration) { final String pol = cal.polarization; final String ss = cal.subSwath; for (String bandName : targetBandNames) { if (isMultiSwath) { if (bandName.contains(pol) && bandName.contains(ss)) { targetBandToCalInfo.put(bandName, cal); } } else { if (bandName.contains(pol)) { targetBandToCalInfo.put(bandName, cal); } } } } }
private void reactToSourceProductChange(Product product) { Object selected = referenceBandNameBox.getSelectedItem(); referenceBandNameBox.removeAllItems(); String[] bandNames = new String[0]; if (product != null) { bandNames = product.getBandNames(); } referenceBandNameBox.setModel(new DefaultComboBoxModel<>(bandNames)); referenceBandNameBox.setEditable(false); if(selected != null) { referenceBandNameBox.setSelectedItem(selected); } updateReferenceBandTargetWidthAndHeight(); } }
private static String getCheckForNoDataExpression(final Product product, final String exp) { final String[] bandNames = product.getBandNames(); StringBuilder checkForNoData = new StringBuilder("(" + exp + " == NaN"); if (StringUtils.contains(bandNames, exp)) { double nodatavalue = product.getBand(exp).getNoDataValue(); checkForNoData.append(" or " + exp + " == " + nodatavalue); } checkForNoData.append(") ? NaN : "); return checkForNoData.toString(); }
private String[] getFeatures() { final ArrayList<String> featureNames = new ArrayList<>(5); if (sourceProducts != null) { for (Product prod : sourceProducts) { for (String name : prod.getBandNames()) { if (BaseClassifier.excludeBand(name)) continue; if (sourceProducts.length > 1) { featureNames.add(name + "::" + prod.getName()); } else { featureNames.add(name); } } } } return featureNames.toArray(new String[featureNames.size()]); } }
private void reactToSourceProductChange(Product product) { referenceBandNameBox.removeAllItems(); String[] bandNames = new String[0]; if (product != null) { bandNames = product.getBandNames(); } bindingContext.getPropertySet().getProperty(REFERENCE_BAND_NAME_PROPERTY_NAME).getDescriptor().setValueSet(new ValueSet(bandNames)); referenceBandNameBox.setModel(new DefaultComboBoxModel<>(bandNames)); updateReferenceBandTargetWidthAndHeight(); }
/** * Get absolute calibration flag from the abstracted metadata. */ private void getCalibrationFlag() { absoluteCalibrationPerformed = absRoot.getAttribute(AbstractMetadata.abs_calibration_flag).getData().getElemBoolean(); if (absoluteCalibrationPerformed) { if (isComplex) { // Currently the calibrated complex product can only be sigma0, this should be changed later if // complex beta0 and gamma0 are available inputSigmaBand = true; } else { final String[] sourceBandNames = sourceProduct.getBandNames(); for (String bandName : sourceBandNames) { if (bandName.contains("Sigma0")) { inputSigmaBand = true; } else if (bandName.contains("Gamma0")) { inputGammaBand = true; } else if (bandName.contains("Beta0")) { inputBetaBand = true; } else if (bandName.contains("DN")) { inputDNBand = true; } } if (!inputSigmaBand && !inputGammaBand && !inputBetaBand && !inputDNBand) { throw new OperatorException("For calibrated product, Sigma0 or Gamma0 or Beta0 or DN band is expected"); } } } }
/** * Get product co-polarization. */ private void getProductCoPolarization() { final String[] sourceBandNames = sourceProduct.getBandNames(); for (String bandName : sourceBandNames) { if (bandName.contains("HH")) { coPolarization = "HH"; coPolBand = sourceProduct.getBand(bandName); break; } else if (bandName.contains("VV")) { coPolarization = "VV"; coPolBand = sourceProduct.getBand(bandName); break; } } if (coPolarization == null) { throw new OperatorException("Input product does not contain band with HH or VV polarization"); } noDataValue = coPolBand.getNoDataValue(); }
@Override public void selectionChanged(SelectionChangeEvent event) { final Product selectedProduct = (Product) event.getSelection().getSelectedValue(); final String[] validNames; if (selectedProduct != null) { String[] bandNames = selectedProduct.getBandNames(); ArrayList<String> names = new ArrayList<>(bandNames.length); for (String bandName : bandNames) { if (selectedProduct.getBand(bandName).getSpectralWavelength() > 0.0) { names.add(bandName); } } validNames = names.toArray(new String[names.size()]); } else { validNames = new String[0]; } final ValueSet valueSet = new ValueSet(validNames); propertyDescriptor.setValueSet(valueSet); formModel.setSourceProduct(selectedProduct); updateTargetProductName(selectedProduct); } };
@Override protected boolean verifyUserInput() { String name = _paramName.getValueAsText(); if (name == null || name.length() == 0) { showWarningDialog("The field '" + _paramName.getProperties().getLabel() + "' must not be empty"); /*I18N*/ return false; } if (StringUtils.contains(_currentProduct.getBandNames(), name)) { showErrorDialog("A band with the name '" + name + "' already exists.\n" + "Please choose a another one."); /*I18N*/ return false; } return super.verifyUserInput(); }
protected Band createBand(final Product product, String name, final String unit, final int bitsPerSample) { int dataType = ProductData.TYPE_UINT16; if (bitsPerSample == 16) { dataType = isProductSLC ? ProductData.TYPE_INT16 : ProductData.TYPE_UINT16; } else if (bitsPerSample == 32) { dataType = ProductData.TYPE_FLOAT32; } else if (bitsPerSample == 8) { dataType = isProductSLC ? ProductData.TYPE_INT8 : ProductData.TYPE_UINT8; } if(product.getBand(name) != null) { int cnt = 0; for(String bandName : product.getBandNames()) { if(bandName.startsWith(name)) { ++cnt; } } name += "_" + cnt; } final Band band = new Band(name, dataType, sceneWidth, sceneHeight); band.setDescription(name); band.setUnit(unit); band.setNoDataValue(0); band.setNoDataValueUsed(true); product.addBand(band); return band; }
/** * Update the metadata in the target product. */ private void updateTargetProductMetadata() { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(targetProduct); absRoot.getAttribute(AbstractMetadata.abs_calibration_flag).getData().setElemBoolean(true); final String[] targetBandNames = targetProduct.getBandNames(); Sentinel1Utils.updateBandNames(absRoot, selectedPolList, targetBandNames); final MetadataElement[] bandMetadataList = AbstractMetadata.getBandAbsMetadataList(absRoot); for (MetadataElement bandMeta : bandMetadataList) { boolean polFound = false; for (String pol : selectedPolList) { if (bandMeta.getName().contains(pol)) { polFound = true; break; } } if (!polFound) { // remove band metadata if polarization is not included absRoot.removeElement(bandMeta); } } }
private boolean editAggregatorItem(AggregatorItem aggregatorItem, int rowIndex) { Product contextProduct = binningFormModel.getContextProduct(); if (contextProduct == null) { Dialogs.showInformation("Please select source products before adding aggregators."); return false; } String[] varNames = getVariableNames(binningFormModel.getVariableConfigs()); String[] bandNames = contextProduct.getBandNames(); String[] tiePointGridNames = contextProduct.getTiePointGridNames(); String[] maskNames = contextProduct.getMaskGroup().getNodeNames(); String[] sourceNames = StringUtils.addArrays(varNames, bandNames); sourceNames = StringUtils.addArrays(sourceNames, tiePointGridNames); sourceNames = StringUtils.addArrays(sourceNames, maskNames); boolean isNewAggregatorItem = rowIndex < 0; ModalDialog aggregatorDialog = new AggregatorItemDialog(SwingUtilities.getWindowAncestor(grid), sourceNames, aggregatorItem, isNewAggregatorItem); int result = aggregatorDialog.show(); if (result == ModalDialog.ID_OK) { if (isNewAggregatorItem) { addDataRow(aggregatorItem); } else { updateDataRow(aggregatorItem, rowIndex); } return true; } return false; }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); String[] names = getSourceProduct().getBandNames(); for (String name : names) { ProductUtils.copyBand(name, getSourceProduct(), getTargetProduct(), true); ProductUtils.copyGeoCoding(getSourceProduct().getRasterDataNode(name), getTargetProduct().getRasterDataNode(name)); } productConfigurer.copyMasks(); productConfigurer.copyMetadata(); productConfigurer.copyVectorData(); productConfigurer.addBand(InstrumentConsts.AEROSOL_TYPE_NAME, ProductData.TYPE_FLOAT32); }
/** * Update target product metadata. */ private void updateTargetProductMetadata() { final MetadataElement abs = AbstractMetadata.getAbstractedMetadata(targetProduct); final String[] targetBandNames = targetProduct.getBandNames(); Sentinel1Utils.updateBandNames(abs, selectedPolList, targetBandNames); final MetadataElement origMetadataRoot = AbstractMetadata.getOriginalProductMetadata(targetProduct); final MetadataElement annotationElem = origMetadataRoot.getElement("annotation"); final MetadataElement[] annotationDataSetListElem = annotationElem.getElements(); for (MetadataElement elem : annotationDataSetListElem) { final MetadataElement productElem = elem.getElement("product"); final MetadataElement imageAnnotationElem = productElem.getElement("imageAnnotation"); final MetadataElement processingInformationElem = imageAnnotationElem.getElement("processingInformation"); if (removeThermalNoise) { processingInformationElem.getAttribute("thermalNoiseCorrectionPerformed").getData().setElems("true"); } if (reIntroduceThermalNoise) { processingInformationElem.getAttribute("thermalNoiseCorrectionPerformed").getData().setElems("false"); } } }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); String[] names = getSourceProduct().getBandNames(); for (String name : names) { ProductUtils.copyBand(name, getSourceProduct(), getTargetProduct(), true); ProductUtils.copyGeoCoding(getSourceProduct().getRasterDataNode(name), getTargetProduct().getRasterDataNode(name)); } productConfigurer.copyMasks(); productConfigurer.copyMetadata(); productConfigurer.copyVectorData(); final Band waterVapourBand = productConfigurer.addBand(WATER_VAPOUR_BAND_NAME, ProductData.TYPE_FLOAT32); waterVapourBand.setNoDataValue(WV_NO_DATA_VALUE); waterVapourBand.setNoDataValueUsed(true); waterVapourBand.setUnit("kg/m^2"); }