private Band createBand(int number) { return new Band("name" + number, ProductData.TYPE_INT8, 1, 1); }
public static Band createBand(String name, int wavelength) { Band a = new Band(name, ProductData.TYPE_INT16, 10, 10); a.setSpectralWavelength(wavelength); return a; }
private void createTargetProductBands() { aotBand = AerosolUtils.createTargetBand(AotConsts.aot, tarRasterWidth, tarRasterHeight); targetProduct.addBand(aotBand); aotErrorBand = AerosolUtils.createTargetBand(AotConsts.aotErr, tarRasterWidth, tarRasterHeight); aotErrorBand.setValidPixelExpression(InstrumentConsts.VALID_RETRIEVAL_EXPRESSION); targetProduct.addBand(aotErrorBand); latBand = new Band("latitude", ProductData.TYPE_FLOAT32, tarRasterWidth, tarRasterHeight); targetProduct.addBand(latBand); lonBand = new Band("longitude", ProductData.TYPE_FLOAT32, tarRasterWidth, tarRasterHeight); targetProduct.addBand(lonBand); }
/** * Add user selected bands to target product. */ private void addSelectedBands() { final Band[] sourceBands = sourceProduct.getBands(); boolean validProduct = false; for (Band band : sourceBands) { if (band.getName().toLowerCase().startsWith("unw")) { validProduct = true; unwrappedPhaseBand = band; break; } } if (!validProduct) { throw new OperatorException("Cannot find UnwrappedPhase band in the source product."); } final Band targetBand = new Band("displacement", ProductData.TYPE_FLOAT32, sourceImageWidth, sourceImageHeight); targetBand.setUnit(Unit.METERS); targetProduct.addBand(targetBand); }
/** * Add user selected bands to target product. */ private void addSelectedBands() { final Band[] sourceBands = OperatorUtils.getSourceBands(sourceProduct, null, false); boolean validProduct = false; for (Band band : sourceBands) { if (band.getName().toLowerCase().startsWith("unw")) { validProduct = true; unwrappedPhaseBand = band; break; } } if (!validProduct) { throw new OperatorException("Cannot find UnwrappedPhase band in the source product."); } final Band targetBand = new Band("elevation", ProductData.TYPE_FLOAT32, sourceImageWidth, sourceImageHeight); targetBand.setUnit(Unit.METERS); targetProduct.addBand(targetBand); }
@Before public void setUp() { band = new Band("name", ProductData.TYPE_INT8, 1, 1); band.setUnit("unit"); }
private Product createComplexProduct(final File inputFile, final Header header, final int bandType) throws IOException { final int width = header.getNumSamples(); final int height = header.getNumLines(); final Product product = new Product(inputFile.getName(), "RAT", width, height); product.setProductReader(this); product.setFileLocation(inputFile); product.setDescription(header.getDescription()); product.getMetadataRoot().addElement(header.getAsMetadata()); initGeoCoding(product, header); applyBeamProperties(product, header.getBeamProperties()); final Band tgtBandI = new Band("i_band", bandType, width, height); tgtBandI.setUnit("real"); product.addBand(tgtBandI); final Band tgtBandQ = new Band("q_band", bandType, width, height); tgtBandQ.setUnit("imaginary"); product.addBand(tgtBandQ); ReaderUtils.createVirtualIntensityBand(product, tgtBandI, tgtBandQ, "_band"); isComplex = true; String ratFilePath = inputFile.getPath().substring(0, inputFile.getPath().length()-4); inStream = new FileImageInputStream(new File(ratFilePath)); inStream.setByteOrder(header.getJavaByteOrder()); return product; }
public static Band createTargetBand(AotConsts bandFeat, int rasterWidth, int rasterHeight) { Band targetBand = new Band(bandFeat.name, bandFeat.type, rasterWidth, rasterHeight); targetBand.setDescription(bandFeat.description); targetBand.setNoDataValue(bandFeat.noDataValue); targetBand.setNoDataValueUsed(bandFeat.noDataUsed); targetBand.setUnit(bandFeat.unit); targetBand.setScalingFactor(bandFeat.scale); targetBand.setScalingOffset(bandFeat.offset); return targetBand; }
protected Product readProductNodesImpl() throws IOException { final File inputFile = ReaderUtils.getFileFromInput(getInput()); inStream = new FileImageInputStream(inputFile); inStream.setByteOrder(ByteOrder.LITTLE_ENDIAN); readHeader(); final Product product = new Product(inputFile.getName(), "SunRaster", width, height); product.setProductReader(this); product.setFileLocation(inputFile); final Band band = new Band("data", ProductData.TYPE_FLOAT32, width, height); band.setUnit(Unit.AMPLITUDE); product.addBand(band); return product; }
/** * Create target product. */ private void createTargetProduct() { final int sourceImageWidth = sourceProduct[0].getSceneRasterWidth(); final int sourceImageHeight = sourceProduct[0].getSceneRasterHeight(); targetProduct = new Product( sourceProduct[0].getName(), sourceProduct[0].getProductType(), sourceImageWidth, sourceImageHeight); ProductUtils.copyProductNodes(sourceProduct[0], targetProduct); ifgBandI = new Band("i_ifg", ProductData.TYPE_FLOAT32, sourceImageWidth, sourceImageHeight); ifgBandI.setUnit(Unit.REAL); targetProduct.addBand(ifgBandI); ifgBandQ = new Band("q_ifg", ProductData.TYPE_FLOAT32, sourceImageWidth, sourceImageHeight); ifgBandQ.setUnit(Unit.IMAGINARY); targetProduct.addBand(ifgBandQ); ReaderUtils.createVirtualIntensityBand(targetProduct, ifgBandI, ifgBandQ, ""); ReaderUtils.createVirtualPhaseBand(targetProduct, ifgBandI, ifgBandQ, ""); }
static private SpectrumBand createBand(int index) { final Band band = new Band("Radiance_" + (index + 1), ProductData.TYPE_INT16, 100, 100); band.setDescription("Radiance for band " + (index + 1)); band.setSpectralWavelength((float) Math.random()); band.setSpectralBandwidth((float) Math.random()); band.setUnit("sr^-1"); if (index == 7) { band.setUnit("dl"); } return new SpectrumBand(band, true); }
/** * Add bands to the target product. * * @throws OperatorException The exception. */ private void addSelectedBands() throws OperatorException { final String[] targetBandNames = polDecomp.getTargetBandNames(); for (final PolBandUtils.PolSourceBand bandList : srcBandList) { final Band[] targetBands = new Band[targetBandNames.length]; int i = 0; for (String targetBandName : targetBandNames) { final Band targetBand = new Band(targetBandName + bandList.suffix, ProductData.TYPE_FLOAT32, targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight()); polDecomp.setBandUnit(targetBandName + bandList.suffix, targetBand); targetProduct.addBand(targetBand); targetBands[i++] = targetBand; } bandList.addTargetBands(targetBands); } }
@Override public void initialize() { validateSourceProducts(); if (StringHelper.isNullOrEmpty(this.landCoverName)) { throw new OperatorException("No land cover name specified."); } if (StringHelper.isNullOrEmpty(this.landCoverMapIndices)) { throw new OperatorException("No land cover map indices specified."); } this.currentProductBandsNames = findBandNames(this.currentSourceProduct); this.previousProductBandsNames = findBandNames(this.previousSourceProduct); int sceneWidth = this.currentSourceProduct.getSceneRasterWidth(); int sceneHeight = this.currentSourceProduct.getSceneRasterHeight(); Dimension tileSize = JAI.getDefaultTileSize(); this.targetProduct = new Product("ForestCoverChange", this.currentSourceProduct.getProductType(), sceneWidth, sceneHeight); this.targetProduct.setPreferredTileSize(tileSize); ProductUtils.copyGeoCoding(this.currentSourceProduct, this.targetProduct); Band targetBand = new Band("band_1", ProductData.TYPE_INT32, sceneWidth, sceneHeight); this.targetProduct.addBand(targetBand); this.threadCount = Runtime.getRuntime().availableProcessors() - 1; this.threadPool = Executors.newCachedThreadPool(); }
/** * Add bands to the target product. * * @throws OperatorException The exception. */ private void addSelectedBands() throws OperatorException { final String[] targetBandNames = polDecomp.getTargetBandNames(); for (final PolBandUtils.PolSourceBand bandList : srcBandList) { final Band[] targetBands = new Band[targetBandNames.length]; int i = 0; for (String targetBandName : targetBandNames) { final Band targetBand = new Band(targetBandName + bandList.suffix, ProductData.TYPE_FLOAT32, targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight()); polDecomp.setBandUnit(targetBandName + bandList.suffix, targetBand); targetBand.setNoDataValueUsed(true); targetBand.setNoDataValue(0); targetProduct.addBand(targetBand); targetBands[i++] = targetBand; } bandList.addTargetBands(targetBands); } }
public static Band createBand(final Variable variable, final int rasterWidth, final int rasterHeight, int dataType) { final NcAttributeMap attMap = NcAttributeMap.create(variable); final Band band = new Band(variable.getShortName(), (dataType == ProductData.TYPE_UNDEFINED) ? getRasterDataType(variable) : dataType, rasterWidth, rasterHeight); band.setDescription(getDescription(variable, attMap)); band.setUnit(getUnit(variable, attMap)); band.setScalingFactor(getScalingFactor(attMap)); band.setScalingOffset(getAddOffset(attMap)); final Number noDataValue = getNoDataValue(attMap); if (noDataValue != null) { band.setNoDataValue(noDataValue.doubleValue()); band.setNoDataValueUsed(true); } return band; }
private Band addBand(final Product product, String name, final int w, final int h, final ImageIOFile img, final int bandIndex, final String unit) throws IOException { File bandFile = getFile(img.getName()); ProductReader reader = geotiffPlugIn.createReaderInstance(); Product bandProduct = reader.readProductNodes(bandFile, null); if (bandProduct != null) { bandProducts.add(bandProduct); Band srcBand = bandProduct.getBandAt(bandIndex); if (product.containsBand(name)) { name += "2"; } Band band = new Band(name, srcBand.getDataType(), w, h); band.setNoDataValue(0); band.setNoDataValueUsed(true); band.setUnit(unit); band.setSourceImage(srcBand.getSourceImage()); product.addBand(band); return band; } return null; }
private void createTargetProduct() { try { double pixelSpacingInMeter = Math.max(SARGeocoding.getAzimuthPixelSpacing(sourceProduct), SARGeocoding.getRangePixelSpacing(sourceProduct)); double pixelSpacingInDegree = SARGeocoding.getPixelSpacingInDegree(pixelSpacingInMeter); final CRSGeoCodingHandler crsHandler = new CRSGeoCodingHandler(sourceProduct, mapProjection, pixelSpacingInDegree, pixelSpacingInMeter); targetProduct = new Product(bandName, sourceProduct.getProductType(), crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); targetProduct.setSceneGeoCoding(crsHandler.getCrsGeoCoding()); elevationBand = new Band(bandName, ProductData.TYPE_FLOAT32, crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); elevationBand.setUnit(Unit.METERS); elevationBand.setNoDataValue(0); //todo get dem no data value elevationBand.setNoDataValueUsed(true); targetProduct.addBand(elevationBand); } catch (Exception e) { throw new OperatorException(e); } }
private Band createTargetBand(int levels,String[] bandNames, int index, HashMap<Product, String> tiles, TileComponent tileComp) { Band targetBand = new Band(bandNames[index], this.bandDataType, tileComp.getNumColumns(), tileComp.getNumRows()); Band band = setInputSpecificationBand(tiles, index); final Dimension tileSize = JAIUtils.computePreferredTileSize(band.getRasterWidth(), band.getRasterHeight(), 1); setBandProperties(targetBand, band); initBandsGeoCoding(targetBand,tileComp); Map<Band, String> srcBands = getBandTiles(tiles, index); MosaicMultiLevelSource bandSource = new MosaicMultiLevelSource(srcBands, targetBand.getRasterWidth(), targetBand.getRasterHeight(), tileSize.width, tileSize.height, levels,tileComp, targetBand.getGeoCoding() != null ? Product.findImageToModelTransform(targetBand.getGeoCoding()) : Product.findImageToModelTransform(product.getSceneGeoCoding())); targetBand.setSourceImage(new DefaultMultiLevelImage(bandSource)); return targetBand; }
@Test public void propertyChange_band_change() { PropertyContainer propertyContainer = new PropertyContainer(); propertyContainer.addProperty(Property.create("xProduct", Product.class)); propertyContainer.addProperty(Property.create("yProduct", Product.class)); propertyContainer.addProperty(Property.create("zProduct", Product.class)); propertyContainer.addProperty(Property.create("xBand", Band.class)); propertyContainer.addProperty(Property.create("yBand", Band.class)); propertyContainer.addProperty(Property.create("zBand", Band.class)); RefreshActionEnabler refreshActionEnabler = new RefreshActionEnabler(refreshButton); refreshActionEnabler.addProductBandEnablement("xProduct", "xBand"); refreshActionEnabler.addProductBandEnablement("yProduct", "yBand"); refreshActionEnabler.addProductBandEnablement("zProduct", "zBand"); propertyContainer.addPropertyChangeListener(refreshActionEnabler); propertyContainer.setValue("xBand", new Band("name", ProductData.TYPE_INT8, 1, 1)); assertFalse(refreshButton.isEnabled()); propertyContainer.setValue("yBand", new Band("name", ProductData.TYPE_INT8, 1, 1)); assertFalse(refreshButton.isEnabled()); propertyContainer.setValue("zBand", new Band("name", ProductData.TYPE_INT8, 1, 1)); assertTrue(refreshButton.isEnabled()); }
@Test public void testRemoveStxFromProduct() throws Exception { HistogramPanelModel model = new HistogramPanelModel(); Band band = new Band("name", ProductData.TYPE_UINT32, 10, 10); Product product = new Product("dummy", "dummy", 10, 10); product.addBand(band); HistogramPanelModel.HistogramConfig config = new HistogramPanelModel.HistogramConfig( band, "Roy Mask", 10, true ); model.setStx(config, arbitraryStx()); assertTrue(model.hasStx(config)); model.removeStxFromProduct(product); assertFalse(model.hasStx(config)); }