Search in sources :

Example 1 with SourceProduct

use of org.esa.snap.core.gpf.annotations.SourceProduct in project s1tbx by senbox-org.

the class PolarimetricClassificationOp method createTargetProduct.

/**
 * Create target product.
 */
private void createTargetProduct() {
    targetProduct = new Product(sourceProduct.getName() + PRODUCT_SUFFIX, sourceProduct.getProductType(), sourceImageWidth, sourceImageHeight);
    ProductUtils.copyProductNodes(sourceProduct, targetProduct);
    final String targetBandName = classifier.getTargetBandName();
    // add index coding
    final IndexCoding indexCoding = classifier.createIndexCoding();
    targetProduct.getIndexCodingGroup().add(indexCoding);
    // add a target product per source product
    for (final PolBandUtils.PolSourceBand bandList : srcBandList) {
        final Band targetBand = new Band(targetBandName + bandList.suffix, ProductData.TYPE_UINT8, targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight());
        targetBand.setUnit("zone_index");
        targetBand.setNoDataValue(HAlphaWishart.NODATACLASS);
        targetBand.setNoDataValueUsed(true);
        targetProduct.addBand(targetBand);
        bandMap.put(targetBand, bandList);
        targetBand.setSampleCoding(indexCoding);
    }
}
Also used : TargetProduct(org.esa.snap.core.gpf.annotations.TargetProduct) SourceProduct(org.esa.snap.core.gpf.annotations.SourceProduct) PolBandUtils(org.esa.s1tbx.commons.polsar.PolBandUtils)

Example 2 with SourceProduct

use of org.esa.snap.core.gpf.annotations.SourceProduct in project s1tbx by senbox-org.

the class HorizontalVerticalMotionOp method createTargetProduct.

private void createTargetProduct() {
    targetProduct = new Product(sourceProduct.getName() + PRODUCT_SUFFIX, sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight());
    ProductUtils.copyProductNodes(sourceProduct, targetProduct);
    // Band for horizontal motion
    targetBandHorizontalMotion = targetProduct.addBand(HORIZONTAL_MOTION_BAND_NAME, ProductData.TYPE_FLOAT32);
    targetBandHorizontalMotion.setNoDataValue(Double.NaN);
    targetBandHorizontalMotion.setNoDataValueUsed(true);
    targetBandHorizontalMotion.setUnit("millimeters");
    targetBandHorizontalMotion.setDescription("Horizontal motion");
    // Band for vertical motion
    targetBandVerticalMotion = targetProduct.addBand(VERTICAL_MOTION_BAND_NAME, ProductData.TYPE_FLOAT32);
    targetBandVerticalMotion.setNoDataValue(Double.NaN);
    targetBandVerticalMotion.setNoDataValueUsed(true);
    targetBandVerticalMotion.setUnit("millimeters");
    targetBandVerticalMotion.setDescription("Vertical motion");
}
Also used : Product(org.esa.snap.core.datamodel.Product) TargetProduct(org.esa.snap.core.gpf.annotations.TargetProduct) SourceProduct(org.esa.snap.core.gpf.annotations.SourceProduct)

Example 3 with SourceProduct

use of org.esa.snap.core.gpf.annotations.SourceProduct in project s1tbx by senbox-org.

the class OilSpillClusteringOp method createTargetProduct.

/**
 * Create target product.
 */
private void createTargetProduct() {
    targetProduct = new Product(sourceProduct.getName(), sourceProduct.getProductType(), sourceImageWidth, sourceImageHeight);
    ProductUtils.copyProductNodes(sourceProduct, targetProduct);
    addSelectedBands();
}
Also used : Product(org.esa.snap.core.datamodel.Product) TargetProduct(org.esa.snap.core.gpf.annotations.TargetProduct) SourceProduct(org.esa.snap.core.gpf.annotations.SourceProduct)

Example 4 with SourceProduct

use of org.esa.snap.core.gpf.annotations.SourceProduct in project s1tbx by senbox-org.

the class AzimuthShiftOp method createTargetProduct.

/**
 * Create target product.
 */
private void createTargetProduct() {
    targetProduct = new Product(sourceProduct.getName(), sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight());
    ProductUtils.copyProductNodes(sourceProduct, targetProduct);
    final String[] bandNames = sourceProduct.getBandNames();
    for (String srcBandName : bandNames) {
        final Band band = sourceProduct.getBand(srcBandName);
        if (band instanceof VirtualBand) {
            continue;
        }
        Band targetBand;
        if (srcBandName.contains(StackUtils.MST) || srcBandName.contains("derampDemod")) {
            targetBand = ProductUtils.copyBand(srcBandName, sourceProduct, srcBandName, targetProduct, true);
        } else if (srcBandName.contains("azOffset") || srcBandName.contains("rgOffset")) {
            continue;
        } else {
            targetBand = new Band(srcBandName, band.getDataType(), band.getRasterWidth(), band.getRasterHeight());
            targetBand.setUnit(band.getUnit());
            targetProduct.addBand(targetBand);
        }
        if (targetBand != null && srcBandName.startsWith("q_")) {
            final String suffix = srcBandName.substring(1);
            ReaderUtils.createVirtualIntensityBand(targetProduct, targetProduct.getBand("i" + suffix), targetBand, suffix);
        }
    }
    /*
        // test data generation
        final String[] bandNames = sourceProduct.getBandNames();
        String mstBandI = null, mstBandQ = null, slvBandI = null, slvBandQ = null, derampBand = null;
        for (String srcBandName : bandNames) {
            if (srcBandName.contains("i_") && srcBandName.contains(StackUtils.MST)) {
                mstBandI = srcBandName;
            } else if (srcBandName.contains("q_") && srcBandName.contains(StackUtils.MST)) {
                mstBandQ = srcBandName;
            } else if (srcBandName.contains("i_") && srcBandName.contains(StackUtils.SLV)) {
                slvBandI = srcBandName;
            } else if (srcBandName.contains("q_") && srcBandName.contains(StackUtils.SLV)) {
                slvBandQ = srcBandName;
            } else if (srcBandName.contains("derampDemod")) {
                derampBand = srcBandName;
            }
        }

        final Band tgtMstBandI = ProductUtils.copyBand(slvBandI, sourceProduct, mstBandI, targetProduct, true);
        final Band tgtMstBandQ = ProductUtils.copyBand(slvBandQ, sourceProduct, mstBandQ, targetProduct, true);
        ProductUtils.copyBand(derampBand, sourceProduct, derampBand, targetProduct, true);

        Band tgtSlvBandI = new Band(slvBandI,
                sourceProduct.getBand(slvBandI).getDataType(),
                sourceProduct.getBand(slvBandI).getRasterWidth(),
                sourceProduct.getBand(slvBandI).getRasterHeight());

        Band tgtSlvBandQ = new Band(slvBandQ,
                sourceProduct.getBand(slvBandQ).getDataType(),
                sourceProduct.getBand(slvBandQ).getRasterWidth(),
                sourceProduct.getBand(slvBandQ).getRasterHeight());

        tgtSlvBandI.setUnit(Unit.REAL);
        tgtSlvBandQ.setUnit(Unit.IMAGINARY);
        targetProduct.addBand(tgtSlvBandI);
        targetProduct.addBand(tgtSlvBandQ);

        final String slvSuffix = slvBandI.substring(1);
        ReaderUtils.createVirtualIntensityBand(targetProduct, tgtSlvBandI, tgtSlvBandQ, slvSuffix);

        final String mstSuffix = mstBandI.substring(1);
        ReaderUtils.createVirtualIntensityBand(targetProduct, tgtMstBandI, tgtMstBandQ, mstSuffix);
        //==============
        */
    targetProduct.setPreferredTileSize(512, subSwath[subSwathIndex - 1].linesPerBurst);
    updateTargetMetadata();
}
Also used : TargetProduct(org.esa.snap.core.gpf.annotations.TargetProduct) SourceProduct(org.esa.snap.core.gpf.annotations.SourceProduct)

Example 5 with SourceProduct

use of org.esa.snap.core.gpf.annotations.SourceProduct in project s1tbx by senbox-org.

the class EAPPhaseCorrectionOp method createTargetProduct.

/**
 * Create target product.
 */
void createTargetProduct() {
    targetProduct = new Product(sourceProduct.getName(), sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight());
    ProductUtils.copyProductNodes(sourceProduct, targetProduct);
    addSelectedBands();
    updateTargetProductMetadata();
}
Also used : TargetProduct(org.esa.snap.core.gpf.annotations.TargetProduct) SourceProduct(org.esa.snap.core.gpf.annotations.SourceProduct)

Aggregations

SourceProduct (org.esa.snap.core.gpf.annotations.SourceProduct)81 TargetProduct (org.esa.snap.core.gpf.annotations.TargetProduct)81 Product (org.esa.snap.core.datamodel.Product)47 Band (org.esa.snap.core.datamodel.Band)16 OperatorException (org.esa.snap.core.gpf.OperatorException)10 VirtualBand (org.esa.snap.core.datamodel.VirtualBand)5 MetadataElement (org.esa.snap.core.datamodel.MetadataElement)4 InputProductValidator (org.esa.snap.engine_utilities.gpf.InputProductValidator)4 ArrayList (java.util.ArrayList)3 CRSGeoCodingHandler (org.esa.s1tbx.commons.CRSGeoCodingHandler)3 File (java.io.File)1 IOException (java.io.IOException)1 java.util (java.util)1 HashMap (java.util.HashMap)1 PolBandUtils (org.esa.s1tbx.commons.polsar.PolBandUtils)1 IndexCoding (org.esa.snap.core.datamodel.IndexCoding)1 ThreadExecutor (org.esa.snap.core.util.ThreadExecutor)1 ThreadRunnable (org.esa.snap.core.util.ThreadRunnable)1 GeoPoint (org.jlinda.core.GeoPoint)1 Point (org.jlinda.core.Point)1