use of org.esa.snap.core.datamodel.VirtualBand in project snap-novasar-reader by bcdev.
the class NovaSARProductReader method pauliVirtualBands.
private static Band[] pauliVirtualBands(final Product product) {
final VirtualBand r = new VirtualBand("pauli_r", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HH-i_VV)*(i_HH-i_VV)+(q_HH-q_VV)*(q_HH-q_VV))/2");
final VirtualBand g = new VirtualBand("pauli_g", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HV+i_VH)*(i_HV+i_VH)+(q_HV+q_VH)*(q_HV+q_VH))/2");
final VirtualBand b = new VirtualBand("pauli_b", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HH+i_VV)*(i_HH+i_VV)+(q_HH+q_VV)*(q_HH+q_VV))/2");
return new Band[] { r, g, b };
}
use of org.esa.snap.core.datamodel.VirtualBand in project s1tbx by senbox-org.
the class Radarsat2ProductReader method pauliVirtualBands.
public static Band[] pauliVirtualBands(final Product product) {
final VirtualBand r = new VirtualBand("pauli_r", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HH-i_VV)*(i_HH-i_VV)+(q_HH-q_VV)*(q_HH-q_VV))/2");
final VirtualBand g = new VirtualBand("pauli_g", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HV+i_VH)*(i_HV+i_VH)+(q_HV+q_VH)*(q_HV+q_VH))/2");
final VirtualBand b = new VirtualBand("pauli_b", ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), "((i_HH+i_VV)*(i_HH+i_VV)+(q_HH+q_VV)*(q_HH+q_VV))/2");
return new Band[] { r, g, b };
}
use of org.esa.snap.core.datamodel.VirtualBand in project s1tbx by senbox-org.
the class AdaptiveThresholdingOp method addSelectedBands.
/**
* Add the user selected bands to target product.
*
* @throws OperatorException The exceptions.
*/
private void addSelectedBands() throws OperatorException {
if (sourceBandNames == null || sourceBandNames.length == 0) {
// if user did not select any band
final Band[] bands = sourceProduct.getBands();
final Map<String, String> bandNameMap = new HashMap<>(sourceProduct.getNumBands());
for (Band srcBand : bands) {
// copy all bands
if (srcBand instanceof VirtualBand) {
ProductUtils.copyVirtualBand(targetProduct, (VirtualBand) srcBand, srcBand.getName());
} else {
ProductUtils.copyBand(srcBand.getName(), sourceProduct, targetProduct, true);
}
final String unit = srcBand.getUnit();
if (!(unit == null || unit.contains(Unit.PHASE) || unit.contains(Unit.REAL) || unit.contains(Unit.IMAGINARY))) {
String pol = OperatorUtils.getPolarizationFromBandName(srcBand.getName());
if (pol != null) {
bandNameMap.put(pol, srcBand.getName());
} else {
bandNameMap.put("NoPol", srcBand.getName());
}
}
}
if (bandNameMap.containsKey("hv")) {
sourceBandNames = new String[] { bandNameMap.get("hv") };
} else if (bandNameMap.containsKey("vh")) {
sourceBandNames = new String[] { bandNameMap.get("vh") };
} else if (bandNameMap.containsKey("hh")) {
sourceBandNames = new String[] { bandNameMap.get("hh") };
} else {
sourceBandNames = bandNameMap.values().toArray(new String[bandNameMap.size()]);
}
}
for (String srcBandName : sourceBandNames) {
final Band srcBand = sourceProduct.getBand(srcBandName);
final String unit = srcBand.getUnit();
if (unit != null && (unit.contains(Unit.PHASE) || unit.contains(Unit.REAL) || unit.contains(Unit.IMAGINARY))) {
throw new OperatorException("Please select amplitude or intensity band for ship detection");
} else {
final String targetBandName = srcBandName + SHIPMASK_NAME;
targetBandNameToSourceBandName.put(targetBandName, srcBandName);
if (!targetProduct.containsBand(srcBandName)) {
final Band targetBand = ProductUtils.copyBand(srcBandName, sourceProduct, targetProduct, true);
}
final Band targetBandMask = new Band(targetBandName, ProductData.TYPE_INT8, sourceImageWidth, sourceImageHeight);
targetBandMask.setUnit(Unit.AMPLITUDE);
targetBandMask.setNoDataValue(0);
targetBandMask.setNoDataValueUsed(true);
targetProduct.addBand(targetBandMask);
}
}
}
use of org.esa.snap.core.datamodel.VirtualBand in project s1tbx by senbox-org.
the class ObjectDiscriminationOp method addSelectedBands.
/**
* Add the user selected bands to target product.
*
* @throws OperatorException The exceptions.
*/
private void addSelectedBands() throws OperatorException {
final Band[] bands = sourceProduct.getBands();
for (Band srcBand : bands) {
final String srcBandName = srcBand.getName();
final boolean copySourceImage = !srcBandName.contains(AdaptiveThresholdingOp.SHIPMASK_NAME);
// copy all bands
if (srcBand instanceof VirtualBand) {
ProductUtils.copyVirtualBand(targetProduct, (VirtualBand) srcBand, srcBand.getName());
} else {
ProductUtils.copyBand(srcBand.getName(), sourceProduct, targetProduct, copySourceImage);
}
}
}
use of org.esa.snap.core.datamodel.VirtualBand in project s1tbx by senbox-org.
the class PCAOp method createMeanImageVirtualBand.
/**
* Create mean image as a virtual band from user selected bands.
*
* @param sourceProduct The source product.
* @param sourceBandNames The user selected band names.
* @param meanImageBandName The mean image band name.
*/
private static void createMeanImageVirtualBand(final Product sourceProduct, final String[] sourceBandNames, final String meanImageBandName) {
if (sourceProduct.getBand(meanImageBandName) != null) {
return;
}
boolean isFirstBand = true;
String unit = "";
String expression = "( ";
for (String bandName : sourceBandNames) {
if (isFirstBand) {
expression += bandName;
unit = sourceProduct.getBand(bandName).getUnit();
isFirstBand = false;
} else {
expression += " + " + bandName;
}
}
expression += " ) / " + sourceBandNames.length;
final VirtualBand band = new VirtualBand(meanImageBandName, ProductData.TYPE_FLOAT32, sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight(), expression);
band.setUnit(unit);
band.setDescription("Mean image");
sourceProduct.addBand(band);
}
Aggregations